| @@ -18,8 +18,10 @@ export const clientId = "cf61fa7c121e4869966f69c8694b1cd2"; | |||||
| export const iAmSmartCallbackPath = () => { | export const iAmSmartCallbackPath = () => { | ||||
| let hostname = window.location.hostname; | let hostname = window.location.hostname; | ||||
| if (hostname.match("localhost")) { | |||||
| if (hostname.match("pnspsuat")) { | |||||
| hostname = "pnspsuat.gld.gov.hk"; | hostname = "pnspsuat.gld.gov.hk"; | ||||
| }else{ | |||||
| hostname = "pnspsdev.gld.gov.hk"; | |||||
| } | } | ||||
| return hostname; | return hostname; | ||||
| }; | }; | ||||
| @@ -83,6 +83,10 @@ const Register = () => { | |||||
| } | } | ||||
| const handleNext = async () => { | const handleNext = async () => { | ||||
| if(!idNo){ | |||||
| notifyActionError("資料,請返回注冊頁面。") | |||||
| return; | |||||
| } | |||||
| const test = await handleCheckID() | const test = await handleCheckID() | ||||
| if (test) { | if (test) { | ||||
| notifyActionError("此用戶已注冊,請返回登入頁面並進行登入流程。") | notifyActionError("此用戶已注冊,請返回登入頁面並進行登入流程。") | ||||
| @@ -6,6 +6,7 @@ import React, { | |||||
| import { Link as RouterLink } from 'react-router-dom'; | import { Link as RouterLink } from 'react-router-dom'; | ||||
| import { useNavigate } from 'react-router-dom'; | import { useNavigate } from 'react-router-dom'; | ||||
| import { useForm, } from 'react-hook-form' | import { useForm, } from 'react-hook-form' | ||||
| import { iAmSmartPath, clientId, getBowerType , iAmSmartCallbackPath} from 'auth/utils' | |||||
| // material-ui | // material-ui | ||||
| import { | import { | ||||
| @@ -167,6 +168,21 @@ const AuthLoginCustom = () => { | |||||
| const { handleSubmit } = useForm({}) | const { handleSubmit } = useForm({}) | ||||
| const getQRWithIAmSmart = () => { | |||||
| let callbackUrl = "https://"+iAmSmartCallbackPath()+"/iamsmart/authcallback"; | |||||
| let url = iAmSmartPath + "/api/v1/auth/getQR" | |||||
| + "?clientID=" + clientId | |||||
| + "&responseType=code" | |||||
| +"&source=" + getBowerType() | |||||
| +"&redirectURI="+encodeURIComponent(callbackUrl) | |||||
| +"&scope="+encodeURIComponent("eidapi_auth eidapi_profiles") | |||||
| +"&lang=zh-HK"//en-US, zh-HK, or zh-CN | |||||
| //+"&state=" | |||||
| +"&brokerPage=false" | |||||
| window.location.assign(url); | |||||
| } | |||||
| return ( | return ( | ||||
| <FormikProvider value={formik}> | <FormikProvider value={formik}> | ||||
| <form onSubmit={handleSubmit(tryLogin)}> | <form onSubmit={handleSubmit(tryLogin)}> | ||||
| @@ -261,12 +277,12 @@ const AuthLoginCustom = () => { | |||||
| </Grid> | </Grid> | ||||
| <Grid item xs={12}> | <Grid item xs={12}> | ||||
| <Stack direction="row" justifyContent="space-between" alignItems="center" spacing={2}> | <Stack direction="row" justifyContent="space-between" alignItems="center" spacing={2}> | ||||
| <Button fullWidth size="large" variant="outlined" startIcon={<img src={iAmSmartICon} alt="iAM Smart" width="30" />}><Typography variant="h5">智方便登入</Typography></Button> | |||||
| <Button onClick={()=>getQRWithIAmSmart()} color="iAmSmart" fullWidth size="large" variant="outlined" startIcon={<img src={iAmSmartICon} alt="iAM Smart" width="30" />}><Typography variant="h5">智方便登入</Typography></Button> | |||||
| </Stack> | </Stack> | ||||
| </Grid> | </Grid> | ||||
| <Grid item xs={12}> | <Grid item xs={12}> | ||||
| <Stack direction="row" justifyContent="space-between" alignItems="center" spacing={2}> | <Stack direction="row" justifyContent="space-between" alignItems="center" spacing={2}> | ||||
| <Link href="#"><Typography align="center" variant="h6">了解更多智方便</Typography></Link> | |||||
| <Link href="https://www.iamsmart.gov.hk/tc/"><Typography align="center" variant="h6">{"了解更多 >"}</Typography></Link> | |||||
| </Stack> | </Stack> | ||||
| </Grid> | </Grid> | ||||
| <Grid item xs={12}> | <Grid item xs={12}> | ||||
| @@ -75,8 +75,6 @@ const CustomFormWizard = (props) => { | |||||
| + "授權,否則嚴禁複製、改編、分發、發布或向公眾提供該等版權作品。" | + "授權,否則嚴禁複製、改編、分發、發布或向公眾提供該等版權作品。" | ||||
| const dataStr = "{\"emailAddress\":\"[email protected]\",\"postalAddress\":{\"EngPremisesAddress\":{\"EngDistrict\":{\"DcDistrict\":\"KC\",\"Sub-district\":\"TSING YI\"},\"EngEstate\":{\"EstateName\":\"Cheung Hang Estate\",\"EngPhase\":{\"PhaseName\":\"N/A\"}},\"BuildingName\":\"Hang Lai House\",\"EngBlock\":{\"BlockDescriptor\":\"Block\",\"BlockNo\":\"2\"},\"Region\":\"NT\",\"EngStreet\":{\"StreetName\":\"Liu To Road\",\"BuildingNoFrom\":\"6\"},\"Eng3dAddress\":{\"EngFloor\":{\"FloorNum\":\"33\"},\"EngUnit\":{\"UnitDescriptor\":\"Room\",\"UnitNo\":\"3301\"}}}},\"mobileNumber\":{\"CountryCode\":\"852\",\"SubscriberNumber\":\"99999999\"},\"residentialAddress\":{\"ChiPremisesAddress\":{\"Chi3dAddress\":{\"ChiUnit\":{\"UnitDescriptor\":\"室\",\"UnitNo\":\"1010\"},\"ChiFloor\":{\"FloorNum\":\"10\"}},\"ChiBlock\":{\"BlockDescriptor\":\"座\",\"BlockNo\":\"2\"},\"BuildingName\":\"亨麗樓(第2座)\",\"ChiDistrict\":{\"DcDistrict\":\"KC\",\"Sub-district\":\"青衣\"},\"Region\":\"新界\",\"ChiEstate\":{\"EstateName\":\"長亨邨\"},\"ChiStreet\":{\"StreetName\":\"寮肚路\",\"BuildingNoFrom\":\"6\"}}},\"enName\":{\"UnstructuredName\":\"Testing Co One\"},\"idNo\":{\"Identification\":\"G561107\",\"CheckDigit\":\"4\"},\"chName\":{\"ChineseName\":\"測試商一\"}}"; | |||||
| useEffect(() => { | useEffect(() => { | ||||
| location.state?.responseData ?? {} | location.state?.responseData ?? {} | ||||
| onCaptchaChange(); | onCaptchaChange(); | ||||
| @@ -84,7 +82,8 @@ const CustomFormWizard = (props) => { | |||||
| }, []); | }, []); | ||||
| const responseToData = () => { | const responseToData = () => { | ||||
| let rd = JSON.parse(dataStr); | |||||
| //let rd = JSON.parse("{\"emailAddress\":\"[email protected]\",\"postalAddress\":{\"EngPremisesAddress\":{\"EngDistrict\":{\"DcDistrict\":\"KC\",\"Sub-district\":\"TSING YI\"},\"EngEstate\":{\"EstateName\":\"Cheung Hang Estate\",\"EngPhase\":{\"PhaseName\":\"N/A\"}},\"BuildingName\":\"Hang Lai House\",\"EngBlock\":{\"BlockDescriptor\":\"Block\",\"BlockNo\":\"2\"},\"Region\":\"NT\",\"EngStreet\":{\"StreetName\":\"Liu To Road\",\"BuildingNoFrom\":\"6\"},\"Eng3dAddress\":{\"EngFloor\":{\"FloorNum\":\"33\"},\"EngUnit\":{\"UnitDescriptor\":\"Room\",\"UnitNo\":\"3301\"}}}},\"mobileNumber\":{\"CountryCode\":\"852\",\"SubscriberNumber\":\"99999999\"},\"residentialAddress\":{\"ChiPremisesAddress\":{\"Chi3dAddress\":{\"ChiUnit\":{\"UnitDescriptor\":\"室\",\"UnitNo\":\"1010\"},\"ChiFloor\":{\"FloorNum\":\"10\"}},\"ChiBlock\":{\"BlockDescriptor\":\"座\",\"BlockNo\":\"2\"},\"BuildingName\":\"亨麗樓(第2座)\",\"ChiDistrict\":{\"DcDistrict\":\"KC\",\"Sub-district\":\"青衣\"},\"Region\":\"新界\",\"ChiEstate\":{\"EstateName\":\"長亨邨\"},\"ChiStreet\":{\"StreetName\":\"寮肚路\",\"BuildingNoFrom\":\"6\"}}},\"enName\":{\"UnstructuredName\":\"Testing Co One\"},\"idNo\":{\"Identification\":\"G561107\",\"CheckDigit\":\"4\"},\"chName\":{\"ChineseName\":\"測試商一\"}}"); | |||||
| let rd = props.state.responseData; | |||||
| let data = { | let data = { | ||||
| "enName": rd.enName?.UnstructuredName ?? "", | "enName": rd.enName?.UnstructuredName ?? "", | ||||
| "chName": rd.chName?.ChineseName ?? "", | "chName": rd.chName?.ChineseName ?? "", | ||||
| @@ -394,7 +393,7 @@ const CustomFormWizard = (props) => { | |||||
| </div> | </div> | ||||
| <Typography mt={0.25} variant="h6" sx={{ color: '#f10000' }}>註有*的項目必須輸入資料。</Typography> | <Typography mt={0.25} variant="h6" sx={{ color: '#f10000' }}>註有*的項目必須輸入資料。</Typography> | ||||
| <Stack mt={1} direction="row" style={{ alignItems: "center" }}><img src={iAmSmartICon} alt="iAM Smart" width="30" /><Typography mt={0.25} variant="h6" >: 表示該項由「智方便」提供。</Typography></Stack> | |||||
| <Stack mt={1} direction="row" style={{ alignItems: "center" }}><img src={iAmSmartICon} alt="iAM Smart" width="25" /><Typography mt={0.25} variant="h6" >: 表示該項由「智方便」提供。</Typography></Stack> | |||||
| </Stack> | </Stack> | ||||
| </Grid> | </Grid> | ||||
| @@ -441,6 +440,7 @@ const CustomFormWizard = (props) => { | |||||
| <Typography variant="h5"> | <Typography variant="h5"> | ||||
| 地址 | 地址 | ||||
| <span style={{ color: '#f10000' }}>*</span> | <span style={{ color: '#f10000' }}>*</span> | ||||
| {iAmSmartData.address1?<img src={iAmSmartICon} alt="iAM Smart" width="25" />:null} | |||||
| </Typography> | </Typography> | ||||
| </InputLabel> | </InputLabel> | ||||
| <OutlinedInput | <OutlinedInput | ||||
| @@ -557,6 +557,7 @@ const CustomFormWizard = (props) => { | |||||
| <Typography variant="h5"> | <Typography variant="h5"> | ||||
| 電郵 | 電郵 | ||||
| <span style={{ color: '#f10000' }}>*</span> | <span style={{ color: '#f10000' }}>*</span> | ||||
| {iAmSmartData.email?<img src={iAmSmartICon} alt="iAM Smart" width="25" />:null} | |||||
| </Typography> | </Typography> | ||||
| </InputLabel> | </InputLabel> | ||||
| <OutlinedInput | <OutlinedInput | ||||
| @@ -635,6 +636,7 @@ const CustomFormWizard = (props) => { | |||||
| <Typography variant="h5"> | <Typography variant="h5"> | ||||
| 聯絡電話 | 聯絡電話 | ||||
| <span style={{ color: '#f10000' }}>*</span> | <span style={{ color: '#f10000' }}>*</span> | ||||
| {iAmSmartData.phone?<img src={iAmSmartICon} alt="iAM Smart" width="25" />:null} | |||||
| </Typography> | </Typography> | ||||
| </InputLabel> | </InputLabel> | ||||
| <Stack direction="row"> | <Stack direction="row"> | ||||
| @@ -21,7 +21,7 @@ const Index = () => { | |||||
| let params = new URLSearchParams(window.location.search) | let params = new URLSearchParams(window.location.search) | ||||
| if(params.get("code")){ | if(params.get("code")){ | ||||
| HttpUtils.post({ | HttpUtils.post({ | ||||
| url: UrlUtils.GET_SMART_PROFILE, | |||||
| url: UrlUtils.GET_SMART_LOGIN, | |||||
| params:{ | params:{ | ||||
| code: params.get("code") | code: params.get("code") | ||||
| }, | }, | ||||
| @@ -0,0 +1,43 @@ | |||||
| import * as React from "react"; | |||||
| import * as HttpUtils from "utils/HttpUtils"; | |||||
| import * as UrlUtils from "utils/ApiPathConst"; | |||||
| import { useNavigate } from "react-router-dom"; | |||||
| import Loadable from 'components/Loadable'; | |||||
| const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); | |||||
| // ==============================|| DASHBOARD - DEFAULT ||============================== // | |||||
| const Index = () => { | |||||
| const navigate = useNavigate() | |||||
| React.useEffect(() => { | |||||
| getPrfile(); | |||||
| }, []); | |||||
| function getPrfile(){ | |||||
| let params = new URLSearchParams(window.location.search) | |||||
| if(params.get("code")){ | |||||
| HttpUtils.post({ | |||||
| url: UrlUtils.GET_SMART_PROFILE, | |||||
| params:{ | |||||
| code: params.get("code") | |||||
| }, | |||||
| onSuccess: (responseData) => { | |||||
| navigate('/iAmSmartRegisterFrom', { state: { responseData: responseData } }); | |||||
| } | |||||
| }); | |||||
| } | |||||
| } | |||||
| return ( | |||||
| <LoadingComponent /> | |||||
| ); | |||||
| }; | |||||
| export default Index; | |||||
| @@ -15,6 +15,7 @@ const ErrorPage = Loadable(lazy(() => import('pages/extra-pages/ErrorPage'))); | |||||
| const IAmSmart_FailCallback = Loadable(lazy(() => import('pages/iAmSmart/FailCallback'))); | const IAmSmart_FailCallback = Loadable(lazy(() => import('pages/iAmSmart/FailCallback'))); | ||||
| const IAmSmart_SuccessCallback = Loadable(lazy(() => import('pages/iAmSmart/SuccessCallback'))); | const IAmSmart_SuccessCallback = Loadable(lazy(() => import('pages/iAmSmart/SuccessCallback'))); | ||||
| const IAmSmart_AuthCallback = Loadable(lazy(() => import('pages/iAmSmart/AuthCallback'))); | const IAmSmart_AuthCallback = Loadable(lazy(() => import('pages/iAmSmart/AuthCallback'))); | ||||
| const IAmSmart_RegistryCallback = Loadable(lazy(() => import('pages/iAmSmart/RegistryCallback'))); | |||||
| //TODO: this page for testing only, please remove at prod | //TODO: this page for testing only, please remove at prod | ||||
| const TestMailPage = Loadable(lazy(() => import('pages/pnspsNotifyTest'))); | const TestMailPage = Loadable(lazy(() => import('pages/pnspsNotifyTest'))); | ||||
| @@ -58,6 +59,10 @@ const LoginRoutes = { | |||||
| path: 'iamsmart/authcallback', | path: 'iamsmart/authcallback', | ||||
| element: <IAmSmart_AuthCallback/> | element: <IAmSmart_AuthCallback/> | ||||
| }, | }, | ||||
| { | |||||
| path: 'iamsmart/registrycallback', | |||||
| element: <IAmSmart_RegistryCallback/> | |||||
| }, | |||||
| { | { | ||||
| path: 'iamsmart/loginfallback', | path: 'iamsmart/loginfallback', | ||||
| element: <IAmSmart_FailCallback/> | element: <IAmSmart_FailCallback/> | ||||
| @@ -83,6 +83,12 @@ const Palette = (mode) => { | |||||
| dark: '#b0671e', | dark: '#b0671e', | ||||
| contrastText: '#fff', | contrastText: '#fff', | ||||
| }, | }, | ||||
| iAmSmart: { | |||||
| main: '#2B7366', | |||||
| light: '#ff5e5e', | |||||
| dark: '#b0671e', | |||||
| contrastText: '#fff', | |||||
| }, | |||||
| backgroundColor: { | backgroundColor: { | ||||
| default: '#F2F2F2' | default: '#F2F2F2' | ||||
| } | } | ||||
| @@ -106,4 +106,5 @@ export const POST_EMAIL_SAVE = apiPath+'/email/save'; | |||||
| export const DELETE_EMAIL = apiPath+'/email/delete'; | export const DELETE_EMAIL = apiPath+'/email/delete'; | ||||
| //iAmSmart | //iAmSmart | ||||
| export const GET_SMART_PROFILE = apiPath+'smart/getProfile'; //POST | |||||
| export const GET_SMART_PROFILE = apiPath+'smart/getProfile'; //POST | |||||
| export const GET_SMART_LOGIN = apiPath+'smart/login'; //POST | |||||