1
1
import { UpdatePassword } from '@/api/users'
2
- import { Container , Typography , Divider , Box , Button } from '@mui/joy'
2
+ import { Container , Typography , Divider , Box , Button , Select , Option } from '@mui/joy'
3
3
import React from 'react'
4
4
import { PassowrdChangeModal } from '../Modals/Inputs/PasswordChangeModal'
5
5
import { APITokenSettings } from './APITokenSettings'
6
6
import { NotificationSetting } from '../Notifications/NotificationSettings'
7
7
import { ThemeToggle } from './ThemeToggle'
8
+ import { storeValue } from '@/utils/storage'
9
+ import { getHomeView , HomeView } from '@/utils/navigation'
10
+ import { SelectValue } from '@mui/base'
11
+
12
+ type SettingsProps = object
13
+ type SettingsState = {
14
+ homeView : HomeView
15
+ }
16
+
17
+ export class Settings extends React . Component < SettingsProps , SettingsState > {
18
+ constructor ( props : SettingsProps ) {
19
+ super ( props )
20
+
21
+ this . state = {
22
+ homeView : getHomeView ( ) ,
23
+ }
24
+ }
8
25
9
- export class Settings extends React . Component {
10
26
private changePasswordModal = React . createRef < PassowrdChangeModal > ( )
11
27
12
28
private onPasswordChanged = async ( password : string | null ) => {
@@ -21,7 +37,18 @@ export class Settings extends React.Component {
21
37
this . changePasswordModal . current ?. open ( )
22
38
}
23
39
40
+ private onHomeViewChange = async ( e : React . MouseEvent | React . KeyboardEvent | React . FocusEvent | null , option : SelectValue < HomeView , false > ) => {
41
+ const homeView = option as HomeView
42
+ await this . setState ( {
43
+ homeView,
44
+ } )
45
+
46
+ storeValue < HomeView > ( 'home_view' , homeView )
47
+ }
48
+
24
49
render ( ) : React . ReactNode {
50
+ const { homeView } = this . state
51
+
25
52
return (
26
53
< Container sx = { {
27
54
paddingBottom : '16px' ,
@@ -34,7 +61,22 @@ export class Settings extends React.Component {
34
61
paddingBottom : '4' ,
35
62
} }
36
63
>
37
- < Typography level = 'h3' > Password</ Typography >
64
+ < Typography level = 'h3' > Preferred view</ Typography >
65
+ < Divider />
66
+ < Typography > Choose your default view:</ Typography >
67
+ < Select
68
+ value = { homeView }
69
+ sx = { {
70
+ maxWidth : '200px' ,
71
+ } }
72
+ onChange = { this . onHomeViewChange }
73
+ >
74
+ < Option value = 'my_tasks' > My Tasks</ Option >
75
+ < Option value = 'tasks_overview' > Tasks Overview</ Option >
76
+ </ Select >
77
+ < Typography level = 'h3' sx = { {
78
+ mt : 2 ,
79
+ } } > Password</ Typography >
38
80
< Divider />
39
81
< Box sx = { {
40
82
mt : 1 ,
0 commit comments