From 3efd663f0d8de72d490af329435a477c2d0cf068 Mon Sep 17 00:00:00 2001 From: bcjang Date: Fri, 7 Mar 2025 18:32:20 +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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/Land.js | 30 ++ src/assets/data/index.js | 4 +- src/assets/data/options.js | 11 + .../ServiceManage/modal/OwnerChangeModal.js | 350 ++++++++++++++++++ src/i18n.js | 1 + src/pages/DataManage/LandInfoView.js | 49 ++- src/pages/ServiceManage/MailRegist.js | 1 - src/styles/ModuleComponents.js | 7 +- 8 files changed, 436 insertions(+), 17 deletions(-) create mode 100644 src/components/ServiceManage/modal/OwnerChangeModal.js diff --git a/src/apis/Land.js b/src/apis/Land.js index c69bfb1..6c4bb26 100644 --- a/src/apis/Land.js +++ b/src/apis/Land.js @@ -69,6 +69,21 @@ export const LandAuctionSingleRegist = async (token, params) => { } }; +// 랜드 소유권 변경 등록 +export const LandOwnedChangesRegist = async (token, params) => { + try { + const res = await Axios.post(`/api/v1/land/change`, params, { + headers: { Authorization: `Bearer ${token}` }, + }); + + return res.data; + } catch (e) { + if (e instanceof Error) { + throw new Error('LandAuctionSingleRegist Error', e); + } + } +}; + // 랜드 경매 수정 export const LandAuctionModify = async (token, id, params) => { try { @@ -84,6 +99,21 @@ export const LandAuctionModify = async (token, id, params) => { } }; +// 랜드 소유권 변경 수정 +export const LandOwnedChangesModify = async (token, id, params) => { + try { + const res = await Axios.put(`/api/v1/land/change/${id}`, params, { + headers: { Authorization: `Bearer ${token}` }, + }); + + return res.data; + } catch (e) { + if (e instanceof Error) { + throw new Error('LandAuctionModify Error', e); + } + } +}; + // 랜드 경매 삭제 export const LandAuctionDelete = async (token, params, id) => { try { diff --git a/src/assets/data/index.js b/src/assets/data/index.js index c75a927..c46d8a7 100644 --- a/src/assets/data/index.js +++ b/src/assets/data/index.js @@ -18,6 +18,8 @@ export { landAuctionStatus, landSearchType, CurrencyType, - languageType + languageType, + opLandCategoryType, + opLandOwnedType } from './options' export {benItems, MinuteList, HourList, caliumRequestInitData, STATUS_STYLES, months} from './data' \ No newline at end of file diff --git a/src/assets/data/options.js b/src/assets/data/options.js index 4e57abe..c4f4b58 100644 --- a/src/assets/data/options.js +++ b/src/assets/data/options.js @@ -206,3 +206,14 @@ export const eventSearchType = [ export const battleEventRoundCount = [1,2,3,4,8,12,16]; export const battleEventHotTime = [1,2,3,4,5,6,7,8]; + +export const opLandOwnedType = [ + { value: true, name: '가능' }, + { value: false, name: '불가능' }, +]; + +export const opLandCategoryType = [ + { value: 'public', name: '공공 임대형' }, + { value: 'auction', name: '경매' }, + { value: 'event', name: '이벤트 지급' }, +]; \ No newline at end of file diff --git a/src/components/ServiceManage/modal/OwnerChangeModal.js b/src/components/ServiceManage/modal/OwnerChangeModal.js new file mode 100644 index 0000000..6696585 --- /dev/null +++ b/src/components/ServiceManage/modal/OwnerChangeModal.js @@ -0,0 +1,350 @@ +import React, { useState, Fragment, useEffect } from 'react'; +import { useTranslation } from 'react-i18next'; +import Button from '../../common/button/Button'; +import Loading from '../../common/Loading'; + +import { + Title, + BtnWrapper, + SearchBarAlert, SelectInput, +} from '../../../styles/Components'; + +import { + FormInput, + FormLabel, + MessageWrapper, + FormRowGroup, + FormStatusBar, + FormStatusLabel, + FormStatusWarning, + FormButtonContainer, FormGroup, FormItemGroup, SubText, +} from '../../../styles/ModuleComponents'; +import { modalTypes } from '../../../assets/data'; +import { DynamicModal, Modal, SingleDatePicker, SingleTimePicker } from '../../common'; +import { NONE, TYPE_MODIFY, TYPE_REGISTRY } from '../../../assets/data/adminConstants'; +import { useModal } from '../../../utils/hook'; +import { convertKTCDate } from '../../../utils'; +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'; + +const OwnerChangeModal = ({ modalType, detailView, handleDetailView, content, setDetailData }) => { + const { t } = useTranslation(); + const token = sessionStorage.getItem('token'); + + const [loading, setLoading] = useState(false); // 로딩 창 + const { + modalState, + handleModalView, + handleModalClose + } = useModal({ + cancel: 'hidden', + registConfirm: 'hidden', + registComplete: 'hidden' + }); + + const [isNullValue, setIsNullValue] = useState(false); // 데이터 값 체크 + const [alertMsg, setAlertMsg] = useState(''); + + const [resultData, setResultData] = useState(initData); //데이터 정보 + + useEffect(() => { + if(content && Object.keys(content).length > 0){ + setResultData({ + ...resultData, + land_id: content.land_id, + land_name: content.land_name, + building_id: content.building_id, + building_name: content.building_name, + }); + } + }, [modalType, content]); + + useEffect(() => { + if (checkCondition()) { + setIsNullValue(false); + } else { + setIsNullValue(true); + } + }, [resultData]); + + // 날짜 변경 핸들러 + const handleStartDateChange = (date) => { + if (!date) return; + + const newDate = new Date(date); + + setResultData(prev => ({ + ...prev, + reservation_dt: newDate + })); + }; + + // 시간 변경 핸들러 + const handleStartTimeChange = (time) => { + if (!time) return; + + const newDateTime = resultData.reservation_dt + ? new Date(resultData.reservation_dt) + : new Date(); + + newDateTime.setHours( + time.getHours(), + time.getMinutes(), + 0, + 0 + ); + + setResultData(prev => ({ + ...prev, + reservation_dt: newDateTime + })); + }; + + const handleReset = () => { + setDetailData({}); + setResultData(initData); + handleDetailView(); + } + + const handleSubmit = async (type, param = null) => { + switch (type) { + case "submit": + if (!checkCondition()) return; + + + + handleModalView('registConfirm'); + break; + case "cancel": + handleModalView('cancel'); + break; + case "cancelConfirm": + handleModalClose('cancel'); + handleReset(); + break; + case "user": + const guid = resultData.user_guid; + if(!guid || guid.length !== 32){ + setAlertMsg(t('WARNING_GUID_CHECK')) + return; + } + setLoading(true); + await UserInfoView(token, guid).then(data => { + setLoading(false); + if(Object.keys(data).length === 0){ + setAlertMsg(t('WARNING_GUID_CHECK')); + setResultData({ ...resultData, user_name: '' }) + return; + } + const nickname = data.char_info.character_name; + setResultData({ ...resultData, user_name: nickname }) + }).catch(reason => { + setAlertMsg(t('API_FAIL')); + }); + break; + case "registConfirm": + setLoading(true); + + 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(''); + break; + } + } + + const checkCondition = () => { + return ( + resultData.land_id !== '' + && resultData.land_name !== '' + && resultData.user_guid !== '' + && resultData.user_name !== '' + && (!resultData.is_reserve || (resultData.is_reserve && resultData.reservation_dt !== '')) + ); + }; + + const isView = (label) => { + switch (label) { + case "modify": + return modalType === TYPE_MODIFY && (content?.status === battleEventStatusType.stop); + case "start_dt": + case "repeat": + 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)); + default: + return modalType === TYPE_MODIFY && (content?.status !== battleEventStatusType.stop); + } + } + + return ( + <> + + 소유권 변경 + + + {/**/} + {/* setResultData({ ...resultData, is_reserve: e.target.checked, reservation_dt: new Date() })}*/} + {/* />*/} + {/**/} + {resultData.is_reserve && ( + <> + + + + )} + + + * 예약 발송 미선택 시 등록과 함께 우편이 즉시 발송됩니다. + + 변경 랜드 + + + + + 수신 대상 + setResultData({ ...resultData, user_guid: e.target.value })} + /> +