Added auto focus field on render
This commit is contained in:
1 parent
a13d804d82
commit
5b19854edc
3 files changed
+38
-14
No files matched your search
@@ -236,18 +236,18 @@ const Login = () => {
|
|||||||
const [errors, setErrors] = useState({});
|
const [errors, setErrors] = useState({});
|
||||||
const [step, setStep] = useState(0);
|
const [step, setStep] = useState(0);
|
||||||
|
|
||||||
// useEffect(() => {
|
useEffect(() => {
|
||||||
// axiosInstance
|
axiosInstance
|
||||||
// .get("/auth/users/admin")
|
.get("/auth/users/admin")
|
||||||
// .then((response) => {
|
.then((response) => {
|
||||||
// if (response.data.data === false) {
|
if (response.data.data === false) {
|
||||||
// navigate("/register");
|
navigate("/register");
|
||||||
// }
|
}
|
||||||
// })
|
})
|
||||||
// .catch((error) => {
|
.catch((error) => {
|
||||||
// console.log(error);
|
console.log(error);
|
||||||
// });
|
});
|
||||||
// }, [navigate]);
|
}, [navigate]);
|
||||||
|
|
||||||
const handleChange = (event) => {
|
const handleChange = (event) => {
|
||||||
const { value, id } = event.target;
|
const { value, id } = event.target;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect, useRef } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { Box, Stack, Typography } from "@mui/material";
|
import { Box, Stack, Typography } from "@mui/material";
|
||||||
@@ -58,6 +58,14 @@ const LandingPage = ({ isAdmin, onSignup }) => {
|
|||||||
|
|
||||||
const StepOne = ({ form, errors, onSubmit, onChange, onBack }) => {
|
const StepOne = ({ form, errors, onSubmit, onChange, onBack }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const inputRef = useRef(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (inputRef.current) {
|
||||||
|
inputRef.current.focus();
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack gap={theme.gap.large} textAlign="center">
|
<Stack gap={theme.gap.large} textAlign="center">
|
||||||
@@ -76,6 +84,7 @@ const StepOne = ({ form, errors, onSubmit, onChange, onBack }) => {
|
|||||||
value={form.firstName}
|
value={form.firstName}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
error={errors.firstName}
|
error={errors.firstName}
|
||||||
|
ref={inputRef}
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
<form noValidate spellCheck={false} onSubmit={onSubmit}>
|
<form noValidate spellCheck={false} onSubmit={onSubmit}>
|
||||||
@@ -124,6 +133,13 @@ const StepOne = ({ form, errors, onSubmit, onChange, onBack }) => {
|
|||||||
|
|
||||||
const StepTwo = ({ form, errors, onSubmit, onChange, onBack }) => {
|
const StepTwo = ({ form, errors, onSubmit, onChange, onBack }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const inputRef = useRef(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (inputRef.current) {
|
||||||
|
inputRef.current.focus();
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -144,6 +160,7 @@ const StepTwo = ({ form, errors, onSubmit, onChange, onBack }) => {
|
|||||||
value={form.email}
|
value={form.email}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
error={errors.email}
|
error={errors.email}
|
||||||
|
ref={inputRef}
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -178,6 +195,13 @@ const StepTwo = ({ form, errors, onSubmit, onChange, onBack }) => {
|
|||||||
|
|
||||||
const StepThree = ({ form, errors, onSubmit, onChange, onBack }) => {
|
const StepThree = ({ form, errors, onSubmit, onChange, onBack }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const inputRef = useRef(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (inputRef.current) {
|
||||||
|
inputRef.current.focus();
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -198,6 +222,7 @@ const StepThree = ({ form, errors, onSubmit, onChange, onBack }) => {
|
|||||||
value={form.password}
|
value={form.password}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
error={errors.password}
|
error={errors.password}
|
||||||
|
ref={inputRef}
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
<form noValidate spellCheck={false} onSubmit={onSubmit}>
|
<form noValidate spellCheck={false} onSubmit={onSubmit}>
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
color: var(--env-var-color-1);
|
color: var(--env-var-color-1);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
.login-page button,
|
|
||||||
.set-new-password-page p.MuiTypography-root,
|
.set-new-password-page p.MuiTypography-root,
|
||||||
.set-new-password-page button,
|
.set-new-password-page button,
|
||||||
.password-confirmed-page p.MuiTypography-root,
|
.password-confirmed-page p.MuiTypography-root,
|
||||||
|
|||||||
Reference in new issue
Block a user