Skip to content

Commit

Permalink
Minor updates to schedule rotation form and preview (#2316)
Browse files Browse the repository at this point in the history
- When editing a shift, use `shiftStart` as `rotationStart` value
(originally, `rotationStart` was most of the time the timestamp of
creation, which is confusing in the new form; otoh, for newly created
shifts, the `shiftStart` will match `rotationStart`)
- Since shift preview is requested starting the day before the start of
the week, sometimes the displayed preview is missing the last day of the
week (preview returns 7 days by default)
  • Loading branch information
matiasb authored Jun 23, 2023
1 parent edec623 commit d4dff87
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/containers/RotationForm/RotationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,11 @@ const RotationForm = observer((props: RotationFormProps) => {
useEffect(() => {
if (shift) {
setRotationName(getShiftName(shift));
const rotationStart = getDateTime(shift.rotation_start);
setRotationStart(rotationStart);
setRotationEnd(shift.until ? getDateTime(shift.until) : getDateTime(shift.shift_start).add(1, 'month'));
const shiftStart = getDateTime(shift.shift_start);
// use shiftStart as rotationStart for existing shifts
// (original rotationStart defaulted to the shift creation timestamp)
setRotationStart(shiftStart);
setRotationEnd(shift.until ? getDateTime(shift.until) : getDateTime(shift.shift_start).add(1, 'month'));
setShiftStart(shiftStart);
const shiftEnd = getDateTime(shift.shift_end);
setShiftEnd(shiftEnd);
Expand Down
2 changes: 1 addition & 1 deletion src/models/schedule/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export class ScheduleStore extends BaseStore {
const dayBefore = startMoment.subtract(1, 'day');

const response = await makeRequest(`/oncall_shifts/preview/`, {
params: { date: getFromString(dayBefore) },
params: { date: getFromString(dayBefore), days: 8 },
data: { type, schedule: scheduleId, shift_pk: shiftId === 'new' ? undefined : shiftId, ...params },
method: 'POST',
});
Expand Down

0 comments on commit d4dff87

Please sign in to comment.