From a0545e871521f617759be4429441d1cf49265a19 Mon Sep 17 00:00:00 2001 From: Jason Chuang Date: Sat, 12 Sep 2026 04:22:02 +0800 Subject: [PATCH] CADD 2026 #18 GET mapping that write data --- src/components/FileList.js | 9 ++------- .../DetailPage/OrganizationCard.js | 4 ++-- .../Proof/Reply_GLD/ApplicationDetails.js | 2 +- src/pages/PublicNotice/Details_GLD/index.js | 12 +++++------ .../PublicNotice/Details_Public/index.js | 2 +- .../UserInformationCard_Individual.js | 6 +++--- .../UserInformationCard_Organization.js | 6 +++--- src/pages/User/ManagePage_OrgPublic/index.js | 4 ++-- src/pages/User/SearchPage/UserTable.js | 4 ++-- src/pages/_Test/index.js | 2 +- src/utils/ApiPathConst.js | 20 +++++++++---------- src/utils/HttpUtils.js | 8 ++++++++ 12 files changed, 41 insertions(+), 38 deletions(-) diff --git a/src/components/FileList.js b/src/components/FileList.js index 48f9156d..fe20c13c 100644 --- a/src/components/FileList.js +++ b/src/components/FileList.js @@ -28,14 +28,9 @@ export default function FileList({ refType, refId, allowDelete, sx, dateHideable }, []); const onDeleteClick = (fileId, skey, filename) => () => { - HttpUtils.get( + HttpUtils.del( { - url: UrlUtils.GET_FILE_DELETE, - params: { - fileId: fileId, - skey: skey, - filename: filename - }, + url: `${UrlUtils.GET_FILE_DELETE}/${fileId}/${skey}/${encodeURIComponent(filename)}`, onSuccess: function () { loadData(); } diff --git a/src/pages/Organization/DetailPage/OrganizationCard.js b/src/pages/Organization/DetailPage/OrganizationCard.js index 9b127cd7..ea398d78 100644 --- a/src/pages/Organization/DetailPage/OrganizationCard.js +++ b/src/pages/Organization/DetailPage/OrganizationCard.js @@ -227,7 +227,7 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => { const markAsNonCreditor = () => { setNonCreditorConfirmPopUp(false); - HttpUtils.get({ + HttpUtils.post({ url: UrlUtils.GET_ORG_MARK_AS_NON_CREDITOR + "/" + id, onSuccess: () => { loadDataFun(); @@ -237,7 +237,7 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => { const sendDn_Overdue = () => { setNonCreditorConfirmPopUp(false); - HttpUtils.get({ + HttpUtils.post({ url: UrlUtils.GET_SEND_OVERDUE_CREDITOR_LIST + "/" + id, onSuccess: (responseData) => { setOverduePublicNotice(responseData.overduePublicNotice); diff --git a/src/pages/Proof/Reply_GLD/ApplicationDetails.js b/src/pages/Proof/Reply_GLD/ApplicationDetails.js index dbc53bf3..53a23517 100644 --- a/src/pages/Proof/Reply_GLD/ApplicationDetails.js +++ b/src/pages/Proof/Reply_GLD/ApplicationDetails.js @@ -104,7 +104,7 @@ const ApplicationDetailCard = ({ if (cancellingRef.current) return; cancellingRef.current = true; setCancelLoading(true); - HttpUtils.get({ + HttpUtils.post({ url: UrlUtils.CANCEL_PROOF + "/" + params.id, onSuccess: function (responseData) { cancellingRef.current = false; diff --git a/src/pages/PublicNotice/Details_GLD/index.js b/src/pages/PublicNotice/Details_GLD/index.js index 394803c8..0918d42b 100644 --- a/src/pages/PublicNotice/Details_GLD/index.js +++ b/src/pages/PublicNotice/Details_GLD/index.js @@ -274,7 +274,7 @@ const PublicNoticeDetail_GLD = () => { setStatusWindowAccepted(false); return; } - HttpUtils.get({ + HttpUtils.post({ url: `${SET_PUBLIC_NOTICE_STATUS_PUBLISH}/${params.id}`, onSuccess: function () { setOpen(false); @@ -299,7 +299,7 @@ const PublicNoticeDetail_GLD = () => { const onPaidClick = () => { if (params.id > 0) { - axios.get(`${SET_PUBLIC_NOTICE_STATUS_PAID}/${params.id}`) + axios.post(`${SET_PUBLIC_NOTICE_STATUS_PAID}/${params.id}`) .then((response) => { if (response.status === 204) { setOpen(false); @@ -325,7 +325,7 @@ const PublicNoticeDetail_GLD = () => { const onComplatedClick = () => { if (params.id > 0) { - axios.get(`${SET_PUBLIC_NOTICE_STATUS_COMPLATED}/${params.id}`) + axios.post(`${SET_PUBLIC_NOTICE_STATUS_COMPLATED}/${params.id}`) .then((response) => { if (response.status === 204) { setOpen(false); @@ -351,7 +351,7 @@ const PublicNoticeDetail_GLD = () => { const onWithdrawnClick = () => { if (params.id > 0) { - axios.get(`${SET_PUBLIC_NOTICE_STATUS_WITHDRAW}/${params.id}`) + axios.post(`${SET_PUBLIC_NOTICE_STATUS_WITHDRAW}/${params.id}`) .then((response) => { if (response.status === 204) { setOpen(false); @@ -421,7 +421,7 @@ const PublicNoticeDetail_GLD = () => { setStatusWindowAccepted(false); return; } - HttpUtils.get({ + HttpUtils.post({ url: `${SET_PUBLIC_NOTICE_STATUS_REVOKE}/${params.id}`, onSuccess: function () { setOpen(false); @@ -447,7 +447,7 @@ const PublicNoticeDetail_GLD = () => { useEffect(() => { const status = applicationDetailData.data != undefined ? applicationDetailData.data.status : "" if (status === "submitted" && params.id > 0 && getUploadStatus) { - axios.get(`${SET_PUBLIC_NOTICE_STATUS_REVIEWED}/${params.id}`) + axios.post(`${SET_PUBLIC_NOTICE_STATUS_REVIEWED}/${params.id}`) .then((response) => { if (response.status === 204) { setUploadStatus(false); diff --git a/src/pages/PublicNotice/Details_Public/index.js b/src/pages/PublicNotice/Details_Public/index.js index 9ccc2a47..84d7579c 100644 --- a/src/pages/PublicNotice/Details_Public/index.js +++ b/src/pages/PublicNotice/Details_Public/index.js @@ -145,7 +145,7 @@ const DashboardDefault = () => { if (params.id > 0) { cancellingRef.current = true; setCancelLoading(true); - axios.get(`${SET_PUBLIC_NOTICE_STATUS_CANCELLED}/${params.id}`) + axios.post(`${SET_PUBLIC_NOTICE_STATUS_CANCELLED}/${params.id}`) .then((response) => { if (response.status === 204) { notifyActionSuccess("取消成功!") diff --git a/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js b/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js index 6977ec00..afa8f110 100644 --- a/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js +++ b/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js @@ -264,7 +264,7 @@ const UserInformationCard_Individual = ({ formData, loadDataFun }) => { }; const onVerifiedClick = () => { - HttpUtils.get({ + HttpUtils.post({ url: UrlUtils.GET_IND_USER_VERIFY + "/" + formData.id, onSuccess: function () { notifyVerifySuccess() @@ -274,7 +274,7 @@ const UserInformationCard_Individual = ({ formData, loadDataFun }) => { }; const doLock = () => { - HttpUtils.get({ + HttpUtils.post({ url: UrlUtils.GET_USER_LOCK + "/" + formData.id, onSuccess: function () { notifyLockSuccess() @@ -284,7 +284,7 @@ const UserInformationCard_Individual = ({ formData, loadDataFun }) => { }; const doUnlock = () => { - HttpUtils.get({ + HttpUtils.post({ url: UrlUtils.GET_USER_UNLOCK + "/" + formData.id, onSuccess: function () { notifyActiveSuccess() diff --git a/src/pages/User/DetailsPage_Organization/UserInformationCard_Organization.js b/src/pages/User/DetailsPage_Organization/UserInformationCard_Organization.js index 4507659b..506ecf71 100644 --- a/src/pages/User/DetailsPage_Organization/UserInformationCard_Organization.js +++ b/src/pages/User/DetailsPage_Organization/UserInformationCard_Organization.js @@ -130,7 +130,7 @@ const UserInformationCard_Organization = ({ userData, loadDataFun, orgData }) => const onVerifiedClick = () => { if (formik?.values?.orgId) { - HttpUtils.get({ + HttpUtils.post({ url: GET_IND_USER_VERIFY + "/" + userData.id, onSuccess: function () { notifyVerifySuccess() @@ -148,7 +148,7 @@ const UserInformationCard_Organization = ({ userData, loadDataFun, orgData }) => setConfirmText("Confirm to Lock this Account?"); setConfirmAction({ function: function () { - HttpUtils.get({ + HttpUtils.post({ url: GET_USER_LOCK + "/" + userData.id, onSuccess: function () { notifyLockSuccess() @@ -165,7 +165,7 @@ const UserInformationCard_Organization = ({ userData, loadDataFun, orgData }) => setConfirmAction({ function: function () { - HttpUtils.get({ + HttpUtils.post({ url: GET_USER_UNLOCK + "/" + userData.id, onSuccess: function () { notifyActiveSuccess() diff --git a/src/pages/User/ManagePage_OrgPublic/index.js b/src/pages/User/ManagePage_OrgPublic/index.js index edbe16cf..5d27e0fe 100644 --- a/src/pages/User/ManagePage_OrgPublic/index.js +++ b/src/pages/User/ManagePage_OrgPublic/index.js @@ -77,7 +77,7 @@ const ManageOrgUserPage = () => { function onActiveClick(params) { - HttpUtils.get({ + HttpUtils.post({ url: GET_USER_UNLOCK + "/" + params.row.id, onSuccess: () => { setReloadTime(new Date()); @@ -117,7 +117,7 @@ const ManageOrgUserPage = () => { const setPrimaryUser = () => { setIsWarningPopUp(false) - HttpUtils.get( + HttpUtils.post( { url: (!selectUser.row.primaryUser ? GET_SET_PRIMARY_USER : GET_SET_UN_PRIMARY_USER) + "/" + selectUser.row.id, onSuccess: function () { diff --git a/src/pages/User/SearchPage/UserTable.js b/src/pages/User/SearchPage/UserTable.js index 1f7c4b8d..f903d64d 100644 --- a/src/pages/User/SearchPage/UserTable.js +++ b/src/pages/User/SearchPage/UserTable.js @@ -37,7 +37,7 @@ export default function UserTable({searchCriteria, applyGridOnReady,applySearch} } const doLock = (id) => { - HttpUtils.get({ + HttpUtils.post({ url: GET_USER_LOCK+"/"+id, onSuccess: function(){ //setChangeLocked(true) @@ -48,7 +48,7 @@ export default function UserTable({searchCriteria, applyGridOnReady,applySearch} }; const doUnlock = (id) => { - HttpUtils.get({ + HttpUtils.post({ url: GET_USER_UNLOCK+"/"+id, onSuccess: function(){ //setChangeLocked(true) diff --git a/src/pages/_Test/index.js b/src/pages/_Test/index.js index 2eab2145..e1440f8c 100644 --- a/src/pages/_Test/index.js +++ b/src/pages/_Test/index.js @@ -61,7 +61,7 @@ const Mail = () => { }); const setReminderDate=()=>{ - HttpUtils.get({ + HttpUtils.post({ url: apiPath + "/demandNote/set-expect-reminder", onSuccess: function () { setResponsText("Success"); diff --git a/src/utils/ApiPathConst.js b/src/utils/ApiPathConst.js index 843dcd97..4a1059f7 100644 --- a/src/utils/ApiPathConst.js +++ b/src/utils/ApiPathConst.js @@ -29,11 +29,11 @@ export const GLD_USER_PROFILE_PATH = apiPath+'/user/gldProfile'; export const GET_AUTH_LIST = '/user/auth/combo'; export const GET_USER_COMBO_LIST = '/user/combo'; export const GET_USER_GLD_COMBO_LIST = '/user/combo/gld'; -export const GET_USER_LOCK = apiPath+'/user/lock'; -export const GET_USER_UNLOCK = apiPath+'/user/unlock'; +export const GET_USER_LOCK = apiPath+'/user/lock'; //POST +export const GET_USER_UNLOCK = apiPath+'/user/unlock'; //POST export const GET_IND_USER_PATH = apiPath+'/user/ind'; -export const GET_IND_USER_VERIFY = apiPath+'/user/verify'; +export const GET_IND_USER_VERIFY = apiPath+'/user/verify'; //POST export const POST_IND_USER = apiPath+'/user/ind'; export const GET_ORG_USER_PATH = apiPath+'/user/org'; @@ -51,10 +51,10 @@ export const POST_ORG_SAVE_PATH = apiPath+'/org/save'; export const GET_ORG_COMBO = apiPath+'/org/combo'; export const GET_ORG_CHECK_CREDITOR = apiPath+'/org/check-creditor'; export const GET_ORG_MARK_AS_CREDITOR = apiPath+'/org/mark-as-creditor'; -export const GET_ORG_MARK_AS_NON_CREDITOR = apiPath+'/org/mark-as-non-creditor'; -export const GET_SEND_TERMINATION_OF_CREDIT = apiPath+'/org/sendDn_terminationOfCredit'; +export const GET_ORG_MARK_AS_NON_CREDITOR = apiPath+'/org/mark-as-non-creditor'; //POST +export const GET_SEND_TERMINATION_OF_CREDIT = apiPath+'/org/sendDn_terminationOfCredit'; //POST export const GET_ORG_EXPORT = apiPath+'/org/export'; -export const GET_SEND_OVERDUE_CREDITOR_LIST = apiPath+'/org/sendDn_OverdueCreditorList'; +export const GET_SEND_OVERDUE_CREDITOR_LIST = apiPath+'/org/sendDn_OverdueCreditorList'; //POST //public export const GET_PUB_ORG_PATH = apiPath+'/org/pub'; @@ -79,7 +79,7 @@ export const CHECK_OVERDUE = apiPath+'/application/check-overdue'; export const FILE_UP_POST = apiPath+'/file/ul'; export const FILE_DOWN_GET = apiPath+"/file/dl"; export const POST_FILE_LIST = apiPath+'/file/list'; -export const GET_FILE_DELETE = apiPath+'/file/delete'; +export const GET_FILE_DELETE = apiPath+'/file/delete'; //DELETE /{fileId}/{skey}/{filename} //export const FILE_DOWN_GET = ({id,skey,filename})=>{ return apiPath+'/file/dl/'+id+'/'+skey+'/'+filename}; export const DR_EXPORT = apiPath+'/settings/dr/export'; @@ -120,8 +120,8 @@ export const PATCH_CHANGE_PASSWORD = apiPath+'/user/change-password'; //Public export const GET_PUBLIC_ORG_USER_LIST = apiPath+'/user/listOrg'; -export const GET_SET_PRIMARY_USER = apiPath+'/user/primary'; -export const GET_SET_UN_PRIMARY_USER = apiPath+'/user/un-primary'; +export const GET_SET_PRIMARY_USER = apiPath+'/user/primary'; //POST +export const GET_SET_UN_PRIMARY_USER = apiPath+'/user/un-primary'; //POST export const GET_PUBLIC_NOTICE_LIST = apiPath+'/application/list'; export const GET_PUBLIC_NOTICE_LIST_ListByStatus = apiPath+'/application/status-list'; @@ -175,7 +175,7 @@ export const GET_PROOF = apiPath+'/proof/details';//GET export const REPLY_PROOF = apiPath+'/proof/reply';//GET export const PROOF_CHECK_PRICE = apiPath+'/proof/check-price';//GET export const GET_PROOF_PAY = apiPath+'/proof/pay-details';//GET -export const CANCEL_PROOF = apiPath+'/proof/cancel';//GET +export const CANCEL_PROOF = apiPath+'/proof/cancel';//POST //payment export const PAYMENT_CREATE = apiPath+'/payment/create';//POST diff --git a/src/utils/HttpUtils.js b/src/utils/HttpUtils.js index b8cd6058..fe8aea75 100644 --- a/src/utils/HttpUtils.js +++ b/src/utils/HttpUtils.js @@ -34,6 +34,14 @@ export const patch = ({ url, params, onSuccess, onFail, onError }) => { }); }; +export const del = ({ url, params, onSuccess, onFail, onError }) => { + axios.delete(url, { params }).then( + (response) => { onResponse(response, onSuccess, onFail); } + ).catch(error => { + return handleError(error, onError); + }); +}; + export const post = ({ url, params, onSuccess, onFail, onError, headers }) => { headers = headers ? headers : { "Content-Type": "application/json"