전투시스템 중지 처리

This commit is contained in:
2025-02-20 11:16:34 +09:00
parent 6760219734
commit c6dac677f6
5 changed files with 173 additions and 55 deletions

View File

@@ -6,7 +6,7 @@ import 'react-datepicker/dist/react-datepicker.css';
import {
BattleConfigView,
BattleEventDelete,
BattleEventDetailView,
BattleEventDetailView, BattleEventStop,
BattleEventView,
BattleRewardView,
} from '../../apis/Battle';
@@ -28,7 +28,7 @@ import {
Pagination,
ViewTableInfo, ExcelDownButton,
} from '../../components/common';
import { convertKTC, timeDiffMinute } from '../../utils';
import { convertKTC, convertKTCDate, convertUTC, timeDiffMinute } from '../../utils';
import { BattleEventModal, LandAuctionModal, LandAuctionSearchBar } from '../../components/ServiceManage';
import { INITIAL_PAGE_SIZE, INITIAL_PAGE_LIMIT } from '../../assets/data/adminConstants';
import { useDataFetch, useModal, useTable, withAuth } from '../../utils/hook';
@@ -38,7 +38,8 @@ import { battleEventStatus, battleRepeatType } from '../../assets/data/options';
import BattleEventSearchBar, {
useBattleEventSearch,
} from '../../components/ServiceManage/searchBar/BattleEventSearchBar';
import { getTimeOnly } from '../../utils/date';
import { getDateOnly, getTimeOnly, secondToMinutes } from '../../utils/date';
import { battleEventStatusType } from '../../assets/data/types';
const BattleEvent = () => {
const token = sessionStorage.getItem('token');
@@ -53,6 +54,8 @@ const BattleEvent = () => {
handleModalView,
handleModalClose
} = useModal({
stopConfirm: 'hidden',
stopComplete: 'hidden',
detail: 'hidden',
deleteConfirm: 'hidden',
deleteComplete: 'hidden'
@@ -85,6 +88,41 @@ const BattleEvent = () => {
data: battleRewardData
} = useDataFetch(() => BattleRewardView(token), [token]);
const endTime = (start_dt, operation_time) =>{
const startDate = new Date(start_dt);
startDate.setSeconds(startDate.getSeconds() + operation_time);
return startDate;
}
const isStopMinutes = (time) => {
const givenDate = new Date(time);
const currentDate = convertUTC(new Date());
// 시간만 비교하기 위해 년,월,일을 동일하게 설정
givenDate.setFullYear(currentDate.getFullYear());
givenDate.setMonth(currentDate.getMonth());
givenDate.setDate(currentDate.getDate());
// 두 시간의 차이를 밀리초로 계산
const timeDifference = currentDate.getTime() - givenDate.getTime();
// 밀리초로 변환
const fiveMinutesInMs = 5 * 60 * 1000;
return timeDifference < 0 && Math.abs(timeDifference) <= fiveMinutesInMs;
}
const isRunningTime = (time, operation_time) =>{
const startDate = new Date(time);
const endDate = new Date(startDate.getTime() + (operation_time * 1000));
const currentDate = convertUTC(new Date());
return currentDate >= startDate && currentDate <= endDate;
}
const handleModalSubmit = async (type, param = null) => {
switch (type) {
case "regist":
@@ -112,6 +150,42 @@ const BattleEvent = () => {
return;
}
handleModalView('deleteConfirm');
break;
case "stop":
const select_item = selectedRows[0];
if(select_item.status === battleEventStatusType.running){
setAlertMsg(t('BATTLE_EVENT_STATUS_RUNNING_WARNING'));
return;
}
console.log(select_item)
const isStopTimeCheck = isStopMinutes(select_item.event_start_dt);
if(isStopTimeCheck){
setAlertMsg(t('BATTLE_EVENT_STOP_5MINUTES_DATE_WARNING'));
return;
}
if(isRunningTime(select_item.event_start_dt, select_item.event_operation_time)){
setAlertMsg(t('BATTLE_EVENT_STATUS_RUNNING_WARNING'));
return;
}
handleModalView('stopConfirm');
break;
case "stopConfirm":
const stop_item = selectedRows[0];
await BattleEventStop(token, stop_item.id, stop_item).then(data => {
handleModalClose('stopConfirm');
if(data.result === "SUCCESS") {
handleModalView('stopComplete');
}else if(data.result === "ERROR_BATTLE_EVENT_STATUS_START_IMPOSSIBLE"){
setAlertMsg(t('BATTLE_EVENT_STATUS_RUNNING_WARNING'));
}else{
setAlertMsg(t('STOP_FAIL'));
}
}).catch(reason => {
setAlertMsg(t('API_FAIL'));
});
break;
case "deleteConfirm":
let list = [];
@@ -149,6 +223,10 @@ const BattleEvent = () => {
handleModalClose('deleteComplete');
window.location.reload();
break;
case "stopComplete":
handleModalClose('stopComplete');
window.location.reload();
break;
case "warning":
setAlertMsg('')
break;
@@ -175,8 +253,11 @@ const BattleEvent = () => {
</FormWrapper>
<ViewTableInfo total={dataList?.total} total_all={dataList?.total_all} handleOrderBy={handleOrderByChange} handlePageSize={handlePageSizeChange}>
<ExcelDownButton tableRef={tableRef} fileName={t('FILE_BATTLE_EVENT')} />
{/*{userInfo.auth_list?.some(auth => auth.id === authType.battleEventDelete) && (*/}
{/* <Button theme={selectedRows.length === 0 ? 'disable' : 'line'} text="이벤트 삭제" handleClick={() => handleModalSubmit('delete')} />*/}
{/*)}*/}
{userInfo.auth_list?.some(auth => auth.id === authType.battleEventDelete) && (
<Button theme={selectedRows.length === 0 ? 'disable' : 'line'} text="이벤트 중단" handleClick={() => handleModalSubmit('delete')} />
<Button theme={selectedRows.length === 0 ? 'disable' : 'line'} text="이벤트 중단" handleClick={() => handleModalSubmit('stop')} />
)}
{userInfo.auth_list?.some(auth => auth.id === authType.battleEventUpdate) && (
<Button
@@ -194,17 +275,18 @@ const BattleEvent = () => {
<tr>
<th width="40"></th>
<th width="90">그룹</th>
<th width="60">이벤트 ID</th>
<th width="150">이벤트명</th>
<th width="70">이벤트 ID</th>
<th width="200">이벤트명</th>
<th width="80">반복</th>
<th width="120">이벤트 시작시간</th>
<th width="120">이벤트 종료시간</th>
<th width="100">이벤트 시작시간(KST)</th>
<th width="100">이벤트 종료시간(KST)</th>
<th width="90">이벤트 상태</th>
<th width="90">라운드 시간</th>
<th width="80">라운드 </th>
<th width="80">핫타임</th>
<th width="200">기간 시작일</th>
<th width="200">기간 종료일</th>
<th width="90">배정포드</th>
<th width="70">라운드 </th>
<th width="70">핫타임</th>
<th width="100">기간 시작일(KST)</th>
<th width="100">기간 종료일(KST)</th>
<th width="100">확인 / 수정</th>
<th width="150">히스토리</th>
</tr>
@@ -218,25 +300,26 @@ const BattleEvent = () => {
checked={isRowSelected(battle.id)} />
</td>
<td>{battle.group_id}</td>
<td>{battle.id}</td>
<td>{battle.event_id}</td>
<td>{battle.event_name}</td>
<StatusWapper>
<StatusLabel $status={battle.repeat_type}>
{battleRepeatType.find(data => data.value === battle.repeat_type).name}
</StatusLabel>
</StatusWapper>
<td>{getTimeOnly(battle.event_start_dt)}</td>
<td>{battle.end_time}</td>
<td>{getTimeOnly(convertKTCDate(battle.event_start_dt))}</td>
<td>{getTimeOnly(endTime(convertKTCDate(battle.event_start_dt), battle.event_operation_time))}</td>
<StatusWapper>
<StatusLabel $status={battle.status}>
{battleEventStatus.find(data => data.value === battle.status).name}
</StatusLabel>
</StatusWapper>
<td>{battle.round_time}</td>
<td>{secondToMinutes(battle.round_time)}</td>
<td>{battle.reward_group_id}</td>
<td>{battle.round_count}</td>
<td>{battle.hot_time}</td>
<td>{convertKTC(battle.event_start_dt)}</td>
<td>{convertKTC(battle.event_end_dt)}</td>
<td>{getDateOnly(convertKTCDate(battle.event_start_dt))}</td>
<td>{getDateOnly(convertKTCDate(battle.event_end_dt))}</td>
<td>
<Button theme="line" text="상세보기"
handleClick={e => handleModalSubmit('detail', battle.id)} />
@@ -253,13 +336,28 @@ const BattleEvent = () => {
{/*상세*/}
<BattleEventModal modalType={modalType} detailView={modalState.detailModal} handleDetailView={() => handleModalClose('detail')} content={detailData} setDetailData={setDetailData} configData={battleConfigData} rewardData={battleRewardData} />
{/*중단 확인*/}
<DynamicModal
modalType={modalTypes.confirmOkCancel}
view={modalState.stopConfirmModal}
handleCancel={() => handleModalClose('stopConfirm')}
handleSubmit={() => handleModalSubmit('stopConfirm')}
modalText={t('BATTLE_EVENT_SELECT_STOP')}
/>
{/*중단 완료*/}
<DynamicModal
modalType={modalTypes.completed}
view={modalState.stopCompleteModal}
handleSubmit={() => handleModalSubmit('stopComplete')}
modalText={t('STOP_COMPLETE')}
/>
{/*삭제 확인*/}
<DynamicModal
modalType={modalTypes.confirmOkCancel}
view={modalState.deleteConfirmModal}
handleCancel={() => handleModalClose('deleteConfirm')}
handleSubmit={() => handleModalSubmit('deleteConfirm')}
modalText={t('LAND_AUCTION_SELECT_DELETE')}
modalText={t('BATTLE_EVENT_SELECT_DELETE')}
/>
{/*삭제 완료*/}
<DynamicModal