Skip to content

Commit

Permalink
feat: disabled search for testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbenary committed Oct 16, 2024
1 parent b651be7 commit e97a775
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
30 changes: 22 additions & 8 deletions src/components/sidebar-navigation/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as HoverCard from '@radix-ui/react-hover-card';
import Link from 'next/link';
import React, { useCallback, useEffect, useRef, useState } from 'react';

import { networkId } from '@/config';
import useDebounce from '@/hooks/useDebounce';
import { fetchSearchHits } from '@/utils/algoliaSearchApi';
import { fetchCatalog } from '@/utils/catalogSearchApi';
Expand Down Expand Up @@ -51,11 +52,15 @@ export const Search = ({ inputRef }: { inputRef: any }) => {
const fetchResults = useCallback(async () => {
setIsLoading(true);

const [docs, apps, components] = await Promise.all([
const isMainnet = networkId === 'mainnet';

const fetchPromises = [
fetchSearchHits('Docs', debouncedSearchTerm),
fetchCatalog(debouncedSearchTerm),
fetchSearchHits('Components', debouncedSearchTerm),
]);
isMainnet ? fetchCatalog(debouncedSearchTerm) : Promise.resolve(),
isMainnet ? fetchSearchHits('Components', debouncedSearchTerm) : Promise.resolve(),
];

const [docs, apps, components] = await Promise.all(fetchPromises);

setResults({
Docs: renderResults('Docs', docs),
Expand Down Expand Up @@ -135,11 +140,20 @@ export const Search = ({ inputRef }: { inputRef: any }) => {
<S.Tab $active={activeTab === 'Docs'} onClick={() => handleTabChange('Docs')} $isFirst={true}>
Docs
</S.Tab>
<S.Tab $active={activeTab === 'Apps'} onClick={() => handleTabChange('Apps')}>
Apps
<S.Tab
$active={activeTab === 'Apps'}
onClick={() => handleTabChange('Apps')}
disabled={networkId == 'testnet'}
>
Apps {networkId == 'testnet' && '(Mainnet only)'}
</S.Tab>
<S.Tab $active={activeTab === 'Components'} onClick={() => handleTabChange('Components')} $isLast={true}>
Components
<S.Tab
$active={activeTab === 'Components'}
onClick={() => handleTabChange('Components')}
disabled={networkId == 'testnet'}
$isLast={true}
>
Components {networkId == 'testnet' && '(Mainnet only)'}
</S.Tab>
</S.TabContainer>

Expand Down
2 changes: 1 addition & 1 deletion src/components/sidebar-navigation/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const Sidebar = () => {
icon={<CaretDown />}
size="xs"
style={{
marginBottom: '2px',
marginBottom: '1px',
transform: isOpenNetwork ? 'rotate(180deg)' : 'rotate(0deg)',
transition: 'all 200ms',
}}
Expand Down

0 comments on commit e97a775

Please sign in to comment.