From db2f050c4ba3281bdea41eebfb0b9bc70d158d1a Mon Sep 17 00:00:00 2001 From: AmitChauhan63390 Date: Sat, 16 Nov 2024 21:56:03 +0530 Subject: [PATCH] design changed --- src/pages/Login.tsx | 292 +++++++++++++++++++--------------- src/pages/Register.tsx | 353 ++++++++++++++++++++++++----------------- 2 files changed, 368 insertions(+), 277 deletions(-) diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx index 9d075f98..d03718dc 100644 --- a/src/pages/Login.tsx +++ b/src/pages/Login.tsx @@ -1,5 +1,5 @@ import axios from "axios"; -import { useState, useContext, useEffect } from "react"; +import { useState, useContext, useEffect, FormEvent } from "react"; import { useNavigate, Link } from "react-router-dom"; import { AuthContext } from "../context/auth"; import { @@ -8,6 +8,7 @@ import { TextField, Button, CircularProgress, + Grid, } from "@mui/material"; import { useGlobalInfoStore } from "../context/globalInfo"; import { apiUrl } from "../apiConfig"; @@ -32,12 +33,12 @@ const Login = () => { } }, [user, navigate]); - const handleChange = (e: any) => { + const handleChange = (e:any) => { const { name, value } = e.target; setForm({ ...form, [name]: value }); }; - const submitForm = async (e: any) => { + const submitForm = async (e:any) => { e.preventDefault(); setLoading(true); try { @@ -49,148 +50,175 @@ const Login = () => { notify("success", "Welcome to Maxun!"); window.localStorage.setItem("user", JSON.stringify(data)); navigate("/"); - } catch (err: any) { - notify("error", err.response.data || "Login Failed. Please try again."); + } catch (err) { + notify("error", "Login Failed. Please try again."); setLoading(false); } }; return ( - - + {/* Left Side: Login Form */} + - - Welcome Back! - - - - - + + Welcome Back! + + + - - Don’t have an account?{" "} - - Register - - - - + + + + Don’t have an account?{" "} + + Register + + + + + + {/* Right Side: Aesthetic Info Section */} + + + + Welcome to Maxun + + + Maxun is a powerful visual website scraper that makes extracting data from any website as easy as a few clicks. + No more complex code or time-consuming processes—Maxun does the heavy lifting for you. Start your data extraction journey with us! + + + + ); }; diff --git a/src/pages/Register.tsx b/src/pages/Register.tsx index 59006c76..3b90d4a5 100644 --- a/src/pages/Register.tsx +++ b/src/pages/Register.tsx @@ -1,14 +1,14 @@ -import { useState, useContext, useEffect } from "react"; -import { useNavigate, Link } from "react-router-dom"; import axios from "axios"; +import { useState, useContext, useEffect, FormEvent } from "react"; +import { useNavigate, Link } from "react-router-dom"; import { AuthContext } from "../context/auth"; import { + Box, + Typography, TextField, Button, CircularProgress, - Typography, - Box, - Container, + Grid, } from "@mui/material"; import { useGlobalInfoStore } from "../context/globalInfo"; import { apiUrl } from "../apiConfig"; @@ -17,17 +17,21 @@ const Register = () => { const [form, setForm] = useState({ email: "", password: "", + confirmPassword: "", }); const [loading, setLoading] = useState(false); const { notify } = useGlobalInfoStore(); - const { email, password } = form; + const { email, password, confirmPassword } = form; const { state, dispatch } = useContext(AuthContext); const { user } = state; + const navigate = useNavigate(); useEffect(() => { - if (user !== null) navigate("/"); + if (user) { + navigate("/"); + } }, [user, navigate]); const handleChange = (e: any) => { @@ -37,165 +41,224 @@ const Register = () => { const submitForm = async (e: any) => { e.preventDefault(); + if (password !== confirmPassword) { + notify("error", "Passwords do not match."); + return; + } setLoading(true); try { const { data } = await axios.post(`${apiUrl}/auth/register`, { email, password, }); - dispatch({ - type: "LOGIN", - payload: data, - }); + dispatch({ type: "LOGIN", payload: data }); notify("success", "Welcome to Maxun!"); window.localStorage.setItem("user", JSON.stringify(data)); navigate("/"); - } catch (err: any) { - notify( - "error", - err.response.data || "Registration Failed. Please try again." - ); - } finally { + } catch (err) { + notify("error", "Registration Failed. Please try again."); setLoading(false); } }; return ( - - + {/* Left Side: Register Form */} + - - Create an account - - - - - - Already have an account?{" "} - - Login - - - - + + Create an Account + + + + + + + + + Already have an account?{" "} + + Login + + + + + + {/* Right Side: Aesthetic Info Section */} + + + + Welcome to Maxun + + + Maxun is a powerful visual website scraper that makes extracting data from any website as easy as a few clicks. + No more complex code or time-consuming processes—Maxun does the heavy lifting for you. Start your data extraction journey with us! + + + + ); };