Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
thecybernanny-webapp
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
asranov0003
thecybernanny-webapp
Commits
f620bab7
Commit
f620bab7
authored
Sep 22, 2025
by
asranov0003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: render and settimezone
parent
b1a872bd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
2 deletions
+68
-2
timezones.ts
src/constants/timezones.ts
+0
-0
Settings.tsx
src/pages/Settings/Settings.tsx
+32
-2
accountSlice.ts
src/stores/slices/accountSlice.ts
+36
-0
No files found.
src/constants/timezones.ts
0 → 100644
View file @
f620bab7
This diff is collapsed.
Click to expand it.
src/pages/Settings/Settings.tsx
View file @
f620bab7
import
React
,
{
useState
}
from
"react"
;
import
React
,
{
use
Effect
,
use
State
}
from
"react"
;
import
"./Settings.css"
;
import
{
useLanguage
}
from
"../../contexts/LanguageContext/useLanguage"
;
import
CSelect
from
"../../components/CSelect"
;
...
...
@@ -19,10 +19,15 @@ import CModal from "../../components/CModal";
import
CButton
from
"../../components/CButton"
;
import
{
Link
}
from
"react-router-dom"
;
import
CInput
from
"../../components/CInput"
;
import
{
checkPassword
}
from
"../../stores/slices/accountSlice"
;
import
{
checkPassword
,
setTimezone
}
from
"../../stores/slices/accountSlice"
;
import
{
TIME_ZONES
}
from
"../../constants/timezones"
;
const
Settings
:
React
.
FC
=
()
=>
{
const
[
password
,
setPassword
]
=
useState
(
""
);
const
[
selectedTimezone
,
setSelectedTimezone
]
=
useState
({
ianaId
:
"Asia/Tashkent"
,
name
:
"(UTC+05:00) Ashgabat, Tashkent"
,
});
const
[
isOpenLogoutModal
,
setIsOpenLogoutModal
]
=
useState
(
false
);
const
[
isOpenDeleteAccountModal
,
setIsOpenDeleteAccountModal
]
=
useState
(
false
);
...
...
@@ -31,6 +36,7 @@ const Settings: React.FC = () => {
const
{
isCheckPasswordLoading
,
errorCheckPassword
}
=
useAppSelector
(
(
state
:
RootState
)
=>
state
.
account
);
const
{
session
}
=
useAppSelector
((
state
:
RootState
)
=>
state
.
account
);
const
dispatch
=
useAppDispatch
();
const
toggleLogoutModal
=
()
=>
{
...
...
@@ -41,6 +47,15 @@ const Settings: React.FC = () => {
setIsOpenDeleteAccountModal
((
prev
)
=>
!
prev
);
};
useEffect
(()
=>
{
if
(
session
.
timeZoneStr
)
{
const
tz
=
TIME_ZONES
.
find
((
tz
)
=>
tz
.
ianaId
===
session
.
timeZoneStr
);
if
(
tz
)
{
setSelectedTimezone
(
tz
);
}
}
},
[
session
]);
return
(
<
div
className=
"settings"
>
<
h3
className=
"settings__title"
>
{
t
(
"settings.title"
)
}
</
h3
>
...
...
@@ -88,6 +103,21 @@ const Settings: React.FC = () => {
]
}
/>
<
CSelect
value=
{
selectedTimezone
.
ianaId
}
options=
{
TIME_ZONES
.
map
((
tz
)
=>
({
label
:
tz
.
name
,
value
:
tz
.
ianaId
,
}))
}
onChange=
{
(
ianaId
:
string
)
=>
{
const
tz
=
TIME_ZONES
.
find
((
tz
)
=>
tz
.
ianaId
===
ianaId
);
if
(
tz
)
{
setSelectedTimezone
(
tz
);
dispatch
(
setTimezone
({
zone
:
tz
.
ianaId
,
offset
:
tz
.
offset
}));
}
}
}
/>
<
h3
>
{
t
(
"settings.account"
)
}
</
h3
>
<
div
...
...
src/stores/slices/accountSlice.ts
View file @
f620bab7
...
...
@@ -6,6 +6,8 @@ interface ISession {
login
:
string
;
emailVerified
:
boolean
;
subDateEnd
:
string
;
paid
:
boolean
;
timeZoneStr
:
string
;
}
interface
IAccountState
{
...
...
@@ -20,6 +22,8 @@ const initialState: IAccountState = {
login
:
""
,
emailVerified
:
false
,
subDateEnd
:
""
,
paid
:
true
,
timeZoneStr
:
""
,
},
loading
:
false
,
isCheckPasswordLoading
:
false
,
...
...
@@ -80,6 +84,28 @@ export const checkPassword = createAsyncThunk(
}
);
export
const
setTimezone
=
createAsyncThunk
(
"account/setTimezone"
,
async
(
{
zone
,
offset
}:
{
zone
:
string
;
offset
:
number
},
{
rejectWithValue
}
)
=>
{
try
{
const
response
=
await
sendRpcRequest
(
"account.setTimeZone"
,
{
zone
,
offset
,
});
return
response
;
}
catch
(
error
)
{
if
(
typeof
error
===
"object"
&&
error
!==
null
&&
"message"
in
error
)
{
return
rejectWithValue
((
error
as
{
message
:
string
}).
message
);
}
return
rejectWithValue
(
"Unknown error occurred"
);
}
}
);
const
accountSlice
=
createSlice
({
name
:
"account"
,
initialState
,
...
...
@@ -107,6 +133,16 @@ const accountSlice = createSlice({
.
addCase
(
checkPassword
.
rejected
,
(
state
,
action
)
=>
{
state
.
isCheckPasswordLoading
=
false
;
state
.
errorCheckPassword
=
action
.
payload
as
string
;
})
.
addCase
(
setTimezone
.
pending
,
(
state
)
=>
{
state
.
loading
=
true
;
})
.
addCase
(
setTimezone
.
fulfilled
,
(
state
)
=>
{
state
.
loading
=
false
;
})
.
addCase
(
setTimezone
.
rejected
,
(
state
)
=>
{
state
.
loading
=
false
;
});
},
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment