Skip to content

Commit

Permalink
fix(edit-room): correct initial periodic room end date (#308)
Browse files Browse the repository at this point in the history
* refactor(edit-room): set room count precision to 0

* fix(edit-room): correct initial periodic room end date
  • Loading branch information
crimx authored Feb 19, 2021
1 parent 3ac29ca commit c7d84c5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/renderer-app/src/components/EditRoomPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Button, Checkbox, Input, Form, Divider, Modal } from "antd";
import { observer } from "mobx-react-lite";
import { Link, useHistory } from "react-router-dom";
import { CheckboxChangeEvent } from "antd/lib/checkbox";
import { getDay, addWeeks, endOfDay, addMinutes } from "date-fns";
import { getDay, addWeeks, endOfDay } from "date-fns";
import { generateRoutePath, RouteNameType } from "../../utils/routes";
import MainPageLayout from "../../components/MainPageLayout";
import { RoomTypeSelect } from "../../components/RoomType";
Expand Down Expand Up @@ -58,7 +58,7 @@ export const EditRoomPage = observer<EditRoomPageProps>(function EditRoomPage({
endType: PeriodicEndType.Rate,
weeks: [getDay(initialValues.beginTime)],
rate: 7,
endTime: addWeeks(addMinutes(initialValues.beginTime, 30), 6),
endTime: addWeeks(initialValues.beginTime, 6),
},
...initialValues,
};
Expand Down Expand Up @@ -237,7 +237,7 @@ export const EditRoomPage = observer<EditRoomPageProps>(function EditRoomPage({
periodic: {
weeks: [getDay(today)],
rate: 7,
endTime: endOfDay(addWeeks(today, 7)),
endTime: endOfDay(addWeeks(today, 6)),
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ export function renderPeriodicForm(
const {
beginTime,
periodic,
}: Pick<
EditRoomFormValues,
"beginTime" | "endTime" | "periodic"
> = form.getFieldsValue(["beginTime", "periodic"]);
}: Pick<EditRoomFormValues, "beginTime" | "periodic"> = form.getFieldsValue([
"beginTime",
"periodic",
]);
syncPeriodicEndAmount(form, beginTime, { ...periodic, rate });
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer-app/src/pages/UserScheduledPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const UserScheduledPage = observer(function UserScheduledPage() {
endType: PeriodicEndType.Rate,
weeks: [getDay(scheduleBeginTime)],
rate: 7,
endTime: addWeeks(addMinutes(scheduleBeginTime, 30), 6),
endTime: addWeeks(scheduleBeginTime, 6),
},
};
});
Expand Down

0 comments on commit c7d84c5

Please sign in to comment.