From 50c24d1a3e5b0513ec8322e825fec0d6958365e0 Mon Sep 17 00:00:00 2001 From: Varsani2520 Date: Mon, 1 Jul 2024 12:39:00 +0530 Subject: [PATCH] sign up and login ui done --- app/components/LoginPage.jsx | 68 +++++++++++--------- app/components/SignUp.jsx | 118 +++++++++++++++++++---------------- 2 files changed, 103 insertions(+), 83 deletions(-) diff --git a/app/components/LoginPage.jsx b/app/components/LoginPage.jsx index 8da3eb4..5a5240e 100644 --- a/app/components/LoginPage.jsx +++ b/app/components/LoginPage.jsx @@ -1,12 +1,11 @@ "use client"; import React, { useState } from "react"; -import TextField from "@mui/material/TextField"; import Button from "@mui/material/Button"; import { loginservice } from "../service/loginService"; import { toast } from "react-toastify"; import "react-toastify/dist/ReactToastify.css"; import { useRouter } from "next/navigation"; -import { Box, Container, Grid, Typography, Paper, useTheme } from "@mui/material"; +import { Box, Container, Grid, Typography, useTheme } from "@mui/material"; import { useDispatch } from "react-redux"; import { loginUserFailure, loginUserSuccess } from "../action/action"; import Link from "next/link"; @@ -18,7 +17,7 @@ import Cookies from "js-cookie"; const LoginPage = () => { const dispatch = useDispatch(); const router = useRouter(); - const theme = useTheme() + const theme = useTheme(); const [login, setLogin] = useState({ username: "", password: "", @@ -49,12 +48,19 @@ const LoginPage = () => { return ( -
+
- + - + { justifyContent: "center", }} > - {/* */}
- + Login - setLogin({ ...login, @@ -91,13 +100,18 @@ const LoginPage = () => { }) } value={login.username} - margin="normal" /> - setLogin({ ...login, @@ -105,7 +119,6 @@ const LoginPage = () => { }) } value={login.password} - margin="normal" />
diff --git a/app/components/SignUp.jsx b/app/components/SignUp.jsx index 77efdc8..c83b6c3 100644 --- a/app/components/SignUp.jsx +++ b/app/components/SignUp.jsx @@ -1,16 +1,15 @@ -'use client' +"use client" import React, { useState } from "react"; import Button from "@mui/material/Button"; import Box from "@mui/material/Box"; import Typography from "@mui/material/Typography"; -import { Container, Grid, TextField, useTheme } from "@mui/material"; +import { Container, Grid, useTheme } from "@mui/material"; import { signupservice } from "../service/signupservice"; +import { toast } from "react-toastify"; import "react-toastify/dist/ReactToastify.css"; import Link from "next/link"; import Lottie from "lottie-react"; import loginAnimation from "../lottie-animation/loginAnimation.json"; -import { toast } from "react-toastify"; -import Toast from "./Toast"; const SignUp = () => { const theme = useTheme(); @@ -25,7 +24,7 @@ const SignUp = () => { e.preventDefault(); // Validate if all fields are filled - if (!signup.username || !signup.password || !signup.name || !signup.address ) { + if (!signup.username || !signup.password || !signup.name || !signup.address) { toast.error("Please fill in all fields"); return; } @@ -48,10 +47,11 @@ const SignUp = () => { signup.username, signup.password, signup.name, - signup.address, + signup.address ); console.log(response); toast.success("Account Created Successfully"); + // Assuming `router` is properly set up with useRouter() from Next.js router.push("/pages/login"); } catch (error) { toast.error("Failed to Create Account"); @@ -61,12 +61,18 @@ const SignUp = () => { return ( -
- +
- + { Create Account - - setSignup({ - ...signup, - username: e.target.value, - }) - } + setSignup({ ...signup, username: e.target.value })} + style={{ + width: "80%", + padding: "10px", + marginBottom: "15px", + border: "1px solid #ccc", + borderRadius: "4px", + outline: "none", + }} /> - - setSignup({ - ...signup, - password: e.target.value, - }) - } + placeholder="Password" value={signup.password} - margin="normal" + onChange={(e) => setSignup({ ...signup, password: e.target.value })} + style={{ + width: "80%", + padding: "10px", + marginBottom: "15px", + border: "1px solid #ccc", + borderRadius: "4px", + outline: "none", + }} /> - - setSignup({ - ...signup, - name: e.target.value, - }) - } + setSignup({ ...signup, name: e.target.value })} + style={{ + width: "80%", + padding: "10px", + marginBottom: "15px", + border: "1px solid #ccc", + borderRadius: "4px", + outline: "none", + }} /> - - setSignup({ - ...signup, - address: e.target.value, - }) - } + setSignup({ ...signup, address: e.target.value })} + style={{ + width: "80%", + padding: "10px", + marginBottom: "15px", + border: "1px solid #ccc", + borderRadius: "4px", + outline: "none", + }} /> -