main
parent
0df8bf9445
commit
c3d1017419
10 changed files with 52 additions and 24 deletions
@ -1,11 +1,11 @@ |
||||
import React from 'react' |
||||
import { Layout } from 'antd' |
||||
import { useUserContext } from '../contexts/UserContext' |
||||
import { Login } from '../pages/Login' |
||||
import { Login } from './pages/Login' |
||||
import { Route, Switch } from 'react-router' |
||||
import { Dashboard } from '../pages/Dashboard' |
||||
import { NavRoute, AppHeader } from './AppHeader' |
||||
import { Profile } from '../pages/Profile' |
||||
import { Dashboard } from './pages/Dashboard' |
||||
import { NavRoute, AppHeader } from './layout/AppHeader' |
||||
import { Profile } from './pages/Profile' |
||||
|
||||
export const CoreLayout = () => { |
||||
const { user } = useUserContext() |
@ -0,0 +1,36 @@ |
||||
import { Button, Form, Input, message } from 'antd' |
||||
import { User } from '../../types' |
||||
|
||||
type NewUserForm = Omit<User, 'id'> & { |
||||
password1: string |
||||
password2: string |
||||
} |
||||
|
||||
export const NewUser = () => { |
||||
const [form] = Form.useForm<NewUserForm>() |
||||
|
||||
const handleFinish = (user: NewUserForm) => { |
||||
if (user.password1 !== user.password2) { |
||||
message.error('passwords do not match') |
||||
return |
||||
} |
||||
} |
||||
|
||||
return ( |
||||
<Form form={form} onFinish={handleFinish}> |
||||
<Form.Item label="username" name="name"> |
||||
<Input></Input> |
||||
</Form.Item> |
||||
<Form.Item label="email" name="email"> |
||||
<Input></Input> |
||||
</Form.Item> |
||||
<Form.Item label="password" name="password1"> |
||||
<Input></Input> |
||||
</Form.Item> |
||||
<Form.Item label="confirm" name="password2"> |
||||
<Input></Input> |
||||
</Form.Item> |
||||
<Button htmlType="submit">Create</Button> |
||||
</Form> |
||||
) |
||||
} |
@ -1,7 +1,7 @@ |
||||
import React from 'react' |
||||
import { Avatar, Button, Typography } from 'antd' |
||||
import { Header } from 'antd/lib/layout/layout' |
||||
import { User } from '../types' |
||||
import { User } from '../../types' |
||||
import { Link, useHistory } from 'react-router-dom' |
||||
|
||||
export type NavRoute = { |
@ -1,5 +1,5 @@ |
||||
import { FormEvent, useState } from 'react' |
||||
import { useUserContext } from '../contexts/UserContext' |
||||
import { useUserContext } from '../../contexts/UserContext' |
||||
|
||||
export const Login = () => { |
||||
const { handleLogin } = useUserContext() |
@ -1,14 +0,0 @@ |
||||
import { Form, Input, Layout } from 'antd' |
||||
import { User } from '../../types' |
||||
|
||||
export const NewUser = () => { |
||||
const [form] = Form.useForm<User>() |
||||
|
||||
return ( |
||||
<Form form={form}> |
||||
<Form.Item label="username" name="name"> |
||||
<Input></Input> |
||||
</Form.Item> |
||||
</Form> |
||||
) |
||||
} |
@ -1,4 +1,5 @@ |
||||
export type User = { |
||||
id: string; |
||||
username: string; |
||||
}; |
||||
id: string |
||||
username: string |
||||
email: string |
||||
} |
||||
|
Loading…
Reference in new issue