@@ -60,20 +60,14 @@ const Days: React.FC<Props> = ({
6060 let className = "" ;
6161
6262 if ( dayjs ( fullDay ) . isSame ( period . start ) && dayjs ( fullDay ) . isSame ( period . end ) ) {
63- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
64- // @ts -ignore
6563 className = ` ${ BG_COLOR [ "500" ] [ primaryColor ] } text-white font-medium rounded-full` ;
6664 } else if ( dayjs ( fullDay ) . isSame ( period . start ) ) {
67- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
68- // @ts -ignore
6965 className = ` ${ BG_COLOR [ "500" ] [ primaryColor ] } text-white font-medium ${
7066 dayjs ( fullDay ) . isSame ( dayHover ) && ! period . end
7167 ? "rounded-full"
7268 : "rounded-l-full"
7369 } `;
7470 } else if ( dayjs ( fullDay ) . isSame ( period . end ) ) {
75- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
76- // @ts -ignore
7771 className = ` ${ BG_COLOR [ "500" ] [ primaryColor ] } text-white font-medium ${
7872 dayjs ( fullDay ) . isSame ( dayHover ) && ! period . start
7973 ? "rounded-full"
@@ -97,46 +91,30 @@ const Days: React.FC<Props> = ({
9791 } `;
9892
9993 if ( period . start && period . end ) {
100- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
101- // @ts -ignore
10294 if ( dayjs ( fullDay ) . isBetween ( period . start , period . end , "day" , "[)" ) ) {
103- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
104- // @ts -ignore
10595 return ` ${ BG_COLOR [ "100" ] [ primaryColor ] } ${ currentDateClass (
10696 day
10797 ) } dark:bg-white/10`;
10898 }
10999 }
110100
111101 if ( ! dayHover ) {
112- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
113- // @ts -ignore
114102 return className ;
115103 }
116104
117- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
118- // @ts -ignore
119105 if ( period . start && dayjs ( fullDay ) . isBetween ( period . start , dayHover , "day" , "[)" ) ) {
120- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
121- // @ts -ignore
122106 className = ` ${ BG_COLOR [ "100" ] [ primaryColor ] } ${ currentDateClass (
123107 day
124108 ) } dark:bg-white/10`;
125109 }
126110
127- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
128- // @ts -ignore
129111 if ( period . end && dayjs ( fullDay ) . isBetween ( dayHover , period . end , "day" , "[)" ) ) {
130- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
131- // @ts -ignore
132112 className = ` ${ BG_COLOR [ "100" ] [ primaryColor ] } ${ currentDateClass (
133113 day
134114 ) } dark:bg-white/10`;
135115 }
136116
137117 if ( dayHover === fullDay ) {
138- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
139- // @ts -ignore
140118 const bgColor = BG_COLOR [ "500" ] [ primaryColor ] ;
141119 className = ` transition-all duration-500 text-white font-medium ${ bgColor } ${
142120 period . start ? "rounded-r-full" : "rounded-l-full"
@@ -149,7 +127,7 @@ const Days: React.FC<Props> = ({
149127 ) ;
150128
151129 const isDateTooEarly = useCallback (
152- ( day : number , type : string ) => {
130+ ( day : number , type : "current" | "previous" | "next" ) => {
153131 if ( ! minDate ) {
154132 return false ;
155133 }
@@ -159,18 +137,16 @@ const Days: React.FC<Props> = ({
159137 next : nextMonth ( calendarData . date )
160138 } ;
161139 const newDate = object [ type as keyof typeof object ] ;
162- const formattedDate = `${ newDate . year ( ) } -${ newDate . month ( ) + 1 } -${
163- day >= 10 ? day : "0" + day
164- } `;
165- return dayjs ( formattedDate ) . isSame ( dayjs ( minDate ) )
140+ const formattedDate = newDate . set ( "date" , day ) ;
141+ return dayjs ( formattedDate ) . isSame ( dayjs ( minDate ) , "day" )
166142 ? false
167143 : dayjs ( formattedDate ) . isBefore ( dayjs ( minDate ) ) ;
168144 } ,
169145 [ calendarData . date , minDate ]
170146 ) ;
171147
172148 const isDateTooLate = useCallback (
173- ( day : number , type : string ) => {
149+ ( day : number , type : "current" | "previous" | "next" ) => {
174150 if ( ! maxDate ) {
175151 return false ;
176152 }
@@ -180,18 +156,16 @@ const Days: React.FC<Props> = ({
180156 next : nextMonth ( calendarData . date )
181157 } ;
182158 const newDate = object [ type as keyof typeof object ] ;
183- const formattedDate = `${ newDate . year ( ) } -${ newDate . month ( ) + 1 } -${
184- day >= 10 ? day : "0" + day
185- } `;
186- return dayjs ( formattedDate ) . isSame ( maxDate )
159+ const formattedDate = newDate . set ( "date" , day ) ;
160+ return dayjs ( formattedDate ) . isSame ( dayjs ( maxDate ) , "day" )
187161 ? false
188162 : dayjs ( formattedDate ) . isAfter ( dayjs ( maxDate ) ) ;
189163 } ,
190164 [ calendarData . date , maxDate ]
191165 ) ;
192166
193167 const isDateDisabled = useCallback (
194- ( day : number , type : string ) => {
168+ ( day : number , type : "current" | "previous" | "next" ) => {
195169 if ( isDateTooEarly ( day , type ) || isDateTooLate ( day , type ) ) {
196170 return true ;
197171 }
@@ -230,7 +204,7 @@ const Days: React.FC<Props> = ({
230204 ) ;
231205
232206 const buttonClass = useCallback (
233- ( day : number , type : string ) => {
207+ ( day : number , type : "current" | "previous" | "next" ) => {
234208 const baseClass = "flex items-center justify-center w-12 h-12 lg:w-10 lg:h-10" ;
235209 return cn (
236210 baseClass ,
0 commit comments