Skip to content
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

fix(flat-components): incorrect end time picker at same hour #1981

Merged
merged 1 commit into from
Aug 2, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export function renderBeginTimePicker(
const { endTime, periodic }: Pick<EditRoomFormValues, "endTime" | "periodic"> =
form.getFieldsValue(["endTime", "periodic"]);

const compareTime = addMinutes(beginTime, MIN_CLASS_DURATION);
const compareTime = addMinutes(beginTime, MIN_CLASS_DURATION * 2);

if (compareMinute(endTime, compareTime) < 0) {
form.setFieldsValue({ endTime: compareTime });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,10 @@ export function renderEndTimePicker(
form.getFieldsValue(["beginTime", "endTime"]);

const compareTime = addMinutes(beginTime, MIN_CLASS_DURATION);

const diff = compareDay(compareTime, endTime);

if (nextPeriodicRoomEndTime) {
const nextPeriodicEndTime = new Date(nextPeriodicRoomEndTime);
const compareTime = addMinutes(beginTime, MIN_CLASS_DURATION);
const diff = compareDay(compareTime, endTime);
const endDiff = compareDay(nextPeriodicEndTime, endTime);

if (diff < 0) {
Expand Down Expand Up @@ -99,24 +96,20 @@ export function renderEndTimePicker(

if (nextPeriodicRoomEndTime) {
const nextPeriodicEndTime = new Date(nextPeriodicRoomEndTime);
const comparedTime = addMinutes(beginTime, MIN_CLASS_DURATION);
const selectedEndTime = setHours(endTime, selectedHour);

const diff = compareDay(comparedTime, selectedEndTime);
const sameHour = selectedHour === nextPeriodicEndTime.getHours();
const endDiff = compareHour(nextPeriodicEndTime, endTime);

if (diff < 0) {
if (sameHour) {
return excludeRange(nextPeriodicEndTime.getMinutes(), 59);
if (endDiff === 0) {
return excludeRange(nextPeriodicEndTime.getMinutes() + 1, 59);
}
return [];
}

if (diff === 0) {
if (sameHour) {
return excludeRange(nextPeriodicEndTime.getMinutes(), 59);
if (endDiff === 0) {
return excludeRange(nextPeriodicEndTime.getMinutes() + 1, 59);
}
return [];
return excludeRange(comparedTime.getMinutes());
}

return excludeRange(59);
Expand Down