mirror of
https://github.com/ershisan99/flashcards-example-project.git
synced 2025-12-16 20:59:27 +00:00
lesson 4 live 30/12
This commit is contained in:
@@ -1,9 +1,26 @@
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { toast } from 'react-toastify'
|
||||
|
||||
import { Page, SignIn } from '@/components'
|
||||
import { useLoginMutation } from '@/services/auth/auth.service'
|
||||
import { LoginArgs } from '@/services/auth/auth.types'
|
||||
|
||||
export const SignInPage = () => {
|
||||
const [signIn] = useLoginMutation()
|
||||
const navigate = useNavigate()
|
||||
const handleSignIn = async (data: LoginArgs) => {
|
||||
try {
|
||||
await signIn(data).unwrap()
|
||||
navigate('/')
|
||||
} catch (error: any) {
|
||||
console.log(error)
|
||||
toast.error(error?.data?.message ?? 'Could not sign in')
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<SignIn onSubmit={() => {}} />
|
||||
<SignIn onSubmit={handleSignIn} />
|
||||
</Page>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user