From 6b6959bb8380ed6114252c1a7faba6ace28c8b4b Mon Sep 17 00:00:00 2001 From: Aman <aman.kumar@criodo.com> Date: Tue, 5 Mar 2024 11:46:47 +0530 Subject: [PATCH] Logout functionality add commit --- src/components/Auth/Login/Login.css | 4 +++ src/components/Auth/Login/Login.jsx | 2 ++ src/components/Auth/Register/Register.css | 5 +++ src/components/Auth/Register/Register.jsx | 4 +++ .../TaskDashboard/TaskDashboard.jsx | 35 +++++++++++++------ 5 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/components/Auth/Login/Login.css b/src/components/Auth/Login/Login.css index 0f6deec..c19f383 100644 --- a/src/components/Auth/Login/Login.css +++ b/src/components/Auth/Login/Login.css @@ -9,4 +9,8 @@ /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */ background: linear-gradient(to right, rgba(106, 17, 203, 1), rgba(37, 117, 252, 1)) + } + + .form-input{ + color:#fff !important } \ No newline at end of file diff --git a/src/components/Auth/Login/Login.jsx b/src/components/Auth/Login/Login.jsx index 2634841..69dd02d 100644 --- a/src/components/Auth/Login/Login.jsx +++ b/src/components/Auth/Login/Login.jsx @@ -76,6 +76,7 @@ function Login() { name="email" onChange={(e) => handleInputUpdate(e)} id="formControlLg" + className="form-input" type="email" size="lg" /> @@ -85,6 +86,7 @@ function Login() { label="Password" name="password" id="formControlLg" + className="form-input" type="password" onChange={(e) => handleInputUpdate(e)} size="lg" diff --git a/src/components/Auth/Register/Register.css b/src/components/Auth/Register/Register.css index 3f91b42..4af7a36 100644 --- a/src/components/Auth/Register/Register.css +++ b/src/components/Auth/Register/Register.css @@ -10,3 +10,8 @@ /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */ background: linear-gradient(to right, rgba(106, 17, 203, 1), rgba(37, 117, 252, 1)) } + + + .form-input{ + color:#fff !important + } diff --git a/src/components/Auth/Register/Register.jsx b/src/components/Auth/Register/Register.jsx index 24ec36a..c4580d2 100644 --- a/src/components/Auth/Register/Register.jsx +++ b/src/components/Auth/Register/Register.jsx @@ -83,6 +83,7 @@ function Register() { wrapperClass="mb-4 mx-5 w-100" color="white" labelClass="text-white" + className="form-input" onChange={(e) => handleInputUpdate(e)} name="username" label="User name" @@ -93,6 +94,7 @@ function Register() { <MDBInput wrapperClass="mb-4 mx-5 w-100" labelClass="text-white" + className="form-input" onChange={(e) => handleInputUpdate(e)} name="email" label="Email address" @@ -103,6 +105,7 @@ function Register() { <MDBInput wrapperClass="mb-4 mx-5 w-100" labelClass="text-white" + className="form-input" onChange={(e) => handleInputUpdate(e)} name="password" label="Password" @@ -113,6 +116,7 @@ function Register() { <MDBInput wrapperClass="mb-4 mx-5 w-100" labelClass="text-white" + className="form-input" onChange={(e) => handleInputUpdate(e)} name="confirmPassword" label="Confirm Password" diff --git a/src/components/TaskDashboard/TaskDashboard.jsx b/src/components/TaskDashboard/TaskDashboard.jsx index 416c2b0..99516c2 100644 --- a/src/components/TaskDashboard/TaskDashboard.jsx +++ b/src/components/TaskDashboard/TaskDashboard.jsx @@ -158,16 +158,18 @@ export default function Register() { </h6> </td> <td className="align-middle"> - <MDBTooltip tag="a" wrapperProps={{ href: "#!" }} title="Done"> - <MDBIcon - fas - icon="check" - color="success" - size="lg" - className="me-3" - onClick={() => updateTaskStatus(task._id)} - /> - </MDBTooltip> + {!task.isCompletedTask && ( + <MDBTooltip tag="a" wrapperProps={{ href: "#!" }} title="Done"> + <MDBIcon + fas + icon="check" + color="success" + size="lg" + className="me-3" + onClick={() => updateTaskStatus(task._id)} + /> + </MDBTooltip> + )} <MDBTooltip tag="a" wrapperProps={{ href: "#!" }} title="Remove"> <MDBIcon fas @@ -191,6 +193,18 @@ export default function Register() { <MDBRow className="d-flex justify-content-center align-items-center"> <MDBCol md="12" xl="10"> <MDBCard> + {isLoggedIn && ( + <MDBBtn + style={{ position: "absolute", right: "10px", top: "10px" }} + color="danger" + onClick={() => { + localStorage.removeItem("token"); // Clear token from localStorage + window.location.reload(); // Reload the page + }} + > + Logout + </MDBBtn> + )} <MDBCardBody className="p-4 text-black"> <div className="text-center pt-3 pb-2"> <img @@ -199,6 +213,7 @@ export default function Register() { width="60" /> <h2 className="my-4">Task List</h2> + {isLoggedIn && ( <MDBBtn onClick={() => setShowForm(!showForm)}> Create Task -- GitLab