Add result count on search

pull/5385/head
Kamran Ahmed 8 months ago
parent 88ddeeb5fb
commit 7cffcccfe8
  1. 3
      src/components/ExploreAIRoadmap/ExploreAIRoadmap.tsx
  2. 12
      src/components/ExploreAIRoadmap/ExploreAISearch.tsx

@ -12,7 +12,7 @@ import { Pagination } from '../Pagination/Pagination.tsx';
import { LoadingRoadmaps } from './LoadingRoadmaps.tsx'; import { LoadingRoadmaps } from './LoadingRoadmaps.tsx';
import { EmptyRoadmaps } from './EmptyRoadmaps.tsx'; import { EmptyRoadmaps } from './EmptyRoadmaps.tsx';
import { AIRoadmapsList } from './AIRoadmapsList.tsx'; import { AIRoadmapsList } from './AIRoadmapsList.tsx';
import {ExploreAISearch} from "./ExploreAISearch.tsx"; import { ExploreAISearch } from './ExploreAISearch.tsx';
export interface AIRoadmapDocument { export interface AIRoadmapDocument {
_id?: string; _id?: string;
@ -153,6 +153,7 @@ export function ExploreAIRoadmap() {
<div className="my-3.5 flex items-stretch justify-between gap-2.5"> <div className="my-3.5 flex items-stretch justify-between gap-2.5">
<ExploreAISearch <ExploreAISearch
total={roadmapsResponse?.totalCount || 0}
isLoading={isLoading} isLoading={isLoading}
value={pageState.searchTerm} value={pageState.searchTerm}
onSubmit={(term: string) => { onSubmit={(term: string) => {

@ -5,12 +5,13 @@ import { Spinner } from '../ReactIcons/Spinner.tsx';
type ExploreAISearchProps = { type ExploreAISearchProps = {
value: string; value: string;
total: number;
isLoading: boolean; isLoading: boolean;
onSubmit: (search: string) => void; onSubmit: (search: string) => void;
}; };
export function ExploreAISearch(props: ExploreAISearchProps) { export function ExploreAISearch(props: ExploreAISearchProps) {
const { onSubmit, isLoading = false, value: defaultValue } = props; const { onSubmit, isLoading = false, total, value: defaultValue } = props;
const [term, setTerm] = useState(defaultValue); const [term, setTerm] = useState(defaultValue);
const debouncedTerm = useDebounceValue(term, 500); const debouncedTerm = useDebounceValue(term, 500);
@ -32,7 +33,8 @@ export function ExploreAISearch(props: ExploreAISearchProps) {
}, [debouncedTerm]); }, [debouncedTerm]);
return ( return (
<div className="relative w-full max-w-[350px]"> <div className="relative flex w-full items-center gap-3">
<div className="relative flex w-full max-w-[310px] items-center">
<label <label
className="absolute left-3 flex h-full items-center text-gray-500" className="absolute left-3 flex h-full items-center text-gray-500"
htmlFor="search" htmlFor="search"
@ -54,5 +56,11 @@ export function ExploreAISearch(props: ExploreAISearchProps) {
</span> </span>
)} )}
</div> </div>
{total > 0 && (
<p className="flex-shrink-0 text-sm text-gray-500">
{total} results found
</p>
)}
</div>
); );
} }

Loading…
Cancel
Save