From 3f9b05b1ddac57cffa2ce2da3f1f1863de6322f2 Mon Sep 17 00:00:00 2001 From: Elijah Lucian Date: Thu, 15 Jul 2021 16:08:21 -0600 Subject: [PATCH] registration page and such --- frontend/src/CoreLayout.tsx | 5 +- frontend/src/pages/Login/index.tsx | 46 ++++++++++--------- frontend/src/pages/NewUser/index.tsx | 29 +++++++----- server/server/api/management/commands/seed.py | 9 +++- server/setup.sh | 4 +- 5 files changed, 55 insertions(+), 38 deletions(-) diff --git a/frontend/src/CoreLayout.tsx b/frontend/src/CoreLayout.tsx index 2926e6f..52cc4ee 100644 --- a/frontend/src/CoreLayout.tsx +++ b/frontend/src/CoreLayout.tsx @@ -24,7 +24,10 @@ export const CoreLayout = () => {
{!user ? ( - + + + + ) : ( diff --git a/frontend/src/pages/Login/index.tsx b/frontend/src/pages/Login/index.tsx index 15b6972..d4decf0 100644 --- a/frontend/src/pages/Login/index.tsx +++ b/frontend/src/pages/Login/index.tsx @@ -14,31 +14,33 @@ export const Login = () => { const [form] = useForm() const handleFinish = async ({ username, password }: FormValues) => { - const res = await appContext.post('/dj-rest-auth/login', { - username, - password, - }) - console.log(res) + try { + const res = await appContext.post('/dj-rest-auth/login', { + username, + password, + }) + console.log('logging in', res) + } catch (err) { + console.log('error logging in') + } } return ( -
-
-

Log In

- - - - - - + +

Log In

+ + + + + + -
- No Account? Sign Up! - -
-
-
+
+ No Account? Sign Up! + +
+ ) } diff --git a/frontend/src/pages/NewUser/index.tsx b/frontend/src/pages/NewUser/index.tsx index 552a15b..c648cda 100644 --- a/frontend/src/pages/NewUser/index.tsx +++ b/frontend/src/pages/NewUser/index.tsx @@ -1,5 +1,9 @@ -import { Button, Form, Input, Layout, message } from 'antd' -import axios from 'axios' +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 & { @@ -8,7 +12,8 @@ type NewUserForm = Omit & { } export const NewUser = () => { - const [form] = Form.useForm() + const api = useAppContext() + const [form] = useForm() const handleFinish = (user: NewUserForm) => { if (user.password1 !== user.password2) { @@ -16,23 +21,23 @@ export const NewUser = () => { return } - axios.post(`/dj-rest-auth/registration/`, user) + api.post(`/dj-rest-auth/registration`, user) } return (
- + - - + + - - + + - - + + - + diff --git a/server/server/api/management/commands/seed.py b/server/server/api/management/commands/seed.py index edac929..ad8a614 100644 --- a/server/server/api/management/commands/seed.py +++ b/server/server/api/management/commands/seed.py @@ -19,8 +19,15 @@ class Command(BaseCommand): email="tanner@westwinds.io", password="toffee15").save() + self.stdout.write(User.objects.all()) + self.stdout.write('Users Created!') + Account.objects.all().delete() - home = Account() + home = Account(name="home", details="home stacks", + income=4000, expenses=2000) + + self.stdout.write(Account.objects.all().count()) + self.stdout.write('Accounts Created!') # create seed accounts # Home Account # $3000 diff --git a/server/setup.sh b/server/setup.sh index d471379..e8fb5e2 100755 --- a/server/setup.sh +++ b/server/setup.sh @@ -1,5 +1,5 @@ python manage.py migrate -python manage.py createsuperuser --email admin@example.com --username admin python manage.py makemigrations python manage.py migrate -python manage.py seed \ No newline at end of file +python manage.py seed +python manage.py createsuperuser --email admin@example.com --username admin \ No newline at end of file