정산달력 연속 클릭 방어코드 추가
This commit is contained in:
@@ -29,9 +29,12 @@ export const CalendarWrap = () => {
|
|||||||
|
|
||||||
const [lastMonth, setLastMonth] = useState<boolean>(false);
|
const [lastMonth, setLastMonth] = useState<boolean>(false);
|
||||||
|
|
||||||
|
const [onActionCalendar, setOnActionCalendar] = useState<boolean>(true);
|
||||||
|
|
||||||
const { mutateAsync: settlementsCalendar } = useSettlementsCalendarMutation();
|
const { mutateAsync: settlementsCalendar } = useSettlementsCalendarMutation();
|
||||||
|
|
||||||
const callCalendar = () => {
|
const callCalendar = () => {
|
||||||
|
|
||||||
let params: SettlementsCalendarParams = {
|
let params: SettlementsCalendarParams = {
|
||||||
mid: mid,
|
mid: mid,
|
||||||
yearMonth: yearMonth
|
yearMonth: yearMonth
|
||||||
@@ -72,20 +75,37 @@ export const CalendarWrap = () => {
|
|||||||
else{
|
else{
|
||||||
setLastMonth(true);
|
setLastMonth(true);
|
||||||
}
|
}
|
||||||
|
setOnActionCalendar(true);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const initialList = () => {
|
||||||
|
// API 응답시간 문제로 초기화 한다
|
||||||
|
setScheduledList([]);
|
||||||
|
setCompletedList([]);
|
||||||
|
setScheduledDateList([]);
|
||||||
|
setCompletedDateList([]);
|
||||||
|
setOnActionCalendar(false);
|
||||||
|
};
|
||||||
|
|
||||||
const onClickToMoveMonthPrev = () => {
|
const onClickToMoveMonthPrev = () => {
|
||||||
let newYearMonth = moment(yearMonth).subtract(1, 'month').format('YYYYMM');
|
if(onActionCalendar){
|
||||||
setYearMonth(newYearMonth);
|
let newYearMonth = moment(yearMonth).subtract(1, 'month').format('YYYYMM');
|
||||||
|
setYearMonth(newYearMonth);
|
||||||
|
setYearMonth(newYearMonth);
|
||||||
|
initialList();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const onClickToMoveMonthNext = () => {
|
const onClickToMoveMonthNext = () => {
|
||||||
let maxYearMonth = moment().format('YYYYMM');
|
if(onActionCalendar){
|
||||||
let maxYearMonthValue = moment(maxYearMonth).format('YYYYMM');
|
let maxYearMonth = moment().format('YYYYMM');
|
||||||
let newYearMonth = moment(yearMonth).add(1, 'month').format('YYYYMM');
|
let maxYearMonthValue = moment(maxYearMonth).format('YYYYMM');
|
||||||
let newYearMonthValue = moment(newYearMonth).format('YYYYMM');
|
let newYearMonth = moment(yearMonth).add(1, 'month').format('YYYYMM');
|
||||||
if(parseInt(newYearMonthValue) <= parseInt(maxYearMonthValue)){
|
let newYearMonthValue = moment(newYearMonth).format('YYYYMM');
|
||||||
setYearMonth(newYearMonth);
|
if(parseInt(newYearMonthValue) <= parseInt(maxYearMonthValue)){
|
||||||
|
setYearMonth(newYearMonth);
|
||||||
|
initialList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -116,7 +136,7 @@ export const CalendarWrap = () => {
|
|||||||
|
|
||||||
<div className="month-group">
|
<div className="month-group">
|
||||||
<button
|
<button
|
||||||
className="month-btn"
|
className={ `month-btn ${(!onActionCalendar)? 'disabled': ''}` }
|
||||||
aria-label="이전 달"
|
aria-label="이전 달"
|
||||||
onClick={ onClickToMoveMonthPrev }
|
onClick={ onClickToMoveMonthPrev }
|
||||||
>
|
>
|
||||||
@@ -127,7 +147,7 @@ export const CalendarWrap = () => {
|
|||||||
</button>
|
</button>
|
||||||
<div className="month-title">{ moment(yearMonth).format('YYYY년 MM월') }</div>
|
<div className="month-title">{ moment(yearMonth).format('YYYY년 MM월') }</div>
|
||||||
<button
|
<button
|
||||||
className={ `month-btn ${lastMonth? 'disabled': ''}` }
|
className={ `month-btn ${(lastMonth || !onActionCalendar)? 'disabled': ''}` }
|
||||||
aria-label="다음 달"
|
aria-label="다음 달"
|
||||||
onClick={ onClickToMoveMonthNext }
|
onClick={ onClickToMoveMonthNext }
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -307,8 +307,7 @@ export const ListWrap = ({
|
|||||||
mid, periodType,
|
mid, periodType,
|
||||||
startDate, endDate,
|
startDate, endDate,
|
||||||
paymentMethod
|
paymentMethod
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
Reference in New Issue
Block a user