-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
83 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import dayjs, { Dayjs } from "dayjs"; | ||
import { flatten } from "lodash"; | ||
import getDayListItemBlocks from "./day-list.item.blocks"; | ||
|
||
/** | ||
* Get range of days from today (inclusive) for the next `len` working days (defined as Mon-Fri). | ||
*/ | ||
const dayRange = (len: number, days: Dayjs[] = [], i = 0): Dayjs[] => { | ||
if (i >= len) { | ||
return days; | ||
} | ||
|
||
if (days.length === 0) { | ||
days.push(dayjs()); | ||
return dayRange(len, days, i + 1); | ||
} | ||
|
||
const prevDate = days.at(-1); | ||
const prevDay = prevDate.day(); | ||
// Skip Saturdays (day 6) and Sundays (day 0). | ||
const daysToAdd = prevDay === 5 ? 3 : prevDay === 6 ? 2 : 1; | ||
days.push(prevDate.add(daysToAdd, "d")); | ||
|
||
return dayRange(len, days, i + 1); | ||
}; | ||
|
||
const getDayListBlocks = () => { | ||
const dates = dayRange(14); | ||
const blockLists = dates.map((date) => getDayListItemBlocks({ date })); | ||
return flatten(blockLists); | ||
}; | ||
|
||
export default getDayListBlocks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import devTools from "../../dev/dev-tools"; | ||
import getDayListBlocks from "./day-list.blocks"; | ||
|
||
const getHomeTabBlocks = () => [ | ||
...devTools, | ||
{ | ||
type: "header", | ||
text: { | ||
type: "plain_text", | ||
text: "Ilmoittautumiset", | ||
}, | ||
}, | ||
...getDayListBlocks(), | ||
]; | ||
|
||
export default getHomeTabBlocks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters