9
9
Settings ,
10
10
Trash ,
11
11
} from "lucide-react" ;
12
- import { usePathname } from "next/navigation" ;
12
+ import { useParams , usePathname } from "next/navigation" ;
13
13
import { ElementRef , useEffect , useRef , useState } from "react" ;
14
14
import { useMediaQuery } from "usehooks-ts" ;
15
15
import UserItem from "./UserItem" ;
@@ -21,8 +21,14 @@ import DocumentList from "./DocumentList";
21
21
import { Popover , PopoverContent } from "@/components/ui/popover" ;
22
22
import { PopoverTrigger } from "@radix-ui/react-popover" ;
23
23
import TrashBox from "./TrashBox" ;
24
+ import { useSearch } from "@/hooks/use-search" ;
25
+ import { useSettings } from "@/hooks/use-settings" ;
26
+ import Navbar from "./Navbar" ;
24
27
25
28
const Navigation = ( ) => {
29
+ const search = useSearch ( ) ;
30
+ const settings = useSettings ( ) ;
31
+ const params = useParams ( ) ;
26
32
const pathname = usePathname ( ) ;
27
33
const isMobile = useMediaQuery ( "(max-width: 768px)" ) ;
28
34
const create = useMutation ( api . documents . create ) ;
@@ -147,17 +153,8 @@ const Navigation = () => {
147
153
</ div >
148
154
< div >
149
155
< UserItem />
150
- < Item
151
- label = "Search"
152
- icon = { Search }
153
- isSearch
154
- onClick = { ( ) => console . log ( "search" ) }
155
- />
156
- < Item
157
- label = "Settings"
158
- icon = { Settings }
159
- onClick = { ( ) => console . log ( "settings" ) }
160
- />
156
+ < Item label = "Search" icon = { Search } isSearch onClick = { search . onOpen } />
157
+ < Item label = "Settings" icon = { Settings } onClick = { settings . onOpen } />
161
158
< Item onClick = { handleCreate } label = "New Page" icon = { PlusCircle } />
162
159
</ div >
163
160
< div className = "mt-4" >
@@ -191,15 +188,19 @@ const Navigation = () => {
191
188
isMobile && "left-0 w-full"
192
189
) }
193
190
>
194
- < nav className = "bg-transparent px-3 py-2 w-full" >
195
- { isCollapsed && (
196
- < MenuIcon
197
- onClick = { resetWidth }
198
- className = "w-6 h-6 text-muted-foreground"
199
- role = "button"
200
- />
201
- ) }
202
- </ nav >
191
+ { ! ! params . documentId ? (
192
+ < Navbar isCollapsed = { isCollapsed } onResetWidth = { resetWidth } />
193
+ ) : (
194
+ < nav className = "bg-transparent px-3 py-2 w-full" >
195
+ { isCollapsed && (
196
+ < MenuIcon
197
+ onClick = { resetWidth }
198
+ className = "w-6 h-6 text-muted-foreground"
199
+ role = "button"
200
+ />
201
+ ) }
202
+ </ nav >
203
+ ) }
203
204
</ div >
204
205
</ >
205
206
) ;
0 commit comments