1
- "use client"
1
+ "use client" ;
2
2
3
- import { CommandDialog , CommandEmpty , CommandGroup , CommandInput , CommandItem , CommandList } from "@dingify/ui/components/command"
4
- import Link from "next/link"
5
- import { useEffect , useState } from "react"
3
+ import { useEffect , useState } from "react" ;
4
+ import Link from "next/link" ;
5
+
6
+ import {
7
+ CommandDialog ,
8
+ CommandEmpty ,
9
+ CommandGroup ,
10
+ CommandInput ,
11
+ CommandItem ,
12
+ CommandList ,
13
+ } from "@dingify/ui/components/command" ;
6
14
7
15
export default function GlobalSearch ( ) {
8
- const [ open , setOpen ] = useState ( false )
9
-
10
- useEffect ( ( ) => {
11
- const down = ( e : KeyboardEvent ) => {
12
- if ( e . key === "k" && ( e . metaKey || e . ctrlKey ) ) {
13
- e . preventDefault ( )
14
- setOpen ( ( open ) => ! open )
15
- }
16
+ const [ open , setOpen ] = useState ( false ) ;
17
+
18
+ useEffect ( ( ) => {
19
+ const down = ( e : KeyboardEvent ) => {
20
+ if ( e . key === "k" && ( e . metaKey || e . ctrlKey ) ) {
21
+ e . preventDefault ( ) ;
22
+ setOpen ( ( open ) => ! open ) ;
16
23
}
17
- document . addEventListener ( "keydown" , down )
18
- return ( ) => document . removeEventListener ( "keydown" , down )
19
- } , [ ] )
20
-
21
- return (
22
- < CommandDialog open = { open } onOpenChange = { setOpen } >
23
- < CommandInput placeholder = "Type a command or search..." />
24
- < CommandList >
25
- < CommandEmpty > No results found.</ CommandEmpty >
26
- < CommandGroup heading = "Suggestions" >
27
- < CommandItem > < Link className = "w-full" href = "/property" > Eiendommer</ Link > </ CommandItem >
28
- < CommandItem > < Link className = "w-full" href = "/tenant" > Leietakere</ Link > </ CommandItem >
29
- < CommandItem > < Link className = "w-full" href = "/analytics" > Analyser</ Link > </ CommandItem >
30
- </ CommandGroup >
31
- </ CommandList >
32
- </ CommandDialog >
33
- )
34
- }
24
+ } ;
25
+ document . addEventListener ( "keydown" , down ) ;
26
+ return ( ) => document . removeEventListener ( "keydown" , down ) ;
27
+ } , [ ] ) ;
28
+
29
+ return (
30
+ < CommandDialog open = { open } onOpenChange = { setOpen } >
31
+ < CommandInput placeholder = "Skriv hva du søker etter..." />
32
+ < CommandList >
33
+ < CommandEmpty > No results found.</ CommandEmpty >
34
+ < CommandGroup heading = "Suggestions" >
35
+ < CommandItem >
36
+ < Link className = "w-full" href = "/property" >
37
+ Eiendommer
38
+ </ Link >
39
+ </ CommandItem >
40
+ < CommandItem >
41
+ < Link className = "w-full" href = "/tenant" >
42
+ Leietakere
43
+ </ Link >
44
+ </ CommandItem >
45
+ < CommandItem >
46
+ < Link className = "w-full" href = "/analytics" >
47
+ Analyser
48
+ </ Link >
49
+ </ CommandItem >
50
+ </ CommandGroup >
51
+ </ CommandList >
52
+ </ CommandDialog >
53
+ ) ;
54
+ }
0 commit comments