날짜 필터 캘린더 Invalid Date 오류 수정
react-calendar에 전달되는 날짜 문자열('YYYY.MM.DD' 형식)을 moment를 사용하여 명시적으로 파싱하도록 수정하여 Invalid Date 에러 해결
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -29,7 +29,7 @@ const NiceCalendar = ({
|
||||
minDate: propMinDate,
|
||||
maxDate: propMaxDate
|
||||
}: NiceCalendarProps) => {
|
||||
const [valueDate, setValueDate] = useState<string>();
|
||||
const [valueDate, setValueDate] = useState<Date | undefined>();
|
||||
const [minDate, setMinDate] = useState<Date | undefined>();
|
||||
const [maxDate, setMaxDate] = useState<Date | undefined>();
|
||||
const onchangeToDate = (selectedDate: any) => {
|
||||
@@ -44,21 +44,21 @@ const NiceCalendar = ({
|
||||
if(calendarType === CalendarType.Start){
|
||||
setMinDate(propMinDate || undefined);
|
||||
if(!!endDate){
|
||||
setMaxDate(new Date(endDate));
|
||||
setMaxDate(moment(endDate, 'YYYY.MM.DD').toDate());
|
||||
}
|
||||
setValueDate(startDate);
|
||||
setValueDate(startDate ? moment(startDate, 'YYYY.MM.DD').toDate() : undefined);
|
||||
}
|
||||
else if(calendarType === CalendarType.End){
|
||||
if(!!startDate){
|
||||
setMinDate(new Date(startDate));
|
||||
setMinDate(moment(startDate, 'YYYY.MM.DD').toDate());
|
||||
}
|
||||
setMaxDate(propMaxDate || new Date());
|
||||
setValueDate(endDate);
|
||||
setValueDate(endDate ? moment(endDate, 'YYYY.MM.DD').toDate() : undefined);
|
||||
}
|
||||
else if(calendarType === CalendarType.Single){
|
||||
setMinDate(propMinDate || undefined);
|
||||
setMaxDate(propMaxDate || undefined);
|
||||
setValueDate(singleDate);
|
||||
setValueDate(singleDate ? moment(singleDate, 'YYYY.MM.DD').toDate() : undefined);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user