2024-10-31 06:09:59 -04:00
import { useEffect , useRef } from "react" ;
import PropTypes from "prop-types" ;
import { useTheme } from "@emotion/react" ;
import { Box , Button , Stack , Typography } from "@mui/material" ;
import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded" ;
2024-11-26 13:14:46 +08:00
import TextInput from "../../../../Components/Inputs/TextInput" ;
2025-02-07 01:59:54 +03:00
import { useTranslation } from "react-i18next" ;
2024-10-31 06:09:59 -04:00
StepTwo . propTypes = {
form : PropTypes . object ,
errors : PropTypes . object ,
onSubmit : PropTypes . func ,
onChange : PropTypes . func ,
onBack : PropTypes . func ,
};
/**
* Renders the second step of the sign up process.
*
* @param {Object} props
* @param {Object} props.form - Form state object.
* @param {Object} props.errors - Object containing form validation errors.
* @param {Function} props.onSubmit - Callback function to handle form submission.
* @param {Function} props.onChange - Callback function to handle form input changes.
* @param {Function} props.onBack - Callback function to handle "Back" button click.
* @returns {JSX.Element}
*/
function StepTwo ({ form , errors , onSubmit , onChange , onBack }) {
const theme = useTheme ();
const inputRef = useRef ( null );
2025-02-07 01:59:54 +03:00
const { t } = useTranslation ();
2024-10-31 06:09:59 -04:00
useEffect (() => {
if ( inputRef . current ) {
inputRef . current . focus ();
}
}, []);
return (
<>
< Stack
gap = {{ xs : theme . spacing ( 8 ), sm : theme . spacing ( 12 ) }}
textAlign = "center"
>
< Box >
2025-02-07 01:59:54 +03:00
< Typography component = "h1" >{ t ( "signUp" )}</ Typography >
< Typography >{ t ( "enterEmail" )}</ Typography >
2024-10-31 06:09:59 -04:00
</ Box >
2024-11-01 19:10:50 -04:00
< Box
component = "form"
textAlign = "left"
noValidate
spellCheck = { false }
onSubmit = { onSubmit }
mb = { theme . spacing ( 5 )}
display = "grid"
gap = {{ xs : theme . spacing ( 12 ), sm : theme . spacing ( 16 ) }}
2024-10-31 06:09:59 -04:00
>
2024-11-26 13:14:46 +08:00
< TextInput
2024-11-01 19:10:50 -04:00
type = "email"
id = "register-email-input"
2025-04-27 15:27:50 -04:00
label = { t ( "authRegisterEmail" )}
2024-11-01 19:10:50 -04:00
isRequired = { true }
placeholder = "jordan.ellis@domain.com"
autoComplete = "email"
value = { form . email }
onInput = {( e ) => ( e . target . value = e . target . value . toLowerCase ())}
onChange = { onChange }
2024-11-26 13:14:46 +08:00
error = { errors . email ? true : false }
2025-05-06 22:15:27 -04:00
helperText = { errors . email && ( errors . email === "Email is required" ? t ( "authRegisterEmailRequired" ) : errors . email === "Must be a valid email address" ? t ( "authRegisterEmailInvalid" ) : errors . email )}
2024-11-01 19:10:50 -04:00
ref = { inputRef }
/>
< Stack
direction = "row"
justifyContent = "space-between"
2024-10-31 06:09:59 -04:00
>
2024-11-01 19:10:50 -04:00
< Button
variant = "outlined"
color = "info"
onClick = { onBack }
sx = {{
px : theme . spacing ( 5 ),
"& svg.MuiSvgIcon-root" : {
mr : theme . spacing ( 3 ),
},
"&:focus-visible" : {
outline : `2px solid ${ theme . palette . primary . main } ` ,
outlineOffset : `2px` ,
},
}}
>
< ArrowBackRoundedIcon />
2025-02-07 01:59:54 +03:00
{ t ( "commonBack" )}
2024-11-01 19:10:50 -04:00
</ Button >
< Button
variant = "contained"
2025-01-14 08:09:03 -05:00
color = "accent"
2024-11-01 19:10:50 -04:00
onClick = { onSubmit }
disabled = { errors . email && true }
sx = {{
width : "30%" ,
"&.Mui-focusVisible" : {
outline : `2px solid ${ theme . palette . primary . main } ` ,
outlineOffset : `2px` ,
boxShadow : `none` ,
},
}}
>
2025-02-07 01:59:54 +03:00
{ t ( "continue" )}
2024-11-01 19:10:50 -04:00
</ Button >
</ Stack >
</ Box >
2024-10-31 06:09:59 -04:00
</ Stack >
</>
);
}
export { StepTwo };