Skip to content

Commit

Permalink
fix(flat-components): incorrect end time picker at same hour (#1981)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrious authored Aug 2, 2023
1 parent 911b2d0 commit cc77d5e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
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

0 comments on commit cc77d5e

Please sign in to comment.