22
33import { MobileIconArrowLeftGray , MobileIconArrowRightGray } from "@setaday/icon" ;
44import { useState } from "react" ;
5- import { DAY , MAX_DATE , MONTH_NAMES } from "../../constants/selectDateConst" ;
5+ import { DAY , MAX_DATE , MONTH_NAMES , TODAYS_MONTH , TODAYS_YEAR } from "../../constants/selectDateConst" ;
66import type { ClickDateProps , SelctDateCalendarProps , SelectedDateType } from "../../type/selectedDateType" ;
77import { getCalendarDate } from "../../utils/getCalendarDate" ;
88
99function SelectDateCalendar ( { selectedDateNum, selectedDate, handleSelectDate } : SelctDateCalendarProps ) {
10- const [ year , setYear ] = useState ( new Date ( ) . getFullYear ( ) ) ;
11- const [ month , setMonth ] = useState ( new Date ( ) . getMonth ( ) + 1 ) ;
10+ const [ year , setYear ] = useState ( TODAYS_YEAR ) ;
11+ const [ month , setMonth ] = useState ( TODAYS_MONTH ) ;
1212
1313 const ALL_DATE = getCalendarDate ( { year, month } ) ;
1414
@@ -249,8 +249,9 @@ function SelectDateCalendar({ selectedDateNum, selectedDate, handleSelectDate }:
249249
250250 < div className = "grid grid-cols-7 grid-rows-5 gap-y-[1.8rem]" >
251251 { ALL_DATE . map ( ( { id, date, color } ) =>
252- date . map ( ( curDate ) => {
253- const isActiveClick = id === "currentDate" ;
252+ date . map ( ( curDate , idx ) => {
253+ const isActiveClick = id === "validDate" ;
254+
254255 const idxOfStartDate = selectedDate . findIndex (
255256 ( { startDate, startMonth, startYear } ) =>
256257 startDate === curDate && startMonth === month && startYear === year
@@ -286,10 +287,11 @@ function SelectDateCalendar({ selectedDateNum, selectedDate, handleSelectDate }:
286287 const isRightSelection = ! ! ( matchedObj && matchedObj . endDate > 0 && matchedObj . startDate > 0 ) ;
287288
288289 return (
289- // biome-ignore lint/a11y/useKeyWithClickEvents: <explanation>
290- < div
291- key = { id + curDate }
290+ < button
291+ // biome-ignore lint/suspicious/noArrayIndexKey: <explanation>
292+ key = { id + curDate + idx }
292293 className = "flex items-center justify-center relative"
294+ type = "button"
293295 onClick = { ( ) =>
294296 isActiveClick &&
295297 ! isInRange &&
@@ -315,7 +317,7 @@ function SelectDateCalendar({ selectedDateNum, selectedDate, handleSelectDate }:
315317 >
316318 { curDate }
317319 </ p >
318- </ div >
320+ </ button >
319321 ) ;
320322 } )
321323 ) }
0 commit comments