MCPcopy Create free account
hub / github.com/TryCatchLearn/Overflow / QuestionsHeader

Function QuestionsHeader

webapp/src/app/questions/QuestionsHeader.tsx:15–59  ·  view source on GitHub ↗
({ tag, total }: Props)

Source from the content-addressed store, hash-verified

13}
14
15export default function QuestionsHeader({ tag, total }: Props) {
16 const router = useRouter();
17 const searchParams = useSearchParams();
18 const selectedTag = useTagStore((state) => state.getTagBySlug(tag ?? ''));
19
20 const tabs = [
21 {key: 'newest', label: 'Newest'},
22 {key: 'active', label: 'Active'},
23 {key: 'unanswered', label: 'Unanswered'},
24 ]
25
26 const selected = searchParams.get('sort') ?? 'newest';
27
28 const handleTabChange = (tab: Key) => {
29 const params = new URLSearchParams(searchParams);
30 params.set('sort', tab.toString());
31 router.push(`?${params.toString()}`);
32 }
33
34 return (
35 <div className='flex flex-col w-full border-b gap-4 pb-4'>
36 <div className='flex justify-between px-6'>
37 <div className='flex flex-col items-start gap-2'>
38 <div className='text-3xl font-semibold'>{tag ? `[${tag}]` : 'Newest questions'}</div>
39 <p className='font-light'>{selectedTag?.description}</p>
40 </div>
41 <Button as={Link} href='/questions/ask' color='secondary'>Ask Question</Button>
42 </div>
43 <div className='flex items-center justify-between px-6'>
44 <div>{total} {total === 1 ? 'Question' : 'Questions'}</div>
45
46 <div className='flex items-center'>
47 <Tabs
48 selectedKey={selected}
49 onSelectionChange={handleTabChange}
50 >
51 {tabs.map((item) => (
52 <Tab key={item.key} title={item.label} />
53 ))}
54 </Tabs>
55 </div>
56 </div>
57 </div>
58 )
59}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…