New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add unavailable dates feature #45
add unavailable dates feature #45
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your PR. I propose some changes in the code review.
@@ -266,6 +268,7 @@ function Datepicker( | |||
scrollTopToMonthGrid() | |||
} | |||
|
|||
console.log('BLOCKED ARRAY', unavailableDates) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove console.log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sry, done
@@ -321,6 +325,8 @@ function Day({day, date}: DayProps) { | |||
[dayProps.isSelected, dayProps.isSelectedStartOrEnd, theme, dayProps.isWithinHoverRange], | |||
) | |||
|
|||
console.log('DAY', day) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove console.log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sry, done
@@ -76,6 +78,7 @@ function App({ | |||
} | |||
} | |||
|
|||
console.log('APP BLOCK', unavailableDates) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove console.log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sry, done
packages/hooks/src/useDay/useDay.ts
Outdated
|
||
function isInUnavailableDates(unavailableDates: Date[], date: Date) { | ||
let isBlocked = false | ||
unavailableDates.forEach(_date => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use reduce function instead forEach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
used a .some
packages/hooks/src/useDay/useDay.ts
Outdated
@@ -13,6 +14,7 @@ interface UseDayProps { | |||
onDateSelect(date: Date): void | |||
onDateHover(date: Date): void | |||
dayRef: React.RefObject<HTMLButtonElement> | |||
unavailableDates: Date[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prop should be optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
c8a31fc
to
87da71e
Compare
chore: add unavailableDates to useDate tests fix: fix comments chore: build chore: clean up
87da71e
to
dee83ba
Compare
Add
unavailableDates
prop to context that allows a consumer to supply an array of dates that can be marked as unavailable.work was mostly introduced here:
packages/styled/src/components/Day/Day.tsx
packages/hooks/src/useDay/useDay.ts
packages/styled/src/context/datepickerContext.ts