From d594acf422b0723ed9abdf9b169504609acd1dc9 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 16 Jan 2024 10:55:53 +0800 Subject: [PATCH 1/4] iAmSmart fix and dashboard --- .../Payment/Details_Public/PaymentDetails.js | 2 +- src/pages/Payment/FPS/AckPage.js | 3 +- src/pages/Payment/PaymentCallback.js | 2 +- .../auth-forms/AuthLoginCustom.js | 6 +- src/pages/dashboard/Public/Message.js | 30 ++++++++ src/pages/dashboard/Public/Notice.js | 31 +++++++++ src/pages/dashboard/Public/index.js | 51 ++++++++++++-- src/pages/iAmSmart/AuthCallback/index.js | 1 - .../iAmSmart/DirectLoginCallback/index.js | 69 +++++++++++++++++++ src/routes/LoginRoutes.js | 7 +- src/themes/palette.js | 6 ++ 11 files changed, 192 insertions(+), 16 deletions(-) create mode 100644 src/pages/dashboard/Public/Message.js create mode 100644 src/pages/dashboard/Public/Notice.js create mode 100644 src/pages/iAmSmart/DirectLoginCallback/index.js diff --git a/src/pages/Payment/Details_Public/PaymentDetails.js b/src/pages/Payment/Details_Public/PaymentDetails.js index e12965d..b7e6037 100644 --- a/src/pages/Payment/Details_Public/PaymentDetails.js +++ b/src/pages/Payment/Details_Public/PaymentDetails.js @@ -35,7 +35,7 @@ const PaymentDetails = ({ formData,doPrint }) => { }, [data]); const getPaymentMethod=()=>{ - let paymentmethod = data.payload.paymentdetail.paymentmethod; + let paymentmethod = data?.payload?.paymentdetail?.paymentmethod; if("01" == paymentmethod) return "PPS"; if("02" == paymentmethod || "03" == paymentmethod) return "Credit Card"; if("04" == paymentmethod) return "FPS"; diff --git a/src/pages/Payment/FPS/AckPage.js b/src/pages/Payment/FPS/AckPage.js index ba0b67c..86eed41 100644 --- a/src/pages/Payment/FPS/AckPage.js +++ b/src/pages/Payment/FPS/AckPage.js @@ -90,7 +90,7 @@ const AckPage = () => { }, onSuccess: function(responseData){ setResponeDataData(responseData) - setPaymentId(responseData.paymentdetail.paymentid) + if (responseData.paymentdetail?.result?.paymentstatuscode === "APPR") { localStorage.removeItem("webtoken"); localStorage.removeItem("transactionid"); @@ -111,6 +111,7 @@ const AckPage = () => { setItemList(responseData2.paymentItemList) setPaymentData(responseData2.data); localStorage.removeItem("paymentId"); + setPaymentId(responseData2.id) } }); } diff --git a/src/pages/Payment/PaymentCallback.js b/src/pages/Payment/PaymentCallback.js index 987f2cb..1bcdb4d 100644 --- a/src/pages/Payment/PaymentCallback.js +++ b/src/pages/Payment/PaymentCallback.js @@ -113,7 +113,6 @@ const Index = () => { }, onSuccess: function (responseData) { setResponeDataData(responseData) - setPaymentId(responseData.paymentdetail.paymentid) if (responseData.paymentdetail?.result?.paymentstatuscode === "APPR") { localStorage.removeItem("webtoken"); localStorage.removeItem("transactionid"); @@ -134,6 +133,7 @@ const Index = () => { setItemList(responseData2.paymentItemList) setPaymentData(responseData2.data); localStorage.removeItem("paymentId"); + setPaymentId(responseData2.id) } }); } diff --git a/src/pages/authentication/auth-forms/AuthLoginCustom.js b/src/pages/authentication/auth-forms/AuthLoginCustom.js index fe4a2af..d331698 100644 --- a/src/pages/authentication/auth-forms/AuthLoginCustom.js +++ b/src/pages/authentication/auth-forms/AuthLoginCustom.js @@ -193,9 +193,9 @@ const AuthLoginCustom = () => { } const openApp = () => { - setTimeout(function () { - openQR(); - }, 1000); + // setTimeout(function () { + // openQR(); + // }, 1000); let callbackUrl = "https://" + iAmSmartCallbackPath() + "/iamsmart/authcallback"; let url = iAmSmartAppPath + "auth" + "?clientID=" + clientId diff --git a/src/pages/dashboard/Public/Message.js b/src/pages/dashboard/Public/Message.js new file mode 100644 index 0000000..39f5168 --- /dev/null +++ b/src/pages/dashboard/Public/Message.js @@ -0,0 +1,30 @@ +// material-ui +import { + Stack, + Typography +} from '@mui/material'; +import MainCard from "components/MainCard"; +import * as React from "react"; + +// ==============================|| DASHBOARD - DEFAULT ||============================== // + + +const SearchDemandNoteForm = () => { + + return ( + + + + + + + + + ); +}; + +export default SearchDemandNoteForm; diff --git a/src/pages/dashboard/Public/Notice.js b/src/pages/dashboard/Public/Notice.js new file mode 100644 index 0000000..b7a1029 --- /dev/null +++ b/src/pages/dashboard/Public/Notice.js @@ -0,0 +1,31 @@ +// material-ui +import { + Typography, + Stack +} from '@mui/material'; +import MainCard from "components/MainCard"; +import * as React from "react"; + +// ==============================|| DASHBOARD - DEFAULT ||============================== // + + +const SearchDemandNoteForm = () => { + + return ( + + + + + + + + + + ); +}; + +export default SearchDemandNoteForm; diff --git a/src/pages/dashboard/Public/index.js b/src/pages/dashboard/Public/index.js index c2db5de..4b49340 100644 --- a/src/pages/dashboard/Public/index.js +++ b/src/pages/dashboard/Public/index.js @@ -4,13 +4,19 @@ import { Grid, Typography, - Stack + Stack, + Button, + Box } from '@mui/material'; -import { - isORGLoggedIn, -} from "utils/Utils"; +import { isORGLoggedIn, } from "utils/Utils"; import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' import {FormattedMessage} from "react-intl"; +import AdsClickRoundedIcon from '@mui/icons-material/AdsClickRounded'; +import * as React from "react"; +import Loadable from 'components/Loadable'; +const Message = Loadable(React.lazy(() => import('./Message'))); +const Notice = Loadable(React.lazy(() => import('./Notice'))); + // ==============================|| DASHBOARD - DEFAULT ||============================== // const DashboardDefault = () => { @@ -20,13 +26,13 @@ const DashboardDefault = () => { backgroundImage: `url(${titleBackgroundImg})`, width: '100%', height: '100%', - backgroundSize:'contain', + backgroundSize: 'contain', backgroundRepeat: 'no-repeat', backgroundColor: '#0C489E', backgroundPosition: 'right' } return ( - +
@@ -37,6 +43,39 @@ const DashboardDefault = () => {
+ + + + + + + + 提交公共啟事申請 + 提供你的啟事內容作排版,校對及計價。 + + + + + 公告 + + + + + + + + + 系統消息 + + + + + + + +
); }; diff --git a/src/pages/iAmSmart/AuthCallback/index.js b/src/pages/iAmSmart/AuthCallback/index.js index 5f30bb6..a87236a 100644 --- a/src/pages/iAmSmart/AuthCallback/index.js +++ b/src/pages/iAmSmart/AuthCallback/index.js @@ -56,7 +56,6 @@ const Index = () => { }, onError:(error)=>{ console.log(error); - //window.location.assign("/iamsmart/loginFail"); } }); } diff --git a/src/pages/iAmSmart/DirectLoginCallback/index.js b/src/pages/iAmSmart/DirectLoginCallback/index.js new file mode 100644 index 0000000..a87236a --- /dev/null +++ b/src/pages/iAmSmart/DirectLoginCallback/index.js @@ -0,0 +1,69 @@ + +import * as React from "react"; +import * as HttpUtils from "utils/HttpUtils"; +import * as UrlUtils from "utils/ApiPathConst"; +import { useNavigate } from "react-router-dom"; +import { useDispatch } from "react-redux"; +import { handleLogoutFunction, handleLogin } from 'auth/index'; + +import Loadable from 'components/Loadable'; +const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); + + +// ==============================|| DASHBOARD - DEFAULT ||============================== // + +const Index = () => { + + const dispatch = useDispatch() + const navigate = useNavigate() + + React.useEffect(() => { + goLogin(); + }, []); + + function goLogin(){ + dispatch(handleLogoutFunction()); + + let params = new URLSearchParams(window.location.search) + if(params.get("code")){ + HttpUtils.post({ + url: UrlUtils.GET_SMART_LOGIN, + params:{ + code: params.get("code") + }, + onSuccess: (responseData) => { + console.log("responseData"); + console.log(responseData); + const userData = { + id: responseData.id, + fullenName: responseData.name, + fullchName: responseData.chName, + email: responseData.email, + type: responseData.type, + role: responseData.role, + abilities: responseData.abilities, + creditor: responseData.creditor, + //avatar: require('src/assets/images/users/avatar-3.png').default, + } + const data = { ...userData, accessToken: responseData.accessToken, refreshToken: responseData.refreshToken } + dispatch(handleLogin(data)) + navigate('/dashboard'); + }, + onFail: (response)=>{ + console.log("Fail"); + console.log(response); + window.location.assign("/iamsmart/loginFail"); + }, + onError:(error)=>{ + console.log(error); + } + }); + } + } + + return ( + + ); +}; + +export default Index; \ No newline at end of file diff --git a/src/routes/LoginRoutes.js b/src/routes/LoginRoutes.js index 0a745f0..04f4dc6 100644 --- a/src/routes/LoginRoutes.js +++ b/src/routes/LoginRoutes.js @@ -12,7 +12,8 @@ const RegisterForm = Loadable(lazy(() => import('pages/authentication/Register') const BusRegisterForm = Loadable(lazy(() => import('pages/authentication/BusRegister'))); const IAmSmartRegister = Loadable(lazy(() => import('pages/authentication/IAmSmartRegister'))); const ErrorPage = Loadable(lazy(() => import('pages/extra-pages/ErrorPage'))); -const IAmSmart_FallCallback = Loadable(lazy(() => import('pages/iAmSmart/FallCallback'))); +//const IAmSmart_DirectLoginCallback = Loadable(lazy(() => import('pages/iAmSmart/DirectLoginCallback'))); +//const IAmSmart_FallCallback = Loadable(lazy(() => import('pages/iAmSmart/FallCallback'))); const IAmSmart_FailCallback = Loadable(lazy(() => import('pages/iAmSmart/FailCallback'))); const IAmSmart_SuccessCallback = Loadable(lazy(() => import('pages/iAmSmart/SuccessCallback'))); const IAmSmart_AuthCallback = Loadable(lazy(() => import('pages/iAmSmart/AuthCallback'))); @@ -60,11 +61,11 @@ const LoginRoutes = { }, { path: 'iamsmart/logincallback', - element: + element: }, { path: 'iamsmart/loginfallback', - element: + element: }, { path: 'iamsmart/authcallback', diff --git a/src/themes/palette.js b/src/themes/palette.js index 80eda43..ea3f267 100644 --- a/src/themes/palette.js +++ b/src/themes/palette.js @@ -53,6 +53,12 @@ const Palette = (mode) => { paper: paletteColor.grey[0], default: paletteColor.grey.A50 }, + gray: { + main: '#777', + light: '#777', + dark: '#777', + contrastText: '#FFF', + }, white: { main: '#fff', light: '#fff', From 1dc1465fe586fbe33dbbaa0159ee4d22416421c0 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 16 Jan 2024 17:48:07 +0800 Subject: [PATCH 2/4] iAmSmart fix bug --- src/pages/authentication/RegisterCustom.js | 21 +++--- .../auth-forms/AuthLoginCustom.js | 25 +++++-- .../iAmSmart/DirectLoginCallback/index.js | 2 +- src/pages/iAmSmart/FallCallback/index.js | 72 ------------------- src/routes/LoginRoutes.js | 4 +- src/utils/ApiPathConst.js | 1 + 6 files changed, 34 insertions(+), 91 deletions(-) delete mode 100644 src/pages/iAmSmart/FallCallback/index.js diff --git a/src/pages/authentication/RegisterCustom.js b/src/pages/authentication/RegisterCustom.js index b64074e..33d236f 100644 --- a/src/pages/authentication/RegisterCustom.js +++ b/src/pages/authentication/RegisterCustom.js @@ -9,7 +9,7 @@ import Typography from '@mui/material/Typography'; import iAmSmartICon from 'assets/images/icons/icon_iAmSmart.png'; import banner from 'assets/images/bg_ml.jpg'; import { Stack } from '../../../node_modules/@mui/material/index'; -import { iAmSmartPath, iAmSmartAppPath, clientId, getBowserType, isAppBowser, iAmSmartCallbackPath} from 'auth/utils' +import { iAmSmartPath, clientId, getBowserType, isAppBowser, iAmSmartCallbackPath} from 'auth/utils' import * as React from 'react'; import {FormattedMessage, useIntl} from "react-intl"; @@ -48,20 +48,17 @@ const RegisterCustom = () => { } const openApp = () => { - setTimeout(function () { - openQR(); - }, 1000); - let callbackUrl = "https://" + iAmSmartCallbackPath() + "/iamsmart/registrycallback"; - let url = iAmSmartAppPath + "auth" + let callbackUrl = "https://"+iAmSmartCallbackPath()+"/iamsmart/registrycallback"; + let url = iAmSmartPath + "/api/v1/auth/getQR" + "?clientID=" + clientId + "&responseType=code" - + "&source=" + getBowserType() - + "&redirectURI=" + encodeURIComponent(callbackUrl) - + "&scope=" + encodeURIComponent("eidapi_auth eidapi_profiles") - + "&lang=zh-HK"//en-US, zh-HK, or zh-CN + +"&source=" + getBowserType() + +"&redirectURI="+encodeURIComponent(callbackUrl) + +"&scope="+encodeURIComponent("eidapi_auth eidapi_profiles") + +"&lang=zh-HK"//en-US, zh-HK, or zh-CN //+"&state=" - + "&brokerPage=false" - window.location=url; + +"&brokerPage=true" + window.location.assign(url); } return ( diff --git a/src/pages/authentication/auth-forms/AuthLoginCustom.js b/src/pages/authentication/auth-forms/AuthLoginCustom.js index d331698..0784c6a 100644 --- a/src/pages/authentication/auth-forms/AuthLoginCustom.js +++ b/src/pages/authentication/auth-forms/AuthLoginCustom.js @@ -6,7 +6,8 @@ import React, { import { Link as RouterLink } from 'react-router-dom'; import { useNavigate } from 'react-router-dom'; import { useForm, } from 'react-hook-form' -import { iAmSmartPath, iAmSmartAppPath, clientId, getBowserType, isAppBowser, iAmSmartCallbackPath } from 'auth/utils' +import { iAmSmartPath, clientId, getBowserType, isAppBowser, iAmSmartCallbackPath } from 'auth/utils' +//iAmSmartAppPath // material-ui import { @@ -196,8 +197,23 @@ const AuthLoginCustom = () => { // setTimeout(function () { // openQR(); // }, 1000); + // let callbackUrl = "https://" + iAmSmartCallbackPath() + "/iamsmart/authcallback"; + + // let source = getBowserType() + // console.log(source) + // let url = iAmSmartAppPath + "auth" + // + "?clientID=" + clientId + // + "&responseType=code" + // + "&source=" + getBowserType() + // + "&redirectURI=" + encodeURIComponent(callbackUrl) + // + "&scope=" + encodeURIComponent("eidapi_auth eidapi_profiles") + // + "&lang=zh-HK"//en-US, zh-HK, or zh-CN + // //+"&state=" + // + "&brokerPage=true" + // window.location=url; + let callbackUrl = "https://" + iAmSmartCallbackPath() + "/iamsmart/authcallback"; - let url = iAmSmartAppPath + "auth" + let url = iAmSmartPath + "/api/v1/auth/getQR" + "?clientID=" + clientId + "&responseType=code" + "&source=" + getBowserType() @@ -205,8 +221,9 @@ const AuthLoginCustom = () => { + "&scope=" + encodeURIComponent("eidapi_auth eidapi_profiles") + "&lang=zh-HK"//en-US, zh-HK, or zh-CN //+"&state=" - + "&brokerPage=false" - window.location=url; + + "&brokerPage=true" + window.location=url; + } diff --git a/src/pages/iAmSmart/DirectLoginCallback/index.js b/src/pages/iAmSmart/DirectLoginCallback/index.js index a87236a..89208b8 100644 --- a/src/pages/iAmSmart/DirectLoginCallback/index.js +++ b/src/pages/iAmSmart/DirectLoginCallback/index.js @@ -27,7 +27,7 @@ const Index = () => { let params = new URLSearchParams(window.location.search) if(params.get("code")){ HttpUtils.post({ - url: UrlUtils.GET_SMART_LOGIN, + url: UrlUtils.GET_SMART_DIRECT_LOGIN, params:{ code: params.get("code") }, diff --git a/src/pages/iAmSmart/FallCallback/index.js b/src/pages/iAmSmart/FallCallback/index.js deleted file mode 100644 index 7716ad5..0000000 --- a/src/pages/iAmSmart/FallCallback/index.js +++ /dev/null @@ -1,72 +0,0 @@ - -import * as React from "react"; -import * as HttpUtils from "utils/HttpUtils"; -import * as UrlUtils from "utils/ApiPathConst"; -import { useNavigate } from "react-router-dom"; -import { useDispatch } from "react-redux"; -import { handleLogoutFunction, handleLogin } from 'auth/index'; - -import Loadable from 'components/Loadable'; -const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); - - -// ==============================|| DASHBOARD - DEFAULT ||============================== // - -const Index = () => { - - const dispatch = useDispatch() - const navigate = useNavigate() - - React.useEffect(() => { - getPrfile(); - }, []); - - function getPrfile(){ - dispatch(handleLogoutFunction()); - - let params = new URLSearchParams(window.location.search) - if(params.get("code")){ - HttpUtils.post({ - url: UrlUtils.GET_SMART_LOGIN, - params:{ - code: params.get("code") - }, - onSuccess: (responseData) => { - - //navigate('/iAmSmartRegisterFrom', { state: { responseData: responseData } }); - - console.log(response) - const userData = { - id: responseData.id, - fullenName: responseData.name, - fullchName: responseData.chName, - email: responseData.email, - type: responseData.type, - role: responseData.role, - abilities: responseData.abilities, - creditor: responseData.creditor, - //avatar: require('src/assets/images/users/avatar-3.png').default, - } - const data = { ...userData, accessToken: responseData.accessToken, refreshToken: responseData.refreshToken } - // setSuccess(true) - dispatch(handleLogin(data)) - navigate('/dashboard'); - location.reload() - - }, - onFail: ()=>{ - window.location.assign("/login"); - }, - onError:()=>{ - window.location.assign("/login"); - } - }); - } - } - - return ( - - ); -}; - -export default Index; \ No newline at end of file diff --git a/src/routes/LoginRoutes.js b/src/routes/LoginRoutes.js index 04f4dc6..b3c7533 100644 --- a/src/routes/LoginRoutes.js +++ b/src/routes/LoginRoutes.js @@ -12,7 +12,7 @@ const RegisterForm = Loadable(lazy(() => import('pages/authentication/Register') const BusRegisterForm = Loadable(lazy(() => import('pages/authentication/BusRegister'))); const IAmSmartRegister = Loadable(lazy(() => import('pages/authentication/IAmSmartRegister'))); const ErrorPage = Loadable(lazy(() => import('pages/extra-pages/ErrorPage'))); -//const IAmSmart_DirectLoginCallback = Loadable(lazy(() => import('pages/iAmSmart/DirectLoginCallback'))); +const IAmSmart_DirectLoginCallback = Loadable(lazy(() => import('pages/iAmSmart/DirectLoginCallback'))); //const IAmSmart_FallCallback = Loadable(lazy(() => import('pages/iAmSmart/FallCallback'))); const IAmSmart_FailCallback = Loadable(lazy(() => import('pages/iAmSmart/FailCallback'))); const IAmSmart_SuccessCallback = Loadable(lazy(() => import('pages/iAmSmart/SuccessCallback'))); @@ -61,7 +61,7 @@ const LoginRoutes = { }, { path: 'iamsmart/logincallback', - element: + element: }, { path: 'iamsmart/loginfallback', diff --git a/src/utils/ApiPathConst.js b/src/utils/ApiPathConst.js index 316270e..77fd0e6 100644 --- a/src/utils/ApiPathConst.js +++ b/src/utils/ApiPathConst.js @@ -124,6 +124,7 @@ export const DELETE_EMAIL = apiPath+'/email/delete'; //iAmSmart export const GET_SMART_PROFILE = apiPath+'/smart/getProfile'; //POST export const GET_SMART_LOGIN = apiPath+'/smart/login'; //POST +export const GET_SMART_DIRECT_LOGIN = apiPath+'/smart/directLogin'; //POST //gen report From fd871f97afa780c5e5fef0acb703abb5e13177c0 Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 17 Jan 2024 12:54:47 +0800 Subject: [PATCH 3/4] fix bug --- src/pages/iAmSmart/AuthCallback/index.js | 3 +++ src/pages/iAmSmart/RegistryCallback/index.js | 14 +++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/pages/iAmSmart/AuthCallback/index.js b/src/pages/iAmSmart/AuthCallback/index.js index a87236a..b83ba04 100644 --- a/src/pages/iAmSmart/AuthCallback/index.js +++ b/src/pages/iAmSmart/AuthCallback/index.js @@ -56,8 +56,11 @@ const Index = () => { }, onError:(error)=>{ console.log(error); + window.location.assign("/iamsmart/loginFail"); } }); + }else{ + window.location.assign("/iamsmart/loginFail"); } } diff --git a/src/pages/iAmSmart/RegistryCallback/index.js b/src/pages/iAmSmart/RegistryCallback/index.js index 0c03fbe..ab69b32 100644 --- a/src/pages/iAmSmart/RegistryCallback/index.js +++ b/src/pages/iAmSmart/RegistryCallback/index.js @@ -27,14 +27,22 @@ const Index = () => { }, onSuccess: (responseData) => { navigate('/iAmSmartRegisterFrom', { state: { responseData: responseData } }); + }, + onFail: (response)=>{ + console.log("Fail"); + console.log(response); + window.location.assign("/register"); + }, + onError:(error)=>{ + console.log(error); + window.location.assign("/register"); } }); + }else{ + window.location.assign("/register"); } } - - - return ( ); From 78e2a66898f6b454fe5a2ed1f7c0f295a731247b Mon Sep 17 00:00:00 2001 From: Alex Cheung Date: Wed, 17 Jan 2024 17:48:28 +0800 Subject: [PATCH 4/4] update for web to app payload --- src/pages/Payment/FPS/FPS.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/Payment/FPS/FPS.js b/src/pages/Payment/FPS/FPS.js index 1c4c0e2..7250439 100644 --- a/src/pages/Payment/FPS/FPS.js +++ b/src/pages/Payment/FPS/FPS.js @@ -176,6 +176,7 @@ const Index = () => { + encodeURIComponent("https://"+window.location.hostname+ '/paymentPage/fps/fpscallback?TRANSACTION_ID='+paymentData.transactionid+"&WEB_TOKEN="+paymentData.webtoken+"&PAYMENT_ID="+localStorage.getItem("paymentId")); setFpsqrcodeurl(openPASGUrl) setFpsqrcodeurlPrd(openPASGUrlPrd) + } });