Add loading button

This commit is contained in:
Alex Holliday committed 2024-11-27 11:30:59 +08:00
1 parent 82a514f637
commit 2c6b1d07f4
1 file changed
+15 -2
+15 -2
View File
@@ -4,6 +4,7 @@ import { Box, Button, Stack, Typography } from "@mui/material";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { credentials } from "../../Validation/validation"; import { credentials } from "../../Validation/validation";
import { login } from "../../Features/Auth/authSlice"; import { login } from "../../Features/Auth/authSlice";
import LoadingButton from "@mui/lab/LoadingButton";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { createToast } from "../../Utils/toastUtils"; import { createToast } from "../../Utils/toastUtils";
import { networkService } from "../../main"; import { networkService } from "../../main";
@@ -231,6 +232,7 @@ const StepTwo = ({ form, errors, onSubmit, onChange, onBack }) => {
const theme = useTheme(); const theme = useTheme();
const navigate = useNavigate(); const navigate = useNavigate();
const inputRef = useRef(null); const inputRef = useRef(null);
const authState = useSelector((state) => state.auth);
useEffect(() => { useEffect(() => {
if (inputRef.current) { if (inputRef.current) {
@@ -302,10 +304,11 @@ const StepTwo = ({ form, errors, onSubmit, onChange, onBack }) => {
<ArrowBackRoundedIcon /> <ArrowBackRoundedIcon />
Back Back
</Button> </Button>
<Button {/* <LoadingButton
variant="contained" variant="contained"
color="primary" color="primary"
type="submit" type="submit"
loading={authState.isLoading}
disabled={errors.password && true} disabled={errors.password && true}
sx={{ sx={{
width: "30%", width: "30%",
@@ -317,7 +320,15 @@ const StepTwo = ({ form, errors, onSubmit, onChange, onBack }) => {
}} }}
> >
Continue Continue
</Button> </LoadingButton> */}
<LoadingButton
type="submit"
variant="contained"
color="primary"
loading={authState.isLoading}
>
{"Continue"}
</LoadingButton>
</Stack> </Stack>
</Box> </Box>
<Box <Box
@@ -379,6 +390,8 @@ const Login = () => {
const [errors, setErrors] = useState({}); const [errors, setErrors] = useState({});
const [step, setStep] = useState(0); const [step, setStep] = useState(0);
useEffect(() => {}, [authState.isLoading]);
useEffect(() => { useEffect(() => {
if (authToken) { if (authToken) {
navigate("/monitors"); navigate("/monitors");