@@ -6,12 +6,24 @@ import ModeToggle from "@/components/toggle-theme";
6
6
import Link from "next/link" ;
7
7
import { usePathname } from "next/navigation" ;
8
8
import { ArrowDownLeftIcon } from "lucide-react" ;
9
+ import SearchbarChild from "./Searchbar/searchbar-child" ;
10
+ import { fetchSubjects } from "./Searchbar/searchbar" ;
11
+ import { useEffect , useState } from "react" ;
9
12
10
13
function Navbar ( ) {
11
14
const pathname = usePathname ( ) ;
15
+ const [ subjects , setSubjects ] = useState < string [ ] > ( [ ] ) ;
16
+
17
+ useEffect ( ( ) => {
18
+ const getSubjects = async ( ) => {
19
+ const subs = await fetchSubjects ( ) ;
20
+ setSubjects ( subs ) ;
21
+ } ;
22
+ getSubjects ( ) ;
23
+ } , [ ] ) ;
12
24
13
25
return (
14
- < div className = "sticky top-0 z-10 flex h-[85px] w-full items-center justify-between gap-x-3 overflow-hidden bg-[#B2B8FF] px-2 py-6 dark:bg-[#130E1F] md:px-12" >
26
+ < div className = "sticky top-0 z-10 flex h-[85px] w-full items-center justify-between gap-x-3 bg-[#B2B8FF] px-2 py-6 dark:bg-[#130E1F] md:px-12" >
15
27
< div className = "flex items-center gap-x-2 md:w-auto" >
16
28
< a
17
29
href = "https://www.codechefvit.com/"
@@ -32,6 +44,15 @@ function Navbar() {
32
44
Papers
33
45
</ Link >
34
46
</ div >
47
+
48
+ { pathname === "/catalogue" && (
49
+ < div className = "hidden flex-1 justify-center md:flex" >
50
+ < div className = "w-[60%] max-w-[500px]" >
51
+ < SearchbarChild initialSubjects = { subjects } />
52
+ </ div >
53
+ </ div >
54
+ ) }
55
+
35
56
< div className = "md:w/[20%] flex items-center justify-end gap-x-2" >
36
57
< div className = "scale-75 sm:scale-100" >
37
58
< ModeToggle />
@@ -52,4 +73,4 @@ function Navbar() {
52
73
) ;
53
74
}
54
75
55
- export default Navbar ;
76
+ export default Navbar ;
0 commit comments