-
Notifications
You must be signed in to change notification settings - Fork 52
✨ Feat(web): Add move to next/prev week/month shortcuts for someday event #559
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -375,3 +375,48 @@ export const setEventStartEndDatesToCurrentMonth = ( | |
| endDate: monthEnd.format(), | ||
| }; | ||
| }; | ||
|
|
||
| export const setEventStartEndDates = ( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you rename this so it doesn't start with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes makes sense, thanks for pointing this out. |
||
| to: { | ||
| direction: "prev" | "next" | "current"; | ||
| duration: "week" | "month"; | ||
| }, | ||
| event: Schema_Event, | ||
| ): Schema_Event => { | ||
| const reference = | ||
| to.direction === "current" ? dayjs(new Date()) : dayjs(event.startDate); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious, why use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uhhhh no particular reason, I guess I was used to it but now after reading your comment I realized that the latter is the better practice, thanks for the headsup |
||
|
|
||
| let start: Dayjs; | ||
| let end: Dayjs; | ||
|
|
||
| if (to.duration === "week") { | ||
| start = reference.startOf("week"); | ||
| end = reference.endOf("week"); | ||
|
|
||
| if (to.direction === "prev") { | ||
| start = start.subtract(1, "week"); | ||
| end = end.subtract(1, "week"); | ||
| } else if (to.direction === "next") { | ||
| start = start.add(1, "week"); | ||
| end = end.add(1, "week"); | ||
| } | ||
| } else { | ||
| // duration is month | ||
| start = reference.startOf("month"); | ||
| end = reference.endOf("month"); | ||
|
|
||
| if (to.direction === "prev") { | ||
| start = start.subtract(1, "month"); | ||
| end = end.subtract(1, "month"); | ||
| } else if (to.direction === "next") { | ||
| start = start.add(1, "month"); | ||
| end = end.add(1, "month"); | ||
| } | ||
| } | ||
|
|
||
| return { | ||
| ...event, | ||
| startDate: start.format(), | ||
| endDate: end.format(), | ||
| }; | ||
| }; | ||
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.
Let's add some unit tests for this, as I'm already seeing some bugs with its implementation
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.
For sure, but can you share what bugs did you stumble upon?
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.
#560
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.
#561