11import dayjs from "dayjs" ;
22import { useMemo } from "react" ;
3- import { DAYS_IN_WEEK , MIN_COUNT , WEEKEND_DAYS } from "./constants" ;
4- import type { CalendarDayCell , CalendarMatrixResult } from "./types" ;
3+ import { DAYS_IN_WEEK } from "./constants" ;
4+ import type { CalendarData , CalendarDayCell , CalendarMatrixResult } from "./types" ;
55
66export interface UseCalendarMatrixParams {
77 month : string ;
8- data : Record < string , number > ;
8+ data : CalendarData ;
99 weekDays : string [ ] ;
1010 weekStartDayOffset : number ;
1111 today : string ;
@@ -15,7 +15,7 @@ export interface UseCalendarMatrixParams {
1515const createCalendarDayCell = (
1616 current : dayjs . Dayjs ,
1717 monthKey : string ,
18- data : Record < string , number > ,
18+ data : CalendarData ,
1919 today : string ,
2020 selectedDate : string ,
2121) : CalendarDayCell => {
@@ -30,7 +30,6 @@ const createCalendarDayCell = (
3030 isCurrentMonth,
3131 isToday : isoDate === today ,
3232 isSelected : isoDate === selectedDate ,
33- isWeekend : WEEKEND_DAYS . includes ( current . day ( ) as 0 | 6 ) ,
3433 } ;
3534} ;
3635
@@ -68,7 +67,6 @@ export const useCalendarMatrix = ({
6867 const { calendarStart, dayCount } = calculateCalendarBoundaries ( monthStart , weekStartDayOffset ) ;
6968
7069 const weeks : CalendarMatrixResult [ "weeks" ] = [ ] ;
71- let maxCount = 0 ;
7270
7371 // Iterate through each day in the calendar grid
7472 for ( let index = 0 ; index < dayCount ; index += 1 ) {
@@ -82,13 +80,11 @@ export const useCalendarMatrix = ({
8280 // Create the day cell object with data and status flags
8381 const dayCell = createCalendarDayCell ( current , monthKey , data , today , selectedDate ) ;
8482 weeks [ weekIndex ] . days . push ( dayCell ) ;
85- maxCount = Math . max ( maxCount , dayCell . count ) ;
8683 }
8784
8885 return {
8986 weeks,
9087 weekDays : rotatedWeekDays ,
91- maxCount : Math . max ( maxCount , MIN_COUNT ) ,
9288 } ;
9389 } , [ month , data , weekDays , weekStartDayOffset , today , selectedDate ] ) ;
9490} ;
0 commit comments