Skip to content

Commit 16dc61c

Browse files
committed
[ADDED] : Loading added in login page
There is no loading after calling login api so i added loader in which this loader will start when we click on login and finish after we get the response.
1 parent b5bfe27 commit 16dc61c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

frontend/src/pages/auth/Login.jsx

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import React from "react";
1+
import React, { useState } from "react";
22
import { Box, Button, TextField, Typography } from "@mui/material";
33
import { Link, useNavigate } from "react-router-dom";
44
import { apiAuth } from "../../services/models/authModel";
55
import { toast } from "react-hot-toast";
66
import * as Yup from "yup";
77
import { useFormik } from "formik";
8+
import { ColorRing } from 'react-loader-spinner'
89

910
const Login = () => {
1011
const navigate = useNavigate();
12+
const [loading, setLoading] = useState(false)
1113

1214
const initialValues = {
1315
email: "",
@@ -30,7 +32,7 @@ const Login = () => {
3032
initialValues,
3133
validationSchema,
3234
onSubmit: (values) => {
33-
// setLoading(true);
35+
setLoading(true);
3436
loginUser(values.email, values.password);
3537
},
3638
});
@@ -52,6 +54,7 @@ const Login = () => {
5254
} else {
5355
toast.error("Error");
5456
}
57+
setLoading(false)
5558
});
5659
};
5760

@@ -97,8 +100,15 @@ const Login = () => {
97100
variant="contained"
98101
sx={ { display: "block", mt: 2, mx: "auto" } }
99102
type="submit"
100-
>
101-
Login
103+
disabled={ loading }
104+
>{ loading ? <ColorRing
105+
visible={ true }
106+
height="30"
107+
width="30"
108+
wrapperStyle={ {} }
109+
wrapperClass="blocks-wrapper"
110+
colors={ [''] }
111+
/> : "Login" }
102112
</Button>
103113
<Typography variant="h6" component="p" sx={ { my: 2 } }>
104114
Don't have an account ? Then{ " " }

0 commit comments

Comments
 (0)