랜드 소유권 변경 예약 처리 및 취소 처리
This commit is contained in:
@@ -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
|
||||
<Title $align="center">소유권 변경</Title>
|
||||
<MessageWrapper>
|
||||
<FormRowGroup>
|
||||
{/*<FormItemGroup>*/}
|
||||
{/* <CheckBox*/}
|
||||
{/* label="예약"*/}
|
||||
{/* id="reserve"*/}
|
||||
{/* checked={resultData.is_reserve}*/}
|
||||
{/* setData={e => setResultData({ ...resultData, is_reserve: e.target.checked, reservation_dt: new Date() })}*/}
|
||||
{/* />*/}
|
||||
{/*</FormItemGroup>*/}
|
||||
<FormItemGroup>
|
||||
<CheckBox
|
||||
label="예약"
|
||||
id="reserve"
|
||||
checked={resultData.is_reserve}
|
||||
setData={e => setResultData({ ...resultData, is_reserve: e.target.checked, reservation_dt: new Date() })}
|
||||
disabled={!isView('user')}
|
||||
/>
|
||||
</FormItemGroup>
|
||||
{resultData.is_reserve && (
|
||||
<>
|
||||
<SingleDatePicker
|
||||
@@ -244,12 +277,16 @@ const OwnerChangeModal = ({ modalType, detailView, handleDetailView, content, se
|
||||
width='150px'
|
||||
value={resultData?.land_id}
|
||||
readOnly={true}
|
||||
handleClick={() => handleSubmit('user')}
|
||||
disabled={!isView('user')}
|
||||
/>
|
||||
<FormInput
|
||||
type="text"
|
||||
width='250px'
|
||||
value={resultData?.land_name}
|
||||
readOnly={true}
|
||||
handleClick={() => handleSubmit('user')}
|
||||
disabled={!isView('user')}
|
||||
/>
|
||||
</FormRowGroup>
|
||||
<FormRowGroup>
|
||||
@@ -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')}
|
||||
/>
|
||||
<Button
|
||||
text="확인"
|
||||
theme="primary"
|
||||
theme={!isView() ? 'primary' : 'disable'}
|
||||
type="submit"
|
||||
size="large"
|
||||
width="100px"
|
||||
@@ -277,6 +315,7 @@ const OwnerChangeModal = ({ modalType, detailView, handleDetailView, content, se
|
||||
width='300px'
|
||||
value={resultData?.user_name}
|
||||
readOnly={true}
|
||||
disabled={!isView('user')}
|
||||
/>
|
||||
</FormRowGroup>
|
||||
{!isView() && isNullValue && <SearchBarAlert $marginTop="25px" $align="right">{t('REQUIRED_VALUE_CHECK')}</SearchBarAlert>}
|
||||
@@ -288,8 +327,8 @@ const OwnerChangeModal = ({ modalType, detailView, handleDetailView, content, se
|
||||
<Button text="취소" theme="line" handleClick={() => handleSubmit('cancel')} />
|
||||
<Button
|
||||
type="submit"
|
||||
text={isView('modify') ? "수정" : "등록"}
|
||||
name="등록버튼"
|
||||
text={isView() ? "예약 삭제": "등록"}
|
||||
name={isView() ? "삭제버튼": "등록버튼"}
|
||||
theme={
|
||||
checkCondition()
|
||||
? 'primary'
|
||||
@@ -306,7 +345,7 @@ const OwnerChangeModal = ({ modalType, detailView, handleDetailView, content, se
|
||||
<DynamicModal
|
||||
modalType={modalTypes.confirmOkCancel}
|
||||
view={modalState.registConfirmModal}
|
||||
modalText={isView('modify') ? t('BATTLE_EVENT_UPDATE_CONFIRM') : t('BATTLE_EVENT_REGIST_CONFIRM')}
|
||||
modalText={isView() ? t('LAND_OWNED_CHANGES_SELECT_DELETE') : t('LAND_OWNED_CHANGES_REGIST_CONFIRM')}
|
||||
handleSubmit={() => handleSubmit('registConfirm')}
|
||||
handleCancel={() => handleModalClose('registConfirm')}
|
||||
/>
|
||||
@@ -314,7 +353,7 @@ const OwnerChangeModal = ({ modalType, detailView, handleDetailView, content, se
|
||||
<DynamicModal
|
||||
modalType={modalTypes.completed}
|
||||
view={modalState.registCompleteModal}
|
||||
modalText={isView('modify') ? t('UPDATE_COMPLETED') : t('REGIST_COMPLTE')}
|
||||
modalText={isView() ? t('CANCEL_COMPLETED') : t('REGIST_COMPLTE')}
|
||||
handleSubmit={() => handleSubmit('registComplete')}
|
||||
/>
|
||||
{/* 취소 모달 */}
|
||||
|
||||
@@ -3,7 +3,8 @@ import Button from '../../common/button/Button';
|
||||
import { SearchBarLayout, SearchPeriod } from '../../common/SearchBar';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { LandAuctionView, LandInfoData } from '../../../apis';
|
||||
import { landAuctionStatus, landSearchType, landSize } from '../../../assets/data';
|
||||
import { landAuctionStatus, landSearchType, landSize, opLandCategoryType } from '../../../assets/data';
|
||||
import { opLandInfoStatusType } from '../../../assets/data/options';
|
||||
|
||||
export const useLandInfoSearch = (token, initialPageSize) => {
|
||||
const [searchParams, setSearchParams] = useState({
|
||||
@@ -157,7 +158,7 @@ const LandInfoSearchBar = ({ searchParams, onSearch, onReset }) => {
|
||||
<>
|
||||
<InputLabel>랜드상태</InputLabel>
|
||||
<SelectInput value={searchParams.status} onChange={e => onSearch({ status: e.target.value }, false)} >
|
||||
{landAuctionStatus.map((data, index) => (
|
||||
{opLandInfoStatusType.map((data, index) => (
|
||||
<option key={index} value={data.value}>
|
||||
{data.name}
|
||||
</option>
|
||||
@@ -170,7 +171,7 @@ const LandInfoSearchBar = ({ searchParams, onSearch, onReset }) => {
|
||||
<>
|
||||
<InputLabel>카테고리</InputLabel>
|
||||
<SelectInput value={searchParams.category} onChange={e => onSearch({ category: e.target.value }, false)}>
|
||||
{landAuctionStatus.map((data, index) => (
|
||||
{opLandCategoryType.map((data, index) => (
|
||||
<option key={index} value={data.value}>
|
||||
{data.name}
|
||||
</option>
|
||||
|
||||
Reference in New Issue
Block a user