Skip to content

Commit

Permalink
fix: fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jeangovil authored and jongomez committed Oct 5, 2023
1 parent cdc6b5a commit 16363ee
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions packages/lsd-react/src/components/Calendar/Month.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ export const Month = ({
return date.getDate()
}

const getDay = (index: number) =>
days[index] as {
dayLabel: string
date: Date
}

useClickAway(ref, (event) => {
if (!changeYear) return

Expand Down Expand Up @@ -127,8 +133,8 @@ export const Month = ({
.map((_, idx) => (
<Day
date={new Date()}
day={renderOtherDays(idx - 7, days[0].date).toString()}
key={`feb-pad-${idx}`}
day={renderOtherDays(idx - 7, getDay(0).date).toString()}
key={`prev-${idx}`}
disabled={true}
/>
))}
Expand All @@ -137,12 +143,12 @@ export const Month = ({
<Day date={ele.date} day={ele.dayLabel} key={ele.dayLabel} />
) : (
<Day
date={days[idx + days.lastIndexOf(0) + 1].date}
date={getDay(idx + days.lastIndexOf(0) + 1).date}
day={renderOtherDays(
idx - days.filter((day) => day === 0).length,
days[days.lastIndexOf(0) + 1].date,
getDay(days.lastIndexOf(0) + 1).date,
).toString()}
key={`prev-${idx}`}
key={`current-${idx}`}
disabled={true}
/>
),
Expand All @@ -155,10 +161,10 @@ export const Month = ({
.fill(null)
.map((ele, idx) => (
<Day
date={days[idx + days.lastIndexOf(0) + 1].date}
date={getDay(idx + days.lastIndexOf(0) + 1).date}
day={renderOtherDays(
idx,
days[days.lastIndexOf(0) + 1].date,
getDay(days.lastIndexOf(0) + 1).date,
).toString()}
key={`after-${idx}`}
disabled={true}
Expand Down

0 comments on commit 16363ee

Please sign in to comment.