Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
"transform": {
"^.+\\.(j|t)sx?$": "esbuild-jest"
},
"rootDir": "web/src"
"rootDir": "web/src",
"transformIgnorePatterns": [
"node_modules/(?!wouter)"
]
},
"standard": {
"parser": "babel-eslint",
Expand Down
7 changes: 1 addition & 6 deletions web/src/app/schedules/temp-sched/TempSchedShiftsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,7 @@ export default function TempSchedShiftsList({
zone,
handleCoverageGapClick,
)
const subheaderItems = getSubheaderItems(
schedInterval,
shifts,
shiftDur as Duration,
zone,
)
const subheaderItems = getSubheaderItems(schedInterval, shifts, zone)

const outOfBoundsItems = getOutOfBoundsItems(schedInterval, shifts, zone)

Expand Down
13 changes: 4 additions & 9 deletions web/src/app/schedules/temp-sched/shiftsListUtil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@ describe('getSubheaderItems', () => {
const schedInterval = Interval.fromISO(tc.schedIntervalISO, {
zone: tc.zone,
})
const result = getSubheaderItems(
schedInterval,
tc.shifts,
tc.shiftDuration as Duration,
tc.zone,
)
const result = getSubheaderItems(schedInterval, tc.shifts, tc.zone)

expect(result).toHaveLength(tc.expected.length)
expect(_.uniq(result.map((r) => r.id))).toHaveLength(tc.expected.length)
Expand Down Expand Up @@ -87,7 +82,7 @@ describe('getSubheaderItems', () => {
schedIntervalISO: `${'2021-08-13T00:00:00.000-05:00'}/${'2021-08-14T01:00:00.000-05:00'}`,
shifts: [],
shiftDuration: Duration.fromObject({ hours: 25 }),
expected: ['Friday, August 13'],
expected: ['Friday, August 13', 'Saturday, August 14'],
zone: chicago,
})

Expand All @@ -96,7 +91,7 @@ describe('getSubheaderItems', () => {
schedIntervalISO: `${'2021-08-13T00:00:00.000-05:00'}/${'2021-08-15T02:00:00.000-05:00'}`,
shifts: [],
shiftDuration: Duration.fromObject({ hours: 50 }),
expected: ['Friday, August 13'],
expected: ['Friday, August 13', 'Saturday, August 14', 'Sunday, August 15'],
zone: chicago,
})

Expand Down Expand Up @@ -177,7 +172,7 @@ describe('getSubheaderItems', () => {
},
],
shiftDuration: Duration.fromObject({ hours: 30 }),
expected: ['Friday, August 13', 'Saturday, August 14'],
expected: ['Friday, August 13', 'Saturday, August 14', 'Sunday, August 15'],
zone: chicago,
})
})
Expand Down
13 changes: 8 additions & 5 deletions web/src/app/schedules/temp-sched/shiftsListUtil.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export type Sortable<T> = T & {
export function getSubheaderItems(
schedInterval: Interval,
shifts: Shift[],
shiftDur: Duration,
zone: ExplicitZone,
): Sortable<FlatListSub>[] {
if (!schedInterval.isValid) {
Expand All @@ -49,10 +48,14 @@ export function getSubheaderItems(
...shifts.map((s) => DateTime.fromISO(s.end, { zone })),
)

const dayInvs = splitShift(
Interval.fromDateTimes(lowerBound, upperBound),
shiftDur,
)
const dayInvs: Interval[] = []
let currentDay = lowerBound.startOf('day')

while (currentDay < upperBound) {
const nextDay = currentDay.plus({ days: 1 })
dayInvs.push(Interval.fromDateTimes(currentDay, nextDay))
currentDay = nextDay
}

return dayInvs.map((day) => {
const at = day.start.startOf('day')
Expand Down
Loading