From 74c1ff90c31335872b8b240698b3bf3c4e91b668 Mon Sep 17 00:00:00 2001 From: Silvafox76 Date: Tue, 29 Apr 2025 22:27:35 -0400 Subject: [PATCH 01/14] Static Web Pages --- server/djangoproj/settings.py | 13 +++-- server/djangoproj/urls.py | 2 + server/frontend/static/About.html | 59 +++++++++++---------- server/frontend/static/Contact.html | 82 +++++++++++++++++++++++++++++ 4 files changed, 122 insertions(+), 34 deletions(-) create mode 100644 server/frontend/static/Contact.html diff --git a/server/djangoproj/settings.py b/server/djangoproj/settings.py index e0b1092a5c..2634d76fa5 100644 --- a/server/djangoproj/settings.py +++ b/server/djangoproj/settings.py @@ -28,8 +28,8 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = [] -CSRF_TRUSTED_ORIGINS = [] +ALLOWED_HOSTS=['localhost','https://ryanwdear-8000.theianext-1-labs-prod-misc-tools-us-east-0.proxy.cognitiveclass.ai'] +CSRF_TRUSTED_ORIGINS=['https://ryanwdear-8000.theianext-1-labs-prod-misc-tools-us-east-0.proxy.cognitiveclass.ai'] REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': [], @@ -61,7 +61,9 @@ TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], + 'DIRS': [ + os.path.join(BASE_DIR,'frontend/static') + ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -134,5 +136,6 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' -STATICFILES_DIRS = [] - +STATICFILES_DIRS = [ + os.path.join(BASE_DIR,'frontend/static') +] \ No newline at end of file diff --git a/server/djangoproj/urls.py b/server/djangoproj/urls.py index 6808da9141..5825f366ef 100644 --- a/server/djangoproj/urls.py +++ b/server/djangoproj/urls.py @@ -23,4 +23,6 @@ path('admin/', admin.site.urls), path('djangoapp/', include('djangoapp.urls')), path('', TemplateView.as_view(template_name="Home.html")), + path('about/', TemplateView.as_view(template_name="About.html")), + path('contact/', TemplateView.as_view(template_name="Contact.html")), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) diff --git a/server/frontend/static/About.html b/server/frontend/static/About.html index 484efd960f..755c34beb1 100644 --- a/server/frontend/static/About.html +++ b/server/frontend/static/About.html @@ -1,6 +1,7 @@ - + +
- -
- -
-
- Card image + +
+ +
+ +
+ Card image
-

Person1

-

Person1 Title

-

Some text that explains the person1 in about 2 short sentences

-

person1@example.com

+

Jackson Reed

+

Chief Performance Officer

+

With a background in motorsports engineering, Jackson brings speed, precision, and a love for turbochargers to the team.

+

jackson.reed@bestcars.com

-
- Card image +
+ Card image
-

Person2

-

Person2 Title

-

Some text that explains the person2 in about 2 short sentences

-

person2@example.com

+

Camila Torres

+

VP of Customer Experience

+

Camila's passion is matching people with the perfect ride. She makes "stress-free" feel like standard equipment.

+

camila.torres@bestcars.com

-
- Card image +
+ Card image
-

Person3

-

Person3 Title

-

Some text that explains the person3 in about 2 short sentences

-

person3@example.com

+

Marcus Grant

+

Head of Global Imports

+

Marcus tracks trends and treasures from Tokyo to Turin. If it’s rare and roadworthy, it’s on his radar.

+

marcus.grant@bestcars.com

+
-
-
- +
- diff --git a/server/frontend/static/Contact.html b/server/frontend/static/Contact.html new file mode 100644 index 0000000000..3d71345d9f --- /dev/null +++ b/server/frontend/static/Contact.html @@ -0,0 +1,82 @@ + + + + Contact Us + + + + + + + + + + + +
+

Contact Us

+

Need help choosing your next ride? Have questions? We’re here to put you in the driver's seat.

+ +
+

🏒 Best Cars Dealership HQ

+

Address icon123 Turbo Lane, Driveville, ON K1X 2B3

+

Phone icon+1 (800) 555-FAST

+

Email iconcontact@bestcars.com

+

Hours: Mon–Sat: 9am–7pm | Sun: Closed

+
+ +
+
πŸ§‘β€πŸ”§ Contact Our Team
+

Need to talk to a specific department? Email us directly at support@bestcars.com and we'll get back to you within one business day.

+
+ + +
+
πŸ“ Find Us
+ +
+ +
+ + + From 53f4bd73b925ff7f7d77ebcb5594b505fd7a973a Mon Sep 17 00:00:00 2001 From: Silvafox76 Date: Tue, 29 Apr 2025 22:53:37 -0400 Subject: [PATCH 02/14] FrontEndUpdates --- server/djangoapp/views.py | 18 ++++++++---------- server/djangoproj/settings.py | 8 ++++++-- server/frontend/package-lock.json | 30 +++++++++++++++++++++++++++--- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/server/djangoapp/views.py b/server/djangoapp/views.py index b16409f419..364913dcbc 100644 --- a/server/djangoapp/views.py +++ b/server/djangoapp/views.py @@ -1,19 +1,17 @@ -# Uncomment the required imports before adding the code - -# from django.shortcuts import render -# from django.http import HttpResponseRedirect, HttpResponse -# from django.contrib.auth.models import User -# from django.shortcuts import get_object_or_404, render, redirect -# from django.contrib.auth import logout -# from django.contrib import messages -# from datetime import datetime +from django.shortcuts import render +from django.http import HttpResponseRedirect, HttpResponse +from django.contrib.auth.models import User +from django.shortcuts import get_object_or_404, render, redirect +from django.contrib.auth import logout +from django.contrib import messages +from datetime import datetime from django.http import JsonResponse from django.contrib.auth import login, authenticate import logging import json from django.views.decorators.csrf import csrf_exempt -# from .populate import initiate +from .populate import initiate # Get an instance of a logger diff --git a/server/djangoproj/settings.py b/server/djangoproj/settings.py index 2634d76fa5..02d4320267 100644 --- a/server/djangoproj/settings.py +++ b/server/djangoproj/settings.py @@ -62,7 +62,9 @@ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ - os.path.join(BASE_DIR,'frontend/static') + os.path.join(BASE_DIR, 'frontend/static'), + os.path.join(BASE_DIR, 'frontend/build'), + os.path.join(BASE_DIR, 'frontend/build/static'), ], 'APP_DIRS': True, 'OPTIONS': { @@ -137,5 +139,7 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' STATICFILES_DIRS = [ - os.path.join(BASE_DIR,'frontend/static') + os.path.join(BASE_DIR, 'frontend/static'), + os.path.join(BASE_DIR, 'frontend/build'), + os.path.join(BASE_DIR, 'frontend/build/static'), ] \ No newline at end of file diff --git a/server/frontend/package-lock.json b/server/frontend/package-lock.json index 0797425307..bdb21fad35 100644 --- a/server/frontend/package-lock.json +++ b/server/frontend/package-lock.json @@ -16,6 +16,9 @@ "react-router-dom": "^6.19.0", "react-scripts": "5.0.1", "web-vitals": "^2.1.4" + }, + "devDependencies": { + "@babel/plugin-proposal-private-property-in-object": "^7.21.11" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -646,9 +649,18 @@ } }, "node_modules/@babel/plugin-proposal-private-property-in-object": { - "version": "7.21.0-placeholder-for-preset-env.2", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz", - "integrity": "sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w==", + "version": "7.21.11", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.11.tgz", + "integrity": "sha512-0QZ8qP/3RLDVBwBFoWAwCtgcDZJVwA5LUJRZU8x2YFfKNuFq161wK3cuGrALu5yiPu+vzwTAg/sMWVNeWeNyaw==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-property-in-object instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.18.6", + "@babel/helper-create-class-features-plugin": "^7.21.0", + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/plugin-syntax-private-property-in-object": "^7.14.5" + }, "engines": { "node": ">=6.9.0" }, @@ -1891,6 +1903,18 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/preset-env/node_modules/@babel/plugin-proposal-private-property-in-object": { + "version": "7.21.0-placeholder-for-preset-env.2", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz", + "integrity": "sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/preset-env/node_modules/semver": { "version": "6.3.1", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", From 4c23187d06452c428e12fff58e513b92d3ae6676 Mon Sep 17 00:00:00 2001 From: Silvafox76 Date: Tue, 29 Apr 2025 23:17:24 -0400 Subject: [PATCH 03/14] FrontEndUpdates2 --- server/djangoapp/urls.py | 5 ++--- server/djangoproj/urls.py | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/djangoapp/urls.py b/server/djangoapp/urls.py index 0edc274f90..99ecb3703c 100644 --- a/server/djangoapp/urls.py +++ b/server/djangoapp/urls.py @@ -1,5 +1,4 @@ -# Uncomment the imports before you add the code -# from django.urls import path +from django.urls import path from django.conf.urls.static import static from django.conf import settings # from . import views @@ -9,7 +8,7 @@ # # path for registration # path for login - # path(route='login', view=views.login_user, name='login'), + path(route='login', view=views.login_user, name='login'), # path for dealer reviews view diff --git a/server/djangoproj/urls.py b/server/djangoproj/urls.py index 5825f366ef..6d7d867f41 100644 --- a/server/djangoproj/urls.py +++ b/server/djangoproj/urls.py @@ -21,6 +21,7 @@ urlpatterns = [ path('admin/', admin.site.urls), + path('login/', TemplateView.as_view(template_name="index.html")), path('djangoapp/', include('djangoapp.urls')), path('', TemplateView.as_view(template_name="Home.html")), path('about/', TemplateView.as_view(template_name="About.html")), From ae080276f9b2a5decaacc38bd28b0b5bc580f312 Mon Sep 17 00:00:00 2001 From: Silvafox76 Date: Thu, 1 May 2025 09:10:58 -0400 Subject: [PATCH 04/14] FrontEndReact-LoginAndSignUp --- server/djangoapp/urls.py | 38 ++++-- server/djangoapp/views.py | 45 ++++++-- server/djangoproj/settings.py | 108 +++++++++--------- server/djangoproj/urls.py | 25 ++-- server/frontend/src/App.js | 6 +- .../src/components/Register/Register.jsx | 98 ++++++++++++++++ server/frontend/static/Home.html | 17 ++- 7 files changed, 261 insertions(+), 76 deletions(-) create mode 100644 server/frontend/src/components/Register/Register.jsx diff --git a/server/djangoapp/urls.py b/server/djangoapp/urls.py index 99ecb3703c..a42b951208 100644 --- a/server/djangoapp/urls.py +++ b/server/djangoapp/urls.py @@ -1,17 +1,37 @@ +# Uncomment the imports before you add the code from django.urls import path from django.conf.urls.static import static from django.conf import settings -# from . import views +from . import views -app_name = 'djangoapp' +app_name = "djangoapp" urlpatterns = [ - # # path for registration - + + # path for registration + path(route="register", view=views.registration, name="register"), + # path for login - path(route='login', view=views.login_user, name='login'), - + path(route="login", view=views.login_user, name="login"), + path(route="logout", view=views.logout_request, name="logout"), + # path for dealer reviews view - + #path(route="get_cars", view=views.get_cars, name="getcars"), + #path(route="get_dealers/", view=views.get_dealerships, name="get_dealers"), + #path( + #route="get_dealers/", + #view=views.get_dealerships, + #name="get_dealers_by_state", + #), + #path( + #route="dealer/", + #view=views.get_dealer_details, + #name="dealer_details", + #), + #path( + #route="reviews/dealer/", + #view=views.get_dealer_reviews, + #name="dealer_details", + #), # path for add a review view - -] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + #path(route="add_review", view=views.add_review, name="add_review"), +] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ No newline at end of file diff --git a/server/djangoapp/views.py b/server/djangoapp/views.py index 364913dcbc..56ab29dce9 100644 --- a/server/djangoapp/views.py +++ b/server/djangoapp/views.py @@ -25,8 +25,8 @@ def login_user(request): # Get username and password from request.POST dictionary data = json.loads(request.body) - username = data['userName'] - password = data['password'] + username = data["userName"] + password = data["password"] # Try to check if provide credential can be authenticated user = authenticate(username=username, password=password) data = {"userName": username} @@ -36,14 +36,45 @@ def login_user(request): data = {"userName": username, "status": "Authenticated"} return JsonResponse(data) + # Create a `logout_request` view to handle sign out request -# def logout_request(request): -# ... +def logout_request(request): + logout(request) + data = {"userName": ""} + return JsonResponse(data) # Create a `registration` view to handle sign up request -# @csrf_exempt -# def registration(request): -# ... +@csrf_exempt +def registration(request): + context = {} + + data = json.loads(request.body) + username = data['userName'] + password = data['password'] + first_name = data['firstName'] + last_name = data['lastName'] + email = data['email'] + username_exist = False + email_exist = False + try: + # Check if user already exists + User.objects.get(username=username) + username_exist = True + except: + # If not, simply log this is a new user + logger.debug("{} is new user".format(username)) + + # If it is a new user + if not username_exist: + # Create user in auth_user table + user = User.objects.create_user(username=username, first_name=first_name, last_name=last_name,password=password, email=email) + # Login the user and redirect to list page + login(request, user) + data = {"userName":username,"status":"Authenticated"} + return JsonResponse(data) + else : + data = {"userName":username,"error":"Already Registered"} + return JsonResponse(data) # # Update the `get_dealerships` view to render the index page with # a list of dealerships diff --git a/server/djangoproj/settings.py b/server/djangoproj/settings.py index 02d4320267..db36b123c0 100644 --- a/server/djangoproj/settings.py +++ b/server/djangoproj/settings.py @@ -32,91 +32,97 @@ CSRF_TRUSTED_ORIGINS=['https://ryanwdear-8000.theianext-1-labs-prod-misc-tools-us-east-0.proxy.cognitiveclass.ai'] REST_FRAMEWORK = { - 'DEFAULT_AUTHENTICATION_CLASSES': [], + "DEFAULT_AUTHENTICATION_CLASSES": [], } # Application definition INSTALLED_APPS = [ - 'djangoapp.apps.DjangoappConfig', - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', + "djangoapp.apps.DjangoappConfig", + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", ] MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", ] -ROOT_URLCONF = 'djangoproj.urls' +ROOT_URLCONF = "djangoproj.urls" TEMPLATES = [ { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [ - os.path.join(BASE_DIR, 'frontend/static'), - os.path.join(BASE_DIR, 'frontend/build'), - os.path.join(BASE_DIR, 'frontend/build/static'), + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [ + os.path.join(BASE_DIR, "frontend/static"), + os.path.join(BASE_DIR, "frontend/build"), + os.path.join(BASE_DIR, "frontend/build/static"), ], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.debug", + "django.template.context_processors.request", + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", ], }, }, ] -WSGI_APPLICATION = 'djangoproj.wsgi.application' +WSGI_APPLICATION = "djangoproj.wsgi.application" # Database # https://docs.djangoproject.com/en/3.2/ref/settings/#databases DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": BASE_DIR / "db.sqlite3", } } AUTH_PASSWORD_VALIDATORS = [ { - 'NAME': - 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + "NAME": ( + "django.contrib.auth.password_validation." + "UserAttributeSimilarityValidator" + ), }, { - 'NAME': - 'django.contrib.auth.password_validation.MinimumLengthValidator', + "NAME": ( + "django.contrib.auth.password_validation." + "MinimumLengthValidator" + ), }, { - 'NAME': - 'django.contrib.auth.password_validation.CommonPasswordValidator', + "NAME": ( + "django.contrib.auth.password_validation." + "CommonPasswordValidator" + ), }, { - 'NAME': - 'django.contrib.auth.password_validation.NumericPasswordValidator', + "NAME": ( + "django.contrib.auth.password_validation." + "NumericPasswordValidator" + ), }, ] - - # Internationalization # https://docs.djangoproject.com/en/3.2/topics/i18n/ -LANGUAGE_CODE = 'en-us' +LANGUAGE_CODE = "en-us" -TIME_ZONE = 'UTC' +TIME_ZONE = "UTC" USE_I18N = True @@ -128,18 +134,18 @@ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.2/howto/static-files/ -STATIC_URL = '/static/' -STATIC_ROOT = os.path.join(BASE_DIR, 'static') -MEDIA_ROOT = os.path.join(STATIC_ROOT, 'media') -MEDIA_URL = '/media/' +STATIC_URL = "/static/" +STATIC_ROOT = os.path.join(BASE_DIR, "static") +MEDIA_ROOT = os.path.join(STATIC_ROOT, "media") +MEDIA_URL = "/media/" # Default primary key field type # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field -DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' +DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" STATICFILES_DIRS = [ - os.path.join(BASE_DIR, 'frontend/static'), - os.path.join(BASE_DIR, 'frontend/build'), - os.path.join(BASE_DIR, 'frontend/build/static'), + os.path.join(BASE_DIR, "frontend/static"), + os.path.join(BASE_DIR, "frontend/build"), + os.path.join(BASE_DIR, "frontend/build/static"), ] \ No newline at end of file diff --git a/server/djangoproj/urls.py b/server/djangoproj/urls.py index 6d7d867f41..fb29ed40a7 100644 --- a/server/djangoproj/urls.py +++ b/server/djangoproj/urls.py @@ -13,6 +13,7 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ + from django.contrib import admin from django.urls import path, include from django.views.generic import TemplateView @@ -20,10 +21,20 @@ from django.conf import settings urlpatterns = [ - path('admin/', admin.site.urls), - path('login/', TemplateView.as_view(template_name="index.html")), - path('djangoapp/', include('djangoapp.urls')), - path('', TemplateView.as_view(template_name="Home.html")), - path('about/', TemplateView.as_view(template_name="About.html")), - path('contact/', TemplateView.as_view(template_name="Contact.html")), -] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) + path("admin/", admin.site.urls), + path("djangoapp/", include("djangoapp.urls")), + path("", TemplateView.as_view(template_name="Home.html")), + path("about/", TemplateView.as_view(template_name="About.html")), + path("contact/", TemplateView.as_view(template_name="Contact.html")), + path("login/", TemplateView.as_view(template_name="index.html")), + path("register/", TemplateView.as_view(template_name="index.html")), + path("dealers/", TemplateView.as_view(template_name="index.html")), + path( + "dealer/", + TemplateView.as_view(template_name="index.html"), + ), + path( + "postreview/", + TemplateView.as_view(template_name="index.html"), + ), +] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) \ No newline at end of file diff --git a/server/frontend/src/App.js b/server/frontend/src/App.js index aceac6974d..f0a3e40400 100644 --- a/server/frontend/src/App.js +++ b/server/frontend/src/App.js @@ -1,11 +1,15 @@ import LoginPanel from "./components/Login/Login" import { Routes, Route } from "react-router-dom"; +import Register from "./components/Register/Register"; + function App() { return ( } /> + } /> + ); } -export default App; +export default App; \ No newline at end of file diff --git a/server/frontend/src/components/Register/Register.jsx b/server/frontend/src/components/Register/Register.jsx new file mode 100644 index 0000000000..9f1a290327 --- /dev/null +++ b/server/frontend/src/components/Register/Register.jsx @@ -0,0 +1,98 @@ +import React, { useState } from "react"; +import "./Register.css"; +import user_icon from "../assets/person.png" +import email_icon from "../assets/email.png" +import password_icon from "../assets/password.png" +import close_icon from "../assets/close.png" + +const Register = () => { + + const [userName, setUserName] = useState(""); + const [password, setPassword] = useState(""); + const [email, setEmail] = useState(""); + const [firstName, setFirstName] = useState(""); + const [lastName, setlastName] = useState(""); + + + const gohome = ()=> { + window.location.href = window.location.origin; + } + + const register = async (e) => { + e.preventDefault(); + + let register_url = window.location.origin+"/djangoapp/register"; + + const res = await fetch(register_url, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + "userName": userName, + "password": password, + "firstName":firstName, + "lastName":lastName, + "email":email + }), + }); + + const json = await res.json(); + if (json.status) { + sessionStorage.setItem('username', json.userName); + window.location.href = window.location.origin; + } + else if (json.error === "Already Registered") { + alert("The user with same username is already registered"); + window.location.href = window.location.origin; + } +}; + + return( +
+ + +
+
+
+ Username + setUserName(e.target.value)}/> +
+
+ First Name + setFirstName(e.target.value)}/> +
+ +
+ Last Name + setlastName(e.target.value)}/> +
+ +
+ Email + setEmail(e.target.value)}/> +
+ +
+ password + setPassword(e.target.value)}/> +
+ +
+
+ +
+
+
+ ) +} + +export default Register; \ No newline at end of file diff --git a/server/frontend/static/Home.html b/server/frontend/static/Home.html index fb0c3fb617..a4070803ea 100644 --- a/server/frontend/static/Home.html +++ b/server/frontend/static/Home.html @@ -7,7 +7,22 @@