Skip to content

Commit 2b168ae

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

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

frontend/src/pages/auth/Signup.jsx

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
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 Signup = () => {
1011
const navigate = useNavigate();
12+
const [loading, setLoading] = useState(false)
13+
1114

1215
const initialValues = {
1316
email: "",
@@ -30,7 +33,7 @@ const Signup = () => {
3033
initialValues,
3134
validationSchema,
3235
onSubmit: (values) => {
33-
// setLoading(true);
36+
setLoading(true);
3437
registerUser(values.email, values.password);
3538
},
3639
});
@@ -52,6 +55,8 @@ const Signup = () => {
5255
} else {
5356
toast.error("Error");
5457
}
58+
setLoading(false)
59+
5560
});
5661
};
5762

@@ -97,8 +102,16 @@ const Signup = () => {
97102
variant="contained"
98103
sx={{ display: "block", mt: 2, mx: "auto" }}
99104
type="submit"
105+
disabled={loading}
100106
>
101-
Signup
107+
{loading ? <ColorRing
108+
visible={ true }
109+
height="30"
110+
width="30"
111+
wrapperStyle={ {} }
112+
wrapperClass="blocks-wrapper"
113+
colors={ [''] }
114+
/> : 'Signup' }
102115
</Button>
103116
<Typography variant="h6" component="p" sx={{ my: 2 }}>
104117
Have an account already ? Then{" "}

0 commit comments

Comments
 (0)