From 8c91b3030ab7483c79e71892050bc1b8f5f1af75 Mon Sep 17 00:00:00 2001 From: Chaiyawut Thengket Date: Fri, 17 Nov 2023 10:44:54 +0700 Subject: [PATCH 1/9] create apiview --- backend/core/settings.py | 1 + backend/core/urls.py | 1 + backend/dashboard/__init__.py | 0 backend/dashboard/admin.py | 3 ++ backend/dashboard/apps.py | 6 +++ backend/dashboard/migrations/__init__.py | 0 backend/dashboard/models.py | 3 ++ backend/dashboard/serializers.py | 7 +++ backend/dashboard/tests.py | 3 ++ backend/dashboard/urls.py | 6 +++ backend/dashboard/views.py | 58 ++++++++++++++++++++++++ 11 files changed, 88 insertions(+) create mode 100644 backend/dashboard/__init__.py create mode 100644 backend/dashboard/admin.py create mode 100644 backend/dashboard/apps.py create mode 100644 backend/dashboard/migrations/__init__.py create mode 100644 backend/dashboard/models.py create mode 100644 backend/dashboard/serializers.py create mode 100644 backend/dashboard/tests.py create mode 100644 backend/dashboard/urls.py create mode 100644 backend/dashboard/views.py diff --git a/backend/core/settings.py b/backend/core/settings.py index 5c01d05..4936805 100644 --- a/backend/core/settings.py +++ b/backend/core/settings.py @@ -52,6 +52,7 @@ INSTALLED_APPS = [ 'tasks', 'users', 'authentications', + 'dashboard', 'corsheaders', 'drf_spectacular', diff --git a/backend/core/urls.py b/backend/core/urls.py index a02869c..434a21f 100644 --- a/backend/core/urls.py +++ b/backend/core/urls.py @@ -27,4 +27,5 @@ urlpatterns = [ path('api/schema/', SpectacularAPIView.as_view(), name='schema'), path('api/schema/swagger-ui/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'), path('api/schema/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'), + path('dashboard/', include('dashboard.urls')), ] \ No newline at end of file diff --git a/backend/dashboard/__init__.py b/backend/dashboard/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/dashboard/admin.py b/backend/dashboard/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/backend/dashboard/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/backend/dashboard/apps.py b/backend/dashboard/apps.py new file mode 100644 index 0000000..7b1cc05 --- /dev/null +++ b/backend/dashboard/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class DashboardConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'dashboard' diff --git a/backend/dashboard/migrations/__init__.py b/backend/dashboard/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/dashboard/models.py b/backend/dashboard/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/backend/dashboard/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/backend/dashboard/serializers.py b/backend/dashboard/serializers.py new file mode 100644 index 0000000..ddc207b --- /dev/null +++ b/backend/dashboard/serializers.py @@ -0,0 +1,7 @@ +from rest_framework import serializers +from .models import UserStats + +class UserStatsSerializer(serializers.ModelSerializer): + class Meta: + model = UserStats + fields = ['health', 'gold', 'experience', 'strength', 'intelligence', 'endurance', 'perception', 'luck', 'level'] \ No newline at end of file diff --git a/backend/dashboard/tests.py b/backend/dashboard/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/backend/dashboard/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/backend/dashboard/urls.py b/backend/dashboard/urls.py new file mode 100644 index 0000000..beb8f1b --- /dev/null +++ b/backend/dashboard/urls.py @@ -0,0 +1,6 @@ +from django.urls import path +from .views import DashboardStatsAPIView + +urlpatterns = [ + path('dashboard/stats/', DashboardStatsAPIView.as_view(), name='dashboard-stats'), +] diff --git a/backend/dashboard/views.py b/backend/dashboard/views.py new file mode 100644 index 0000000..4475d77 --- /dev/null +++ b/backend/dashboard/views.py @@ -0,0 +1,58 @@ +from rest_framework.views import APIView +from rest_framework.response import Response +from rest_framework import status +from rest_framework.permissions import IsAuthenticated +from django.db.models import Count +from django.utils import timezone + +from tasks.models import Todo, RecurrenceTask + +class DashboardStatsAPIView(APIView): + permission_classes = [IsAuthenticated] + + def get(self, request): + user = request.user + + # Calculate task usage statistics + todo_count = Todo.objects.filter(user=user).count() + recurrence_task_count = RecurrenceTask.objects.filter(user=user).count() + + # Calculate how many tasks were completed in the last 7 days + completed_todo_count_last_week = Todo.objects.filter(user=user, completed=True, last_update__gte=timezone.now() - timezone.timedelta(days=7)).count() + completed_recurrence_task_count_last_week = RecurrenceTask.objects.filter(user=user, completed=True, last_update__gte=timezone.now() - timezone.timedelta(days=7)).count() + + # Calculate subtask completion rate + total_subtasks = Todo.objects.filter(user=user).aggregate(total=Count('subtask__id'))['total'] + completed_subtasks = Todo.objects.filter(user=user, subtask__completed=True).aggregate(total=Count('subtask__id'))['total'] + + # Calculate overall completion rate + total_tasks = todo_count + recurrence_task_count + completed_tasks = completed_todo_count_last_week + completed_recurrence_task_count_last_week + overall_completion_rate = (completed_tasks / total_tasks) * 100 if total_tasks > 0 else 0 + + data = { + 'todo_count': todo_count, + 'recurrence_task_count': recurrence_task_count, + 'completed_todo_count_last_week': completed_todo_count_last_week, + 'completed_recurrence_task_count_last_week': completed_recurrence_task_count_last_week, + 'total_subtasks': total_subtasks, + 'completed_subtasks': completed_subtasks, + 'overall_completion_rate': overall_completion_rate, + } + + return Response(data, status=status.HTTP_200_OK) + + def post(self, request): + # Handle incoming data from the POST request + # Update the necessary information based on the data + + task_id = request.data.get('task_id') + is_completed = request.data.get('is_completed') + + try: + task = Todo.objects.get(id=task_id, user=request.user) + task.completed = is_completed + task.save() + return Response({'message': 'Task completion status updated successfully'}, status=status.HTTP_200_OK) + except Todo.DoesNotExist: + return Response({'error': 'Task not found'}, status=status.HTTP_404_NOT_FOUND) \ No newline at end of file From 8954bff35888c2eb8b0285c85a2b15c76b502f6c Mon Sep 17 00:00:00 2001 From: Wissarut Kanasub Date: Sat, 18 Nov 2023 10:56:18 +0700 Subject: [PATCH 2/9] add signup panel --- frontend/package.json | 3 ++ frontend/pnpm-lock.yaml | 42 +++++++++++++++++++++++ frontend/src/App.jsx | 2 ++ frontend/src/components/signup/Signup.jsx | 39 +++++++++++++++++++++ 4 files changed, 86 insertions(+) create mode 100644 frontend/src/components/signup/Signup.jsx diff --git a/frontend/package.json b/frontend/package.json index e03bc04..d850234 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -16,6 +16,9 @@ "@dnd-kit/utilities": "^3.2.2", "@emotion/react": "^11.11.1", "@emotion/styled": "^11.11.0", + "@fortawesome/fontawesome-svg-core": "^6.4.2", + "@fortawesome/free-brands-svg-icons": "^6.4.2", + "@fortawesome/react-fontawesome": "^0.2.0", "@fullcalendar/core": "^6.1.9", "@fullcalendar/daygrid": "^6.1.9", "@fullcalendar/interaction": "^6.1.9", diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index acf0447..2bce532 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -23,6 +23,15 @@ dependencies: '@emotion/styled': specifier: ^11.11.0 version: 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.37)(react@18.2.0) + '@fortawesome/fontawesome-svg-core': + specifier: ^6.4.2 + version: 6.4.2 + '@fortawesome/free-brands-svg-icons': + specifier: ^6.4.2 + version: 6.4.2 + '@fortawesome/react-fontawesome': + specifier: ^0.2.0 + version: 0.2.0(@fortawesome/fontawesome-svg-core@6.4.2)(react@18.2.0) '@fullcalendar/core': specifier: ^6.1.9 version: 6.1.9 @@ -820,6 +829,39 @@ packages: resolution: {integrity: sha512-OfX7E2oUDYxtBvsuS4e/jSn4Q9Qb6DzgeYtsAdkPZ47znpoNsMgZw0+tVijiv3uGNR6dgNlty6r9rzIzHjtd/A==} dev: false + /@fortawesome/fontawesome-common-types@6.4.2: + resolution: {integrity: sha512-1DgP7f+XQIJbLFCTX1V2QnxVmpLdKdzzo2k8EmvDOePfchaIGQ9eCHj2up3/jNEbZuBqel5OxiaOJf37TWauRA==} + engines: {node: '>=6'} + requiresBuild: true + dev: false + + /@fortawesome/fontawesome-svg-core@6.4.2: + resolution: {integrity: sha512-gjYDSKv3TrM2sLTOKBc5rH9ckje8Wrwgx1CxAPbN5N3Fm4prfi7NsJVWd1jklp7i5uSCVwhZS5qlhMXqLrpAIg==} + engines: {node: '>=6'} + requiresBuild: true + dependencies: + '@fortawesome/fontawesome-common-types': 6.4.2 + dev: false + + /@fortawesome/free-brands-svg-icons@6.4.2: + resolution: {integrity: sha512-LKOwJX0I7+mR/cvvf6qIiqcERbdnY+24zgpUSouySml+5w8B4BJOx8EhDR/FTKAu06W12fmUIcv6lzPSwYKGGg==} + engines: {node: '>=6'} + requiresBuild: true + dependencies: + '@fortawesome/fontawesome-common-types': 6.4.2 + dev: false + + /@fortawesome/react-fontawesome@0.2.0(@fortawesome/fontawesome-svg-core@6.4.2)(react@18.2.0): + resolution: {integrity: sha512-uHg75Rb/XORTtVt7OS9WoK8uM276Ufi7gCzshVWkUJbHhh3svsUUeqXerrM96Wm7fRiDzfKRwSoahhMIkGAYHw==} + peerDependencies: + '@fortawesome/fontawesome-svg-core': ~1 || ~6 + react: '>=16.3' + dependencies: + '@fortawesome/fontawesome-svg-core': 6.4.2 + prop-types: 15.8.1 + react: 18.2.0 + dev: false + /@fullcalendar/core@6.1.9: resolution: {integrity: sha512-eeG+z9BWerdsU9Ac6j16rpYpPnE0wxtnEHiHrh/u/ADbGTR3hCOjCD9PxQOfhOTHbWOVs7JQunGcksSPu5WZBQ==} dependencies: diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index ad9dc97..c4b93eb 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -12,6 +12,7 @@ import IconSideNav from "./components/navigations/IconSideNav"; import Eisenhower from "./components/eisenhowerMatrix/Eisenhower"; import PrivateRoute from "./PrivateRoute"; import ProfileUpdatePage from "./components/profilePage"; +import Signup from "./components/signup/Signup"; const App = () => { @@ -43,6 +44,7 @@ const App = () => { } /> } /> + diff --git a/frontend/src/components/signup/Signup.jsx b/frontend/src/components/signup/Signup.jsx new file mode 100644 index 0000000..3958feb --- /dev/null +++ b/frontend/src/components/signup/Signup.jsx @@ -0,0 +1,39 @@ +import React from 'react'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { faGoogle, faGithub } from '@fortawesome/free-brands-svg-icons'; + +function Signup() { + return ( +
+
+

Create your account

+

+ Start spending more time on your own table. +

+
+
+ +
+ +
+ +
+ +
+ +
+
+
+
+ ); +} + +export default Signup; From 9cd87e5180f16c626727170c33759e7c1291822c Mon Sep 17 00:00:00 2001 From: Wissarut Kanasub Date: Sat, 18 Nov 2023 10:57:41 +0700 Subject: [PATCH 3/9] delete signup-panel from app --- frontend/src/App.jsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index c4b93eb..ad9dc97 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -12,7 +12,6 @@ import IconSideNav from "./components/navigations/IconSideNav"; import Eisenhower from "./components/eisenhowerMatrix/Eisenhower"; import PrivateRoute from "./PrivateRoute"; import ProfileUpdatePage from "./components/profilePage"; -import Signup from "./components/signup/Signup"; const App = () => { @@ -44,7 +43,6 @@ const App = () => { } /> } /> - From 5d86550382651a7154c4569acf6abe785cc668b5 Mon Sep 17 00:00:00 2001 From: THIS ONE IS A LITTLE BIT TRICKY KRUB Date: Sun, 19 Nov 2023 19:47:37 +0700 Subject: [PATCH 4/9] Modifying signup page. --- .../components/authentication/SignUpPage.jsx | 210 ++++++++++++------ 1 file changed, 137 insertions(+), 73 deletions(-) diff --git a/frontend/src/components/authentication/SignUpPage.jsx b/frontend/src/components/authentication/SignUpPage.jsx index 28eb1c2..06f3ce0 100644 --- a/frontend/src/components/authentication/SignUpPage.jsx +++ b/frontend/src/components/authentication/SignUpPage.jsx @@ -1,7 +1,6 @@ import React, { useState } from "react"; import { useNavigate } from "react-router-dom"; import axiosapi from "../../api/AuthenticationApi"; - import Avatar from "@mui/material/Avatar"; import Button from "@mui/material/Button"; import CssBaseline from "@mui/material/CssBaseline"; @@ -13,8 +12,9 @@ import Grid from "@mui/material/Grid"; import Box from "@mui/material/Box"; import LockOutlinedIcon from "@mui/icons-material/LockOutlined"; import Typography from "@mui/material/Typography"; -import Container from "@mui/material/Container"; -import { createTheme, ThemeProvider } from "@mui/material/styles"; +import { useCallback } from "react"; +import Particles from "react-tsparticles"; +import { loadFull } from "tsparticles"; function Copyright(props) { return ( @@ -29,7 +29,6 @@ function Copyright(props) { ); } -const defaultTheme = createTheme(); export default function SignUp() { const Navigate = useNavigate(); @@ -62,82 +61,147 @@ export default function SignUp() { const { name, value } = e.target; setFormData({ ...formData, [name]: value }); }; + { + /* Particles Loader*/ + } + const particlesInit = useCallback(async (engine) => { + console.log(engine); + await loadFull(engine); + }, []); + + const particlesLoaded = useCallback(async (container) => { + console.log(container); + }, []); + return ( - - - - - - - +
+ {/* Particles Container */} +
+ +
+
+
+ {/* Register Form */} Sign up - - - - - - - - - - - - - } - label="I want to receive inspiration, marketing promotions and updates via email." - /> - - +
+ + + + } + label="I want to receive inspiration, marketing promotions and updates via email." + /> - - - - Already have an account? Sign in - - - - - - - - + {/* Already have an account? */} + + +
+
+
); + } From 61a11d51d5a52a050bac5ef12d383a6faa016319 Mon Sep 17 00:00:00 2001 From: THIS ONE IS A LITTLE BIT TRICKY KRUB Date: Sun, 19 Nov 2023 20:06:04 +0700 Subject: [PATCH 5/9] Modifying signup page. --- .../components/authentication/SignUpPage.jsx | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/frontend/src/components/authentication/SignUpPage.jsx b/frontend/src/components/authentication/SignUpPage.jsx index 06f3ce0..8a2168c 100644 --- a/frontend/src/components/authentication/SignUpPage.jsx +++ b/frontend/src/components/authentication/SignUpPage.jsx @@ -1,16 +1,11 @@ import React, { useState } from "react"; import { useNavigate } from "react-router-dom"; import axiosapi from "../../api/AuthenticationApi"; -import Avatar from "@mui/material/Avatar"; import Button from "@mui/material/Button"; -import CssBaseline from "@mui/material/CssBaseline"; import TextField from "@mui/material/TextField"; import FormControlLabel from "@mui/material/FormControlLabel"; import Checkbox from "@mui/material/Checkbox"; import Link from "@mui/material/Link"; -import Grid from "@mui/material/Grid"; -import Box from "@mui/material/Box"; -import LockOutlinedIcon from "@mui/icons-material/LockOutlined"; import Typography from "@mui/material/Typography"; import { useCallback } from "react"; import Particles from "react-tsparticles"; @@ -18,18 +13,20 @@ import { loadFull } from "tsparticles"; function Copyright(props) { return ( - +
{"Copyright © "} - + TurTask - {" "} + {" "} {new Date().getFullYear()} {"."} - +
); } - export default function SignUp() { const Navigate = useNavigate(); @@ -41,7 +38,7 @@ export default function SignUp() { const [error, setError] = useState(null); const [isSubmitting, setIsSubmitting] = useState(false); - const handleSubmit = async e => { + const handleSubmit = async (e) => { e.preventDefault(); setIsSubmitting(true); setError(null); @@ -57,7 +54,7 @@ export default function SignUp() { Navigate("/login"); }; - const handleChange = e => { + const handleChange = (e) => { const { name, value } = e.target; setFormData({ ...formData, [name]: value }); }; @@ -73,9 +70,11 @@ export default function SignUp() { console.log(container); }, []); - return ( -
+
{/* Particles Container */}
-
+
{/* Register Form */} - - Sign up - +

Signup

} label="I want to receive inspiration, marketing promotions and updates via email." /> - - {/* Already have an account? */} - + {/* Already have an account? */} + +
); - } From de62190f0c2b199f35672c4bc764e568c687da8c Mon Sep 17 00:00:00 2001 From: THIS ONE IS A LITTLE BIT TRICKY KRUB Date: Sun, 19 Nov 2023 20:32:21 +0700 Subject: [PATCH 6/9] Completed Signup page improvement. --- .../components/authentication/SignUpPage.jsx | 110 ++++++++++-------- 1 file changed, 62 insertions(+), 48 deletions(-) diff --git a/frontend/src/components/authentication/SignUpPage.jsx b/frontend/src/components/authentication/SignUpPage.jsx index 8a2168c..daf452f 100644 --- a/frontend/src/components/authentication/SignUpPage.jsx +++ b/frontend/src/components/authentication/SignUpPage.jsx @@ -1,12 +1,6 @@ import React, { useState } from "react"; import { useNavigate } from "react-router-dom"; import axiosapi from "../../api/AuthenticationApi"; -import Button from "@mui/material/Button"; -import TextField from "@mui/material/TextField"; -import FormControlLabel from "@mui/material/FormControlLabel"; -import Checkbox from "@mui/material/Checkbox"; -import Link from "@mui/material/Link"; -import Typography from "@mui/material/Typography"; import { useCallback } from "react"; import Particles from "react-tsparticles"; import { loadFull } from "tsparticles"; @@ -108,13 +102,13 @@ export default function SignUp() { }, particles: { color: { - value: "#008000", + value: "#023020", }, links: { - color: "#00ff00", + color: "#228B22", distance: 150, enable: true, - opacity: 0.1, + opacity: 0.5, width: 1, }, move: { @@ -141,7 +135,7 @@ export default function SignUp() { type: "circle", }, size: { - value: { min: 4, max: 5 }, + value: { min: 6, max: 8 }, }, }, detectRetina: true, @@ -152,55 +146,75 @@ export default function SignUp() {
{/* Register Form */}

Signup

-
- + + - + {/* Username Input */} +
+ + - + {/* Password Input */} +
+ + - } - label="I want to receive inspiration, marketing promotions and updates via email." +
+

+
+ - - {/* Already have an account? */} - - + +
+ + {/* Login Button */} + + {/* Already have an account? */} +
From e372c1b3ba4c5bf17e046e8a47c324cd4c6b95b4 Mon Sep 17 00:00:00 2001 From: sosokker Date: Mon, 20 Nov 2023 01:38:34 +0700 Subject: [PATCH 7/9] Update API url --- backend/core/urls.py | 2 +- backend/dashboard/models.py | 3 --- ...recurrencetask_completed_todo_completed.py | 23 +++++++++++++++++++ backend/tasks/models.py | 3 ++- 4 files changed, 26 insertions(+), 5 deletions(-) delete mode 100644 backend/dashboard/models.py create mode 100644 backend/tasks/migrations/0014_recurrencetask_completed_todo_completed.py diff --git a/backend/core/urls.py b/backend/core/urls.py index 434a21f..06a4fd2 100644 --- a/backend/core/urls.py +++ b/backend/core/urls.py @@ -27,5 +27,5 @@ urlpatterns = [ path('api/schema/', SpectacularAPIView.as_view(), name='schema'), path('api/schema/swagger-ui/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'), path('api/schema/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'), - path('dashboard/', include('dashboard.urls')), + path('api/', include('dashboard.urls')), ] \ No newline at end of file diff --git a/backend/dashboard/models.py b/backend/dashboard/models.py deleted file mode 100644 index 71a8362..0000000 --- a/backend/dashboard/models.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.db import models - -# Create your models here. diff --git a/backend/tasks/migrations/0014_recurrencetask_completed_todo_completed.py b/backend/tasks/migrations/0014_recurrencetask_completed_todo_completed.py new file mode 100644 index 0000000..d89360d --- /dev/null +++ b/backend/tasks/migrations/0014_recurrencetask_completed_todo_completed.py @@ -0,0 +1,23 @@ +# Generated by Django 4.2.6 on 2023-11-17 16:40 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('tasks', '0013_alter_recurrencetask_recurrence_rule'), + ] + + operations = [ + migrations.AddField( + model_name='recurrencetask', + name='completed', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='todo', + name='completed', + field=models.BooleanField(default=False), + ), + ] diff --git a/backend/tasks/models.py b/backend/tasks/models.py index a8fc4e5..9a914c0 100644 --- a/backend/tasks/models.py +++ b/backend/tasks/models.py @@ -18,7 +18,6 @@ class Task(models.Model): :param title: Title of the task. :param notes: Optional additional notes for the task. :param tags: Associated tags for the task. - :param completed: A boolean field indicating whether the task is completed. :param importance: The importance of the task (range: 1 to 5) :param difficulty: The difficulty of the task (range: 1 to 5). :param challenge: Associated challenge (optional). @@ -62,12 +61,14 @@ class Todo(Task): NOT_IMPORTANT_URGENT = 3, 'Not Important & Urgent' NOT_IMPORTANT_NOT_URGENT = 4, 'Not Important & Not Urgent' + completed = models.BooleanField(default=False) priority = models.PositiveSmallIntegerField(choices=EisenhowerMatrix.choices, default=EisenhowerMatrix.NOT_IMPORTANT_NOT_URGENT) def __str__(self): return self.title class RecurrenceTask(Task): + completed = models.BooleanField(default=False) recurrence_rule = models.CharField() def __str__(self) -> str: From c71020f94737c735f9b5977aede16ae8dff22ca3 Mon Sep 17 00:00:00 2001 From: Sirin Puenggun Date: Mon, 20 Nov 2023 01:52:06 +0700 Subject: [PATCH 8/9] Fix Layout and remove buttom checkbox --- .../src/components/authentication/SignUpPage.jsx | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/frontend/src/components/authentication/SignUpPage.jsx b/frontend/src/components/authentication/SignUpPage.jsx index daf452f..0370d55 100644 --- a/frontend/src/components/authentication/SignUpPage.jsx +++ b/frontend/src/components/authentication/SignUpPage.jsx @@ -192,26 +192,14 @@ export default function SignUp() { />


-
- - -
{/* Login Button */} {/* Already have an account? */} -
- + From ae2b55bf0e2e6f03b9651d9ca744642e3cfa86c2 Mon Sep 17 00:00:00 2001 From: sosokker Date: Mon, 20 Nov 2023 02:01:58 +0700 Subject: [PATCH 9/9] Add google login to signup / Increase profile dropdown z --- .../components/authentication/LoginPage.jsx | 4 ++- .../components/authentication/SignUpPage.jsx | 33 +++++++++++++++++++ .../src/components/navigations/Navbar.jsx | 2 +- frontend/src/components/navigators/Navbar.jsx | 0 4 files changed, 37 insertions(+), 2 deletions(-) delete mode 100644 frontend/src/components/navigators/Navbar.jsx diff --git a/frontend/src/components/authentication/LoginPage.jsx b/frontend/src/components/authentication/LoginPage.jsx index 12ad18e..a48c075 100644 --- a/frontend/src/components/authentication/LoginPage.jsx +++ b/frontend/src/components/authentication/LoginPage.jsx @@ -7,6 +7,8 @@ import { loadFull } from "tsparticles"; import refreshAccessToken from "./refreshAcesstoken"; import axiosapi from "../../api/AuthenticationApi"; import { useAuth } from "../../hooks/authentication/IsAuthenticated"; +import { FcGoogle } from "react-icons/fc"; + function LoginPage() { const Navigate = useNavigate(); @@ -208,7 +210,7 @@ function LoginPage() { className="btn btn-outline btn-secondary w-full " onClick={() => googleLoginImplicit()} > - Login with Google + Login with Google {/* Forgot Password Link */}
diff --git a/frontend/src/components/authentication/SignUpPage.jsx b/frontend/src/components/authentication/SignUpPage.jsx index 0370d55..50d893b 100644 --- a/frontend/src/components/authentication/SignUpPage.jsx +++ b/frontend/src/components/authentication/SignUpPage.jsx @@ -4,6 +4,9 @@ import axiosapi from "../../api/AuthenticationApi"; import { useCallback } from "react"; import Particles from "react-tsparticles"; import { loadFull } from "tsparticles"; +import { FcGoogle } from "react-icons/fc"; +import { useGoogleLogin } from "@react-oauth/google"; + function Copyright(props) { return ( @@ -64,6 +67,28 @@ export default function SignUp() { console.log(container); }, []); + const googleLoginImplicit = useGoogleLogin({ + flow: "auth-code", + redirect_uri: "postmessage", + onSuccess: async (response) => { + try { + const loginResponse = await axiosapi.googleLogin(response.code); + if (loginResponse && loginResponse.data) { + const { access_token, refresh_token } = loginResponse.data; + + localStorage.setItem("access_token", access_token); + localStorage.setItem("refresh_token", refresh_token); + setIsAuthenticated(true); + Navigate("/"); + } + } catch (error) { + console.error("Error with the POST request:", error); + setIsAuthenticated(false); + } + }, + onError: (errorResponse) => console.log(errorResponse), + }); + return (