@@ -19,7 +19,6 @@ import { ChevronDownIcon } from "@radix-ui/react-icons";
1919import Link from "next/link" ;
2020import { usePathname , useRouter , useSearchParams } from "next/navigation" ;
2121import { buildSearchParams } from "@/lib/helpers" ;
22- import { useTransition } from "react" ;
2322
2423export default function NoteCard ( {
2524 note,
@@ -32,9 +31,7 @@ export default function NoteCard({
3231 const pathname = usePathname ( ) ;
3332 const searchParams = useSearchParams ( ) ;
3433
35- const [ isPending , startTransition ] = useTransition ( ) ;
36-
37- const selectedConceptIds = searchParams . getAll ( "conceptId" ) ;
34+ const ids = searchParams . get ( "ids" ) ?. split ( "," ) . filter ( Boolean ) ?? [ ] ;
3835
3936 const pmcid = note . note_source_value ?. match ( / P M C ( \d + ) / ) ?. [ 1 ] ;
4037
@@ -51,31 +48,25 @@ export default function NoteCard({
5148 ) ;
5249
5350 const selectConcept = ( conceptId : string ) => {
54- const existing = searchParams . getAll ( "conceptId" ) ;
51+ const existing = ids ;
5552
5653 const nextConceptIds = existing . includes ( conceptId )
5754 ? existing . filter ( ( id ) => id !== conceptId )
5855 : [ ...existing , conceptId ] ;
5956
6057 const query = buildSearchParams ( {
61- conceptIds : nextConceptIds ,
58+ ids : nextConceptIds ,
6259 domain : searchParams . get ( "domain" ) ,
6360 page : 1 ,
6461 } ) ;
6562
66- startTransition ( ( ) => {
67- router . replace ( `${ pathname } ?${ query } ` , {
68- scroll : false ,
69- } ) ;
70- } ) ;
63+ router . push ( `${ pathname } ?${ query } ` , { scroll : false } ) ;
7164 } ;
7265
7366 return (
7467 < Card
7568 className = { `
7669 bg-zinc-50 ring-foreground/15 dark:bg-neutral-800 mb-5
77- transition-opacity
78- ${ isPending ? "opacity-60 pointer-events-none" : "" }
7970 ` }
8071 >
8172 < CardHeader >
@@ -89,29 +80,20 @@ export default function NoteCard({
8980 { article . title }
9081 </ Link >
9182 ) : (
92- < p className = "text-sm text-gray-400" >
93- Loading Case Reports...
94- </ p >
83+ < p className = "text-sm text-gray-400" > Loading Case Reports...</ p >
9584 ) }
9685 </ CardTitle >
97-
98- { isPending && (
99- < div className = "text-sm text-muted-foreground" >
100- Loading Case Reports...
101- </ div >
102- ) }
10386 </ CardHeader >
10487
10588 < CardContent className = "flex flex-wrap items-center gap-2 md:flex-row" >
10689 { article ? (
107- < Collapsible defaultOpen = { true } className = "w-full rounded-md data-[state=open]:bg-muted" >
90+ < Collapsible
91+ defaultOpen = { true }
92+ className = "w-full rounded-md data-[state=open]:bg-muted"
93+ >
10894 < CollapsibleTrigger asChild >
109- < Button
110- variant = "ghost"
111- className = "group w-full bg-transparent"
112- >
95+ < Button variant = "ghost" className = "group w-full bg-transparent" >
11396 Description
114-
11597 < ChevronDownIcon className = "ml-auto transition-transform group-data-[state=open]:rotate-180" />
11698 </ Button >
11799 </ CollapsibleTrigger >
@@ -121,18 +103,14 @@ export default function NoteCard({
121103 </ CollapsibleContent >
122104 </ Collapsible >
123105 ) : (
124- < p className = "text-sm text-gray-400" >
125- Loading Case Reports...
126- </ p >
106+ < p className = "text-sm text-gray-400" > Loading Case Reports...</ p >
127107 ) }
128108 </ CardContent >
129109
130110 < CardFooter className = "bg-neutral-50 border-t-gray-200 dark:bg-neutral-900 dark:border-t-neutral-600" >
131111 < div className = "flex flex-wrap gap-2" >
132112 { uniqueConcepts . map ( ( c : Concept ) => {
133- const selected = selectedConceptIds . includes (
134- String ( c . concept_id ) ,
135- ) ;
113+ const selected = ids . includes ( String ( c . concept_id ) ) ;
136114
137115 return (
138116 < Badge
@@ -178,4 +156,4 @@ export default function NoteCard({
178156 </ CardFooter >
179157 </ Card >
180158 ) ;
181- }
159+ }
0 commit comments