Skip to content
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

Merged
merged 2 commits into from Dec 23, 2019

Conversation

rarescrisan
Copy link

@rarescrisan rarescrisan commented Dec 21, 2019

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

@rarescrisan rarescrisan changed the title add unavaiable dates feature add unavailable dates feature Dec 21, 2019
Copy link
Collaborator

@tresko tresko left a 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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove console.log

Copy link
Author

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove console.log

Copy link
Author

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove console.log

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sry, done


function isInUnavailableDates(unavailableDates: Date[], date: Date) {
let isBlocked = false
unavailableDates.forEach(_date => {
Copy link
Collaborator

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used a .some

@@ -13,6 +14,7 @@ interface UseDayProps {
onDateSelect(date: Date): void
onDateHover(date: Date): void
dayRef: React.RefObject<HTMLButtonElement>
unavailableDates: Date[]
Copy link
Collaborator

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@rarescrisan rarescrisan force-pushed the @rarescrisan/add-unavailable-dates branch from c8a31fc to 87da71e Compare December 23, 2019 15:21
chore: add unavailableDates to useDate tests

fix: fix comments

chore: build

chore: clean up
@rarescrisan rarescrisan force-pushed the @rarescrisan/add-unavailable-dates branch from 87da71e to dee83ba Compare December 23, 2019 15:25
@tresko tresko merged commit 3d147cc into t0gre:master Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants