From 459daed60cfbe040bf5bda1936f9313125521dce Mon Sep 17 00:00:00 2001 From: AmitChauhan63390 Date: Sat, 16 Nov 2024 23:21:59 +0530 Subject: [PATCH] removed overkilling stuff --- src/pages/Login.tsx | 127 +++++------------ src/pages/Register.tsx | 313 ++++++++++++++--------------------------- 2 files changed, 136 insertions(+), 304 deletions(-) diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx index d03718dc..de44af12 100644 --- a/src/pages/Login.tsx +++ b/src/pages/Login.tsx @@ -2,14 +2,7 @@ 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, - Grid, -} from "@mui/material"; +import { Box, Typography, TextField, Button, CircularProgress, Grid } from "@mui/material"; import { useGlobalInfoStore } from "../context/globalInfo"; import { apiUrl } from "../apiConfig"; @@ -33,12 +26,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 { @@ -57,36 +50,35 @@ const Login = () => { }; return ( - - {/* Left Side: Login Form */} - + + - + logo + Welcome Back! { sx={{ "& .MuiOutlinedInput-root": { backgroundColor: email ? "#ffe6f9" : "#ffffff", - "& fieldset": { - borderColor: "#ff33cc", - }, - "&:hover fieldset": { - borderColor: "#ff33cc", - }, - "&.Mui-focused fieldset": { - borderColor: "#ff33cc", - }, + "& fieldset": { borderColor: "#ff33cc" }, + "&:hover fieldset": { borderColor: "#ff33cc" }, + "&.Mui-focused fieldset": { borderColor: "#ff33cc" }, }, "& input:-webkit-autofill": { WebkitBoxShadow: "0 0 0 1000px #ffe6f9 inset", WebkitTextFillColor: "#000", }, - "& .MuiInputLabel-root": { - color: email ? "#ff33cc" : "#000000", - }, - "& .MuiInputLabel-root.Mui-focused": { - color: "#ff33cc", - }, + "& .MuiInputLabel-root": { color: email ? "#ff33cc" : "#000000" }, + "& .MuiInputLabel-root.Mui-focused": { color: "#ff33cc" }, }} /> { sx={{ "& .MuiOutlinedInput-root": { backgroundColor: password ? "#ffe6f9" : "#ffffff", - "& fieldset": { - borderColor: "#ff33cc", - }, - "&:hover fieldset": { - borderColor: "#ff33cc", - }, - "&.Mui-focused fieldset": { - borderColor: "#ff33cc", - }, + "& fieldset": { borderColor: "#ff33cc" }, + "&:hover fieldset": { borderColor: "#ff33cc" }, + "&.Mui-focused fieldset": { borderColor: "#ff33cc" }, }, "& input:-webkit-autofill": { WebkitBoxShadow: "0 0 0 1000px #ffe6f9 inset", WebkitTextFillColor: "#000", }, - "& .MuiInputLabel-root": { - color: password ? "#ff33cc" : "#000000", - }, - "& .MuiInputLabel-root.Mui-focused": { - color: "#ff33cc", - }, + "& .MuiInputLabel-root": { color: password ? "#ff33cc" : "#000000" }, + "& .MuiInputLabel-root.Mui-focused": { color: "#ff33cc" }, }} /> - - Don’t have an account?{" "} @@ -184,41 +154,8 @@ const 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! - - - + ); }; diff --git a/src/pages/Register.tsx b/src/pages/Register.tsx index 3b90d4a5..90f33ed0 100644 --- a/src/pages/Register.tsx +++ b/src/pages/Register.tsx @@ -1,15 +1,8 @@ import axios from "axios"; -import { useState, useContext, useEffect, FormEvent } from "react"; +import { useState, useContext, useEffect } from "react"; import { useNavigate, Link } from "react-router-dom"; import { AuthContext } from "../context/auth"; -import { - Box, - Typography, - TextField, - Button, - CircularProgress, - Grid, -} from "@mui/material"; +import { Box, Typography, TextField, Button, CircularProgress } from "@mui/material"; import { useGlobalInfoStore } from "../context/globalInfo"; import { apiUrl } from "../apiConfig"; @@ -17,11 +10,10 @@ const Register = () => { const [form, setForm] = useState({ email: "", password: "", - confirmPassword: "", }); const [loading, setLoading] = useState(false); const { notify } = useGlobalInfoStore(); - const { email, password, confirmPassword } = form; + const { email, password } = form; const { state, dispatch } = useContext(AuthContext); const { user } = state; @@ -41,10 +33,6 @@ 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`, { @@ -52,7 +40,7 @@ const Register = () => { password, }); dispatch({ type: "LOGIN", payload: data }); - notify("success", "Welcome to Maxun!"); + notify("success", "Registration Successful!"); window.localStorage.setItem("user", JSON.stringify(data)); navigate("/"); } catch (err) { @@ -62,203 +50,110 @@ const Register = () => { }; return ( - - {/* Left Side: Register Form */} - + - - - 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! - - - - + logo + + Create an Account + + + + + + Already have an account?{" "} + + Login + + + + ); };