1
1
import { Layout , Menu } from "antd" ;
2
2
import { Route , Switch , useLocation , useHistory } from "react-router-dom" ;
3
- import {
4
- CheckOutlined ,
5
- LockOutlined ,
6
- MailOutlined ,
7
- SafetyOutlined ,
8
- SettingOutlined ,
9
- } from "@ant-design/icons" ;
3
+ import { LockOutlined , SafetyOutlined , SettingOutlined , UserOutlined } from "@ant-design/icons" ;
10
4
import ChangePasswordView from "./change_password_view" ;
11
5
import AuthTokenView from "./auth_token_view" ;
12
- import { useWkSelector } from "libs/react_hooks" ;
13
- import type { APIUserTheme } from "types/api_types" ;
14
- import { getSystemColorTheme } from "theme" ;
15
- import { updateSelectedThemeOfUser } from "admin/rest_api" ;
16
- import Store from "viewer/store" ;
17
- import { setActiveUserAction } from "viewer/model/actions/user_actions" ;
18
- import { setThemeAction } from "viewer/model/actions/ui_actions" ;
6
+ import ProfileView from "./profile_view" ;
19
7
20
8
const { Sider, Content } = Layout ;
21
9
22
- function EmailSettings ( ) {
23
- return (
24
- < div >
25
- < h2 > Email Settings</ h2 >
26
- < p > Email settings page content will be added here.</ p >
27
- </ div >
28
- ) ;
29
- }
30
-
31
10
function PasskeysSettings ( ) {
32
11
return (
33
12
< div >
@@ -37,66 +16,16 @@ function PasskeysSettings() {
37
16
) ;
38
17
}
39
18
40
- function AppearanceSettings ( ) {
41
- const activeUser = useWkSelector ( ( state ) => state . activeUser ) ;
42
- const { selectedTheme } = activeUser || { selectedTheme : "auto" } ;
43
-
44
- const setSelectedTheme = async ( newTheme : APIUserTheme ) => {
45
- if ( ! activeUser ) return ;
46
-
47
- if ( newTheme === "auto" ) newTheme = getSystemColorTheme ( ) ;
48
-
49
- if ( selectedTheme !== newTheme ) {
50
- const newUser = await updateSelectedThemeOfUser ( activeUser . id , newTheme ) ;
51
- Store . dispatch ( setThemeAction ( newTheme ) ) ;
52
- Store . dispatch ( setActiveUserAction ( newUser ) ) ;
53
- }
54
- } ;
55
-
56
- return (
57
- < div >
58
- < h2 > Appearance</ h2 >
59
- < div style = { { marginTop : 16 } } >
60
- < h3 > Theme</ h3 >
61
- < Menu
62
- mode = "inline"
63
- selectedKeys = { [ selectedTheme ] }
64
- items = { [
65
- {
66
- key : "auto" ,
67
- label : "System Default" ,
68
- icon : selectedTheme === "auto" ? < CheckOutlined /> : null ,
69
- onClick : ( ) => setSelectedTheme ( "auto" ) ,
70
- } ,
71
- {
72
- key : "light" ,
73
- label : "Light" ,
74
- icon : selectedTheme === "light" ? < CheckOutlined /> : null ,
75
- onClick : ( ) => setSelectedTheme ( "light" ) ,
76
- } ,
77
- {
78
- key : "dark" ,
79
- label : "Dark" ,
80
- icon : selectedTheme === "dark" ? < CheckOutlined /> : null ,
81
- onClick : ( ) => setSelectedTheme ( "dark" ) ,
82
- } ,
83
- ] }
84
- />
85
- </ div >
86
- </ div >
87
- ) ;
88
- }
89
-
90
19
function AccountSettingsView ( ) {
91
20
const location = useLocation ( ) ;
92
21
const history = useHistory ( ) ;
93
- const selectedKey = location . pathname . split ( "/" ) . pop ( ) || "email " ;
22
+ const selectedKey = location . pathname . split ( "/" ) . pop ( ) || "profile " ;
94
23
95
24
const menuItems = [
96
25
{
97
- key : "email " ,
98
- icon : < MailOutlined /> ,
99
- label : "Email " ,
26
+ key : "profile " ,
27
+ icon : < UserOutlined /> ,
28
+ label : "Profile " ,
100
29
} ,
101
30
{
102
31
key : "password" ,
@@ -113,34 +42,31 @@ function AccountSettingsView() {
113
42
icon : < SettingOutlined /> ,
114
43
label : "Auth Token" ,
115
44
} ,
116
- {
117
- key : "appearance" ,
118
- icon : < SettingOutlined /> ,
119
- label : "Appearance" ,
120
- } ,
121
45
] ;
122
46
123
47
return (
124
- < Layout style = { { minHeight : "calc(100vh - 64px)" } } >
125
- < Sider width = { 200 } theme = "light" >
126
- < Menu
127
- mode = "inline"
128
- selectedKeys = { [ selectedKey ] }
129
- style = { { height : "100%" } }
130
- items = { menuItems }
131
- onClick = { ( { key } ) => history . push ( `/account/${ key } ` ) }
132
- />
133
- </ Sider >
134
- < Content style = { { padding : "24px" , minHeight : 280 } } >
135
- < Switch >
136
- < Route path = "/account/email" component = { EmailSettings } />
137
- < Route path = "/account/password" component = { ChangePasswordView } />
138
- < Route path = "/account/passkeys" component = { PasskeysSettings } />
139
- < Route path = "/account/token" component = { AuthTokenView } />
140
- < Route path = "/account/appearance" component = { AppearanceSettings } />
141
- < Route path = "/account" component = { EmailSettings } />
142
- </ Switch >
143
- </ Content >
48
+ < Layout style = { { minHeight : "calc(100vh - 64px)" } } className = "container" >
49
+ < h1 > Account Settings</ h1 >
50
+ < Layout >
51
+ < Sider width = { 200 } >
52
+ < Menu
53
+ mode = "inline"
54
+ selectedKeys = { [ selectedKey ] }
55
+ style = { { height : "100%" } }
56
+ items = { menuItems }
57
+ onClick = { ( { key } ) => history . push ( `/account/${ key } ` ) }
58
+ />
59
+ </ Sider >
60
+ < Content style = { { padding : "24px" , paddingTop : 0 , minHeight : 280 } } >
61
+ < Switch >
62
+ < Route path = "/account/profile" component = { ProfileView } />
63
+ < Route path = "/account/password" component = { ChangePasswordView } />
64
+ < Route path = "/account/passkeys" component = { PasskeysSettings } />
65
+ < Route path = "/account/token" component = { AuthTokenView } />
66
+ < Route path = "/account" component = { ProfileView } />
67
+ </ Switch >
68
+ </ Content >
69
+ </ Layout >
144
70
</ Layout >
145
71
) ;
146
72
}
0 commit comments