You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

1262 line
76 KiB

  1. import { useEffect, useState, } from 'react';
  2. // material-ui
  3. import {
  4. Box,
  5. Button,
  6. FormControl,
  7. FormHelperText,
  8. Grid, IconButton,
  9. InputAdornment,
  10. InputLabel, OutlinedInput,
  11. Stack,
  12. Typography,
  13. FormGroup,
  14. TextField,
  15. Checkbox
  16. // MenuItem
  17. } from '@mui/material';
  18. import {useForm,} from 'react-hook-form'
  19. import Autocomplete from "@mui/material/Autocomplete";
  20. // third party
  21. import { useFormik,FormikProvider } from 'formik';
  22. import * as yup from 'yup';
  23. // import axios from "axios";
  24. // project import
  25. // import AnimateButton from 'components/@extended/AnimateButton';
  26. import { strengthColorChi, strengthIndicator } from 'utils/password-strength';
  27. import {apiPath} from "auth/utils";
  28. import axios from "axios";
  29. import {POST_PUBLIC_USER_REGISTER} from "utils/ApiPathConst";
  30. import * as HttpUtils from 'utils/HttpUtils';
  31. import Loadable from 'components/Loadable';
  32. import { lazy } from 'react';
  33. const UploadFileTable = Loadable(lazy(() => import('./UploadFileTable')));
  34. const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingComponent')));
  35. // import UploadFileTable from './UploadFileTable';
  36. // import LoadingComponent from "../../extra-pages/LoadingComponent";
  37. // assets
  38. import { EyeInvisibleOutlined, EyeOutlined } from '@ant-design/icons';
  39. import CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutline';
  40. import CancelOutlinedIcon from '@mui/icons-material/CancelOutlined';
  41. import { Link } from 'react-router-dom';
  42. // ============================|| FIREBASE - REGISTER ||============================ //
  43. const BusCustomFormWizard = (props) => {
  44. const [level, setLevel] = useState();
  45. const [showPassword, setShowPassword] = useState(false);
  46. const [showConfirmPassword, setshowConfirmPassword] = useState(false);
  47. const [fileList, setFileList] = useState([]);
  48. const [fileListData, setFileListData] = useState([]);
  49. const [checkUpload, setCheckUpload] = useState(false);
  50. const [isLoading, setLoding] = useState(true);
  51. const handleClickShowPassword = () => {
  52. setShowPassword(!showPassword);
  53. };
  54. const handleClickShowConfirmPassword = () => {
  55. setshowConfirmPassword(!showConfirmPassword);
  56. };
  57. const handleMouseDownPassword = (event) => {
  58. event.preventDefault();
  59. };
  60. const changePassword = (value) => {
  61. const temp = strengthIndicator(value);
  62. setLevel(strengthColorChi(temp));
  63. };
  64. const [selectedAddress4, setSelectedAddress4] = useState(null);
  65. const [selectedAddress5, setSelectedAddress5] = useState("香港");
  66. const [termsAndConAccept, setTermsAndConAccept] = useState(false);
  67. const [termsAndConNotAccept, setTermsAndConNotAccept] = useState(false);
  68. const [isValid, setisValid] = useState(false);
  69. const address4ComboList =
  70. ["北區","長洲區","大埔區","大嶼山區","東區","觀塘區","黃大仙區","九龍城區","葵青區","南區","南丫島區",
  71. "坪洲區","荃灣區","沙田區","深水埗區","屯門區","灣仔區","西貢區","油尖旺區","元朗區","中西區"];
  72. const address5ComboList = ["香港","內地","澳門"];
  73. const termsAndCon = "此網址由香港特別行政區政府物流服務署製作及管理。本署會盡力確保網址上的資料無誤,\n"
  74. + "但有絕對酌情權隨時刪除、暫停登載或編輯各項資料而無須給予任何理由。\n由於任何與網址"
  75. + "內資料有關的理由或原因,而導致出現申索、損失或損害,本署概不負責。\n使用者須自行評"
  76. + "估本網址所載或與本網址有關連的各項資料,並應在根據該等資料行事前,參照印行的香港"
  77. + "特別行政區憲報以核實該等資料,以及徵詢獨立意見。\n版權公告本網頁的內容,包括但不限"
  78. + "於所有文本、平面圖像、圖畫、圖片、照片以及數據或其他資料的匯編,均受版權保障。\n香"
  79. + "港特別行政區政府是本網頁內所有版權作品的擁有人,除非預先得到政府物流服務署的書面"
  80. + "授權,否則嚴禁複製、改編、分發、發布或向公眾提供該等版權作品。"
  81. // const refType = "identification";
  82. useEffect(() => {
  83. changePassword('');
  84. }, []);
  85. const checkDataField = (data)=> {
  86. // console.log(data.brExpiryDate)
  87. if (data.username !==""&&
  88. data.password !==""&&
  89. data.confirmPassword !==""&&
  90. data.password == data.confirmPassword&&
  91. data.enCompanyName !==""&&
  92. data.enName !==""&&
  93. data.address1 !==""&&
  94. data.email !==""&&
  95. data.emailConfirm !==""&&
  96. data.phone !==""&&
  97. data.phoneCountryCode !==""&&
  98. termsAndConAccept == true&&
  99. fileList.length!==0&&
  100. handlePassword(data.password)&&
  101. handleEmail(data.email)&&
  102. handlePhone(data.phone)
  103. )
  104. {
  105. setisValid(true)
  106. return isValid
  107. }else{
  108. setisValid(false)
  109. return isValid
  110. }
  111. };
  112. const handleCheckBoxChange = (event) => {
  113. console.log (event.target)
  114. if(event.target.name == 'termsAndConAccept'){
  115. setTermsAndConAccept(event.target.checked)
  116. setTermsAndConNotAccept(!event.target.checked)
  117. }
  118. if(event.target.name == 'termsAndConNotAccept'){
  119. setTermsAndConNotAccept(event.target.checked)
  120. setTermsAndConAccept(!event.target.checked)
  121. }
  122. };
  123. useEffect(() => {
  124. let updateRowList = new DataTransfer();
  125. var updateRowsIndex = updateRows.length;
  126. const saveFileList = [];
  127. if (updateRowsIndex!=null){
  128. for (let i = 0; i < updateRowsIndex; i++){
  129. const file = updateRows[i]
  130. file.id = i;
  131. updateRowList.items.add(file);
  132. saveFileList.push(file);
  133. }
  134. let updatedFileList = updateRowList.files;
  135. setFileList(updatedFileList);
  136. setFileListData(saveFileList)
  137. }
  138. }, [updateRows]);
  139. const handleFileUpload = (event)=>{
  140. let updateList = new DataTransfer();
  141. let currentFileList = fileListData;
  142. const uploadFileList = event.target.files;
  143. const saveFileList = [];
  144. var currentIndex = 0;
  145. if (currentFileList.length!=null){
  146. currentIndex = currentFileList.length;
  147. for (let i = 0; i < currentIndex; i++){
  148. const file = currentFileList[i]
  149. // file.id = currentIndex;
  150. updateList.items.add(file);
  151. saveFileList.push(file);
  152. }
  153. }
  154. for (let i = 0; i < uploadFileList.length && currentIndex<5; i++){
  155. const file = event.target.files[i]
  156. let isDuplicate = false;
  157. // Check if the file name already exists in saveFileList
  158. for (let j = 0; j < saveFileList.length; j++) {
  159. if (saveFileList[j].name === file.name) {
  160. isDuplicate = true;
  161. break;
  162. }
  163. }
  164. if (!isDuplicate) {
  165. file.id = currentIndex+i
  166. saveFileList.push(file)
  167. updateList.items.add(file);
  168. }
  169. }
  170. let updatedFileList = updateList.files;
  171. setFileListData(saveFileList)
  172. setFileList(updatedFileList);
  173. };
  174. useEffect(() => {
  175. props.setUpdateValid(isValid)
  176. }, [isValid])
  177. useEffect(() => {
  178. checkDataField(values)
  179. }, [selectedAddress4,selectedAddress5,
  180. termsAndConAccept,termsAndConNotAccept,fileList])
  181. useEffect(() => {
  182. props.step ==2?_onSubmit():null;
  183. }, [props.step])
  184. const {handleSubmit} = useForm({})
  185. const _onSubmit = () => {
  186. setLoding(true);
  187. values.address4 = selectedAddress4
  188. values.address5 = selectedAddress5
  189. // console.log(values)
  190. const busUserAddress = {
  191. "addressLine1":"",
  192. "addressLine2":"",
  193. "addressLine3":"",
  194. "district":"",
  195. "country":""
  196. };
  197. busUserAddress.addressLine1 = values.address1
  198. busUserAddress.addressLine2 = values.address2
  199. busUserAddress.addressLine3 = values.address3
  200. busUserAddress.district = values.address4
  201. busUserAddress.country = values.address5
  202. const userFaxNo = {
  203. "countryCode":values.faxCountryCode,
  204. "faxNumber":values.fax,
  205. };
  206. const busUserContactTel = {
  207. "countryCode":values.phoneCountryCode,
  208. "phoneNumber":values.phone,
  209. };
  210. let tncFlag = false;
  211. if (termsAndConAccept){
  212. tncFlag = true
  213. }
  214. if (termsAndConNotAccept){
  215. tncFlag = false
  216. }
  217. if (isValid){
  218. axios.post(`${apiPath}${POST_PUBLIC_USER_REGISTER}`, {
  219. username: values.username,
  220. password: values.password,
  221. name: values.username,
  222. enCompanyName: values.enCompanyName,
  223. chCompanyName: values.chCompanyName,
  224. emailBus: values.email,
  225. brNo:values.brNo,
  226. brExpiryDate:values.brExpiryDate,
  227. userFaxNo:userFaxNo,
  228. busUserContactTel:busUserContactTel,
  229. busUserAddress:busUserAddress,
  230. contactPerson: values.enName,
  231. tncFlag:tncFlag,
  232. type:"ORG"
  233. })
  234. .then((response) => {
  235. setCheckUpload(true)
  236. HttpUtils.fileUpload(
  237. {
  238. refType:"brFile",
  239. refId: response.data.id,
  240. file: fileList[0],
  241. onSuccess: (response)=>{
  242. console.log(response);
  243. setLoding(false);
  244. // setOpen(true);
  245. }
  246. }
  247. );
  248. })
  249. .catch(error => {
  250. console.error(error);
  251. setLoding(false);
  252. });
  253. }else{
  254. setLoding(false);
  255. }
  256. }
  257. function handlePhone(phone) {
  258. if (phone.length < 8) {
  259. return false;
  260. } else {
  261. return true;
  262. }
  263. }
  264. function handlePassword(password) {
  265. let new_pass = password;
  266. // regular expressions to validate password
  267. var lowerCase = /[a-z]/g;
  268. var upperCase = /[A-Z]/g;
  269. var numbers = /[0-9]/g;
  270. if (!new_pass.match(lowerCase)) {
  271. return false;
  272. } else if (!new_pass.match(upperCase)) {
  273. return false;
  274. } else if (!new_pass.match(numbers)) {
  275. return false;
  276. } else if (new_pass.length < 8) {
  277. return false;
  278. } else {
  279. return true;
  280. }
  281. }
  282. function handleEmail(email) {
  283. var validRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
  284. // var result = reg.test(email);
  285. var result = email.match(validRegex);
  286. console.log("test1: "+result)
  287. if (result == false) {
  288. return false;
  289. }
  290. return true;
  291. }
  292. const formik = useFormik({
  293. initialValues:({
  294. username:'',
  295. enName: '',
  296. enCompanyName: '',
  297. chCompanyName: '',
  298. email: '',
  299. address1: '',
  300. address2: '',
  301. address3: '',
  302. password: '',
  303. confirmPassword: '',
  304. phone:'',
  305. phoneCountryCode:'852',
  306. submit: null,
  307. fax:'',
  308. faxCountryCode:'852',
  309. brExpiryDate:'',
  310. brNo:'',
  311. }),
  312. validationSchema:yup.object().shape({
  313. username: yup.string().min(6,'用戶名稱最少6位').required('請輸入用戶名稱'),
  314. password: yup.string().min(8,'請輸入最少8位密碼').required('請輸入密碼')
  315. .matches(/^(?=.*[a-z])/, '請包括最少1個小寫字母')
  316. .matches(/^(?=.*[A-Z])/, '請包括最少1個大寫字母')
  317. .matches(/^(?=.*[0-9])/, '請包括最少1個數字')
  318. .matches(/^(?=.*[!@#%&])/, '請包括最少1個特殊字符'),
  319. confirmPassword: yup.string().min(8,'請最少輸入8位密碼').required('請確認密碼').oneOf([yup.ref('password'), null], '請輸入相同密碼'),
  320. enName: yup.string().max(255).required('請輸入英文姓名'),
  321. enCompanyName: yup.string().max(255).required('請輸入英文名稱'),
  322. chName: yup.string().max(255).required('請輸入中文姓名'),
  323. address1: yup.string().max(255).required('請輸入第一行地址'),
  324. address2: yup.string().max(255).required('請輸入第二行地址'),
  325. address3: yup.string().max(255).required('請輸入第三行地址'),
  326. email: yup.string().email('請輸入電郵格式').max(255).required('請輸入電郵'),
  327. emailConfirm: yup.string().email('請輸入電郵格式').max(255).required('請輸入電郵').oneOf([yup.ref('email'), null], '請輸入相同電郵'),
  328. phoneCountryCode: yup.string().min(3,'請輸入3位數字').required('請輸入國際區號'),
  329. faxCountryCode: yup.string().min(3,'請輸入3位數字'),
  330. phone: yup.string().min(8,'請輸入8位數字').required('請輸入聯絡電話'),
  331. fax: yup.string().min(8,'請輸入8位數字'),
  332. brExpiryDate: yup.string().min(8,'請輸入商業登記證有效日期'),
  333. brNo: yup.string().min(8,'請輸入商業登記證號碼'),
  334. })
  335. });
  336. const handleReset = (resetForm) => {
  337. resetForm();
  338. setSelectedAddress4("")
  339. };
  340. const { values } = formik
  341. useEffect(() => {
  342. checkDataField(values)
  343. }, [values])
  344. return (
  345. <FormikProvider value={formik}>
  346. <form onSubmit={handleSubmit(_onSubmit)}>
  347. {/* Input Form */}
  348. <FormGroup id={"inputForm"} sx={{ display: props.step === 0 ? "" : "none" }}>
  349. <Grid container spacing={3}>
  350. <Grid item xs={12} md={12}>
  351. <Stack direction="column" justifyContent="space-between" alignItems="baseline" sx={{ mb: { xs: -0.5, sm: 0.5 } }}>
  352. <Button variant="outlined" type="reset" onClick={handleReset.bind(null, formik.resetForm)} sx={{ fontSize: 16,height:'30px'}}>重置</Button>
  353. <div style={{borderBottom: "3px solid #1A4399", width:"100%", margin_right: "15px"}}>
  354. <Typography display="inline" variant="h3" sx={{ color: '#1A4399'}}>成為新的機構/公司用戶</Typography>
  355. </div>
  356. <Typography mt={0.25} variant="h6" sx={{ fontSize: 12,color: '#f10000'}}>註有*的項目必須輸入資料</Typography>
  357. <Typography mt={0.25} variant="h4" sx={{ color: 'primary.primary'}}>你的登入資料</Typography>
  358. {/* <Typography component={Link} to="/login" variant="body1" sx={{ textDecoration: 'none' }} color="primary">
  359. Already have an account?
  360. </Typography> */}
  361. </Stack>
  362. </Grid>
  363. <Grid item xs={12} md={12}>
  364. <Grid container spacing={1}>
  365. <Grid item xs={12} md={12} >
  366. <Stack spacing={1}>
  367. <InputLabel htmlFor="username-signup">用戶登入名稱
  368. <span style={{color: '#f10000'}}>*</span>
  369. </InputLabel>
  370. <OutlinedInput
  371. id="username-login"
  372. type="text"
  373. value={formik.values.username}
  374. name="username"
  375. onChange={formik.handleChange}
  376. placeholder="用戶登入名稱"
  377. fullWidth
  378. error={Boolean(formik.touched.username && formik.errors.username)}
  379. onBlur={formik.handleBlur}
  380. inputProps={{
  381. onKeyDown: (e) => {
  382. if (e.key === 'Enter') {
  383. e.preventDefault();
  384. }
  385. },
  386. }}
  387. />
  388. {formik.touched.username && formik.errors.username && (
  389. <FormHelperText error id="helper-text-username-signup">
  390. {formik.errors.username}
  391. </FormHelperText>
  392. )}
  393. </Stack>
  394. </Grid>
  395. <Grid item xs={12} md={12}>
  396. <Grid container>
  397. <Grid item xs={12} md={6} >
  398. <Stack spacing={1} sx={{mr:{md:1},mb:1}}>
  399. <Stack direction="row" justifyContent="space-between">
  400. <InputLabel htmlFor="password-signup">密碼
  401. <span style={{color: '#f10000'}}>*</span>
  402. </InputLabel>
  403. <InputLabel htmlFor="password-rule">密碼規則</InputLabel>
  404. </Stack>
  405. <OutlinedInput
  406. fullWidth
  407. error={Boolean(formik.touched.password && formik.errors.password)}
  408. id="password-signup"
  409. type={showPassword ? 'text' : 'password'}
  410. value={formik.values.password}
  411. name="password"
  412. onChange={(e) => {
  413. formik.handleChange(e);
  414. changePassword(e.target.value);
  415. }}
  416. endAdornment={
  417. <InputAdornment position="end">
  418. <IconButton
  419. aria-label="toggle password visibility"
  420. onClick={handleClickShowPassword}
  421. onMouseDown={handleMouseDownPassword}
  422. edge="end"
  423. size="large"
  424. >
  425. {showPassword ? <EyeOutlined /> : <EyeInvisibleOutlined />}
  426. </IconButton>
  427. </InputAdornment>
  428. }
  429. placeholder="密碼"
  430. onBlur={formik.handleBlur}
  431. inputProps={{
  432. onKeyDown: (e) => {
  433. if (e.key === 'Enter') {
  434. e.preventDefault();
  435. }
  436. },
  437. }}
  438. />
  439. {formik.touched.password && formik.errors.password && (
  440. <FormHelperText error id="helper-text-password-signup">
  441. {formik.errors.password}
  442. </FormHelperText>
  443. )}
  444. </Stack>
  445. <FormControl fullWidth sx={{ mt: 2 }}>
  446. <Grid container spacing={2} alignItems="center">
  447. <Grid item>
  448. <Box sx={{ bgcolor: level?.color, width: 85, height: 8, borderRadius: '7px' }} />
  449. </Grid>
  450. <Grid item>
  451. <Typography variant="subtitle1" fontSize="0.75rem">
  452. {level?.label}
  453. </Typography>
  454. </Grid>
  455. </Grid>
  456. </FormControl>
  457. </Grid>
  458. <Grid item xs={12} md={6} >
  459. <Stack spacing={1}>
  460. <InputLabel htmlFor="confirmPassword-signup">確認密碼
  461. <span style={{color: '#f10000'}}>*</span>
  462. </InputLabel>
  463. <OutlinedInput
  464. id="confirmPassword-login"
  465. type={showConfirmPassword ? 'text' : 'password'}
  466. value={formik.values.confirmPassword}
  467. name="confirmPassword"
  468. onBlur={formik.handleBlur}
  469. onChange={(e) => {
  470. formik.handleChange(e);
  471. // changePassword(e.target.value);
  472. }}
  473. inputProps={{
  474. onKeyDown: (e) => {
  475. if (e.key === 'Enter') {
  476. e.preventDefault();
  477. }
  478. },
  479. }}
  480. endAdornment={
  481. <InputAdornment position="end">
  482. <IconButton
  483. aria-label="toggle password visibility"
  484. onClick={handleClickShowConfirmPassword}
  485. onMouseDown={handleMouseDownPassword}
  486. edge="end"
  487. size="large"
  488. >
  489. {showConfirmPassword ? <EyeOutlined /> : <EyeInvisibleOutlined />}
  490. </IconButton>
  491. </InputAdornment>
  492. }
  493. placeholder="確認密碼"
  494. fullWidth
  495. error={Boolean(formik.touched.confirmPassword && formik.errors.confirmPassword)}
  496. />
  497. {formik.touched.confirmPassword && formik.errors.confirmPassword && (
  498. <FormHelperText error id="helper-text-confirmPassword-signup">
  499. {formik.errors.confirmPassword}
  500. </FormHelperText>
  501. )}
  502. </Stack>
  503. </Grid>
  504. </Grid>
  505. </Grid>
  506. <Grid item xs={12} mt={1} mb={1}>
  507. <Stack direction="column" justifyContent="space-between" alignItems="baseline" sx={{ mb: { xs: -0.5, sm: 0.5 } }}>
  508. <Typography display="inline" variant="h4" sx={{ color: '#1A4399'}}>你的機構/公司資料</Typography>
  509. {/* <Typography component={Link} to="/login" variant="body1" sx={{ textDecoration: 'none' }} color="primary">
  510. Already have an account?
  511. </Typography> */}
  512. </Stack>
  513. </Grid>
  514. <Grid item xs={12} md={6}>
  515. <Stack spacing={1}>
  516. <InputLabel htmlFor="enCompanyName-signup">機構/公司英文名稱
  517. <span style={{color: '#f10000'}}>*</span>
  518. </InputLabel>
  519. <OutlinedInput
  520. id="enCompanyName-login"
  521. type="enCompanyName"
  522. value={formik.values.enCompanyName}
  523. name="enCompanyName"
  524. onChange={formik.handleChange}
  525. placeholder="與與商業登記證相同如有"
  526. fullWidth
  527. error={Boolean(formik.touched.enCompanyName && formik.errors.enCompanyName)}
  528. onBlur={formik.handleBlur}
  529. inputProps={{
  530. onKeyDown: (e) => {
  531. if (e.key === 'Enter') {
  532. e.preventDefault();
  533. }
  534. },
  535. }}
  536. />
  537. {formik.touched.enCompanyName && formik.errors.enCompanyName && (
  538. <FormHelperText error id="helper-text-enCompanyName-signup">
  539. {formik.errors.enCompanyName}
  540. </FormHelperText>
  541. )}
  542. </Stack>
  543. </Grid>
  544. <Grid item xs={12} md={6}>
  545. <Stack spacing={1}>
  546. <InputLabel htmlFor="chCompanyName-signup">機構/公司中文名稱</InputLabel>
  547. <OutlinedInput
  548. fullWidth
  549. error={Boolean(formik.touched.chCompanyName && formik.errors.chCompanyName)}
  550. id="chCompanyName-signup"
  551. type="text"
  552. value={formik.values.chCompanyName}
  553. name="chCompanyName"
  554. onChange={formik.handleChange}
  555. placeholder="與與商業登記證相同如有"
  556. inputProps={{
  557. onKeyDown: (e) => {
  558. if (e.key === 'Enter') {
  559. e.preventDefault();
  560. }
  561. },
  562. }}
  563. />
  564. {formik.touched.chCompanyName && formik.errors.chCompanyName && (
  565. <FormHelperText error id="helper-text-chCompanyName-signup">
  566. {formik.errors.chCompanyName}
  567. </FormHelperText>
  568. )}
  569. </Stack>
  570. </Grid>
  571. <Grid item xs={12} md={6}>
  572. <Stack spacing={1}>
  573. <InputLabel htmlFor="brNo-signup">商業登記證號碼</InputLabel>
  574. <OutlinedInput
  575. fullWidth
  576. error={Boolean(formik.touched.brNo && formik.errors.brNo)}
  577. id="brNo-signup"
  578. type="text"
  579. value={formik.values.brNo}
  580. name="brNo"
  581. onChange={formik.handleChange}
  582. placeholder="與與商業登記證相同如有"
  583. inputProps={{
  584. onKeyDown: (e) => {
  585. if (e.key === 'Enter') {
  586. e.preventDefault();
  587. }
  588. },
  589. }}
  590. />
  591. {formik.touched.brNo && formik.errors.brNo && (
  592. <FormHelperText error id="helper-text-brNo-signup">
  593. {formik.errors.brNo}
  594. </FormHelperText>
  595. )}
  596. </Stack>
  597. </Grid>
  598. <Grid item xs={12} md={6}>
  599. <Stack spacing={1}>
  600. <InputLabel htmlFor="brExpiryDate-signup">商業登記證有效日期</InputLabel>
  601. <OutlinedInput
  602. fullWidth
  603. error={Boolean(formik.touched.brExpiryDate && formik.errors.brExpiryDate)}
  604. id="brExpiryDate-signup"
  605. type="date"
  606. value={formik.values.brExpiryDate}
  607. name="brExpiryDate"
  608. onChange={formik.handleChange}
  609. placeholder="與與商業登記證相同如有"
  610. inputProps={{
  611. onKeyDown: (e) => {
  612. if (e.key === 'Enter') {
  613. e.preventDefault();
  614. }
  615. },
  616. }}
  617. />
  618. {formik.touched.brExpiryDate && formik.errors.brExpiryDate && (
  619. <FormHelperText error id="helper-text-brExpiryDate-signup">
  620. {formik.errors.brExpiryDate}
  621. </FormHelperText>
  622. )}
  623. </Stack>
  624. </Grid>
  625. <Grid item xs={12}>
  626. <Stack spacing={1}>
  627. <InputLabel htmlFor="address1-signup">地址
  628. <span style={{color: '#f10000'}}>*</span>
  629. </InputLabel>
  630. <OutlinedInput
  631. fullWidth
  632. error={Boolean(formik.touched.address1 && formik.errors.address1)}
  633. id="address1-signup"
  634. value={formik.values.address1}
  635. name="address1"
  636. onChange={formik.handleChange}
  637. placeholder="第一行"
  638. onBlur={formik.handleBlur}
  639. inputProps={{
  640. onKeyDown: (e) => {
  641. if (e.key === 'Enter') {
  642. e.preventDefault();
  643. }
  644. },
  645. }}
  646. />
  647. <OutlinedInput
  648. fullWidth
  649. error={Boolean(formik.touched.address2 && formik.errors.address2)}
  650. id="address2-signup"
  651. value={formik.values.address2}
  652. name="address2"
  653. onChange={formik.handleChange}
  654. placeholder="第二行"
  655. inputProps={{
  656. onKeyDown: (e) => {
  657. if (e.key === 'Enter') {
  658. e.preventDefault();
  659. }
  660. },
  661. }}
  662. />
  663. <OutlinedInput
  664. fullWidth
  665. error={Boolean(formik.touched.address3 && formik.errors.address3)}
  666. id="address3-signup"
  667. value={formik.values.address3}
  668. name="address3"
  669. onChange={formik.handleChange}
  670. placeholder="第三行"
  671. inputProps={{
  672. onKeyDown: (e) => {
  673. if (e.key === 'Enter') {
  674. e.preventDefault();
  675. }
  676. },
  677. }}
  678. />
  679. <Autocomplete
  680. disablePortal
  681. id="address4-combo"
  682. value={selectedAddress4 === null ? null : selectedAddress4}
  683. options={address4ComboList}
  684. onChange={(event, newValue) => {
  685. if (newValue !== null){
  686. setSelectedAddress4(newValue);
  687. }
  688. }}
  689. sx={{"& .MuiInputBase-root": { height: "41px" },"#address4-combo":{padding: "0px 0px 0px 0px"}, "& .MuiAutocomplete-endAdornment": { top: "auto" },}}
  690. renderInput={(params) => <TextField {...params} placeholder="區域 (只適用於香港)"/>}
  691. />
  692. <Autocomplete
  693. disablePortal
  694. id="address5-combo"
  695. value={selectedAddress5}
  696. options={address5ComboList}
  697. onChange={(event, newValue) => {
  698. if (newValue !== null){
  699. setSelectedAddress5(newValue);
  700. }
  701. }}
  702. sx={{"& .MuiInputBase-root": { height: "41px" },"#address5-combo":{padding: "0px 0px 0px 0px"}, "& .MuiAutocomplete-endAdornment": { top: "auto" },}}
  703. renderInput={(params) => <TextField {...params} placeholder="國家/地區"/>}
  704. />
  705. {formik.touched.address1 && formik.errors.address1 && (
  706. <FormHelperText error id="helper-text-address1-signup">
  707. {formik.errors.address1}
  708. </FormHelperText>
  709. )}
  710. {formik.touched.address2 && formik.errors.address2 && (
  711. <FormHelperText error id="helper-text-address2-signup">
  712. {formik.errors.address2}
  713. </FormHelperText>
  714. )}
  715. {formik.touched.address3 && formik.errors.address3 && (
  716. <FormHelperText error id="helper-text-address3-signup">
  717. {formik.errors.address3}
  718. </FormHelperText>
  719. )}
  720. </Stack>
  721. </Grid>
  722. <Grid item xs={12} mt={1} mb={1}>
  723. <Stack direction="column" justifyContent="space-between" alignItems="baseline" sx={{ mb: { xs: -0.5, sm: 0.5 } }}>
  724. <Typography display="inline" variant="h4" sx={{ color: 'primary.primary'}}>你的聯絡資料</Typography>
  725. </Stack>
  726. </Grid>
  727. <Grid item xs={12} md={12}>
  728. <Stack spacing={1}>
  729. <InputLabel htmlFor="enName-signup">姓名
  730. <span style={{color: '#f10000'}}>*</span>
  731. </InputLabel>
  732. <OutlinedInput
  733. id="enName-login"
  734. type="enName"
  735. value={formik.values.enName}
  736. name="enName"
  737. onChange={formik.handleChange}
  738. placeholder=""
  739. fullWidth
  740. error={Boolean(formik.touched.enName && formik.errors.enName)}
  741. onBlur={formik.handleBlur}
  742. inputProps={{
  743. onKeyDown: (e) => {
  744. if (e.key === 'Enter') {
  745. e.preventDefault();
  746. }
  747. },
  748. }}
  749. />
  750. {formik.touched.enName && formik.errors.enName && (
  751. <FormHelperText error id="helper-text-enName-signup">
  752. {formik.errors.enName}
  753. </FormHelperText>
  754. )}
  755. </Stack>
  756. </Grid>
  757. <Grid item xs={12} md={12}>
  758. <Grid container>
  759. <Grid item xs={12} md={6}>
  760. <Stack spacing={1} sx={{mr:{md:1},mb:1}}>
  761. <InputLabel htmlFor="email-signup">電郵
  762. <span style={{color: '#f10000'}}>*</span>
  763. </InputLabel>
  764. <OutlinedInput
  765. fullWidth
  766. error={Boolean(formik.touched.email && formik.errors.email)}
  767. id="email-login"
  768. type="email"
  769. value={formik.values.email}
  770. name="email"
  771. onChange={formik.handleChange}
  772. placeholder="電郵"
  773. onBlur={formik.handleBlur}
  774. inputProps={{
  775. onKeyDown: (e) => {
  776. if (e.key === 'Enter') {
  777. e.preventDefault();
  778. }
  779. },
  780. }}
  781. />
  782. {formik.touched.email && formik.errors.email && (
  783. <FormHelperText error id="helper-text-email-signup">
  784. {formik.errors.email}
  785. </FormHelperText>
  786. )}
  787. </Stack>
  788. </Grid>
  789. <Grid item xs={12} md={6}>
  790. <Stack spacing={1} >
  791. <InputLabel htmlFor="emailConfirm-signup">確認電郵
  792. <span style={{color: '#f10000'}}>*</span>
  793. </InputLabel>
  794. <OutlinedInput
  795. fullWidth
  796. error={Boolean(formik.touched.emailConfirm && formik.errors.emailConfirm)}
  797. id="emailConfirm-login"
  798. type="email"
  799. value={formik.values.emailConfirm}
  800. name="emailConfirm"
  801. // onBlur={formik.handleBlur}
  802. onChange={formik.handleChange}
  803. placeholder="確認電郵"
  804. onBlur={formik.handleBlur}
  805. inputProps={{
  806. onKeyDown: (e) => {
  807. if (e.key === 'Enter') {
  808. e.preventDefault();
  809. }
  810. },
  811. }}
  812. />
  813. {formik.touched.emailConfirm && formik.errors.emailConfirm && (
  814. <FormHelperText error id="helper-text-emailConfirm-signup">
  815. {formik.errors.emailConfirm}
  816. </FormHelperText>
  817. )}
  818. </Stack>
  819. </Grid>
  820. </Grid>
  821. </Grid>
  822. <Grid item xs={12} md={12}>
  823. <Grid container>
  824. <Grid item xs={12} md={6}>
  825. <Grid container>
  826. <Grid item xs={12} md={12}>
  827. <Stack direction="column" spacing={1} sx={{mr:{md:1},mb:1}}>
  828. <InputLabel htmlFor="phone-signup">聯絡電話
  829. <span style={{color: '#f10000'}}>*</span>
  830. </InputLabel>
  831. <Stack direction="row">
  832. <OutlinedInput
  833. id="phoneCountryCode-login"
  834. type="phoneCountryCode"
  835. value={formik.values.phoneCountryCode}
  836. name="phoneCountryCode"
  837. // onBlur={formik.handleBlur}
  838. onChange={formik.handleChange}
  839. placeholder="國際區號"
  840. error={Boolean(formik.touched.phone && formik.errors.phone)}
  841. onBlur={formik.handleBlur}
  842. inputProps={{
  843. maxLength: 3,
  844. onKeyDown: (e) => {
  845. if (e.key === 'Enter') {
  846. e.preventDefault();
  847. }
  848. },
  849. }}
  850. sx={{width:'25%'}}
  851. />
  852. <OutlinedInput
  853. id="phone-login"
  854. type="phone"
  855. value={formik.values.phone}
  856. name="phone"
  857. onBlur={formik.handleBlur}
  858. onChange={formik.handleChange}
  859. placeholder="聯絡電話"
  860. error={Boolean(formik.touched.phone && formik.errors.phone)}
  861. inputProps={{
  862. maxLength: 8,
  863. onKeyDown: (e) => {
  864. if (e.key === 'Enter') {
  865. e.preventDefault();
  866. }
  867. },
  868. }}
  869. sx={{width:'75%'}}
  870. />
  871. </Stack>
  872. {formik.touched.phone && formik.errors.phone && (
  873. <FormHelperText error id="helper-text-phone-signup">
  874. {formik.errors.phone}
  875. </FormHelperText>
  876. )}
  877. </Stack>
  878. </Grid>
  879. </Grid>
  880. </Grid>
  881. <Grid item xs={12} md={6}>
  882. <Grid container>
  883. <Grid item xs={12} md={12}>
  884. <Stack spacing={1} direction="column">
  885. <InputLabel htmlFor="fax-signup">傳真號碼</InputLabel>
  886. <Stack direction="row">
  887. <OutlinedInput
  888. error={Boolean(formik.touched.fax && formik.errors.fax)}
  889. id="faxCountryCode-login"
  890. type="faxCountryCode"
  891. value={formik.values.faxCountryCode}
  892. name="faxCountryCode"
  893. // onBlur={formik.handleBlur}
  894. onChange={formik.handleChange}
  895. placeholder="國際區號"
  896. inputProps={{
  897. maxLength: 3,
  898. onKeyDown: (e) => {
  899. if (e.key === 'Enter') {
  900. e.preventDefault();
  901. }
  902. },
  903. }}
  904. sx={{width:'25%'}}
  905. />
  906. <OutlinedInput
  907. id="fax-login"
  908. type="fax"
  909. value={formik.values.fax}
  910. name="fax"
  911. // onBlur={formik.handleBlur}
  912. onChange={formik.handleChange}
  913. placeholder="傳真號碼"
  914. inputProps={{
  915. maxLength: 8,
  916. onKeyDown: (e) => {
  917. if (e.key === 'Enter') {
  918. e.preventDefault();
  919. }
  920. },
  921. }}
  922. sx={{width:'75%'}}
  923. />
  924. </Stack>
  925. </Stack>
  926. </Grid>
  927. </Grid>
  928. </Grid>
  929. </Grid>
  930. </Grid>
  931. <Grid item xs={12} md={12} mt={1} mb={1}>
  932. <Grid container>
  933. <Grid item xs={12} md={12}>
  934. <Stack spacing={1} direction="column" justifyContent="space-between" alignItems="baseline" sx={{ mb: { xs: -0.5, sm: 0.5 } }}>
  935. <Typography display="inline" variant="h4" sx={{ color: 'primary.primary'}}>商業登記證及其他文件
  936. <span style={{color: '#f10000'}}>*</span>
  937. </Typography>
  938. <Typography display="inline" variant="h6" sx={{ fontSize: 12,color: 'primary.primary'}}>請上傳你的 有效商業登記證及其他文件 的數碼檔案,以驗證你的身份。</Typography>
  939. <Typography display="inline" variant="h6" sx={{ fontSize: 12,color: 'primary.primary'}}>如: 香港身份證; 護照; 中國內地身份證等</Typography>
  940. <Stack mt={1} direction="row" justifyContent="flex-start" alignItems="center" spacing={2}>
  941. <Button variant="contained" component="label" sx={{ fontSize: 12,height:'40px'}}>上傳商業登記證及其他文件
  942. <input
  943. accept="image/png, .jpg, .bmp, .pdf"
  944. //className={classes.input}
  945. id="contained-button-file"
  946. multiple
  947. type="file"
  948. onChange={handleFileUpload}
  949. style={{display: 'none'}}
  950. />
  951. </Button>
  952. {/* <Typography display="inline" variant="h6" sx={{ fontSize: 12, color: 'primary.primary'}}></Typography> */}
  953. </Stack>
  954. {fileList !=null?
  955. <UploadFileTable recordList={fileListData} />:null}
  956. {/* <Stack mt={1} direction="row" justifyContent="flex-start" alignItems="center" spacing={2}>
  957. <Button variant="contained" type="submit" sx={{ fontSize: 12,height:'25px'}}>Submit</Button>
  958. <Button disabled={!formik.isValid} variant="contained" type="submit" sx={{ fontSize: 12,height:'25px'}}>Submit</Button>
  959. </Stack> */}
  960. </Stack>
  961. </Grid>
  962. </Grid>
  963. </Grid>
  964. </Grid>
  965. <Grid item xs={12} md={12}>
  966. <Grid container>
  967. <Grid item xs={12} md={12}>
  968. <Typography display="inline" variant="h4" sx={{ color: 'primary.primary'}}>
  969. 條款和條件
  970. <span style={{color: '#f10000'}}>*</span>
  971. </Typography>
  972. </Grid>
  973. <Grid item xs={12} md={12}>
  974. <Grid container>
  975. <Grid item xs={12} md={12}>
  976. <Typography height="80%" sx={{textAlign: "left",overflow: "scroll",borderRadius: "inherit", borderStyle: "solid",borderWidth: "1px",borderColor: "#0C489E"}}>
  977. {termsAndCon}
  978. </Typography>
  979. </Grid>
  980. </Grid>
  981. <Grid item xs={12} s={12} md={12} lg={12}>
  982. <Grid container>
  983. <Grid item xs={6} s={6} md={2} lg={2}>
  984. <Grid container>
  985. <Grid item sx={{display: 'flex', alignItems: 'center'}}>
  986. <Checkbox
  987. checked={termsAndConAccept}
  988. onChange={handleCheckBoxChange}
  989. name="termsAndConAccept"
  990. color="primary"
  991. size="small"
  992. />
  993. <Typography>我接受</Typography>
  994. </Grid>
  995. </Grid>
  996. </Grid>
  997. <Grid item xs={6} s={6} md={2} lg={2}>
  998. <Grid container>
  999. <Grid item sx={{display: 'flex', alignItems: 'center'}}>
  1000. <Checkbox
  1001. checked={termsAndConNotAccept}
  1002. onChange={handleCheckBoxChange}
  1003. name="termsAndConNotAccept"
  1004. color="primary"
  1005. size="small"
  1006. />
  1007. <Typography>我不接受</Typography>
  1008. </Grid>
  1009. </Grid>
  1010. </Grid>
  1011. </Grid>
  1012. </Grid>
  1013. </Grid>
  1014. </Grid>
  1015. </Grid>
  1016. </Grid>
  1017. </Grid>
  1018. </FormGroup>
  1019. {/* Preview Form */}
  1020. <FormGroup id={"previewForm"} sx={{ display: props.step === 1 ? "" : "none"}}>
  1021. <Grid container spacing={2}>
  1022. <Grid item xs={12}>
  1023. <Stack direction="column" justifyContent="space-between" alignItems="baseline" sx={{ mb: { xs: -0.5, sm: 0.5 } }}>
  1024. <div style={{borderBottom: "3px solid #1A4399", width:"100%", margin_right: "15px"}}>
  1025. <Typography display="inline" variant="h3" sx={{ color: '#1A4399'}}>成為新的機構/公司用戶</Typography>
  1026. </div>
  1027. {/* <Typography mt={0.25} variant="h6" sx={{ fontSize: 12,color: '#f10000'}}>註有*的項目必須輸入資料</Typography> */}
  1028. <Typography mt={0.25} variant="h4" sx={{ color: 'primary.primary'}}>你的登入資料</Typography>
  1029. {/* <Typography component={Link} to="/login" variant="body1" sx={{ textDecoration: 'none' }} color="primary">
  1030. Already have an account?
  1031. </Typography> */}
  1032. </Stack>
  1033. </Grid>
  1034. <Grid item xs={12}>
  1035. <Grid container spacing={1}>
  1036. <Grid item xs={12} >
  1037. <Stack spacing={1} direction="row">
  1038. <Typography>
  1039. 用戶登入名稱:
  1040. </Typography>
  1041. <Typography id="preview-username-login">
  1042. {formik.values.username}
  1043. </Typography>
  1044. </Stack>
  1045. </Grid>
  1046. <Grid item xs={12} mt={1} mb={1}>
  1047. <Stack direction="column" justifyContent="space-between" alignItems="baseline" sx={{ mb: { xs: -0.5, sm: 0.5 } }}>
  1048. <Typography display="inline" variant="h4" sx={{ color: '#1A4399'}}>你的機構/公司資料</Typography>
  1049. {/* <Typography component={Link} to="/login" variant="body1" sx={{ textDecoration: 'none' }} color="primary">
  1050. Already have an account?
  1051. </Typography> */}
  1052. </Stack>
  1053. </Grid>
  1054. <Grid item xs={12} md={6}>
  1055. <Stack spacing={1} direction="row">
  1056. <Typography>
  1057. 機構/公司英文名稱:
  1058. </Typography>
  1059. <Typography id="preview-enCompanyName-signup">
  1060. {formik.values.enCompanyName}
  1061. </Typography>
  1062. </Stack>
  1063. </Grid>
  1064. <Grid item xs={12} md={6}>
  1065. <Stack spacing={1} direction="row">
  1066. <Typography>
  1067. 機構/公司中文名稱:
  1068. </Typography>
  1069. <Typography id="preview-chCompanyName-signup">
  1070. {formik.values.chCompanyName}
  1071. </Typography>
  1072. </Stack>
  1073. </Grid>
  1074. <Grid item xs={12} md={12} >
  1075. <Stack spacing={1}>
  1076. <Typography>
  1077. 商業登記證
  1078. </Typography>
  1079. </Stack>
  1080. </Grid>
  1081. <Grid item xs={12} md={6}>
  1082. <Stack spacing={1} direction="row">
  1083. <Typography>
  1084. 商業登記證號碼:
  1085. </Typography>
  1086. <Typography id="brNo-login">
  1087. {formik.values.brNo}
  1088. </Typography>
  1089. </Stack>
  1090. </Grid>
  1091. <Grid item xs={12} md={6}>
  1092. <Stack spacing={1} direction="row">
  1093. <Typography>
  1094. 商業登記證有效日期:
  1095. </Typography>
  1096. <Typography id="brExpiryDate-login">
  1097. {formik.values.brExpiryDate}
  1098. </Typography>
  1099. </Stack>
  1100. </Grid>
  1101. <Grid item xs={12}>
  1102. <Stack spacing={1} direction="row">
  1103. <Typography>
  1104. 地址:
  1105. </Typography>
  1106. <Stack spacing={1} direction="column">
  1107. <Typography id="preview-address1-signup">
  1108. {formik.values.address1}
  1109. </Typography>
  1110. {formik.values.address2!=null?
  1111. <Typography id="preview-address2-signup">
  1112. {formik.values.address2}
  1113. </Typography>
  1114. :null}
  1115. {formik.values.address3!=null?
  1116. <Typography id="preview-address3-signup">
  1117. {formik.values.address3}
  1118. </Typography>
  1119. :null}
  1120. {selectedAddress5==("香港")?
  1121. <Typography id="preview-address4-signup">
  1122. 區域 (只適用於香港): {selectedAddress4}
  1123. </Typography>
  1124. :null}
  1125. <Typography id="preview-address5-signup">
  1126. 國家/地區: {selectedAddress5}
  1127. </Typography>
  1128. </Stack>
  1129. </Stack>
  1130. </Grid>
  1131. <Grid item xs={12} mt={1} mb={1}>
  1132. <Stack direction="column" justifyContent="space-between" alignItems="baseline" sx={{ mb: { xs: -0.5, sm: 0.5 } }}>
  1133. <Typography display="inline" variant="h4" sx={{ color: 'primary.primary'}}>你的聯絡資料</Typography>
  1134. </Stack>
  1135. </Grid>
  1136. <Grid item xs={12} md={12}>
  1137. <Stack spacing={1} direction="row">
  1138. <Typography>
  1139. 英文名稱:
  1140. </Typography>
  1141. <Typography id="preview-enName-signup">
  1142. {formik.values.enName}
  1143. </Typography>
  1144. </Stack>
  1145. </Grid>
  1146. <Grid item xs={12} md={12}>
  1147. <Stack spacing={1} direction="row">
  1148. <Typography>
  1149. 電郵:
  1150. </Typography>
  1151. <Typography id="preview-email-signup">
  1152. {formik.values.email}
  1153. </Typography>
  1154. </Stack>
  1155. </Grid>
  1156. <Grid item xs={12} md={6}>
  1157. <Stack spacing={1} direction="row">
  1158. <Typography>
  1159. 聯絡電話:
  1160. </Typography>
  1161. <Typography id="preview-phone-signup">
  1162. +{formik.values.phoneCountryCode} {formik.values.phone}
  1163. </Typography>
  1164. </Stack>
  1165. </Grid>
  1166. <Grid item xs={12} md={6}>
  1167. <Stack spacing={1} direction="row">
  1168. <Typography>
  1169. 傳真號碼:
  1170. </Typography>
  1171. <Typography id="preview-fax-signup">
  1172. +{formik.values.faxCountryCode} {formik.values.fax}
  1173. </Typography>
  1174. </Stack>
  1175. </Grid>
  1176. </Grid>
  1177. </Grid>
  1178. </Grid>
  1179. </FormGroup>
  1180. {/* Submit page */}
  1181. <FormGroup id={"submitForm"} sx={{ display: props.step === 2 ? "" : "none"}}>
  1182. <Grid container spacing={3}>
  1183. {isLoading ?
  1184. <LoadingComponent/>:
  1185. <Grid item xs={12}>
  1186. {checkUpload?
  1187. // SUCCESS page
  1188. <Stack mt={1} direction="column" justifyContent="flex-start" alignItems="center" spacing={2}>
  1189. <CheckCircleOutlineIcon color="success" sx={{width:"200px",height:"200px"}}/>
  1190. <Typography display="inline" variant="h4">帳戶申請已成功提交。</Typography>
  1191. <Typography display="inline" variant="h4">驗證電郵將發送到你的電郵地址,請要指示完成驗證及登入系統。</Typography>
  1192. <Button variant="outlined" component={Link} to="/login" sx={{ fontSize: 20,height:'60px'}}>返回登入頁面</Button>
  1193. </Stack>
  1194. :
  1195. // ERROR page
  1196. <Stack mt={1} direction="column" justifyContent="flex-start" alignItems="center" spacing={2}>
  1197. {/* <Button disabled={true} hidden={true} variant="contained" type="submit" sx={{ fontSize: 12,height:'25px'}}>Submit</Button> */}
  1198. <CancelOutlinedIcon color="error" sx={{width:"200px",height:"200px"}}/>
  1199. <Typography display="inline" variant="h4">申請失敗,請稍後嘗試</Typography>
  1200. <Button color="error" variant="outlined" component={Link} to="/login" sx={{ fontSize: 20,height:'60px'}}>返回登入頁面</Button>
  1201. </Stack>
  1202. }
  1203. </Grid>
  1204. }
  1205. </Grid>
  1206. </FormGroup>
  1207. </form>
  1208. </FormikProvider>
  1209. );
  1210. }
  1211. export default BusCustomFormWizard;