You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

46 lines
1.2 KiB

import { Input, message } from 'antd'
import { useForm } from 'antd/lib/form/Form'
import FormItem from 'antd/lib/form/FormItem'
import { useAppContext } from '../../contexts/AppContext'
import { Button } from '../../elements/Button'
import { Form } from '../../elements/Form'
import { User } from '../../types'
type NewUserForm = Omit<User, 'id'> & {
password1: string
password2: string
}
export const NewUser = () => {
const api = useAppContext()
const [form] = useForm<NewUserForm>()
const handleFinish = (user: NewUserForm) => {
if (user.password1 !== user.password2) {
message.error('passwords do not match')
return
}
api.post(`/dj-rest-auth/registration`, user)
}
return (
<Form form={form} onFinish={handleFinish}>
<FormItem label="username" name="username">
<Input></Input>
</FormItem>
<FormItem label="email" name="email">
<Input type="email"></Input>
</FormItem>
<FormItem label="password" name="password1">
<Input minLength={8}></Input>
</FormItem>
<FormItem label="confirm" name="password2">
<Input></Input>
</FormItem>
<Button type="primary" htmlType="submit">
Create
</Button>
</Form>
)
}