lesson 4 live 30/12

This commit is contained in:
2023-12-30 19:18:54 +01:00
parent 7adcc8d2c9
commit b81d33c1b4
14 changed files with 243 additions and 24 deletions

View File

@@ -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>
)
}