@@ -17,27 +17,27 @@ function SearchBarChild({
1717 const router = useRouter ( ) ;
1818 const [ searchText , setSearchText ] = useState ( "" ) ;
1919 const [ suggestions , setSuggestions ] = useState < string [ ] > ( [ ] ) ;
20- const [ subjectCounts , setSubjectCounts ] = useState < Record < string , number > > (
21- { } ,
22- ) ;
20+ // const [subjectCounts, setSubjectCounts] = useState<Record<string, number>>(
21+ // {},
22+ // );
2323 const suggestionsRef = useRef < HTMLUListElement | null > ( null ) ;
2424 const fuzzy = new Fuse ( initialSubjects ) ;
2525
26- const fetchPaperCount = async ( subjectName : string ) => {
27- try {
28- const cleanSubject = subjectName . replace ( / ^ " | " $ / g, "" ) ;
29- const encodedSubject = encodeURIComponent ( cleanSubject ) ;
26+ // const fetchPaperCount = async (subjectName: string) => {
27+ // try {
28+ // const cleanSubject = subjectName.replace(/^"|"$/g, "");
29+ // const encodedSubject = encodeURIComponent(cleanSubject);
3030
31- const response = await axios . get < { count : number } > (
32- `/api/papers/count?subject=${ encodedSubject } ` ,
33- ) ;
31+ // const response = await axios.get<{ count: number }>(
32+ // `/api/papers/count?subject=${encodedSubject}`,
33+ // );
3434
35- return response . data . count ?? 0 ;
36- } catch ( error ) {
37- console . error ( "Error fetching count for" , subjectName , error ) ;
38- return 0 ;
39- }
40- } ;
35+ // return response.data.count ?? 0;
36+ // } catch (error) {
37+ // console.error("Error fetching count for", subjectName, error);
38+ // return 0;
39+ // }
40+ // };
4141
4242 const handleSearchChange = async ( e : React . ChangeEvent < HTMLInputElement > ) => {
4343 const text = e . target . value ;
@@ -55,25 +55,25 @@ function SearchBarChild({
5555 setSuggestions ( filteredSuggestions ) ;
5656
5757 // Fetch counts in parallel for each suggestion
58- const counts = await Promise . all (
59- filteredSuggestions . map ( async ( subject ) => {
60- const count = await fetchPaperCount ( subject ) ;
61- return { subject, count } ;
62- } ) ,
63- ) ;
64-
65- const countsMap = counts . reduce (
66- ( acc , { subject, count } ) => {
67- acc [ subject ] = count ;
68- return acc ;
69- } ,
70- { } as Record < string , number > ,
71- ) ;
72-
73- setSubjectCounts ( countsMap ) ;
58+ // const counts = await Promise.all(
59+ // filteredSuggestions.map(async (subject) => {
60+ // const count = await fetchPaperCount(subject);
61+ // return { subject, count };
62+ // }),
63+ // );
64+
65+ // const countsMap = counts.reduce(
66+ // (acc, { subject, count }) => {
67+ // acc[subject] = count;
68+ // return acc;
69+ // },
70+ // {} as Record<string, number>,
71+ // );
72+
73+ // setSubjectCounts(countsMap);
7474 } else {
7575 setSuggestions ( [ ] ) ;
76- setSubjectCounts ( { } ) ;
76+ // setSubjectCounts({});
7777 }
7878 } ;
7979
@@ -137,12 +137,12 @@ function SearchBarChild({
137137 onClick = { ( ) => handleSelectSuggestion ( suggestion ) }
138138 className = "flex cursor-pointer items-center rounded p-2 hover:bg-gray-100 dark:hover:bg-gray-800"
139139 >
140- < div
140+ { /* <div
141141 id="paper_count"
142142 className="mr-4 flex h-10 w-10 items-center justify-center rounded-md bg-[#171720] text-sm font-semibold text-white"
143143 >
144144 {subjectCounts[suggestion] ?? "0"}
145- </ div >
145+ </div> */ }
146146 < span
147147 id = "subject"
148148 className = "items-center text-sm tracking-wide text-black dark:text-white sm:text-base"
0 commit comments