From 9ed4af9a17145eac1f8603e30286797ace42d72b Mon Sep 17 00:00:00 2001 From: anna Date: Mon, 25 Mar 2024 18:36:55 +0800 Subject: [PATCH] application show org data --- .../Details_GLD/ClientDetailCard.js | 63 ++++++++++--------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/src/pages/PublicNotice/Details_GLD/ClientDetailCard.js b/src/pages/PublicNotice/Details_GLD/ClientDetailCard.js index 913d7f9..21f868e 100644 --- a/src/pages/PublicNotice/Details_GLD/ClientDetailCard.js +++ b/src/pages/PublicNotice/Details_GLD/ClientDetailCard.js @@ -36,7 +36,6 @@ const ClientDetailCard = ( ) => { // const params = useParams(); const [currentApplicationDetailData, setCurrentApplicationDetailData] = useState({}); - const [orgDetailData, setOrgDetailData] = useState({}); const [brExpiryDate,setBrExpiryDate] = useState(""); const [brNo,setBrNo] = useState(""); const [onReady, setOnReady] = useState(false); @@ -50,40 +49,48 @@ const ClientDetailCard = ( //if user data from parent are not null if (Object.keys(applicationDetailData).length > 0 && applicationDetailData !== undefined) { setCurrentApplicationDetailData(applicationDetailData.userData); - if (!applicationDetailData.orgDetail == null){ - setOrgDetailData(applicationDetailData.orgDetail.data); - } - if (!applicationDetailData.companyName1 == null) { - setCompanyName(applicationDetailData.companyName); - } else { + if (applicationDetailData.orgDetail != null){ + var orgDetail = applicationDetailData.orgDetail?.data; + setBrExpiryDate(DateUtils.dateValue(orgDetail?.brExpiryDate)); + setBrNo(orgDetail?.brNo); const companyNameData = { - enCompanyName: applicationDetailData.userData.enCompanyName, - chCompanyName: applicationDetailData.userData.chCompanyName + enCompanyName: orgDetail?.enCompanyName, + chCompanyName: orgDetail?.chCompanyName + } + setCompanyName(companyNameData) + }else{ + var userData = applicationDetailData.userData; + setBrExpiryDate(DateUtils.dateValue(userData?.brExpiryDate)); + setBrNo(userData?.brNo); + const companyNameData = { + enCompanyName: userData?.enCompanyName, + chCompanyName: userData?.chCompanyName } setCompanyName(companyNameData) } + setOnReady(true); } }, [applicationDetailData]); - useEffect(() => { - //if state data are ready and assign to different field - // console.log(currentApplicationDetailData) - if (Object.keys(currentApplicationDetailData).length > 0) { - if( currentApplicationDetailData.orgId!=null){ - if (Object.keys(orgDetailData).length > 0) { - setBrExpiryDate(DateUtils.dateValue(orgDetailData.brExpiryDate)); - setBrNo(orgDetailData.brNo); - setOnReady(true); - }else{ - setBrExpiryDate(DateUtils.dateValue(currentApplicationDetailData.brExpiryDate)); - setBrNo(currentApplicationDetailData.brNo); - setOnReady(true); - } - }else{ - setOnReady(true); - } - } - }, [currentApplicationDetailData]); + // useEffect(() => { + // //if state data are ready and assign to different field + // // console.log(currentApplicationDetailData) + // if (Object.keys(currentApplicationDetailData).length > 0) { + // if( currentApplicationDetailData.orgId!=null){ + // if (Object.keys(orgDetailData).length > 0) { + // setBrExpiryDate(DateUtils.dateValue(orgDetailData.brExpiryDate)); + // setBrNo(orgDetailData.brNo); + // setOnReady(true); + // }else{ + // setBrExpiryDate(DateUtils.dateValue(currentApplicationDetailData.brExpiryDate)); + // setBrNo(currentApplicationDetailData.brNo); + // setOnReady(true); + // } + // }else{ + // setOnReady(true); + // } + // } + // }, [currentApplicationDetailData, orgDetailData]); useEffect(() => { if (brNo != undefined && brNo.length > 0) {