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
e4ab8dbf
Commit
e4ab8dbf
authored
Jul 14, 2025
by
asranov0003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: auth loading error and success
parent
916db5f2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
34 deletions
+58
-34
Login.tsx
src/pages/Auth/Login/Login.tsx
+5
-3
Recover.tsx
src/pages/Auth/Recover/Recover.tsx
+8
-4
Register.tsx
src/pages/Auth/Register/Register.tsx
+10
-3
authSlice.ts
src/stores/slices/authSlice.ts
+35
-24
No files found.
src/pages/Auth/Login/Login.tsx
View file @
e4ab8dbf
...
...
@@ -31,7 +31,9 @@ const Login: React.FC = () => {
}
=
useForm
<
ILoginFormData
>
();
const
dispatch
=
useAppDispatch
();
const
{
loading
,
error
}
=
useAppSelector
((
state
:
RootState
)
=>
state
.
auth
);
const
{
loadingLogin
,
errorLogin
}
=
useAppSelector
(
(
state
:
RootState
)
=>
state
.
auth
);
const
onSubmit
=
async
(
data
:
ILoginFormData
)
=>
{
try
{
...
...
@@ -79,9 +81,9 @@ const Login: React.FC = () => {
</
p
>
</
div
>
{
error
&&
<
p
className=
"text-danger text-center"
>
{
error
}
</
p
>
}
{
error
Login
&&
<
p
className=
"text-danger text-center"
>
{
errorLogin
}
</
p
>
}
<
CButton
title=
{
`${t("button.continue")}`
}
isLoading=
{
loading
}
/>
<
CButton
title=
{
`${t("button.continue")}`
}
isLoading=
{
loading
Login
}
/>
</
form
>
</
div
>
);
...
...
src/pages/Auth/Recover/Recover.tsx
View file @
e4ab8dbf
...
...
@@ -23,7 +23,7 @@ const Recover: React.FC = () => {
const
{
t
}
=
useTranslation
();
const
navigate
=
useNavigate
();
const
dispatch
=
useAppDispatch
();
const
{
loading
,
error
,
success
}
=
useAppSelector
(
const
{
loading
Recover
,
errorRecover
,
successRecover
}
=
useAppSelector
(
(
state
:
RootState
)
=>
state
.
auth
);
...
...
@@ -74,10 +74,14 @@ const Recover: React.FC = () => {
error=
{
errors
.
repeatPassword
?.
message
as
string
}
/
>
{
success
&&
<
p
className=
"text-success text-center"
>
{
success
}
</
p
>
}
{
error
&&
<
p
className=
"text-danger text-center"
>
{
error
}
</
p
>
}
{
successRecover
&&
(
<
p
className=
"text-success text-center"
>
{
successRecover
}
</
p
>
)
}
{
errorRecover
&&
(
<
p
className=
"text-danger text-center"
>
{
errorRecover
}
</
p
>
)
}
<
CButton
title=
{
`${t("button.continue")}`
}
isLoading=
{
loading
}
/>
<
CButton
title=
{
`${t("button.continue")}`
}
isLoading=
{
loading
Recover
}
/>
</
form
>
</
div
>
);
...
...
src/pages/Auth/Register/Register.tsx
View file @
e4ab8dbf
...
...
@@ -31,7 +31,9 @@ const Register: React.FC = () => {
}
=
useForm
<
IRegisterFormData
>
();
const
dispatch
=
useAppDispatch
();
const
{
loading
,
error
}
=
useSelector
((
state
:
RootState
)
=>
state
.
auth
);
const
{
loadingRegister
,
errorRegister
}
=
useSelector
(
(
state
:
RootState
)
=>
state
.
auth
);
const
onSubmit
=
async
(
data
:
IRegisterFormData
)
=>
{
try
{
...
...
@@ -114,9 +116,14 @@ const Register: React.FC = () => {
)
}
</
div
>
{
error
&&
<
p
className=
"text-danger text-center"
>
{
error
}
</
p
>
}
{
errorRegister
&&
(
<
p
className=
"text-danger text-center"
>
{
errorRegister
}
</
p
>
)
}
<
CButton
title=
{
`${t("button.continue")}`
}
isLoading=
{
loading
}
/>
<
CButton
title=
{
`${t("button.continue")}`
}
isLoading=
{
loadingRegister
}
/>
</
form
>
</
div
>
);
...
...
src/stores/slices/authSlice.ts
View file @
e4ab8dbf
...
...
@@ -12,9 +12,15 @@ interface IAuthUser {
interface
IAuthState
{
user
:
IAuthUser
|
null
;
loading
:
boolean
;
error
:
string
|
null
;
success
:
boolean
|
string
;
loadingLogin
:
boolean
;
loadingRegister
:
boolean
;
loadingRecover
:
boolean
;
errorLogin
:
string
|
null
;
errorRegister
:
string
|
null
;
errorRecover
:
string
|
null
;
successLogin
:
boolean
|
string
;
successRegister
:
boolean
|
string
;
successRecover
:
boolean
|
string
;
}
interface
IResponseError
{
...
...
@@ -24,9 +30,15 @@ interface IResponseError {
const
initialState
:
IAuthState
=
{
user
:
null
,
loading
:
false
,
error
:
null
,
success
:
false
,
loadingLogin
:
false
,
loadingRegister
:
false
,
loadingRecover
:
false
,
errorLogin
:
null
,
errorRegister
:
null
,
errorRecover
:
null
,
successLogin
:
false
,
successRegister
:
false
,
successRecover
:
false
,
};
export
const
authLogin
=
createAsyncThunk
<
...
...
@@ -98,54 +110,53 @@ const authSlice = createSlice({
extraReducers
:
(
builder
)
=>
{
builder
.
addCase
(
authLogin
.
pending
,
(
state
)
=>
{
state
.
loading
=
true
;
state
.
error
=
null
;
state
.
loadingLogin
=
true
;
})
.
addCase
(
authLogin
.
fulfilled
,
(
state
,
action
:
PayloadAction
<
IAuthUser
>
)
=>
{
state
.
loading
=
false
;
state
.
loading
Login
=
false
;
state
.
user
=
action
.
payload
;
state
.
success
=
true
;
state
.
success
Login
=
true
;
}
)
.
addCase
(
authLogin
.
rejected
,
(
state
,
action
)
=>
{
state
.
loading
=
false
;
state
.
error
=
action
.
payload
??
"Login failed"
;
state
.
loading
Login
=
false
;
state
.
error
Login
=
action
.
payload
??
"Login failed"
;
})
.
addCase
(
authRegister
.
pending
,
(
state
)
=>
{
state
.
loading
=
true
;
state
.
error
=
null
;
state
.
loading
Register
=
true
;
state
.
error
Register
=
null
;
})
.
addCase
(
authRegister
.
fulfilled
,
(
state
,
action
:
PayloadAction
<
IAuthUser
>
)
=>
{
state
.
loading
=
false
;
state
.
loading
Register
=
false
;
state
.
user
=
action
.
payload
;
state
.
success
=
true
;
state
.
success
Register
=
true
;
}
)
.
addCase
(
authRegister
.
rejected
,
(
state
,
action
)
=>
{
state
.
loading
=
false
;
state
.
error
=
action
.
payload
??
"Registration failed"
;
state
.
loading
Register
=
false
;
state
.
error
Register
=
action
.
payload
??
"Registration failed"
;
})
.
addCase
(
authRecover
.
pending
,
(
state
)
=>
{
state
.
loading
=
true
;
state
.
error
=
null
;
state
.
loading
Recover
=
true
;
state
.
error
Recover
=
null
;
})
.
addCase
(
authRecover
.
fulfilled
,
(
state
,
action
:
PayloadAction
<
IAuthUser
>
)
=>
{
state
.
loading
=
false
;
state
.
loading
Recover
=
false
;
state
.
user
=
action
.
payload
;
state
.
success
=
"Confirmation code sent to email"
;
state
.
success
Recover
=
"Confirmation code sent to email"
;
}
)
.
addCase
(
authRecover
.
rejected
,
(
state
,
action
)
=>
{
state
.
loading
=
false
;
state
.
error
=
action
.
payload
??
"Recovery failed"
;
state
.
loading
Recover
=
false
;
state
.
error
Recover
=
action
.
payload
??
"Recovery failed"
;
});
},
});
...
...
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