From 9cad8be7a8b2ed0ce3bfb04eedce77c5baf0feb4 Mon Sep 17 00:00:00 2001 From: Alex Cheung Date: Mon, 28 Aug 2023 08:49:54 +0800 Subject: [PATCH] add Organization register and change component with admin and normal user --- src/assets/style/navbarStyles.css | 45 +- src/components/AdminLogo/AdminLogo.js | 51 + src/components/AdminLogo/index.js | 42 + src/layout/MainLayout/Header/index.js | 140 +- src/pages/authentication/BusRegister.js | 205 +++ src/pages/authentication/RegisterCustom.js | 77 +- .../auth-forms/AuthLoginCustom.js | 10 +- .../auth-forms/BusCustomFormWizard.js | 1077 +++++++++++ .../auth-forms/CustomFormWizard.js | 1588 +++++++++-------- .../auth-forms/UploadFileTable.js | 85 + src/routes/LoginRoutes.js | 5 + src/utils/Utils.js | 6 +- 12 files changed, 2506 insertions(+), 825 deletions(-) create mode 100644 src/components/AdminLogo/AdminLogo.js create mode 100644 src/components/AdminLogo/index.js create mode 100644 src/pages/authentication/BusRegister.js create mode 100644 src/pages/authentication/auth-forms/BusCustomFormWizard.js create mode 100644 src/pages/authentication/auth-forms/UploadFileTable.js diff --git a/src/assets/style/navbarStyles.css b/src/assets/style/navbarStyles.css index 813f49a..b11c27c 100644 --- a/src/assets/style/navbarStyles.css +++ b/src/assets/style/navbarStyles.css @@ -43,6 +43,29 @@ top: -4px; left: 20px; } +#navbar div li ul { + background: white; + visibility: hidden; + opacity: 0; + min-width: 16rem; + position: absolute; + /* transition: all 0.5s ease; */ + left: 0; + display: none; + padding-left: 0px; + /* border: 1px solid #0C489E; */ + background-clip: padding-box; + border: 1px solid rgba(0,0,0,.15); + border-radius: 0.25rem; +} +#navbar div li:hover > ul, +#navbar div li:focus-within > ul, +#navbar div li ul:hover, +#navbar div li ul:focus { + visibility: visible; + opacity: 1; + display: block +} #systemTitle{ text-decoration: none; font-size: 1.3rem; @@ -94,4 +117,24 @@ } #sidebar li a:hover{ color: #0C489E; -} \ No newline at end of file +} +#sidebar div li ul { + background: white; + visibility: hidden; + opacity: 0; + min-width: 16rem; + position: absolute; + /* transition: all 0.5s ease; */ + left: 0; + display: none; + padding-left: 0px; + /* border: 1px solid #0C489E; */ + } + #sidebar div li:hover > ul, + #sidebar div li:focus-within > ul, + #sidebar div li ul:hover, + #sidebar div li ul:focus { + visibility: visible; + opacity: 1; + display: block + } \ No newline at end of file diff --git a/src/components/AdminLogo/AdminLogo.js b/src/components/AdminLogo/AdminLogo.js new file mode 100644 index 0000000..251d284 --- /dev/null +++ b/src/components/AdminLogo/AdminLogo.js @@ -0,0 +1,51 @@ +// material-ui +// import { useTheme } from '@mui/material/styles'; + +/** + * if you want to use image instead of uncomment following. + * + * import logoDark from 'assets/images/logo-dark.svg'; + * import logo from 'assets/images/logo.svg'; + * + */ + +// ==============================|| LOGO SVG ||============================== // + +const AdminLogo = () => { + // const theme = useTheme(); + + return ( + /** + * if you want to use image instead of svg uncomment following, and comment out element. + * + * Mantis + * + */ + <> + + + + + + + + + + + + + + + + + + + + + + + + ); +}; + +export default AdminLogo; diff --git a/src/components/AdminLogo/index.js b/src/components/AdminLogo/index.js new file mode 100644 index 0000000..bcc0d89 --- /dev/null +++ b/src/components/AdminLogo/index.js @@ -0,0 +1,42 @@ +import PropTypes from 'prop-types'; +import { Link } from 'react-router-dom'; + +// material-ui +import { ButtonBase } from '@mui/material'; +import { useDispatch, useSelector } from 'react-redux'; + +// project import +import Logo from './AdminLogo'; + +import config from 'config'; +import { activeItem } from 'store/reducers/menu'; +import { Stack } from '@mui/material'; + +// ==============================|| MAIN LOGO ||============================== // + +const LogoSection = ({ sx, to }) => { + const { defaultId } = useSelector((state) => state.menu); + const dispatch = useDispatch(); + return ( + + dispatch(activeItem({ openItem: [defaultId] }))} + to={!to ? config.defaultPath : to} + sx={sx} + > + + + PNSPS + + + ); +}; + +LogoSection.propTypes = { + sx: PropTypes.object, + to: PropTypes.string +}; + +export default LogoSection; diff --git a/src/layout/MainLayout/Header/index.js b/src/layout/MainLayout/Header/index.js index 87b385c..05fc7e8 100644 --- a/src/layout/MainLayout/Header/index.js +++ b/src/layout/MainLayout/Header/index.js @@ -30,16 +30,18 @@ import { Drawer, // useMediaQuery } from '@mui/material'; - import MenuIcon from '@mui/icons-material/Menu'; +import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'; + // project import // import AppBarStyled from './AppBarStyled'; // import HeaderContent from './HeaderContent'; import Logo from 'components/Logo'; +import AdminLogo from 'components/AdminLogo'; import MobileLogo from 'components/MobileLogo'; import Profile from './HeaderContent/Profile'; import "assets/style/navbarStyles.css"; -import {isUserLoggedIn} from "utils/Utils"; +import {isUserLoggedIn,isAdminLoggedIn} from "utils/Utils"; import { handleLogoutFunction } from 'auth/index'; // assets @@ -48,6 +50,7 @@ import { handleLogoutFunction } from 'auth/index'; import { Link } from "react-router-dom"; const drawerWidth = 240; + // const navItems = ['Home', 'About', 'Contact']; // ==============================|| MAIN LAYOUT - HEADER ||============================== // @@ -68,18 +71,60 @@ function Header(props) { }; const loginContent = ( -
+ isAdminLoggedIn() ? +
+
  • + Dashboard +
  • +
  • + Application +
  • +
  • + Proof +
  • +
  • + Payment +
  • +
  • + Client +
      +
    • + User +
    • +
    • + Individual User +
    • +
    • + Organization User +
    • +
    • + User Group +
    • +
    +
  • +
  • + Logout +
  • +
    + : +
    +
  • + 主頁 +
  • +
  • + 我的公共啟示 +
  • - User + 校對記錄
  • - Individual User + 付款記錄
  • - Organization User + 設定
  • - User Group + 登出
  • ); @@ -96,7 +141,7 @@ function Header(props) { ); const drawer = ( - isUserLoggedIn() ? + isUserLoggedIn()? PNSPS @@ -127,35 +172,62 @@ function Header(props) { const container = window !== undefined ? () => window().document.body : undefined; return ( - isUserLoggedIn() ? + isUserLoggedIn() ? + // User Login success - - - - 公共啟事提交及繳費系統 - - - - - - - 公共啟事提交及繳費系統 - - - + {isAdminLoggedIn() + ? + + + + + + + + + PNSPS + + : + + + + 公共啟事提交及繳費系統 + + + + + + + 公共啟事提交及繳費系統 + + + } + + { + const [activeStep, setActiveStep] = useState(0); + const [completed, setCompleted] = useState([false]); + const [isValid, setisValid] = useState(null); + + const updateValid = (value) => { + setisValid(value); + console.log(value) + }; + + const totalSteps = () => { + return steps.length; + }; + + const completedSteps = () => { + return Object.keys(completed).length; + }; + + const isLastStep = () => { + return activeStep === totalSteps() - 1; + }; + + const allStepsCompleted = () => { + return completedSteps() === totalSteps(); + }; + + const handleNext = () => { + console.log("test 1") + 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); + console.log(newActiveStep) + }; + + const handleBack = () => { + setActiveStep((prevActiveStep) => prevActiveStep - 1); + }; + + const handleStep = (step) => () => { + setActiveStep(step); + }; + + // const handleComplete = () => { + // const newCompleted = completed; + // newCompleted[activeStep] = true; + // setCompleted(newCompleted); + // handleNext(); + // }; + + 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 === totalSteps() - 1 ? ( + + ):( + + ) + } + + {activeStep === totalSteps() - 2 ? + ( + + ) : ( activeStep === totalSteps() - 1 ? + ( + + ): + ( + + ) + )} + {/* {activeStep !== steps.length && + (completed[activeStep] ? ( + + Step {activeStep + 1} already completed + + ) : ( + + ))} */} + + + )} + + // + ); +}; + +export default BusRegister; diff --git a/src/pages/authentication/RegisterCustom.js b/src/pages/authentication/RegisterCustom.js index 7998d9f..3f485fd 100644 --- a/src/pages/authentication/RegisterCustom.js +++ b/src/pages/authentication/RegisterCustom.js @@ -4,7 +4,7 @@ import {Link, Button, Card , Box, Grid } from '@mui/material'; import Typography from '@mui/material/Typography'; import iAmSmartICon from 'assets/images/icons/icon_iAmSmart.png'; -import banner from 'assets/images/banner.jpg'; +import banner from 'assets/images/bg_ml.jpg'; import { Stack } from '../../../node_modules/@mui/material/index'; @@ -15,10 +15,7 @@ import { Stack } from '../../../node_modules/@mui/material/index'; const RegisterCustom = () => ( - - banner - - + banner
    ( }} > - 立即成為憲報刊登公告用戶 - 只需4-5分鐘 - - - - 個人用戶 - - - - - 你可點擊「智方便」按鈕,系統會自動輸入個人資料,或自行輸入個人資料,以即時啟動憲報刊登公告帳戶。 -
    如欲使用「智方便」提供個人資料,請先下載「智方便」流動應用程式並登記成為「智方便」用戶。 -
    - 了解更多 -
    - - - - - - - 需上載身份證明文件數碼檔案以進行網上申請。 -
    如:香港身份證;護照;往來港澳通行證等 -
    - -
    - - 機構/公司用戶 - - - 需上載以下任何一份證明文件以進行網上申請。 -
    如:商業登記證;專業執業證書 -
    + + + 立即成為憲報刊登公告用戶 + 只需4-5分鐘 + + + + 個人用戶 + + + + + 你可點擊「智方便」按鈕,系統會自動輸入個人資料,或自行輸入個人資料,以即時啟動憲報刊登公告帳戶。 +
    如欲使用「智方便」提供個人資料,請先下載「智方便」流動應用程式並登記成為「智方便」用戶。 +
    + 了解更多 +
    + + + + + + + 需上載身份證明文件數碼檔案以進行網上申請。 +
    如:香港身份證;護照;往來港澳通行證等 +
    +
    + + 機構/公司用戶 + + + 需上載以下任何一份證明文件以進行網上申請。 +
    如:商業登記證;專業執業證書 +
    +
    +
    +
    diff --git a/src/pages/authentication/auth-forms/AuthLoginCustom.js b/src/pages/authentication/auth-forms/AuthLoginCustom.js index 937b5a6..2dc4e50 100644 --- a/src/pages/authentication/auth-forms/AuthLoginCustom.js +++ b/src/pages/authentication/auth-forms/AuthLoginCustom.js @@ -100,7 +100,7 @@ const AuthLoginCustom = () => { submit: null }} validationSchema={Yup.object().shape({ - username: Yup.string().email('Must be a valid email').max(255).required('Email is required'), + username: Yup.string().max(255).required('請輸入用戶名稱'), password: Yup.string().max(255).required('請輸入密碼'), })} onSubmit={async (values, { setErrors, setStatus, setSubmitting }) => { @@ -141,11 +141,11 @@ const AuthLoginCustom = () => { 密碼 @@ -162,11 +162,11 @@ const AuthLoginCustom = () => { } placeholder="" /> - {touched.password && errors.password && ( + {/* {touched.password && errors.password && ( {errors.password} - )} + )} */}
    diff --git a/src/pages/authentication/auth-forms/BusCustomFormWizard.js b/src/pages/authentication/auth-forms/BusCustomFormWizard.js new file mode 100644 index 0000000..f65f989 --- /dev/null +++ b/src/pages/authentication/auth-forms/BusCustomFormWizard.js @@ -0,0 +1,1077 @@ +import { useEffect, useState, } from 'react'; + +// material-ui +import { + Box, + Button, + FormControl, + FormHelperText, + Grid, IconButton, + InputAdornment, + InputLabel, OutlinedInput, + Stack, + Typography, + FormGroup, + TextField, + Checkbox + // MenuItem +} from '@mui/material'; +import {useForm,} from 'react-hook-form' +import Autocomplete from "@mui/material/Autocomplete"; + +// third party +import { useFormik,FormikProvider } from 'formik'; +import * as Yup from 'yup'; +// import axios from "axios"; + +// project import +// import AnimateButton from 'components/@extended/AnimateButton'; +import { strengthColorChi, strengthIndicator } from 'utils/password-strength'; +import {apiPath} from "auth/utils"; +import axios from "axios"; +import {POST_PUBLIC_USER_REGISTER} from "utils/ApiPathConst"; + +// assets +import { EyeInvisibleOutlined, EyeOutlined } from '@ant-design/icons'; +// import { Paper } from '../../../../node_modules/@mui/material/index'; + +// ============================|| FIREBASE - REGISTER ||============================ // + +const BusCustomFormWizard = (props) => { + + const [level, setLevel] = useState(); + const [showPassword, setShowPassword] = useState(false); + const [showConfirmPassword, setshowConfirmPassword] = useState(false); + + const handleClickShowPassword = () => { + setShowPassword(!showPassword); + }; + const handleClickShowConfirmPassword = () => { + setshowConfirmPassword(!showConfirmPassword); + }; + + const handleMouseDownPassword = (event) => { + event.preventDefault(); + }; + + const changePassword = (value) => { + const temp = strengthIndicator(value); + setLevel(strengthColorChi(temp)); + }; + + const [selectedIdDocType, setSelectedIdDocType] = useState(null); + const [selectedAddress4, setSelectedAddress4] = useState(null); + const [selectedAddress5, setSelectedAddress5] = useState(null); + const [termsAndConAccept, setTermsAndConAccept] = useState(false); + const [termsAndConNotAccept, setTermsAndConNotAccept] = useState(false); + + const idDocTypeComboList = ["passport","HKID","CNID","BR","otherCert"]; + const address4ComboList = + ["北區","長洲區","大埔區","大嶼山區","東區","觀塘區","黃大仙區","九龍城區","葵青區","南區","南丫島區", + "坪洲區","荃灣區","沙田區","深水埗區","屯門區","灣仔區","西貢區","油尖旺區","元朗區","中西區"]; + const address5ComboList = ["香港","內地","澳門"]; + const termsAndCon = "Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy \n" + +"Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy \n" + +"Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy \n"+"Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy \n" + +"Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy \n" + +"Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy \n" + +"Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy \n" + +"Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy \n" + + useEffect(() => { + changePassword(''); + }, []); + + const checkDataField = (data)=> { + if (data.username !=="", + data.password !=="", + data.enName !=="", + data.email !=="", + data.password !=="", + data.password !=="" + ) + { + return true + } + }; + + const handleCheckBoxChange = (event) => { + console.log (event.target) + if(event.target.name == 'termsAndConAccept'){ + setTermsAndConAccept(event.target.checked) + setTermsAndConNotAccept(!event.target.checked) + } + if(event.target.name == 'termsAndConNotAccept'){ + setTermsAndConNotAccept(event.target.checked) + setTermsAndConAccept(!event.target.checked) + } + }; + + const {handleSubmit} = useForm({}) + const _onSubmit = () => { + values.idDocType = selectedIdDocType + values.address4 = selectedAddress4 + values.address5 = selectedAddress5 + console.log(values) + const userAddress = { + "addressLine1":values.address1, + "addressLine2":values.address2, + "addressLine3":values.address4, + "country":values.address5 + }; + const userFaxNo = { + "countryCode":values.faxCountryCode, + "faxNumber":values.fax, + }; + const userMobileNumber = { + "countryCode":values.phoneCountryCode, + "phoneNumber":values.phone, + }; + let tncFlag = false; + if (termsAndConAccept){ + tncFlag = true + } + if (termsAndConNotAccept){ + tncFlag = false + } + console.log(tncFlag) + if (checkDataField(values)){ + axios.post(`${apiPath}${POST_PUBLIC_USER_REGISTER}`, { + username: values.username, + password: values.password, + name: values.username, + enName: values.enName, + chName: values.chName, + emailAddress: values.email, + idDocType:values.idDocType, + identification:values.idNo, + checkDigit:values.checkDigit, + userFaxNo:userFaxNo, + userMobileNumber:userMobileNumber, + userAddress:userAddress, + tncFlag:tncFlag + }) + .then((response) => { + console.log("Success") + console.log(response) + }) + .catch(error => { + console.error(error); + }); + + } + } + + const formik = useFormik({ + initialValues:({ + username:'', + enName: '', + chName: '', + email: '', + address1: '', + address2: '', + address3: '', + password: '', + confirmPassword: '', + phone:'', + phoneCountryCode:'', + idNo:'', + checkDigit:'', + submit: null, + fax:'', + faxCountryCode:'', + }), + validationSchema:Yup.object().shape({ + username: Yup.string().max(255).required('請輸入用戶名稱'), + password: Yup.string().max(255).required('請輸入密碼'), + confirmPassword: Yup.string().max(255).required('請確認密碼'), + enName: Yup.string().max(255).required('請輸入英文姓名'), + chName: Yup.string().max(255).required('請輸入中文姓名'), + address1: Yup.string().max(255).required('請輸入第一行地址'), + address2: Yup.string().max(255).required('請輸入第二行地址'), + address3: Yup.string().max(255).required('請輸入第三行地址'), + email: Yup.string().email('Must be a valid email').max(255).required('Email is required'), + idNo: Yup.string().max(255).required('請輸入證件號碼'), + checkDigit:Yup.string().max(1).required('請輸入證件號碼'), + idType: Yup.string().max(255).required('請輸入第三行地址') + }), + }); + const { values } = formik + useEffect(() => { + // console.log(values) + }, [values]) + + return ( + +
    + {/* Input Form */} + + + + +
    + 成為新的公司/機構用戶 +
    + 註有*的項目必須輸入資料 + 你的登入資料 + {/* + Already have an account? + */} +
    +
    + + + + + 用戶登入名稱 + * + + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + /> + {formik.touched.username && formik.errors.username && ( + + {formik.errors.username} + + )} + + + + + + + + 密碼 + * + + 密碼規則 + + { + formik.handleChange(e); + changePassword(e.target.value); + }} + endAdornment={ + + + {showPassword ? : } + + + } + placeholder="密碼" + onBlur={formik.handleBlur} + inputProps={{ + onKeyDown: (e) => { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + /> + {formik.touched.password && formik.errors.password && ( + + {formik.errors.password} + + )} + + + + + + + + + {level?.label} + + + + + + + + 確認密碼 + * + + { + formik.handleChange(e); + changePassword(e.target.value); + }} + inputProps={{ + onKeyDown: (e) => { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + endAdornment={ + + + {showConfirmPassword ? : } + + + } + placeholder="確認密碼" + fullWidth + error={Boolean(formik.touched.confirmPassword && formik.errors.confirmPassword)} + /> + {formik.touched.confirmPassword && formik.errors.confirmPassword && ( + + {formik.errors.confirmPassword} + + )} + + + + + + + 你的個人資料 + {/* + Already have an account? + */} + + + + + + 身份證明文件 + * + + {/* {formik.touched.enName && formik.errors.enName && ( + + {formik.errors.enName} + + )} */} + + + + + + + { + if (newValue !== null){ + setSelectedIdDocType(newValue); + } + }} + sx={{"& .MuiInputBase-root": { height: "41px" },"#idDocType-combo":{padding: "0px 0px 0px 0px"}, "& .MuiAutocomplete-endAdornment": { top: "auto" },}} + renderInput={(params) => } + /> + + + {selectedIdDocType =="HKID"? + <> + + + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + /> + {formik.touched.idNo && formik.errors.idNo && ( + + {formik.errors.idNo} + + )} + + + + + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + fullWidth + error={Boolean(formik.touched.checkDigit && formik.errors.checkDigit)} + /> + {formik.touched.checkDigit && formik.errors.checkDigit && ( + + {formik.errors.checkDigit} + + )} + + + : + + + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + /> + {formik.touched.idNo && formik.errors.idNo && ( + + {formik.errors.idNo} + + )} + + + } + + + + + 英文姓名 + * + + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + /> + {formik.touched.enName && formik.errors.enName && ( + + {formik.errors.enName} + + )} + + + + + 中文姓名 + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + /> + {formik.touched.chName && formik.errors.chName && ( + + {formik.errors.chName} + + )} + + + + + 地址 + * + + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + /> + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + /> + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + /> + { + if (newValue !== null){ + setSelectedAddress4(newValue); + } + }} + + sx={{"& .MuiInputBase-root": { height: "41px" },"#address4-combo":{padding: "0px 0px 0px 0px"}, "& .MuiAutocomplete-endAdornment": { top: "auto" },}} + renderInput={(params) => } + /> + { + if (newValue !== null){ + setSelectedAddress5(newValue); + } + }} + + sx={{"& .MuiInputBase-root": { height: "41px" },"#address5-combo":{padding: "0px 0px 0px 0px"}, "& .MuiAutocomplete-endAdornment": { top: "auto" },}} + renderInput={(params) => } + /> + {formik.touched.address1 && formik.errors.address1 && ( + + {formik.errors.address1} + + )} + {formik.touched.address2 && formik.errors.address2 && ( + + {formik.errors.address2} + + )} + {formik.touched.address3 && formik.errors.address3 && ( + + {formik.errors.address3} + + )} + + + + + 你的聯絡資料 + + + + + + + 電郵 + * + + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + /> + {formik.touched.email && formik.errors.email && ( + + {formik.errors.email} + + )} + + + + + 確認電郵 + * + + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + /> + {formik.touched.emailConfirm && formik.errors.emailConfirm && ( + + {formik.errors.emailConfirm} + + )} + + + + + + + + + + + 聯絡電話 + * + + + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + sx={{width:'25%'}} + /> + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + sx={{width:'75%'}} + /> + {formik.touched.phone && formik.errors.phone && ( + + {formik.errors.phone} + + )} + + + + + + + + + + 傳真號碼 + + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + sx={{width:'25%'}} + /> + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + sx={{width:'75%'}} + /> + + + + + + + + + + + + 身份證明文件 + 請上傳你的 有效身份證明文件 的數碼檔案,以驗證你的身份。 + 如: 香港身份證; 護照; 中國內地身份證等 + + + {/* */} + 如: 香港身份證; 護照; 中國內地身份證等 + + + + {/* */} + + + + + + + + + + + 條款和條件 + * + + + + + + + {termsAndCon} + + + + + + + + + + 我接受 + + + + + + + + 我不接受 + + + + + + + + + +
    +
    + {/* Preview Form */} + + + + +
    + 成為新的個人用戶 +
    + {/* 註有*的項目必須輸入資料 */} + 你的登入資料 + {/* + Already have an account? + */} +
    +
    + + + + + + 用戶登入名稱: + + + {formik.values.username} + + + + + + 你的個人資料 + {/* + Already have an account? + */} + + + + + + 身份證明文件 + + + + + + + + 證件類別: + + + {formik.values.idDocType} + + + + + + + 證件號碼: + + + {formik.values.idNo} ({formik.values.checkDigit}) + + + + + + + + 英文姓名: + + + {formik.values.enName} + + + + + + + 中文姓名: + + + {formik.values.chName} + + + + + + + 地址: + + + + {formik.values.address1} + + + {formik.values.address2} + + + {formik.values.address3} + + + {formik.values.address4} + + + {formik.values.address5} + + + + + + + 你的聯絡資料 + + + + + + 電郵: + + + {formik.values.email} + + + + + + + 聯絡電話: + + + +{formik.values.phoneCountryCode} {formik.values.phone} + + + + + + + 傳真號碼: + + + +{formik.values.faxCountryCode} {formik.values.fax} + + + + + + 身份證明文件 + 請上傳你的 有效身份證明文件 的數碼檔案,以驗證你的身份。 + 如: 香港身份證; 護照; 中國內地身份證等 + + + 如: 香港身份證; 護照; 中國內地身份證等 + + + + + +
    +
    + {/* Submit page */} + + + + + + {/* */} + + + + + +
    +
    + ); +} + +export default BusCustomFormWizard; diff --git a/src/pages/authentication/auth-forms/CustomFormWizard.js b/src/pages/authentication/auth-forms/CustomFormWizard.js index 29d2670..dac17b1 100644 --- a/src/pages/authentication/auth-forms/CustomFormWizard.js +++ b/src/pages/authentication/auth-forms/CustomFormWizard.js @@ -13,7 +13,7 @@ import { Typography, FormGroup, TextField, -// Paper + Checkbox // MenuItem } from '@mui/material'; import {useForm,} from 'react-hook-form' @@ -30,6 +30,8 @@ import { strengthColorChi, strengthIndicator } from 'utils/password-strength'; import {apiPath} from "auth/utils"; import axios from "axios"; import {POST_PUBLIC_USER_REGISTER} from "utils/ApiPathConst"; +// import * as HttpUtils from 'utils/HttpUtils'; +import UploadFileTable from './UploadFileTable'; // assets import { EyeInvisibleOutlined, EyeOutlined } from '@ant-design/icons'; @@ -42,6 +44,7 @@ const CustomFormWizard = (props) => { const [level, setLevel] = useState(); const [showPassword, setShowPassword] = useState(false); const [showConfirmPassword, setshowConfirmPassword] = useState(false); + const [fileList, setFileList] = useState(null); const handleClickShowPassword = () => { setShowPassword(!showPassword); @@ -62,17 +65,26 @@ const CustomFormWizard = (props) => { const [selectedIdDocType, setSelectedIdDocType] = useState(null); const [selectedAddress4, setSelectedAddress4] = useState(null); const [selectedAddress5, setSelectedAddress5] = useState(null); - + const [termsAndConAccept, setTermsAndConAccept] = useState(false); + const [termsAndConNotAccept, setTermsAndConNotAccept] = useState(false); + const idDocTypeComboList = ["passport","HKID","CNID","BR","otherCert"]; const address4ComboList = ["北區","長洲區","大埔區","大嶼山區","東區","觀塘區","黃大仙區","九龍城區","葵青區","南區","南丫島區", "坪洲區","荃灣區","沙田區","深水埗區","屯門區","灣仔區","西貢區","油尖旺區","元朗區","中西區"]; const address5ComboList = ["香港","內地","澳門"]; + const termsAndCon = "Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy \n" + +"Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy \n" + +"Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy \n"+"Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy \n" + +"Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy \n" + +"Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy \n" + +"Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy \n" + +"Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy Dummy \n" - useEffect(() => { - changePassword(''); + useEffect(() => { + changePassword(''); }, []); - + const checkDataField = (data)=> { if (data.username !=="", data.password !=="", @@ -86,7 +98,44 @@ const CustomFormWizard = (props) => { } }; - const {handleSubmit,register} = useForm({}) + const handleCheckBoxChange = (event) => { + console.log (event.target) + if(event.target.name == 'termsAndConAccept'){ + setTermsAndConAccept(event.target.checked) + setTermsAndConNotAccept(!event.target.checked) + } + if(event.target.name == 'termsAndConNotAccept'){ + setTermsAndConNotAccept(event.target.checked) + setTermsAndConAccept(!event.target.checked) + } + }; + + const handleFileUpload = (event)=>{ + const getfileList = event.target.files + const currentIndex = fileList.length!=null?fileList.length:0 + const index = 0; + getfileList.forEach((element) => element.id=index+1); + getfileList.forEach((element) => { + console.log({ element }); + element.id=currentIndex+numCallbackRuns; + numCallbackRuns++; + }); + console.log(getfileList) + setFileList(getfileList) + // HttpUtils.fileUpload( + // { + // refType:"identification", + // refId: -1, + // file: event.target.files[0], + // onSuccess: (response)=>{ + // console.log(response); + // setOpen(true); + // } + // } + // ); + }; + + const {handleSubmit} = useForm({}) const _onSubmit = () => { values.idDocType = selectedIdDocType values.address4 = selectedAddress4 @@ -97,18 +146,23 @@ const CustomFormWizard = (props) => { "addressLine2":values.address2, "addressLine3":values.address4, "country":values.address5 - } + }; const userFaxNo = { "countryCode":values.faxCountryCode, "faxNumber":values.fax, - } + }; const userMobileNumber = { "countryCode":values.phoneCountryCode, "phoneNumber":values.phone, + }; + let tncFlag = false; + if (termsAndConAccept){ + tncFlag = true + } + if (termsAndConNotAccept){ + tncFlag = false } - console.log(userAddress) - console.log(userFaxNo) - console.log(userMobileNumber) + console.log(tncFlag) if (checkDataField(values)){ axios.post(`${apiPath}${POST_PUBLIC_USER_REGISTER}`, { username: values.username, @@ -123,7 +177,7 @@ const CustomFormWizard = (props) => { userFaxNo:userFaxNo, userMobileNumber:userMobileNumber, userAddress:userAddress, - tncFlag:true + tncFlag:tncFlag }) .then((response) => { console.log("Success") @@ -131,11 +185,13 @@ const CustomFormWizard = (props) => { }) .catch(error => { console.error(error); - }); - - } + }); + // uploadFile(); + } +} + const formik = useFormik({ initialValues:({ username:'', @@ -177,11 +233,11 @@ const CustomFormWizard = (props) => { return ( -
    + {/* Input Form */} - +
    成為新的個人用戶 @@ -193,201 +249,253 @@ const CustomFormWizard = (props) => { */} - + - - - 用戶登入名稱 - * - - { - if (e.key === 'Enter') { - e.preventDefault(); - } - }, - }} - /> - {formik.touched.username && formik.errors.username && ( - - {formik.errors.username} - - )} - - - - - - - - 密碼 - * - - 密碼規則 + + + 用戶登入名稱 + * + + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + /> + {formik.touched.username && formik.errors.username && ( + + {formik.errors.username} + + )} + + + + + + + + 密碼 + * + + 密碼規則 + + { + formik.handleChange(e); + changePassword(e.target.value); + }} + endAdornment={ + + + {showPassword ? : } + + + } + placeholder="密碼" + onBlur={formik.handleBlur} + inputProps={{ + onKeyDown: (e) => { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + /> + {formik.touched.password && formik.errors.password && ( + + {formik.errors.password} + + )} - { - formik.handleChange(e); - changePassword(e.target.value); - }} - endAdornment={ - + + + + + + + + {level?.label} + + + + + + + + 確認密碼 + * + + { + formik.handleChange(e); + changePassword(e.target.value); + }} + inputProps={{ + onKeyDown: (e) => { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + endAdornment={ + - {showPassword ? : } + {showConfirmPassword ? : } - - } - placeholder="密碼" - onBlur={formik.handleBlur} - inputProps={{ - onKeyDown: (e) => { - if (e.key === 'Enter') { - e.preventDefault(); - } - }, - }} - /> - {formik.touched.password && formik.errors.password && ( - - {formik.errors.password} - - )} - - - - - - - - - {level?.label} - - - - + + } + placeholder="確認密碼" + fullWidth + error={Boolean(formik.touched.confirmPassword && formik.errors.confirmPassword)} + /> + {formik.touched.confirmPassword && formik.errors.confirmPassword && ( + + {formik.errors.confirmPassword} + + )} + + - + + + + 你的個人資料 + {/* + Already have an account? + */} + + + + - 確認密碼 + 身份證明文件 * - { - formik.handleChange(e); - changePassword(e.target.value); - }} - inputProps={{ - onKeyDown: (e) => { - if (e.key === 'Enter') { - e.preventDefault(); - } - }, - }} - endAdornment={ - - - {showConfirmPassword ? : } - - - } - placeholder="確認密碼" - fullWidth - error={Boolean(formik.touched.confirmPassword && formik.errors.confirmPassword)} - /> - {formik.touched.confirmPassword && formik.errors.confirmPassword && ( - - {formik.errors.confirmPassword} + {/* {formik.touched.enName && formik.errors.enName && ( + + {formik.errors.enName} - )} - - - - - - - 你的個人資料 - {/* - Already have an account? - */} - - - - - - 身份證明文件 - * - - {/* {formik.touched.enName && formik.errors.enName && ( - - {formik.errors.enName} - - )} */} - - - - - - - { - if (newValue !== null){ - setSelectedIdDocType(newValue); - } - }} - sx={{"& .MuiInputBase-root": { height: "41px" },"#idDocType-combo":{padding: "0px 0px 0px 0px"}, "& .MuiAutocomplete-endAdornment": { top: "auto" },}} - renderInput={(params) => } - /> + )} */} - {selectedIdDocType =="HKID"? - <> - + + + + + { + if (newValue !== null){ + setSelectedIdDocType(newValue); + } + }} + sx={{"& .MuiInputBase-root": { height: "41px" },"#idDocType-combo":{padding: "0px 0px 0px 0px"}, "& .MuiAutocomplete-endAdornment": { top: "auto" },}} + renderInput={(params) => } + /> + + + {selectedIdDocType =="HKID"? + <> + + + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + /> + {formik.touched.idNo && formik.errors.idNo && ( + + {formik.errors.idNo} + + )} + + + + + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + fullWidth + error={Boolean(formik.touched.checkDigit && formik.errors.checkDigit)} + /> + {formik.touched.checkDigit && formik.errors.checkDigit && ( + + {formik.errors.checkDigit} + + )} + + + : + { )} - - - { - if (e.key === 'Enter') { - e.preventDefault(); - } - }, - }} - fullWidth - error={Boolean(formik.touched.checkDigit && formik.errors.checkDigit)} - /> - {formik.touched.checkDigit && formik.errors.checkDigit && ( - - {formik.errors.checkDigit} - - )} - - - : + } + + + + + 英文姓名 + * + + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + /> + {formik.touched.enName && formik.errors.enName && ( + + {formik.errors.enName} + + )} + + + + + 中文姓名 + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + /> + {formik.touched.chName && formik.errors.chName && ( + + {formik.errors.chName} + + )} + + + + + 地址 + * + + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + /> + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + /> + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + /> + { + if (newValue !== null){ + setSelectedAddress4(newValue); + } + }} + + sx={{"& .MuiInputBase-root": { height: "41px" },"#address4-combo":{padding: "0px 0px 0px 0px"}, "& .MuiAutocomplete-endAdornment": { top: "auto" },}} + renderInput={(params) => } + /> + { + if (newValue !== null){ + setSelectedAddress5(newValue); + } + }} + + sx={{"& .MuiInputBase-root": { height: "41px" },"#address5-combo":{padding: "0px 0px 0px 0px"}, "& .MuiAutocomplete-endAdornment": { top: "auto" },}} + renderInput={(params) => } + /> + {formik.touched.address1 && formik.errors.address1 && ( + + {formik.errors.address1} + + )} + {formik.touched.address2 && formik.errors.address2 && ( + + {formik.errors.address2} + + )} + {formik.touched.address3 && formik.errors.address3 && ( + + {formik.errors.address3} + + )} + + + + + 你的聯絡資料 + + + + - + + 電郵 + * + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + /> + {formik.touched.email && formik.errors.email && ( + + {formik.errors.email} + + )} + + + + + 確認電郵 + * + + { if (e.key === 'Enter') { @@ -459,393 +732,205 @@ const CustomFormWizard = (props) => { }, }} /> - {formik.touched.idNo && formik.errors.idNo && ( - - {formik.errors.idNo} + {formik.touched.emailConfirm && formik.errors.emailConfirm && ( + + {formik.errors.emailConfirm} )} + + + + + + + + + + 聯絡電話 + * + + + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + sx={{width:'25%'}} + /> + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + sx={{width:'75%'}} + /> + {formik.touched.phone && formik.errors.phone && ( + + {formik.errors.phone} + + )} + + + + - } + + + + + 傳真號碼 + + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + sx={{width:'25%'}} + /> + { + if (e.key === 'Enter') { + e.preventDefault(); + } + }, + }} + sx={{width:'75%'}} + /> + + + + + + - - - - - 英文姓名 - * - - { - if (e.key === 'Enter') { - e.preventDefault(); - } - }, - }} - /> - {formik.touched.enName && formik.errors.enName && ( - - {formik.errors.enName} - - )} - - - - - 中文姓名 - { - if (e.key === 'Enter') { - e.preventDefault(); - } - }, - }} - /> - {formik.touched.chName && formik.errors.chName && ( - - {formik.errors.chName} - - )} - - - - - 地址 - * - - { - if (e.key === 'Enter') { - e.preventDefault(); - } - }, - }} - /> - { - if (e.key === 'Enter') { - e.preventDefault(); - } - }, - }} - /> - { - if (e.key === 'Enter') { - e.preventDefault(); - } - }, - }} - /> - { - if (newValue !== null){ - setSelectedAddress4(newValue); - } - }} - - sx={{"& .MuiInputBase-root": { height: "41px" },"#address4-combo":{padding: "0px 0px 0px 0px"}, "& .MuiAutocomplete-endAdornment": { top: "auto" },}} - renderInput={(params) => } - /> - { - if (newValue !== null){ - setSelectedAddress5(newValue); - } - }} - - sx={{"& .MuiInputBase-root": { height: "41px" },"#address5-combo":{padding: "0px 0px 0px 0px"}, "& .MuiAutocomplete-endAdornment": { top: "auto" },}} - renderInput={(params) => } - /> - {formik.touched.address1 && formik.errors.address1 && ( - - {formik.errors.address1} - - )} - {formik.touched.address2 && formik.errors.address2 && ( - - {formik.errors.address2} - - )} - {formik.touched.address3 && formik.errors.address3 && ( - - {formik.errors.address3} - - )} - - - - - 你的聯絡資料 - - - - - - - 電郵 - * - - { - if (e.key === 'Enter') { - e.preventDefault(); - } - }, - }} - /> - {formik.touched.email && formik.errors.email && ( - - {formik.errors.email} - - )} - + + + + + 身份證明文件 + 請上傳你的 有效身份證明文件 的數碼檔案,以驗證你的身份。 + 如: 香港身份證; 護照; 中國內地身份證等 + + + {fileList !=null? + :null} + 如: 香港身份證; 護照; 中國內地身份證等 + + {/* + + + */} + + - - - 確認電郵 - * - - { - if (e.key === 'Enter') { - e.preventDefault(); - } - }, - }} - /> - {formik.touched.emailConfirm && formik.errors.emailConfirm && ( - - {formik.errors.emailConfirm} - - )} - - - + + + 條款和條件 + * + + + - - 聯絡電話 - * - - - { - if (e.key === 'Enter') { - e.preventDefault(); - } - }, - }} - sx={{width:'25%'}} - /> - { - if (e.key === 'Enter') { - e.preventDefault(); - } - }, - }} - sx={{width:'75%'}} - /> - {formik.touched.phone && formik.errors.phone && ( - - {formik.errors.phone} - - )} - - + + {termsAndCon} + - - - - - - 傳真號碼 - - { - if (e.key === 'Enter') { - e.preventDefault(); - } - }, - }} - sx={{width:'25%'}} - /> - { - if (e.key === 'Enter') { - e.preventDefault(); - } - }, - }} - sx={{width:'75%'}} - /> - - + + + + + + + 我接受 + + + + + + + + 我不接受 + + + - - - - - - 身份證明文件 - 請上傳你的 有效身份證明文件 的數碼檔案,以驗證你的身份。 - 如: 香港身份證; 護照; 中國內地身份證等 - - - {/* */} - 如: 香港身份證; 護照; 中國內地身份證等 - - - - {/* */} - - - - {/* - - By Signing up, you agree to our   - - Terms of Service - -   and   - - Privacy Policy - - - */} - {formik.errors.submit && ( - - {formik.errors.submit} - - )} + + @@ -854,162 +939,173 @@ const CustomFormWizard = (props) => { - -
    - 成為新的個人用戶 -
    - {/* 註有*的項目必須輸入資料 */} - 你的登入資料 - {/* - Already have an account? - */} -
    + +
    + 成為新的個人用戶 +
    + {/* 註有*的項目必須輸入資料 */} + 你的登入資料 + {/* + Already have an account? + */} +
    - - - - 用戶登入名稱: - - - {formik.values.username} - - - - - - 你的個人資料 - {/* - Already have an account? - */} - - - - - - 身份證明文件 - - - + + + + 用戶登入名稱: + + + {formik.values.username} + + + + + + 你的個人資料 + {/* + Already have an account? + */} + + + + + + 身份證明文件 + + + - - - - 證件類別: - - - {formik.values.idDocType} - - - - - - - 證件號碼: - - - {formik.values.idNo} ({formik.values.checkDigit}) - - - - - - - - 英文姓名: - - - {formik.values.enName} - - - - - - - 中文姓名: - - - {formik.values.chName} - - - - - - - 地址: - - - - {formik.values.address1} + + + + 證件類別: + + + {formik.values.idDocType} - - {formik.values.address2} + + + + + + 證件號碼: - - {formik.values.address3} + + {formik.values.idNo} ({formik.values.checkDigit}) - - {formik.values.address4} + + + + + + + 英文姓名: - - {formik.values.address5} + + {formik.values.enName} - - - - - 你的聯絡資料 - - - - - - 電郵: - - - {formik.values.email} - - - - - - - 聯絡電話: - - - +{formik.values.phoneCountryCode} {formik.values.phone} - - - - - - - 傳真號碼: - - - +{formik.values.faxCountryCode} {formik.values.fax} - - - - - - 身份證明文件 - 請上傳你的 有效身份證明文件 的數碼檔案,以驗證你的身份。 - 如: 香港身份證; 護照; 中國內地身份證等 - - - 如: 香港身份證; 護照; 中國內地身份證等 - - - + + + + + 中文姓名: + + + {formik.values.chName} + + + + + + + 地址: + + + + {formik.values.address1} + + + {formik.values.address2} + + + {formik.values.address3} + + + {formik.values.address4} + + + {formik.values.address5} + + + + + + + 你的聯絡資料 + + + + + + 電郵: + + + {formik.values.email} + + + + + + + 聯絡電話: + + + +{formik.values.phoneCountryCode} {formik.values.phone} + + + + + + + 傳真號碼: + + + +{formik.values.faxCountryCode} {formik.values.fax} + + + + + + 身份證明文件 + 請上傳你的 有效身份證明文件 的數碼檔案,以驗證你的身份。 + 如: 香港身份證; 護照; 中國內地身份證等 + + + 如: 香港身份證; 護照; 中國內地身份證等 + + +
    + {/* Submit page */} + + + + + + {/* */} + + + + diff --git a/src/pages/authentication/auth-forms/UploadFileTable.js b/src/pages/authentication/auth-forms/UploadFileTable.js new file mode 100644 index 0000000..4cd72fc --- /dev/null +++ b/src/pages/authentication/auth-forms/UploadFileTable.js @@ -0,0 +1,85 @@ +// material-ui +import * as React from 'react'; +import { + DataGrid, + // GridActionsCellItem, +} from "@mui/x-data-grid"; +// import EditIcon from '@mui/icons-material/Edit'; +import {useEffect} from "react"; +// import {useNavigate} from "react-router-dom"; +// import { useTheme } from '@mui/material/styles'; +// import Checkbox from '@mui/material/Checkbox'; +// ==============================|| EVENT TABLE ||============================== // + +export default function UploadFileTable({recordList}) { + const [rows, setRows] = React.useState(recordList); + const [rowModesModel] = React.useState({}); + // const theme = useTheme(); + + // const navigate = useNavigate() + + useEffect(() => { + setRows(recordList); + }, [recordList]); + + // const handleEditClick = (id) => () => { + // navigate('/user/'+ id); + // }; + + const columns = [ + // { + // field: 'actions', + // type: 'actions', + // headerName: 'Actions', + // width: 100, + // cellClassName: 'actions', + // getActions: ({id}) => { + // return [ + // } + // label="Edit" + // className="textPrimary" + // onClick={handleEditClick(id)} + // color="primary" + // />] + // }, + // }, + { + id: 'name', + field: 'name', + headerName: 'Name', + flex: 1, + }, + { + id: 'size', + field: 'size', + headerName: 'Size', + flex: 1, + }, + { + id: 'type', + field: 'type', + headerName: 'Type', + flex: 1, + }, + ]; + + return ( +
    + +
    + ); +} diff --git a/src/routes/LoginRoutes.js b/src/routes/LoginRoutes.js index 9419084..a7b48af 100644 --- a/src/routes/LoginRoutes.js +++ b/src/routes/LoginRoutes.js @@ -9,6 +9,7 @@ import MainLayout from 'layout/MainLayout'; const AuthLogin = Loadable(lazy(() => import('pages/authentication/Login'))); const AuthRegister = Loadable(lazy(() => import('pages/authentication/RegisterCustom'))); const RegisterForm = Loadable(lazy(() => import('pages/authentication/Register'))); +const BusRegisterForm = Loadable(lazy(() => import('pages/authentication/BusRegister'))); const ErrorPage = Loadable(lazy(() => import('pages/extra-pages/ErrorPage'))); const TestMailPage = Loadable(lazy(() => import('pages/pnspsNotifyTest'))); @@ -30,6 +31,10 @@ const LoginRoutes = { path: 'registerFrom', element: }, + { + path: 'registerFromOrganization', + element: + }, { path: 'error', element: diff --git a/src/utils/Utils.js b/src/utils/Utils.js index 6a3a720..9d648ca 100644 --- a/src/utils/Utils.js +++ b/src/utils/Utils.js @@ -58,7 +58,11 @@ export const formatDateToMonthShort = (value, toTimeForCurrentDay = true) => { */ export const isUserLoggedIn = () => localStorage.getItem('userData') != null export const getUserData = () => JSON.parse(localStorage.getItem('userData')) - +export const isAdminLoggedIn = () =>{ + if (localStorage.getItem('userData') != null){ + return JSON.parse(localStorage.getItem('userData')).role === 'admin' + } +} /** ** This function is used for demo purpose route navigation ** In real app you won't need this function because your app will navigate to same route for each users regardless of ability