diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index ea14ded..8b5eec4 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,6 +1,6 @@ import { BrowserRouter } from 'react-router-dom' import { UserContextProvider } from './contexts/UserContext' -import { CoreLayout } from './layout/CoreLayout' +import { CoreLayout } from './app/CoreLayout' import './scss/app.scss' const App = () => { diff --git a/frontend/src/layout/CoreLayout.tsx b/frontend/src/app/CoreLayout.tsx similarity index 83% rename from frontend/src/layout/CoreLayout.tsx rename to frontend/src/app/CoreLayout.tsx index 726608d..34f36f6 100644 --- a/frontend/src/layout/CoreLayout.tsx +++ b/frontend/src/app/CoreLayout.tsx @@ -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() diff --git a/frontend/src/app/forms/NewUser.tsx b/frontend/src/app/forms/NewUser.tsx new file mode 100644 index 0000000..a02303e --- /dev/null +++ b/frontend/src/app/forms/NewUser.tsx @@ -0,0 +1,36 @@ +import { Button, Form, Input, message } from 'antd' +import { User } from '../../types' + +type NewUserForm = Omit & { + password1: string + password2: string +} + +export const NewUser = () => { + const [form] = Form.useForm() + + const handleFinish = (user: NewUserForm) => { + if (user.password1 !== user.password2) { + message.error('passwords do not match') + return + } + } + + return ( +
+ + + + + + + + + + + + + +
+ ) +} diff --git a/frontend/src/layout/AppHeader.tsx b/frontend/src/app/layout/AppHeader.tsx similarity index 97% rename from frontend/src/layout/AppHeader.tsx rename to frontend/src/app/layout/AppHeader.tsx index d6fa0fa..35a668f 100644 --- a/frontend/src/layout/AppHeader.tsx +++ b/frontend/src/app/layout/AppHeader.tsx @@ -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 = { diff --git a/frontend/src/pages/Dashboard.tsx b/frontend/src/app/pages/Dashboard.tsx similarity index 100% rename from frontend/src/pages/Dashboard.tsx rename to frontend/src/app/pages/Dashboard.tsx diff --git a/frontend/src/pages/Login.tsx b/frontend/src/app/pages/Login.tsx similarity index 91% rename from frontend/src/pages/Login.tsx rename to frontend/src/app/pages/Login.tsx index f8210c6..74ab501 100644 --- a/frontend/src/pages/Login.tsx +++ b/frontend/src/app/pages/Login.tsx @@ -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() diff --git a/frontend/src/pages/Profile.tsx b/frontend/src/app/pages/Profile.tsx similarity index 100% rename from frontend/src/pages/Profile.tsx rename to frontend/src/app/pages/Profile.tsx diff --git a/frontend/src/contexts/UserContext.tsx b/frontend/src/contexts/UserContext.tsx index a521ddc..c7080c1 100644 --- a/frontend/src/contexts/UserContext.tsx +++ b/frontend/src/contexts/UserContext.tsx @@ -12,6 +12,7 @@ import { useHistory } from 'react-router' import { User } from '../types' import { getLoggedInUser, logIn, logOut } from '../api' +import axios from 'axios' type Props = { children: React.ReactNode @@ -34,6 +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 user = await getLoggedInUser() if (!user) throw new Error() setUser(user) diff --git a/frontend/src/pages/forms/NewUser.tsx b/frontend/src/pages/forms/NewUser.tsx deleted file mode 100644 index 8cff145..0000000 --- a/frontend/src/pages/forms/NewUser.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { Form, Input, Layout } from 'antd' -import { User } from '../../types' - -export const NewUser = () => { - const [form] = Form.useForm() - - return ( -
- - - -
- ) -} diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.ts index 86a1ab4..608c578 100644 --- a/frontend/src/types/index.ts +++ b/frontend/src/types/index.ts @@ -1,4 +1,5 @@ export type User = { - id: string; - username: string; -}; + id: string + username: string + email: string +}