Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

185 строки
9.7 KiB

  1. // material-ui
  2. import {
  3. Grid,
  4. Typography,
  5. Stack,
  6. Card,
  7. FormHelperText,
  8. InputLabel, OutlinedInput,
  9. } from '@mui/material';
  10. import * as React from "react";
  11. import { useFormik, FormikProvider } from 'formik';
  12. import * as yup from 'yup';
  13. import { useParams } from "react-router-dom";
  14. //import { iAmSmartPath, clientId, getBowerType , iAmSmartCallbackPath} from 'auth/utils'
  15. import Loadable from 'components/Loadable';
  16. const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent')));
  17. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  18. const BackgroundHead = {
  19. backgroundImage: `url(${titleBackgroundImg})`,
  20. width: '100%',
  21. height: '100%',
  22. backgroundSize: 'contain',
  23. backgroundRepeat: 'no-repeat',
  24. backgroundColor: '#0C489E',
  25. backgroundPosition: 'right'
  26. }
  27. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  28. const Index = () => {
  29. const params = useParams();
  30. const [onReady, setOnReady] = React.useState(false);
  31. const [checkUsername, setCheckUsername] = React.useState(false);
  32. const [props, setProps] = React.useState({});
  33. React.useEffect(() => {
  34. if(params.code){
  35. setOnReady(true);
  36. setProps({});
  37. }
  38. }, []);
  39. // function loadIAmSmartProfile(){
  40. // }
  41. function displayErrorMsg(errorMsg) {
  42. return <Typography variant="errorMessage1">{errorMsg}</Typography>
  43. }
  44. const formik = useFormik({
  45. initialValues: ({
  46. username: '',
  47. enName: '',
  48. email: '',
  49. address1: '',
  50. address2: '',
  51. address3: '',
  52. password: '',
  53. phone: '',
  54. phoneCountryCode: '852',
  55. }),
  56. validationSchema: yup.object().shape({
  57. username: yup.string().min(6, displayErrorMsg('用戶名稱最少6位')).required(displayErrorMsg('請輸入用戶名稱'))
  58. .matches(/^[aA-zZ0-9\s]+$/, { message: displayErrorMsg("用戶名稱不包含特殊字符") })
  59. .matches(/^\S*$/, { message: displayErrorMsg('用戶名稱不包含空格') }),
  60. enName: yup.string().max(255).required(displayErrorMsg('請輸入英文姓名')),
  61. chName: yup.string().max(255).required(displayErrorMsg('請輸入中文姓名')),
  62. address1: yup.string().max(255).required(displayErrorMsg('請輸入第一行地址')),
  63. address2: yup.string().max(255).required(displayErrorMsg('請輸入第二行地址')),
  64. address3: yup.string().max(255).required(displayErrorMsg('請輸入第三行地址')),
  65. email: yup.string().email(displayErrorMsg('請輸入電郵格式')).max(255).required(displayErrorMsg('請輸入電郵')),
  66. phoneCountryCode: yup.string().min(2, displayErrorMsg('請輸入最少2位數字')).required(displayErrorMsg('請輸入國際區號')),
  67. phone: yup.string().min(8, displayErrorMsg('請輸入最少8位數字')).required(displayErrorMsg('請輸入聯絡電話')),
  68. }, ['username']),
  69. });
  70. return (
  71. !onReady ?
  72. <LoadingComponent />
  73. :
  74. <FormikProvider value={formik}>
  75. <Grid container sx={{ minHeight: '110vh', backgroundColor: '#fff' }} direction="column" justifyContent="flex-start" alignItems="center" style={{ backgroundColor: "#F2F2F2" }} >
  76. <Grid item xs={12} width="100%">
  77. <div style={BackgroundHead} width="100%">
  78. <Stack direction="row" height='70px'>
  79. <Typography ml={15} color='#FFF' variant="h4" sx={{ pt: 2 }}>iAmSmart 登記</Typography>
  80. </Stack>
  81. </div>
  82. </Grid>
  83. {/*row 1*/}
  84. <Grid item xs={12} md={12}>
  85. <Grid container justifyContent="flex-start" alignItems="center" >
  86. <Card
  87. sx={{
  88. maxWidth: { xs: 1, lg: 1000 },
  89. margin: { xs: 2.5, md: 3 },
  90. '& > *': {
  91. flexGrow: 1,
  92. flexBasis: '50%'
  93. },
  94. backgroundColor: "secondary",
  95. p:8,
  96. pl:16,
  97. pr:16
  98. }}
  99. >
  100. <Grid container spacing={3} >
  101. <Grid item xs={12} md={12}>
  102. <Stack direction="column" justifyContent="space-between" alignItems="baseline" sx={{ mb: { xs: -0.5, sm: 0.5 } }}>
  103. <div style={{ borderBottom: "3px solid #1A4399", width: "100%", margin_right: "15px" }}>
  104. <Typography display="inline" variant="h3" sx={{ color: '#1A4399' }}>成為個人用戶</Typography>
  105. </div>
  106. <Typography mt={0.25} variant="h6" sx={{ color: '#f10000' }}>註有*的項目必須輸入資料</Typography>
  107. <Typography mt={0.25} variant="h4" sx={{ color: 'primary.primary' }}>用戶資料</Typography>
  108. {/* <Typography component={Link} to="/login" variant="body1" sx={{ textDecoration: 'none' }} color="primary">
  109. Already have an account?
  110. </Typography> */}
  111. </Stack>
  112. </Grid>
  113. <Grid item xs={12} md={12}>
  114. <Grid container spacing={1}>
  115. <Grid item xs={12} md={12} >
  116. <Stack spacing={1}>
  117. <InputLabel htmlFor="username-signup">
  118. <Typography variant="h5">
  119. 用戶登入名稱
  120. <span style={{ color: '#f10000' }}>*</span>
  121. </Typography>
  122. </InputLabel>
  123. <OutlinedInput
  124. id="username-login"
  125. type="text"
  126. value={formik.values.username.trim()}
  127. name="username"
  128. onChange={(e) => {
  129. setCheckUsername(false)
  130. props.username = e.target.value
  131. formik.handleChange(e)
  132. }}
  133. placeholder="用戶登入名稱"
  134. fullWidth
  135. error={Boolean((formik.touched.username && formik.errors.username) || checkUsername)}
  136. onBlur={formik.handleBlur}
  137. inputProps={{
  138. onKeyDown: (e) => {
  139. if (e.key === 'Enter') {
  140. e.preventDefault();
  141. }
  142. },
  143. }}
  144. />
  145. {formik.touched.username && formik.errors.username && (
  146. <FormHelperText error id="helper-text-username-signup">
  147. {formik.errors.username}
  148. </FormHelperText>
  149. )}
  150. {checkUsername && (
  151. <FormHelperText error id="helper-text-username-signup">
  152. 此用戶登入名稱已被注冊,請使用其他用戶登入名稱
  153. </FormHelperText>
  154. )}
  155. </Stack>
  156. </Grid>
  157. </Grid>
  158. </Grid>
  159. </Grid>
  160. </Card>
  161. </Grid>
  162. </Grid>
  163. {/*row 2*/}
  164. </Grid >
  165. </FormikProvider>
  166. );
  167. };
  168. export default Index;