user log in finished
This commit is contained in:
@@ -4,21 +4,18 @@ import { Link } from 'react-router-dom'
|
||||
import { Form } from '../../elements/Form'
|
||||
import { Button } from '../../elements/Button'
|
||||
import { useForm } from 'antd/lib/form/Form'
|
||||
import { useAppContext } from '../../contexts/AppContext'
|
||||
import { useUserContext } from '../../contexts/UserContext'
|
||||
|
||||
type FormValues = { username: string; password: string }
|
||||
|
||||
export const Login = () => {
|
||||
const appContext = useAppContext()
|
||||
const userContext = useUserContext()
|
||||
|
||||
const [form] = useForm<FormValues>()
|
||||
|
||||
const handleFinish = async ({ username, password }: FormValues) => {
|
||||
try {
|
||||
const res = await appContext.post('/dj-rest-auth/login/', {
|
||||
username,
|
||||
password,
|
||||
})
|
||||
const res = await userContext.handleLogin(username, password)
|
||||
console.log('logging in', res)
|
||||
} catch (err) {
|
||||
console.log('error logging in')
|
||||
|
||||
Reference in New Issue
Block a user