From 5d9b6871fb48b9b63945786ea6eff0b2feefc14a Mon Sep 17 00:00:00 2001 From: bcjang Date: Thu, 13 Mar 2025 14:45:31 +0900 Subject: [PATCH] =?UTF-8?q?=EB=9E=9C=EB=93=9C=20=EC=86=8C=EC=9C=A0?= =?UTF-8?q?=EA=B6=8C=20=EB=B3=80=EA=B2=BD=20=EC=98=88=EC=95=BD=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EB=B0=8F=20=EC=B7=A8=EC=86=8C=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/Land.js | 16 +++ src/assets/data/options.js | 11 ++ .../ServiceManage/modal/OwnerChangeModal.js | 119 ++++++++++++------ .../searchBar/LandInfoSearchBar.js | 7 +- src/i18n.js | 4 + src/pages/DataManage/LandInfoView.js | 82 ++++++------ src/utils/hook.js | 2 +- 7 files changed, 160 insertions(+), 81 deletions(-) diff --git a/src/apis/Land.js b/src/apis/Land.js index 6c4bb26..3f3fa65 100644 --- a/src/apis/Land.js +++ b/src/apis/Land.js @@ -130,6 +130,22 @@ export const LandAuctionDelete = async (token, params, id) => { } }; +// 랜드 소유권 변경 예약 삭제 +export const LandOwnerChangesDelete = async (token, params) => { + try { + const res = await Axios.delete(`/api/v1/land/change/delete`, { + headers: { Authorization: `Bearer ${token}` }, + data: params, + }); + + return res.data; + } catch (e) { + if (e instanceof Error) { + throw new Error('LandAuctionDelete Error', e); + } + } +}; + export const LandView = async (token) => { try { const res = await Axios.get( diff --git a/src/assets/data/options.js b/src/assets/data/options.js index c4f4b58..f8a82f7 100644 --- a/src/assets/data/options.js +++ b/src/assets/data/options.js @@ -213,7 +213,18 @@ export const opLandOwnedType = [ ]; export const opLandCategoryType = [ + { value: 'ALL', name: '전체' }, { value: 'public', name: '공공 임대형' }, { value: 'auction', name: '경매' }, { value: 'event', name: '이벤트 지급' }, +]; + +export const opLandInfoStatusType = [ + { value: 'ALL', name: '전체' }, + { value: 'NONE', name: '' }, + { value: 'OWNED', name: '지급 완료' }, + { value: 'AUCTION_END', name: '경매 완료' }, + { value: 'RESV_START', name: '경매 예정' }, + { value: 'WAIT', name: '경매 대기' }, + { value: 'AUCTION_START', name: '경매 진행' }, ]; \ No newline at end of file diff --git a/src/components/ServiceManage/modal/OwnerChangeModal.js b/src/components/ServiceManage/modal/OwnerChangeModal.js index 6696585..2f847f4 100644 --- a/src/components/ServiceManage/modal/OwnerChangeModal.js +++ b/src/components/ServiceManage/modal/OwnerChangeModal.js @@ -28,7 +28,7 @@ import { BattleEventModify, BattleEventSingleRegist } from '../../../apis/Battle import { battleEventStatusType } from '../../../assets/data/types'; import { isValidDayRange } from '../../../utils/date'; import CheckBox from '../../common/input/CheckBox'; -import { LandOwnedChangesRegist, UserInfoView } from '../../../apis'; +import { LandOwnedChangesRegist, LandOwnerChangesDelete, UserInfoView } from '../../../apis'; const OwnerChangeModal = ({ modalType, detailView, handleDetailView, content, setDetailData }) => { const { t } = useTranslation(); @@ -52,12 +52,24 @@ const OwnerChangeModal = ({ modalType, detailView, handleDetailView, content, se useEffect(() => { if(content && Object.keys(content).length > 0){ + const ownerChanges = content.owner_changes; + let changes_info; + if(ownerChanges && ownerChanges.length > 0){ + changes_info = ownerChanges.filter(item => item.status === 'WAIT').reduce((maxItem, current) => { + return (!maxItem || current.id > maxItem.id ) ? current : maxItem; + }, null); + } setResultData({ ...resultData, land_id: content.land_id, land_name: content.land_name, building_id: content.building_id, building_name: content.building_name, + is_reserve: changes_info?.is_reserve || false, + reservation_dt: (changes_info && convertKTCDate(changes_info.reservation_dt)) || new Date(), + user_guid: changes_info?.user_guid || '', + user_name: changes_info?.user_name || '', + id: changes_info?.id || null }); } }, [modalType, content]); @@ -114,8 +126,6 @@ const OwnerChangeModal = ({ modalType, detailView, handleDetailView, content, se case "submit": if (!checkCondition()) return; - - handleModalView('registConfirm'); break; case "cancel": @@ -126,6 +136,7 @@ const OwnerChangeModal = ({ modalType, detailView, handleDetailView, content, se handleReset(); break; case "user": + if(isView()) return; const guid = resultData.user_guid; if(!guid || guid.length !== 32){ setAlertMsg(t('WARNING_GUID_CHECK')) @@ -148,24 +159,52 @@ const OwnerChangeModal = ({ modalType, detailView, handleDetailView, content, se case "registConfirm": setLoading(true); - await LandOwnedChangesRegist(token, resultData).then(data => { + if(isView()){ + console.log(resultData); setLoading(false); handleModalClose('registConfirm'); - if(data.result === "SUCCESS") { - handleModalView('registComplete'); - }else if(data.result === "GUID_CHECK"){ - setAlertMsg(t('WARNING_GUID_CHECK')); - }else{ - setAlertMsg(t('REGIST_FAIL')); + + const resvDt = resultData.reservation_dt; + const now = new Date(); + if(resvDt < now){ + setAlertMsg(t('LAND_OWNED_CHANGES_DELETE_TIME_WARNING')); + handleReset(); + return; } - }).catch(reason => { - setAlertMsg(t('API_FAIL')); - }); + + await LandOwnerChangesDelete(token, resultData).then(data => { + setLoading(false); + handleModalClose('registConfirm'); + if(data.result === "SUCCESS") { + handleModalView('registComplete'); + }else if(data.result === "ERROR_LAND_OWNER_CHANGES_RESERVATION"){ + setAlertMsg(t('LAND_OWNED_CHANGES_DELETE_STATUS_WARNING')); + }else{ + setAlertMsg(t('DELETE_FAIL')); + } + }).catch(reason => { + setAlertMsg(t('API_FAIL')); + }); + }else{ + await LandOwnedChangesRegist(token, resultData).then(data => { + setLoading(false); + handleModalClose('registConfirm'); + if(data.result === "SUCCESS") { + handleModalView('registComplete'); + }else if(data.result === "GUID_CHECK"){ + setAlertMsg(t('WARNING_GUID_CHECK')); + }else{ + setAlertMsg(t('REGIST_FAIL')); + } + }).catch(reason => { + setAlertMsg(t('API_FAIL')); + }); + } + break; case "registComplete": handleModalClose('registComplete'); handleReset(); - window.location.reload(); break; case "warning": setAlertMsg(''); @@ -186,21 +225,14 @@ const OwnerChangeModal = ({ modalType, detailView, handleDetailView, content, se const isView = (label) => { switch (label) { case "modify": - return modalType === TYPE_MODIFY && (content?.status === battleEventStatusType.stop); - case "start_dt": - case "repeat": + return modalType === TYPE_MODIFY; case "registry": - return modalType === TYPE_REGISTRY - case "end_dt": - case "group": - case "name": - case "config": - case "reward": - case "round": - case "hot": - return modalType === TYPE_REGISTRY || (modalType === TYPE_MODIFY &&(content?.status === battleEventStatusType.stop)); + return modalType === TYPE_REGISTRY; + case "reservation_dt": + case "user": + return modalType === TYPE_REGISTRY || (modalType === TYPE_MODIFY &&resultData?.id === null); default: - return modalType === TYPE_MODIFY && (content?.status !== battleEventStatusType.stop); + return modalType === TYPE_MODIFY && resultData?.id !== null; } } @@ -210,14 +242,15 @@ const OwnerChangeModal = ({ modalType, detailView, handleDetailView, content, se 소유권 변경 - {/**/} - {/* setResultData({ ...resultData, is_reserve: e.target.checked, reservation_dt: new Date() })}*/} - {/* />*/} - {/**/} + + setResultData({ ...resultData, is_reserve: e.target.checked, reservation_dt: new Date() })} + disabled={!isView('user')} + /> + {resultData.is_reserve && ( <> handleSubmit('user')} + disabled={!isView('user')} /> handleSubmit('user')} + disabled={!isView('user')} /> @@ -260,10 +297,11 @@ const OwnerChangeModal = ({ modalType, detailView, handleDetailView, content, se width='300px' value={resultData?.user_guid} onChange={e => setResultData({ ...resultData, user_guid: e.target.value })} + disabled={!isView('user')} />