File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -16,9 +16,7 @@ export const SignIn: React.FC = () => {
1616 const [ loading , setLoading ] = useState ( false ) ;
1717
1818 const handleLogin = async ( ) => {
19- setLoading ( true ) ;
2019 const loginResult = await login ( loginForm . email , loginForm . password ) ;
21- setLoading ( false ) ;
2220 return loginResult ;
2321 } ;
2422
@@ -49,6 +47,7 @@ export const SignIn: React.FC = () => {
4947 color = "#FFF"
5048 marginBottom = "20px"
5149 onClick = { async ( ) => {
50+ setLoading ( true ) ;
5251 try {
5352 if ( ! ( await handleLogin ( ) ) ) {
5453 toaster . create ( {
@@ -67,6 +66,7 @@ export const SignIn: React.FC = () => {
6766 duration : 3000 ,
6867 } ) ;
6968 }
69+ setLoading ( false ) ;
7070 } }
7171 loading = { loading }
7272 disabled = { loading }
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import {
2222} from '../client' ;
2323import { client } from '@web/client/client.gen' ;
2424import { employeesControllerOnboardEmployeeMutation } from '@web/client/@tanstack/react-query.gen' ;
25+ import { AxiosError } from 'axios' ;
2526// Reference: https://blog.finiam.com/blog/predictable-react-authentication-with-the-context-api
2627
2728export const AuthContext = createContext < AuthContextType > (
@@ -127,6 +128,11 @@ export const AuthProvider = ({ children }: any) => {
127128 } ,
128129 } )
129130 . then ( async ( response ) => {
131+ if ( response instanceof AxiosError ) {
132+ if ( response . response ?. status === 401 ) {
133+ throw new Error ( 'Invalid email or password' ) ;
134+ }
135+ }
130136 if ( response . data == null ) {
131137 return false ;
132138 }
You can’t perform that action at this time.
0 commit comments