From fc260bf1650fe1e4056a4d585c9a2a303b8986bb Mon Sep 17 00:00:00 2001 From: anna Date: Fri, 25 Aug 2023 18:00:17 +0800 Subject: [PATCH] add button --- .../UserInformationCard_Public.js | 289 ++++++++++++------ src/pages/pnspsUserDetailPage_Public/index.js | 96 +++++- src/utils/ApiPathConst.js | 3 +- src/utils/HttpUtils.js | 26 +- 4 files changed, 304 insertions(+), 110 deletions(-) diff --git a/src/pages/pnspsUserDetailPage_Public/UserInformationCard_Public.js b/src/pages/pnspsUserDetailPage_Public/UserInformationCard_Public.js index 6ec92c1..e35b69f 100644 --- a/src/pages/pnspsUserDetailPage_Public/UserInformationCard_Public.js +++ b/src/pages/pnspsUserDetailPage_Public/UserInformationCard_Public.js @@ -70,11 +70,7 @@ const UserInformationCard_Public = ({isCollectData, updateUserObject,userData}) HttpFileDownload({ fileId: 1, skey: "W6biVNvk50YVC2T6", - filename: "idCardSample.jpg", - onSuccess: function(response){ - console.log(response); - setOpen(true); - } + filename: "idCardSample.jpg" }); }; @@ -96,13 +92,22 @@ const UserInformationCard_Public = ({isCollectData, updateUserObject,userData})
+ Upload success. - - + + @@ -123,81 +128,70 @@ const UserInformationCard_Public = ({isCollectData, updateUserObject,userData}) - + - ID Type: + English Name: - - + - Identification No.: + Created Date: - - - - + - English Name: + Prefix: - + @@ -218,134 +212,184 @@ const UserInformationCard_Public = ({isCollectData, updateUserObject,userData}) - + - Chinese Name: + Last Updated: - + + - Country: + ID Type: - - + - + + - Address: + Contact Tel: - + - + - + Vetted By: - + + + - + ID No.: - - + + + + + + Fax No.: + - + + + + + + + + - Post: + Last Login: - + + + - + + + + Country: + + + + + + + + + + @@ -365,27 +409,70 @@ const UserInformationCard_Public = ({isCollectData, updateUserObject,userData}) - + - Phone: + Status: + + + + + + + + + Address: + + + + + + - + + + + diff --git a/src/pages/pnspsUserDetailPage_Public/index.js b/src/pages/pnspsUserDetailPage_Public/index.js index cf1309c..43fd409 100644 --- a/src/pages/pnspsUserDetailPage_Public/index.js +++ b/src/pages/pnspsUserDetailPage_Public/index.js @@ -24,15 +24,34 @@ const UserMaintainPage_Public = () => { const [editedCustomerData, setEditedCustomerData] = useState({}); const [userConfirm, setUserConfirm] = useState(false); + const [editMode, setEditMode] = useState(false); + const [locked, setLocked] = useState(false); + + function updateUserObject(userData) { setEditedCustomerData(userData); } const submitData = () => { setUserConfirm(true); + setEditMode(false); setIsCollectData(!isCollectData); } + const onEditClick = () => { + setEditMode(true); + }; + + const doLock = () => { + setLocked(true); + }; + + const doUnlock = () => { + setLocked(false); + }; + + + useEffect(() => { console.log(params) // HttpGet({ @@ -72,10 +91,10 @@ const UserMaintainPage_Public = () => { : - Maintain User + Public User {/*col 1*/} - + { {/*bottom button*/} + + {editMode? + + + + : + <> + {locked? + + : + + + + } + + + + + + + } + + ); }; + export default UserMaintainPage_Public; diff --git a/src/utils/ApiPathConst.js b/src/utils/ApiPathConst.js index 9f0d626..53e04ac 100644 --- a/src/utils/ApiPathConst.js +++ b/src/utils/ApiPathConst.js @@ -16,7 +16,8 @@ export const GET_USER_COMBO_LIST = '/user/combo'; //File Up/Download export const FILE_UP_POST = apiPath+'/file/ul'; -export const FILE_DOWN_GET = apiPath+'/file/dl/{id}/{skey}/{filename}'; +export const FILE_DOWN_GET = apiPath+"/dl/{id}/{skey}/{filename}"; +//export const FILE_DOWN_GET = ({id,skey,filename})=>{ return apiPath+'/file/dl/'+id+'/'+skey+'/'+filename}; // POST request //Login diff --git a/src/utils/HttpUtils.js b/src/utils/HttpUtils.js index 5474ea4..58ae64e 100644 --- a/src/utils/HttpUtils.js +++ b/src/utils/HttpUtils.js @@ -9,14 +9,30 @@ export const HttpGet = ({url, onSuccess, onFail, onError}) =>{ }); }; -export const HttpFileDownload = ({fileId, skey, filename, onSuccess, onFail, onError}) =>{ +export const HttpFileDownload = ({fileId, skey, filename, onSuccess, onError}) =>{ axios.get( FILE_DOWN_GET - .replace("{id}",fileId) - .replace("{skey}",skey) - .replace("{filename}", filename) + .replace("{id}",fileId) + .replace("{skey}",skey) + .replace("{filename}", filename), + { + responseType: 'blob', + } ).then( - (response)=>{onResponse(response, onSuccess, onFail);} + (response)=>{ + if(onSuccess){ + onSuccess(response); + } + const url = URL.createObjectURL(response.data); + const a = document.createElement('a'); + a.style = 'display: none'; + a.href = url; + a.download = 'file.txt'; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); + } ).catch(error => { return handleError(error,onError); });