Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 

74 linhas
3.5 KiB

  1. // material-ui
  2. import { Button, Grid } from '@mui/material';
  3. import { Link } from 'react-router-dom';
  4. import Typography from '@mui/material/Typography';
  5. // import iAmSmartICon from 'assets/images/icons/icon_iAmSmart.png';
  6. // import banner from 'assets/images/bg_ml.jpg';
  7. import { Stack } from '../../../node_modules/@mui/material/index';
  8. import { useEffect, useState } from 'react';
  9. import { useParams } from 'react-router-dom';
  10. import axios from 'axios';
  11. import { GET_VERIFY_USER_ACCOUNT } from 'utils/ApiPathConst';
  12. import Loadable from 'components/Loadable';
  13. import { lazy } from 'react';
  14. const LoadingComponent = Loadable(lazy(() => import('../extra-pages/LoadingComponent')));
  15. const AuthWrapper = Loadable(lazy(() => import('./AuthWrapperCustom')));
  16. import CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutline';
  17. import CancelOutlinedIcon from '@mui/icons-material/CancelOutlined';
  18. export default function Verify() {
  19. const [isLoading, setIsLoading] = useState(true)
  20. const [verifyState, setVerifyState] = useState(null)
  21. const params = useParams()
  22. const handleVerify = async () => {
  23. const response = await axios.get(GET_VERIFY_USER_ACCOUNT, {
  24. params: {
  25. email: decodeURIComponent(params.email),
  26. emailVerifyHash: decodeURIComponent(params.verifyCode)
  27. }
  28. })
  29. if (response.status === 200 && response.data) {
  30. setVerifyState(true)
  31. } else {
  32. setVerifyState(false)
  33. }
  34. setIsLoading(false)
  35. }
  36. let enterUseEffect = false
  37. useEffect(() => {
  38. if (enterUseEffect) handleVerify()
  39. enterUseEffect = true
  40. }, [])
  41. return (
  42. <Stack sx={{ width: '100%', fontSize: '2rem', paddingTop: '65px' }} alignItems="center">
  43. <AuthWrapper>
  44. {isLoading || verifyState == null ?
  45. <LoadingComponent /> :
  46. <Grid item xs={12}>
  47. {verifyState ?
  48. // SUCCESS page
  49. <Stack mt={1} direction="column" justifyContent="flex-start" alignItems="center" spacing={2}>
  50. <CheckCircleOutlineIcon color="success" sx={{ width: "200px", height: "200px" }} />
  51. <Typography display="inline" variant="h4">帳戶已成功驗證。</Typography>
  52. <Button variant="outlined" component={Link} to="/login" sx={{ fontSize: 20, height: '60px' }}><Typography variant="h5">返回登入頁面</Typography></Button>
  53. </Stack>
  54. :
  55. // ERROR page
  56. <Stack mt={1} direction="column" justifyContent="flex-start" alignItems="center" spacing={2}>
  57. {/* <Button disabled={true} hidden={true} variant="contained" type="submit" sx={{ fontSize: 12,height:'25px'}}>Submit</Button> */}
  58. <CancelOutlinedIcon color="error" sx={{ width: "200px", height: "200px" }} />
  59. <Typography display="inline" variant="h4">驗證失敗,請聯絡相關的系統管理員協助。</Typography>
  60. <Button color="error" variant="outlined" component={Link} to="/login" sx={{ fontSize: 20, height: '60px' }}><Typography variant="h5">返回登入頁面</Typography></Button>
  61. </Stack>
  62. }
  63. </Grid>
  64. }
  65. </AuthWrapper>
  66. </Stack>
  67. )
  68. }