Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

86 рядки
3.9 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. import {FormattedMessage} from "react-intl";
  19. export default function Verify() {
  20. const [isLoading, setIsLoading] = useState(true)
  21. const [verifyState, setVerifyState] = useState(null)
  22. const [enterUseEffect, setEnterUseEffect] = useState(false)
  23. const params = useParams()
  24. const handleVerify = async () => {
  25. console.log("handleVerify()");
  26. const response = await axios.get(GET_VERIFY_USER_ACCOUNT, {
  27. params: {
  28. email: decodeURIComponent(params.email),
  29. emailVerifyHash: decodeURIComponent(params.verifyCode)
  30. }
  31. })
  32. if (response.status === 200 && response.data) {
  33. setVerifyState(true)
  34. } else {
  35. setVerifyState(false)
  36. }
  37. setIsLoading(false)
  38. }
  39. useEffect(() => {
  40. console.log("setEnterUseEffect(true)");
  41. setEnterUseEffect(true)
  42. }, [])
  43. useEffect(() => {
  44. console.log("if (enterUseEffect) handleVerify()");
  45. if (enterUseEffect) handleVerify()
  46. }, [enterUseEffect])
  47. return (
  48. <Stack sx={{ width: '100%', fontSize: '2rem', paddingTop: '65px' }} alignItems="center">
  49. <AuthWrapper>
  50. {isLoading || verifyState == null ?
  51. <LoadingComponent /> :
  52. <Grid item xs={12}>
  53. {verifyState ?
  54. // SUCCESS page
  55. <Stack mt={1} direction="column" justifyContent="flex-start" alignItems="center" spacing={2}>
  56. <CheckCircleOutlineIcon color="success" sx={{ width: "200px", height: "200px" }} />
  57. <Typography display="inline" variant="h4">帳戶已成功驗證。</Typography>
  58. <Button variant="outlined" component={Link} to="/login"><Typography variant="h5">
  59. <FormattedMessage id="backToLogin"/>
  60. </Typography></Button>
  61. </Stack>
  62. :
  63. // ERROR page
  64. <Stack mt={1} direction="column" justifyContent="flex-start" alignItems="center" spacing={2}>
  65. {/* <Button disabled={true} hidden={true} variant="contained" type="submit" sx={{ fontSize: 12,height:'25px'}}>Submit</Button> */}
  66. <CancelOutlinedIcon color="error" sx={{ width: "200px", height: "200px" }} />
  67. <Typography display="inline" variant="h4">驗證失敗,請聯絡相關的系統管理員協助。</Typography>
  68. <Button color="error" variant="outlined" component={Link} to="/login"><Typography variant="h5">
  69. <FormattedMessage id="backToLogin"/>
  70. </Typography></Button>
  71. </Stack>
  72. }
  73. </Grid>
  74. }
  75. </AuthWrapper>
  76. </Stack>
  77. )
  78. }