stuff, with a side of things
This commit is contained in:
@@ -2,7 +2,7 @@ import { FundBar } from '../../widgets/FundBar'
|
||||
import { useStacks } from '../../hooks/getMany/useStacks'
|
||||
|
||||
export const Dashboard = () => {
|
||||
const stacks = useStacks('')
|
||||
const stacks = useStacks('42')
|
||||
|
||||
if (!stacks.data) return <div>loading...</div>
|
||||
|
||||
|
||||
@@ -1,28 +1,33 @@
|
||||
import { Input } from 'antd'
|
||||
import FormItem from 'antd/lib/form/FormItem'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { User } from '../../types'
|
||||
import { useUserContext } from '../../contexts/UserContext'
|
||||
import { Form } from '../../elements/Form'
|
||||
import { Button } from '../../elements/Button'
|
||||
import { useForm } from 'antd/lib/form/Form'
|
||||
import { useAppContext } from '../../contexts/AppContext'
|
||||
import { useStacks } from '../../hooks/getMany/useStacks'
|
||||
|
||||
type FormValues = Pick<User, 'name'> & { password: string }
|
||||
type FormValues = { email: string; password: string }
|
||||
|
||||
export const Login = () => {
|
||||
const userContext = useUserContext()
|
||||
const appContext = useAppContext()
|
||||
const stacks = useStacks('')
|
||||
|
||||
const [form] = useForm<FormValues>()
|
||||
|
||||
const handleFinish = ({ name, password }: FormValues) => {
|
||||
userContext.handleLogin(name, password)
|
||||
const handleFinish = async ({ email, password }: FormValues) => {
|
||||
const res = await appContext.post('/dj-rest-auth/login', {
|
||||
email,
|
||||
password,
|
||||
})
|
||||
console.log(res)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="login">
|
||||
<Form onFinish={handleFinish} form={form}>
|
||||
<h1>Log In</h1>
|
||||
<FormItem label="Username" name="username">
|
||||
<FormItem label="email" name="email">
|
||||
<Input />
|
||||
</FormItem>
|
||||
<FormItem label="Password" name="password">
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
import { Button, Form, Input } from 'antd'
|
||||
import { useForm } from 'antd/lib/form/Form'
|
||||
import { useUserContext } from '../../contexts/UserContext'
|
||||
import './style.scss'
|
||||
|
||||
type Credentials = {
|
||||
username: string
|
||||
password: string
|
||||
}
|
||||
|
||||
export const Login = () => {
|
||||
const { handleLogin } = useUserContext()
|
||||
const [form] = useForm<Credentials>()
|
||||
|
||||
const handleSubmit = ({ username, password }: Credentials) => {
|
||||
handleLogin(username, password)
|
||||
}
|
||||
|
||||
return (
|
||||
<Form form={form} onFinish={handleSubmit}>
|
||||
<Form.Item label="username" name="username">
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item label="password" name="password">
|
||||
<Input type="password" />
|
||||
</Form.Item>
|
||||
<Button type="primary" htmlType="submit">
|
||||
Login!
|
||||
</Button>
|
||||
</Form>
|
||||
)
|
||||
}
|
||||
@@ -11,7 +11,6 @@ export const NewUser = () => {
|
||||
const [form] = Form.useForm<NewUserForm>()
|
||||
|
||||
const handleFinish = (user: NewUserForm) => {
|
||||
console.log('Asdfdas')
|
||||
if (user.password1 !== user.password2) {
|
||||
message.error('passwords do not match')
|
||||
return
|
||||
@@ -20,29 +19,23 @@ export const NewUser = () => {
|
||||
axios.post(`/dj-rest-auth/registration/`, user)
|
||||
}
|
||||
|
||||
console.log('ASDFUASDJF')
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
<Layout.Content>
|
||||
<Form form={form} onFinish={handleFinish}>
|
||||
<Form.Item label="username" name="username">
|
||||
<Input></Input>
|
||||
</Form.Item>
|
||||
<Form.Item label="email" name="email">
|
||||
<Input type="email"></Input>
|
||||
</Form.Item>
|
||||
<Form.Item label="password" name="password1">
|
||||
<Input minLength={8}></Input>
|
||||
</Form.Item>
|
||||
<Form.Item label="confirm" name="password2">
|
||||
<Input></Input>
|
||||
</Form.Item>
|
||||
<Button type="primary" htmlType="submit">
|
||||
Create
|
||||
</Button>
|
||||
</Form>
|
||||
</Layout.Content>
|
||||
</Layout>
|
||||
<Form form={form} onFinish={handleFinish}>
|
||||
<Form.Item label="username" name="username">
|
||||
<Input></Input>
|
||||
</Form.Item>
|
||||
<Form.Item label="email" name="email">
|
||||
<Input type="email"></Input>
|
||||
</Form.Item>
|
||||
<Form.Item label="password" name="password1">
|
||||
<Input minLength={8}></Input>
|
||||
</Form.Item>
|
||||
<Form.Item label="confirm" name="password2">
|
||||
<Input></Input>
|
||||
</Form.Item>
|
||||
<Button type="primary" htmlType="submit">
|
||||
Create
|
||||
</Button>
|
||||
</Form>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user