From af853bfb149cf4c35d7a03ef717dc305adccb9b3 Mon Sep 17 00:00:00 2001 From: anna Date: Fri, 24 Nov 2023 16:28:22 +0800 Subject: [PATCH] Verify fix bug& proof add page & build path update --- src/auth/utils.js | 6 +- src/pages/Proof/Create_FromApp/ProofForm.js | 21 ++++-- .../Proof/Create_FromApp/UploadFileTable.js | 67 ++++++++++++++++--- src/pages/authentication/Verify.js | 13 +++- src/pages/iAmSmart/AuthCallback/index.js | 15 ++++- src/utils/ApiPathConst.js | 5 +- 6 files changed, 106 insertions(+), 21 deletions(-) diff --git a/src/auth/utils.js b/src/auth/utils.js index 93a772d..05240c9 100644 --- a/src/auth/utils.js +++ b/src/auth/utils.js @@ -10,10 +10,10 @@ export const hostname = 'localhost'; const hostPort = '8090'; export const hostPath = `http://${hostname}:${hostPort}`; //export const apiPath = `http://192.168.0.112:8090/api`; -export const apiPath = window.location.hostname.match("localhost")?`${hostPath}/api`:`/api`; -//export const apiPath = `/api`; +export const apiPath = window.location.href.match("localhost:3000")?`${hostPath}/api`:`/api`; +//export const apiPath = `/api`;zz export const paymentPath = `https://pnspsdev.gld.gov.hk/payment`; -export const iAmSmartPath = `https://`; +export const iAmSmartPath = `https://apigw-isit.staging-eid.gov.hk`; export const clientId = "cf61fa7c121e4869966f69c8694b1cd2"; export const iAmSmartCallbackPath = () => { diff --git a/src/pages/Proof/Create_FromApp/ProofForm.js b/src/pages/Proof/Create_FromApp/ProofForm.js index 5f143d0..0a1a446 100644 --- a/src/pages/Proof/Create_FromApp/ProofForm.js +++ b/src/pages/Proof/Create_FromApp/ProofForm.js @@ -87,8 +87,16 @@ const FormPanel = ({ formData }) => { colValue = obj.value; return obj.colCount === responseData.data.column })); - formik.setFieldValue("noOfPages", responseData.data.no_of_page); - formik.setFieldValue("fee", (data.groupType == "Private Bill" ? 6552 * responseData.data.no_of_page : responseData.data.length * colValue)); + formik.setFieldValue("noOfPages", responseData.data.total_no_of_page); + formik.setFieldValue("fee", (data.groupType == "Private Bill" ? 6552 * responseData.data.total_no_of_page : responseData.data.length * colValue)); + if(data.groupType == "Private Bill" && responseData.data.file.length>0){ + let attachmentList = attachments; + for(let i=0; i item.name == file.filename)["no_of_page"] = file.no_of_page; + } + setAttachments(attachmentList); + } setWait(false); }, onError: function () { @@ -200,7 +208,7 @@ const FormPanel = ({ formData }) => { WebkitTextFillColor: "#000000", background: "#f8f8f8", }, - width: '15%' + width: '30%' } } /> @@ -233,7 +241,12 @@ const FormPanel = ({ formData }) => { - + { diff --git a/src/pages/Proof/Create_FromApp/UploadFileTable.js b/src/pages/Proof/Create_FromApp/UploadFileTable.js index 37b7ca3..8e1a114 100644 --- a/src/pages/Proof/Create_FromApp/UploadFileTable.js +++ b/src/pages/Proof/Create_FromApp/UploadFileTable.js @@ -16,10 +16,11 @@ import { } from '@mui/material'; // ==============================|| EVENT TABLE ||============================== // -export default function UploadFileTable({ recordList, setRecordList, }) { +export default function UploadFileTable({ recordList, setRecordList, showPageColumn }) { const [rows, setRows] = React.useState(recordList); const [rowModesModel, setRowModesModel] = React.useState({}); + const [showPage, setShowPage] = React.useState(false); // const theme = useTheme(); // const navigate = useNavigate() @@ -29,6 +30,11 @@ export default function UploadFileTable({ recordList, setRecordList, }) { // console.log(disableDelete); }, [recordList]); + useEffect(() => { + setShowPage(showPageColumn); + // console.log(disableDelete); + }, [showPageColumn]); + function NoRowsOverlay() { return ( @@ -53,16 +59,16 @@ export default function UploadFileTable({ recordList, setRecordList, }) { const handlePreviewClick = (param) => () => { var reader = new FileReader(); - reader.onload = function(){ + reader.onload = function () { let path = reader.result; var pdf_newTab = window.open(""); pdf_newTab.document.write( "" - +""+param.row.name+"" - +"" - +"" - +"" - +"" + + "" + param.row.name + "" + + "" + + "" + + "" + + "" ); }; reader.readAsDataURL(param.row); @@ -70,7 +76,52 @@ export default function UploadFileTable({ recordList, setRecordList, }) { - const columns = [ + const columns = showPage?[ + { + field: 'actions', + type: 'actions', + headerName: '', + width: 30, + cellClassName: 'actions', + // hide:true, + getActions: ({ id }) => { + return [ + } + label="delete" + className="textPrimary" + onClick={handleCancelClick(id)} + color="error" + />] + }, + }, + { + field: 'name', + headerName: 'File Name', + flex: 1, + renderCell: (params) => { + return ; + }, + }, + { + id: 'size', + field: 'size', + headerName: 'File Size', + valueGetter: (params) => { + // console.log(params) + return Math.ceil(params.value / 1024) + " KB"; + }, + flex: 1, + }, + { + id: 'no_of_page', + field: 'no_of_page', + headerName: 'Page', + flex: 1, + hide: true + }, + ]:[ { field: 'actions', type: 'actions', diff --git a/src/pages/authentication/Verify.js b/src/pages/authentication/Verify.js index dbcd8aa..e75d101 100644 --- a/src/pages/authentication/Verify.js +++ b/src/pages/authentication/Verify.js @@ -21,9 +21,11 @@ export default function Verify() { const [isLoading, setIsLoading] = useState(true) const [verifyState, setVerifyState] = useState(null) + const [enterUseEffect, setEnterUseEffect] = useState(false) const params = useParams() const handleVerify = async () => { + console.log("handleVerify()"); const response = await axios.get(GET_VERIFY_USER_ACCOUNT, { params: { email: decodeURIComponent(params.email), @@ -38,12 +40,17 @@ export default function Verify() { setIsLoading(false) } - let enterUseEffect = false useEffect(() => { - if (enterUseEffect) handleVerify() - enterUseEffect = true + console.log("setEnterUseEffect(true)"); + setEnterUseEffect(true) }, []) + useEffect(() => { + console.log("if (enterUseEffect) handleVerify()"); + if (enterUseEffect) handleVerify() + }, [enterUseEffect]) + + return ( diff --git a/src/pages/iAmSmart/AuthCallback/index.js b/src/pages/iAmSmart/AuthCallback/index.js index b626731..aa61a40 100644 --- a/src/pages/iAmSmart/AuthCallback/index.js +++ b/src/pages/iAmSmart/AuthCallback/index.js @@ -11,6 +11,8 @@ import * as React from "react"; import { useFormik, FormikProvider } from 'formik'; import * as yup from 'yup'; import { useParams } from "react-router-dom"; +import * as HttpUtils from "utils/HttpUtils"; +import * as UrlUtils from "utils/ApiPathConst"; //import { iAmSmartPath, clientId, getBowerType , iAmSmartCallbackPath} from 'auth/utils' import Loadable from 'components/Loadable'; @@ -40,12 +42,21 @@ const Index = () => { if(params.code){ setOnReady(true); setProps({}); + getPrfile(); } }, []); - // function loadIAmSmartProfile(){ + function getPrfile(){ + HttpUtils.post({ + url: UrlUtils.GET_SMART_PROFILE, + params:{ + code: params.code + }, + onSuccess: () => { - // } + } + }); + } function displayErrorMsg(errorMsg) { return {errorMsg} diff --git a/src/utils/ApiPathConst.js b/src/utils/ApiPathConst.js index 9ec6f36..168f847 100644 --- a/src/utils/ApiPathConst.js +++ b/src/utils/ApiPathConst.js @@ -100,4 +100,7 @@ export const GET_EMAIL_LIST = apiPath+'/email/list'; export const GET_EMAIL_COMBO = apiPath+'/email/combo'; export const GET_EMAIL = apiPath+'/email/load'; export const POST_EMAIL_SAVE = apiPath+'/email/save'; -export const DELETE_EMAIL = apiPath+'/email/delete'; \ No newline at end of file +export const DELETE_EMAIL = apiPath+'/email/delete'; + +//iAmSmart +export const GET_SMART_PROFILE = apiPath+'smart/getProfile'; //POST \ No newline at end of file