전투이벤트 진행시간 추가

진행시간 기준 종료시간 계산
This commit is contained in:
2025-07-01 18:05:59 +09:00
parent d4db33bcf0
commit 0d8fb7b327
4 changed files with 96 additions and 47 deletions

View File

@@ -64,15 +64,15 @@ const BattleEventModal = ({ modalType, detailView, handleDetailView, content, se
}
}, [modalType, content]);
useEffect(() => {
if(modalType === TYPE_REGISTRY && configData?.length > 0){
setResultData(prev => ({
...prev,
round_count: configData[0].default_round_count,
round_time: configData[0].round_time
}));
}
}, [modalType, configData]);
// useEffect(() => {
// if(modalType === TYPE_REGISTRY && configData?.length > 0){
// setResultData(prev => ({
// ...prev,
// round_count: configData[0].default_round_count,
// round_time: configData[0].round_time
// }));
// }
// }, [modalType, configData]);
useEffect(() => {
if (checkCondition()) {
@@ -126,6 +126,26 @@ const BattleEventModal = ({ modalType, detailView, handleDetailView, content, se
}));
};
const handleEndTimeChange = (time) => {
if (!time) return;
const newDateTime = resultData.event_end_time
? new Date(resultData.event_end_time)
: new Date();
newDateTime.setHours(
time.getHours(),
time.getMinutes(),
0,
0
);
setResultData(prev => ({
...prev,
event_end_time: newDateTime
}));
};
// 종료 날짜 변경 핸들러
const handleEndDateChange = (date) => {
if (!date || !resultData.event_start_dt) return;
@@ -190,6 +210,11 @@ const BattleEventModal = ({ modalType, detailView, handleDetailView, content, se
return;
}
if(resultData.event_operation_time < 10){
showToast('BATTLE_EVENT_MODAL_OPERATION_TIME_MIN_CHECK_WARNING', {type: alertTypes.warning});
return;
}
// if(resultData.round_time === 0){
// const config = configData.find(data => data.id === resultData.config_id);
// setResultData({ ...resultData, round_time: config.round_time });
@@ -202,9 +227,15 @@ const BattleEventModal = ({ modalType, detailView, handleDetailView, content, se
break;
case "registConfirm":
const params = {
...resultData,
event_operation_time: resultData.event_operation_time * 60
};
if(isView('modify')){
await withLoading( async () => {
return await BattleEventModify(token, content?.id, resultData);
return await BattleEventModify(token, content?.id, params);
}).then(data => {
if(data.result === "SUCCESS") {
showToast('UPDATE_COMPLETED', {type: alertTypes.success});
@@ -221,7 +252,7 @@ const BattleEventModal = ({ modalType, detailView, handleDetailView, content, se
}
else{
await withLoading( async () => {
return await BattleEventSingleRegist(token, resultData);
return await BattleEventSingleRegist(token, params);
}).then(data => {
if(data.result === "SUCCESS") {
showToast('REGIST_COMPLTE', {type: alertTypes.success});
@@ -265,6 +296,7 @@ const BattleEventModal = ({ modalType, detailView, handleDetailView, content, se
case "round":
case "hot":
case "mode":
case "operation_time":
return modalType === TYPE_REGISTRY || (modalType === TYPE_MODIFY &&(content?.status === battleEventStatusType.stop));
default:
return modalType === TYPE_MODIFY && (content?.status !== battleEventStatusType.stop);
@@ -302,12 +334,23 @@ const BattleEventModal = ({ modalType, detailView, handleDetailView, content, se
onDateChange={handleStartDateChange}
selectedDate={resultData?.event_start_dt}
/>
</FormRowGroup>
<FormRowGroup>
<SingleTimePicker
label="시작시간"
disabled={!isView('start_dt')}
selectedTime={resultData?.event_start_dt}
onTimeChange={handleStartTimeChange}
/>
<FormLabel>진행시간()</FormLabel>
<FormInput
type="number"
disabled={!isView('operation_time')}
width='100px'
min={10}
value={resultData?.event_operation_time}
onChange={e => setResultData({ ...resultData, event_operation_time: e.target.value })}
/>
</FormRowGroup>
<FormRowGroup>
<FormLabel>반복</FormLabel>
@@ -328,24 +371,24 @@ const BattleEventModal = ({ modalType, detailView, handleDetailView, content, se
/>
}
</FormRowGroup>
<FormRowGroup>
{/*<FormLabel>라운드 시간</FormLabel>*/}
{/*<SelectInput value={resultData.config_id} onChange={handleConfigChange} disabled={!isView('config')} width="200px">*/}
{/* {configData && configData?.map((data, index) => (*/}
{/* <option key={index} value={data.id}>*/}
{/* {data.desc}({data.id})*/}
{/* </option>*/}
{/* ))}*/}
{/*</SelectInput>*/}
<FormLabel>라운드 </FormLabel>
<SelectInput value={resultData.round_count} onChange={e => setResultData({ ...resultData, round_count: e.target.value })} disabled={!isView('round')} width="100px">
{battleEventRoundCount.map((data, index) => (
<option key={index} value={data}>
{data}
</option>
))}
</SelectInput>
</FormRowGroup>
{/*<FormRowGroup>*/}
{/* <FormLabel>라운드 시간</FormLabel>*/}
{/* <SelectInput value={resultData.config_id} onChange={handleConfigChange} disabled={!isView('config')} width="200px">*/}
{/* {configData && configData?.map((data, index) => (*/}
{/* <option key={index} value={data.id}>*/}
{/* {data.desc}({data.id})*/}
{/* </option>*/}
{/* ))}*/}
{/* </SelectInput>*/}
{/* <FormLabel>라운드 수</FormLabel>*/}
{/* <SelectInput value={resultData.round_count} onChange={e => setResultData({ ...resultData, round_count: e.target.value })} disabled={!isView('round')} width="100px">*/}
{/* {battleEventRoundCount.map((data, index) => (*/}
{/* <option key={index} value={data}>*/}
{/* {data}*/}
{/* </option>*/}
{/* ))}*/}
{/* </SelectInput>*/}
{/*</FormRowGroup>*/}
<FormRowGroup>
{/*<FormLabel>배정 포드</FormLabel>*/}
{/*<SelectInput value={resultData.reward_group_id} onChange={e => setResultData({ ...resultData, reward_group_id: e.target.value })} disabled={!isView('reward')} width="200px">*/}
@@ -434,7 +477,8 @@ export const initData = {
hot_time: 1,
game_mode_id: 1,
event_start_dt: '',
event_end_dt: ''
event_end_dt: '',
event_operation_time: 10
}
export default BattleEventModal;