2
2
3
3
import { MobileIconArrowLeftGray , MobileIconArrowRightGray } from "@setaday/icon" ;
4
4
import { 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" ;
6
6
import type { ClickDateProps , SelctDateCalendarProps , SelectedDateType } from "../../type/selectedDateType" ;
7
7
import { getCalendarDate } from "../../utils/getCalendarDate" ;
8
8
9
9
function 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 ) ;
12
12
13
13
const ALL_DATE = getCalendarDate ( { year, month } ) ;
14
14
@@ -249,8 +249,9 @@ function SelectDateCalendar({ selectedDateNum, selectedDate, handleSelectDate }:
249
249
250
250
< div className = "grid grid-cols-7 grid-rows-5 gap-y-[1.8rem]" >
251
251
{ 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
+
254
255
const idxOfStartDate = selectedDate . findIndex (
255
256
( { startDate, startMonth, startYear } ) =>
256
257
startDate === curDate && startMonth === month && startYear === year
@@ -286,10 +287,11 @@ function SelectDateCalendar({ selectedDateNum, selectedDate, handleSelectDate }:
286
287
const isRightSelection = ! ! ( matchedObj && matchedObj . endDate > 0 && matchedObj . startDate > 0 ) ;
287
288
288
289
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 }
292
293
className = "flex items-center justify-center relative"
294
+ type = "button"
293
295
onClick = { ( ) =>
294
296
isActiveClick &&
295
297
! isInRange &&
@@ -315,7 +317,7 @@ function SelectDateCalendar({ selectedDateNum, selectedDate, handleSelectDate }:
315
317
>
316
318
{ curDate }
317
319
</ p >
318
- </ div >
320
+ </ button >
319
321
) ;
320
322
} )
321
323
) }
0 commit comments