// import { Link } from 'react-router-dom'; import React, { useState // ,useEffect } from 'react'; // material-ui import { Stepper, Step, StepButton, // Grid, Stack, Typography, Button, } from '@mui/material'; import VisibilityIcon from '@mui/icons-material/Visibility'; import { GET_ID, POST_VERIFY_CAPTCHA } from "utils/ApiPathConst"; // project import import Loadable from 'components/Loadable'; import { lazy } from 'react'; import { notifyActionError } from 'utils/CommonFunction'; import axios from "axios"; const CustomFormWizard = Loadable(lazy(() => import('./auth-forms/IAmSmartFormWizard'))); const AuthWrapper = Loadable(lazy(() => import('./AuthWrapperCustom'))); // ================================|| REGISTER ||================================ // const stepStyle = { width: "40%", boxShadow: 1, backgroundColor: "#FFFFFF", padding: 2, "& .Mui-active": { "&.MuiStepIcon-root": { color: "warning.main", fontSize: "2rem", }, "& .MuiStepConnector-line": { borderColor: "warning.main" } }, "& .Mui-completed": { "&.MuiStepIcon-root": { color: "secondary.main", fontSize: "2rem", }, "& .MuiStepConnector-line": { borderColor: "secondary.main" } } } const steps = ['個人資料', '預覽', '完成提交']; const Register = () => { const [activeStep, setActiveStep] = useState(0); const [completed, setCompleted] = useState([false]); const [updateValid, setUpdateValid] = useState(false); const [idNo, setIdNo] = useState(""); const totalSteps = () => { return steps.length; }; const completedSteps = () => { return Object.keys(completed).length; }; const isLastStep = () => { return activeStep === totalSteps() - 1; }; const allStepsCompleted = () => { return completedSteps() === totalSteps(); }; const handleCheckID = async () => { const response = await axios.get(`${GET_ID}`, { params: { idNo: idNo, } }) return Number(response.data[0]) === 1 } const handleCaptcha = async () => { const response = await axios.post(`${POST_VERIFY_CAPTCHA}`, { captcha: base64Url, checkCode: checkCode, }) return Boolean(response.data["success"]); } const handleNext = async () => { if (!idNo) { notifyActionError("資料,請返回注冊頁面。") return; } const captchaTest = await handleCaptcha(); if (!captchaTest) { notifyActionError("請輸入有效驗證") return; } const test = await handleCheckID() if (test) { notifyActionError("此用戶已注冊,請返回登入頁面並進行登入流程。") } else { const newActiveStep = isLastStep() && !allStepsCompleted() ? // It's the last step, but not all steps have been completed, // find the first step that has been completed steps.findIndex((step, i) => !(i in completed)) : activeStep + 1; setActiveStep(newActiveStep); scrollToTop(); } }; const handleBack = () => { scrollToTop(); setActiveStep((prevActiveStep) => prevActiveStep - 1); }; const scrollToTop = () => { window.scrollTo(0, 0); }; const handleReset = () => { setActiveStep(0); setCompleted({}); }; return ( // {steps.map((label, index) => ( { index < 2 ? ( {label} ) : (} // onClick={handleStep(index)} > {label} ) } ))} {allStepsCompleted() ? ( All steps completed - you're finished ) : ( {/* */} {activeStep === 2 || activeStep === 0 ? ( ) : ( ) } {activeStep === totalSteps() - 2 ? ( ) : (activeStep === totalSteps() - 1 ? ( ) : ( // ) )} {/* {activeStep !== steps.length && (completed[activeStep] ? ( Step {activeStep + 1} already completed ) : ( ))} */} )} // ); }; export default Register;