diff --git a/frontend/src/api/data/index.ts b/frontend/src/api/data/index.ts index b4a36a1..0b3ea0d 100644 --- a/frontend/src/api/data/index.ts +++ b/frontend/src/api/data/index.ts @@ -1,6 +1,7 @@ import { User } from '../../types' export const mockUser: User = { - username: 'TestUser42', id: '4242-4242-4242-4242', + username: 'TestUser42', + email: 'testuser@email.com', } diff --git a/frontend/src/app/CoreLayout.tsx b/frontend/src/app/CoreLayout.tsx index 34f36f6..0a08ae5 100644 --- a/frontend/src/app/CoreLayout.tsx +++ b/frontend/src/app/CoreLayout.tsx @@ -6,6 +6,7 @@ import { Route, Switch } from 'react-router' import { Dashboard } from './pages/Dashboard' import { NavRoute, AppHeader } from './layout/AppHeader' import { Profile } from './pages/Profile' +import { NewUser } from './forms/NewUser' export const CoreLayout = () => { const { user } = useUserContext() @@ -13,6 +14,7 @@ export const CoreLayout = () => { const routes: NavRoute[] = [ { exact: true, path: '/', label: 'Dashboard', component: Dashboard }, { path: '/profile', label: 'Profile', component: Profile }, + { path: '/new/user', label: 'New User', component: NewUser }, ] if (!user) diff --git a/frontend/src/app/forms/NewUser.tsx b/frontend/src/app/forms/NewUser.tsx index a02303e..eec15ab 100644 --- a/frontend/src/app/forms/NewUser.tsx +++ b/frontend/src/app/forms/NewUser.tsx @@ -1,6 +1,9 @@ -import { Button, Form, Input, message } from 'antd' +import { Button, Form, Input, Layout, message } from 'antd' +import axios from 'axios' import { User } from '../../types' +axios.defaults.baseURL = 'http://localhost:8080/' + type NewUserForm = Omit & { password1: string password2: string @@ -10,27 +13,38 @@ export const NewUser = () => { const [form] = Form.useForm() const handleFinish = (user: NewUserForm) => { + console.log('Asdfdas') if (user.password1 !== user.password2) { message.error('passwords do not match') return } + + axios.post(`/dj-rest-auth/registration`, user) } + console.log('ASDFUASDJF') + return ( -
- - - - - - - - - - - - - -
+ + +
+ + + + + + + + + + + + + +
+
+
) } diff --git a/frontend/src/app/layout/AppHeader.tsx b/frontend/src/app/layout/AppHeader.tsx index 35a668f..afc2698 100644 --- a/frontend/src/app/layout/AppHeader.tsx +++ b/frontend/src/app/layout/AppHeader.tsx @@ -32,7 +32,9 @@ export const AppHeader = ({ user, routes }: Props) => {
MVP Django React! 🤠 {routes?.map((route) => ( - {route.label} + + {route.label} + ))}
diff --git a/frontend/src/contexts/UserContext.tsx b/frontend/src/contexts/UserContext.tsx index c7080c1..78ce753 100644 --- a/frontend/src/contexts/UserContext.tsx +++ b/frontend/src/contexts/UserContext.tsx @@ -35,10 +35,10 @@ export const UserContextProvider = ({ children }: Props) => { useEffect(() => { const login = async () => { try { - const res = axios.post('/dj-rest-auth/login', { - email: 'blah', - password: 'blah', - }) + // const res = axios.post('/dj-rest-auth/login', { + // email: 'blah', + // password: 'blah', + // }) const user = await getLoggedInUser() if (!user) throw new Error() setUser(user) diff --git a/frontend/src/scss/app.scss b/frontend/src/scss/app.scss index 408befb..19f70ae 100644 --- a/frontend/src/scss/app.scss +++ b/frontend/src/scss/app.scss @@ -43,3 +43,8 @@ padding: 0; } } + +.ant-layout-content { + max-width: 900px; + margin: auto; +}