1
+ import { Trans , useLingui } from "@lingui/react/macro" ;
1
2
import { createFileRoute , useNavigate , useSearch } from "@tanstack/react-router" ;
2
3
import { zodValidator } from "@tanstack/zod-adapter" ;
3
4
import { z } from "zod" ;
4
5
5
- import { MainSidebar , SettingsHeader , type Tab , TABS } from "@/components/settings/components" ;
6
+ import { TabIcon } from "@/components/settings/components/tab-icon" ;
7
+ import { type Tab , TABS } from "@/components/settings/components/types" ;
6
8
import { Calendar , Feedback , General , Lab , LocalAI , Notifications , Sound } from "@/components/settings/views" ;
9
+ import { cn } from "@hypr/ui/lib/utils" ;
7
10
8
11
const schema = z . object ( {
9
12
tab : z . enum ( TABS . map ( t => t . name ) as [ Tab , ...Tab [ ] ] ) . default ( "general" ) ,
@@ -18,29 +21,100 @@ export const Route = createFileRoute(PATH)({
18
21
function Component ( ) {
19
22
const navigate = useNavigate ( ) ;
20
23
const search = useSearch ( { from : PATH } ) ;
24
+ const { t } = useLingui ( ) ;
21
25
22
26
const handleClickTab = ( tab : Tab ) => {
23
27
navigate ( { to : PATH , search : { ...search , tab } } ) ;
24
28
} ;
25
29
30
+ const getTabTitle = ( tab : string ) => {
31
+ switch ( tab ) {
32
+ case "general" :
33
+ return t `General` ;
34
+ case "profile" :
35
+ return t `Profile` ;
36
+ case "ai" :
37
+ return t `AI` ;
38
+ case "calendar" :
39
+ return t `Calendar` ;
40
+ case "notifications" :
41
+ return t `Notifications` ;
42
+ case "templates" :
43
+ return t `Templates` ;
44
+ case "extensions" :
45
+ return t `Extensions` ;
46
+ case "team" :
47
+ return t `Team` ;
48
+ case "billing" :
49
+ return t `Billing` ;
50
+ default :
51
+ return tab ;
52
+ }
53
+ } ;
54
+
26
55
return (
27
- < div className = "relative flex h-screen w-screen overflow-hidden" >
28
- < div className = "flex h-full w-full flex-col overflow-hidden bg-background" >
56
+ < div className = "flex h-full overflow-hidden" >
57
+ < div className = "flex-1" >
58
+ { /* Sidebar */ }
29
59
< div className = "flex h-full" >
30
60
< div className = "w-60 border-r" >
31
61
< div
32
62
data-tauri-drag-region
33
63
className = "flex items-center h-11 justify-end px-2"
34
64
/>
35
65
36
- < MainSidebar current = { search . tab } onTabClick = { handleClickTab } />
66
+ < div className = "flex h-full flex-col overflow-hidden" >
67
+ < div className = "flex-1 overflow-y-auto p-2" >
68
+ < div className = "space-y-1" >
69
+ { TABS . map ( ( tab ) => (
70
+ < button
71
+ key = { tab . name }
72
+ className = { cn (
73
+ "flex w-full items-center gap-2 rounded-lg p-2 text-sm text-neutral-600 hover:bg-neutral-100" ,
74
+ search . tab === tab . name && "bg-neutral-100 font-medium" ,
75
+ ) }
76
+ onClick = { ( ) => handleClickTab ( tab . name ) }
77
+ >
78
+ < TabIcon tab = { tab . name } />
79
+ < span >
80
+ { tab . name === "general"
81
+ ? < Trans > General</ Trans >
82
+ : tab . name === "calendar"
83
+ ? < Trans > Calendar</ Trans >
84
+ : tab . name === "notifications"
85
+ ? < Trans > Notifications</ Trans >
86
+ : tab . name === "sound"
87
+ ? < Trans > Sound</ Trans >
88
+ : tab . name === "ai"
89
+ ? < Trans > AI</ Trans >
90
+ : tab . name === "lab"
91
+ ? < Trans > Lab</ Trans >
92
+ : tab . name === "feedback"
93
+ ? < Trans > Feedback</ Trans >
94
+ : null }
95
+ </ span >
96
+ </ button >
97
+ ) ) }
98
+ </ div >
99
+ </ div >
100
+ </ div >
37
101
</ div >
38
102
103
+ { /* Main Content */ }
39
104
< div className = "flex-1 flex h-full w-full flex-col overflow-hidden" >
40
- < SettingsHeader
41
- current = { search . tab }
42
- />
43
- < div className = "flex-1 overflow-y-auto p-6" >
105
+ { /* Header */ }
106
+ < header data-tauri-drag-region className = "h-11 w-full flex items-center justify-between border-b px-2" >
107
+ < div className = "w-40" data-tauri-drag-region > </ div >
108
+
109
+ < h1 className = "text-md font-semibold capitalize" data-tauri-drag-region >
110
+ { getTabTitle ( search . tab ) }
111
+ </ h1 >
112
+
113
+ < div className = "w-40" data-tauri-drag-region > </ div >
114
+ </ header >
115
+
116
+ { /* Actual Content */ }
117
+ < div className = "flex-1 overflow-y-auto p-6 w-full" >
44
118
{ search . tab === "general" && < General /> }
45
119
{ search . tab === "calendar" && < Calendar /> }
46
120
{ search . tab === "notifications" && < Notifications /> }
0 commit comments