diff --git a/src/components/RegisterStepIcon.js b/src/components/RegisterStepIcon.js new file mode 100644 index 0000000..e143959 --- /dev/null +++ b/src/components/RegisterStepIcon.js @@ -0,0 +1,55 @@ +import { Box, useTheme } from '@mui/material'; + +/** Darker green for completed register steps (matches PAY button hover). */ +export const REGISTER_STEP_COMPLETED_COLOR = '#488F52'; + +export const registerStepStyle = { + width: { lg: '40%', md: '70%', xs: '100%' }, + boxShadow: 1, + backgroundColor: '#FFFFFF', + padding: 2, + '& .MuiStepLabel-label': { color: '#424242' }, + '& .MuiStepConnector-line': { borderColor: '#9E9E9E' }, + '& .MuiStepConnector-root.Mui-completed .MuiStepConnector-line': { + borderColor: REGISTER_STEP_COMPLETED_COLOR, + }, + '& .MuiStepConnector-root.Mui-active .MuiStepConnector-line': { + borderColor: 'warning.main', + }, +}; + +const RegisterStepIcon = ({ active, completed, className, icon }) => { + const theme = useTheme(); + let circleColor = '#757575'; + let textColor = '#FFFFFF'; + + if (completed) { + circleColor = REGISTER_STEP_COMPLETED_COLOR; + } else if (active) { + circleColor = theme.palette.warning.main; + textColor = '#1A1A1A'; + } + + return ( + + {icon} + + ); +}; + +export default RegisterStepIcon; diff --git a/src/pages/authentication/BusRegister.js b/src/pages/authentication/BusRegister.js index 741b8e2..6e9accf 100644 --- a/src/pages/authentication/BusRegister.js +++ b/src/pages/authentication/BusRegister.js @@ -12,7 +12,8 @@ import { Button, StepLabel, CircularProgress, } from '@mui/material'; -import VisibilityIcon from '@mui/icons-material/Visibility'; +import { POST_USERNAME, POST_VERIFY_CAPTCHA } from "utils/ApiPathConst"; +import RegisterStepIcon, { registerStepStyle } from 'components/RegisterStepIcon'; // project import import Loadable from 'components/Loadable'; @@ -21,7 +22,6 @@ import { notifyActionError } from 'utils/CommonFunction'; const CustomFormWizard = Loadable(lazy(() => import('./auth-forms/BusCustomFormWizard'))); const AuthWrapper = Loadable(lazy(() => import('./AuthWrapperCustom'))); import axios from "axios"; -import { POST_USERNAME, POST_VERIFY_CAPTCHA } from "utils/ApiPathConst"; import {FormattedMessage, useIntl} from "react-intl"; import { PRIMARY_CONTAINED_BUTTON_SX } from "themes/colorConst"; // import CustomFormWizard from './auth-forms/BusCustomFormWizard'; @@ -38,6 +38,7 @@ const BusRegister = () => { const [base64Url, setBase64Url] = useState("") const [checkCode, setCheckCode] = useState("") const [isNextBusy, setIsNextBusy] = useState(false); + const [registrationComplete, setRegistrationComplete] = useState(false); const intl = useIntl(); const steps = [ intl.formatMessage({id: 'personalInformation'}), @@ -45,30 +46,6 @@ const BusRegister = () => { intl.formatMessage({id: 'finishSubmission'}) ]; - const stepStyle = { - width: { lg: "40%", md: "70%", xs: "100%" }, - boxShadow: 1, - backgroundColor: "#FFFFFF", - padding: 2, - - /* Inactive (default) */ - "& .MuiStepIcon-root": { color: "#757575", fontSize: "2rem" }, // darker grey - "& .MuiStepLabel-label": { color: "#424242" }, // label darker - "& .MuiStepConnector-line": { borderColor: "#9E9E9E" }, // connector darker - - /* Active */ - "& .Mui-active": { - "&.MuiStepIcon-root": { color: "warning.main", fontSize: "2rem" }, - "& .MuiStepConnector-line": { borderColor: "warning.main" } - }, - - /* Completed */ - "& .Mui-completed": { - "&.MuiStepIcon-root": { color: "#1976d2", fontSize: "2rem" }, // use your strong blue - "& .MuiStepConnector-line": { borderColor: "#1976d2" } - } - }; - const totalSteps = () => { return steps.length; }; @@ -148,51 +125,30 @@ const BusRegister = () => { const handleReset = () => { setActiveStep(0); setCompleted({}); + setRegistrationComplete(false); }; + const isStepCompleted = (index) => index < activeStep || registrationComplete; + return ( // - + {steps.map((label, index) => ( - - {index < 2 ? ( - - - {label} - - - ) : ( - } - // onClick={handleStep(index)} + + + - - {label} - - - )} + {label} + + ))} @@ -216,6 +172,7 @@ const BusRegister = () => { setUsername={setUsername} setBase64Url={setBase64Url} setCheckCode={setCheckCode} + onRegistrationComplete={() => setRegistrationComplete(true)} /> {/* */} diff --git a/src/pages/authentication/IAmSmartRegister.js b/src/pages/authentication/IAmSmartRegister.js index 3fd578b..45edd96 100644 --- a/src/pages/authentication/IAmSmartRegister.js +++ b/src/pages/authentication/IAmSmartRegister.js @@ -13,10 +13,11 @@ import { Stack, Typography, Button, + StepLabel, CircularProgress, } from '@mui/material'; -import VisibilityIcon from '@mui/icons-material/Visibility'; import { GET_ID, POST_VERIFY_CAPTCHA } from "utils/ApiPathConst"; +import RegisterStepIcon, { registerStepStyle } from 'components/RegisterStepIcon'; // project import import Loadable from 'components/Loadable'; @@ -24,32 +25,10 @@ import { lazy } from 'react'; import { notifyActionError } from 'utils/CommonFunction'; import axios from "axios"; import {FormattedMessage, useIntl} from "react-intl"; +import { PRIMARY_CONTAINED_BUTTON_SX } from "themes/colorConst"; const CustomFormWizard = Loadable(lazy(() => import('./auth-forms/IAmSmartFormWizard'))); const AuthWrapper = Loadable(lazy(() => import('./AuthWrapperCustom'))); // ================================|| REGISTER ||================================ // - const stepStyle = { - width: { lg: "40%", md: "70%", xs: "100%" }, - boxShadow: 1, - backgroundColor: "#FFFFFF", - padding: 2, - - /* Inactive (default) */ - "& .MuiStepIcon-root": { color: "#757575", fontSize: "2rem" }, // darker grey - "& .MuiStepLabel-label": { color: "#424242" }, // label darker - "& .MuiStepConnector-line": { borderColor: "#9E9E9E" }, // connector darker - - /* Active */ - "& .Mui-active": { - "&.MuiStepIcon-root": { color: "warning.main", fontSize: "2rem" }, - "& .MuiStepConnector-line": { borderColor: "warning.main" } - }, - - /* Completed */ - "& .Mui-completed": { - "&.MuiStepIcon-root": { color: "#1976d2", fontSize: "2rem" }, // use your strong blue - "& .MuiStepConnector-line": { borderColor: "#1976d2" } - } - }; const Register = () => { const [activeStep, setActiveStep] = useState(0); @@ -61,6 +40,7 @@ const Register = () => { const [checkCode, setCheckCode] = useState("") const [idNo, setIdNo] = useState(""); const [isNextBusy, setIsNextBusy] = useState(false); + const [registrationComplete, setRegistrationComplete] = useState(false); const intl = useIntl(); const steps = [ intl.formatMessage({id: 'personalInformation'}), @@ -152,37 +132,30 @@ const Register = () => { const handleReset = () => { setActiveStep(0); setCompleted({}); + setRegistrationComplete(false); }; + const isStepCompleted = (index) => index < activeStep || registrationComplete; + return ( // - + {steps.map((label, index) => ( - - {index < 2 ? ( - - {label} - - ) : ( - } - // onClick={handleStep(index)} + + + {label} - - )} + + ))} @@ -207,6 +180,7 @@ const Register = () => { setIdNo={setIdNo} setBase64Url={setBase64Url} setCheckCode={setCheckCode} + onRegistrationComplete={() => setRegistrationComplete(true)} /> {/* */} @@ -239,33 +213,33 @@ const Register = () => { {activeStep === totalSteps() - 2 ? ( ) : (activeStep === totalSteps() - 1 ? ( - ) : ( // diff --git a/src/pages/authentication/Register.js b/src/pages/authentication/Register.js index 2e50f4f..2e6e427 100644 --- a/src/pages/authentication/Register.js +++ b/src/pages/authentication/Register.js @@ -15,8 +15,8 @@ import { Button, StepLabel, CircularProgress, } from '@mui/material'; -import VisibilityIcon from '@mui/icons-material/Visibility'; import { POST_USERNAME, POST_VERIFY_CAPTCHA } from "utils/ApiPathConst"; +import RegisterStepIcon, { registerStepStyle } from 'components/RegisterStepIcon'; // project import import Loadable from 'components/Loadable'; @@ -39,6 +39,7 @@ const Register = () => { const [base64Url, setBase64Url] = useState("") const [checkCode, setCheckCode] = useState("") const [isNextBusy, setIsNextBusy] = useState(false); + const [registrationComplete, setRegistrationComplete] = useState(false); const nextBusyRef = useRef(false); const intl = useIntl(); // Localized document title/meta for register flow @@ -49,30 +50,6 @@ const Register = () => { intl.formatMessage({id: 'finishSubmission'}) ]; - const stepStyle = { - width: { lg: "40%", md: "70%", xs: "100%" }, - boxShadow: 1, - backgroundColor: "#FFFFFF", - padding: 2, - - /* Inactive (default) */ - "& .MuiStepIcon-root": { color: "#757575", fontSize: "2rem" }, // darker grey - "& .MuiStepLabel-label": { color: "#424242" }, // label darker - "& .MuiStepConnector-line": { borderColor: "#9E9E9E" }, // connector darker - - /* Active */ - "& .Mui-active": { - "&.MuiStepIcon-root": { color: "warning.main", fontSize: "2rem" }, - "& .MuiStepConnector-line": { borderColor: "warning.main" } - }, - - /* Completed */ - "& .Mui-completed": { - "&.MuiStepIcon-root": { color: "#1976d2", fontSize: "2rem" }, // use your strong blue - "& .MuiStepConnector-line": { borderColor: "#1976d2" } - } - }; - const totalSteps = () => { return steps.length; }; @@ -154,51 +131,30 @@ const Register = () => { const handleReset = () => { setActiveStep(0); setCompleted({}); + setRegistrationComplete(false); }; + const isStepCompleted = (index) => index < activeStep || registrationComplete; + return ( // - + {steps.map((label, index) => ( - - {index < 2 ? ( - + + - - {label} - - - ) : ( - } - // onClick={handleStep(index)} - > - - {label} - - - )} + {label} + + ))} @@ -222,6 +178,7 @@ const Register = () => { setUsername={setUsername} setBase64Url={setBase64Url} setCheckCode={setCheckCode} + onRegistrationComplete={() => setRegistrationComplete(true)} /> {/* */} diff --git a/src/pages/authentication/auth-forms/BusCustomFormWizard.js b/src/pages/authentication/auth-forms/BusCustomFormWizard.js index e1de58c..8405b81 100644 --- a/src/pages/authentication/auth-forms/BusCustomFormWizard.js +++ b/src/pages/authentication/auth-forms/BusCustomFormWizard.js @@ -500,6 +500,7 @@ const BusCustomFormWizard = (props) => { ) => { // console.log(response) setCheckUpload(true) + props.onRegistrationComplete?.(); setLoding(false); }) .catch(error => { diff --git a/src/pages/authentication/auth-forms/CustomFormWizard.js b/src/pages/authentication/auth-forms/CustomFormWizard.js index 4893ba3..1cb743e 100644 --- a/src/pages/authentication/auth-forms/CustomFormWizard.js +++ b/src/pages/authentication/auth-forms/CustomFormWizard.js @@ -592,6 +592,7 @@ const CustomFormWizard = (props) => { ) => { // console.log(response) setCheckUpload(true) + props.onRegistrationComplete?.(); setLoding(false); }) .catch(error => { diff --git a/src/pages/authentication/auth-forms/IAmSmartFormWizard.js b/src/pages/authentication/auth-forms/IAmSmartFormWizard.js index f8398b8..dcd4aaf 100644 --- a/src/pages/authentication/auth-forms/IAmSmartFormWizard.js +++ b/src/pages/authentication/auth-forms/IAmSmartFormWizard.js @@ -40,7 +40,7 @@ import LoopIcon from '@mui/icons-material/Loop'; import { useTheme } from '@mui/material/styles'; import { useLocation } from "react-router-dom"; import { FormattedMessage, useIntl } from "react-intl"; -import { notifyActionError } from 'utils/CommonFunction'; +import { handleActionKeyDown, notifyActionError } from 'utils/CommonFunction'; // ============================|| FIREBASE - REGISTER ||============================ // @@ -431,6 +431,7 @@ const CustomFormWizard = (props) => { .then((response) => { console.log(response) setCheckUpload(true) + props.onRegistrationComplete?.(); setLoding(false); }) .catch(error => { @@ -584,8 +585,11 @@ const CustomFormWizard = (props) => { {iAmSmartData?.idNo?.slice(0, 4)}{showId ? iAmSmartData?.idNo?.slice(4) : "****"}{showId ? '(' + iAmSmartData.checkDigit + ')' : null} handleActionKeyDown(event, handleClickShowId)} onMouseDown={handleMouseDownId} edge="end" size="medium" @@ -1089,7 +1093,14 @@ const CustomFormWizard = (props) => { - { onCaptchaChange() }}> + { onCaptchaChange() }} + onKeyDown={(event) => handleActionKeyDown(event, () => onCaptchaChange())} + > @@ -1175,8 +1186,11 @@ const CustomFormWizard = (props) => { {/* {formik.values.idNo + "(" + formik.values.checkDigit + ")"} */} handleActionKeyDown(event, handleClickShowComId)} onMouseDown={handleMouseDownComId} edge="end" size="medium"