Skip to content

Commit

Permalink
fix(ZMS-3466): closing new opening hours
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Fink authored and Thomas Fink committed Jan 28, 2025
1 parent 484cbb4 commit e92684e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
5 changes: 0 additions & 5 deletions zmsadmin/js/page/availabilityDay/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,11 @@ export const getNewAvailability = (timestamp, tempId, scope, existingAvailabilit
const dayEndTime = moment('22:00:00', 'HH:mm:ss')
let startTime = moment('07:00:00', 'HH:mm:ss')

// Only use current time if the selected date is today
if (now.format('YYYY-MM-DD') === currentTime.format('YYYY-MM-DD') && currentTime.isAfter(startTime)) {
// Round up to next half hour
startTime = moment(currentTime).add(30 - (currentTime.minutes() % 30), 'minutes')
}
let endTime = moment(startTime).add(1, 'hour')

// Adjust if end time would exceed 22:00
if (endTime.isAfter(dayEndTime)) {
startTime = moment(dayEndTime).subtract(1, 'hour')
endTime = moment(dayEndTime)
Expand All @@ -134,13 +131,11 @@ export const getNewAvailability = (timestamp, tempId, scope, existingAvailabilit
} else {
const lastAvail = todayAvailabilities[todayAvailabilities.length - 1]
startTime = moment(lastAvail.endTime, 'HH:mm:ss')
// Only check current time if it's today
if (now.format('YYYY-MM-DD') === currentTime.format('YYYY-MM-DD') && startTime.isBefore(currentTime)) {
startTime = moment(currentTime).add(30 - (currentTime.minutes() % 30), 'minutes')
}
endTime = moment(startTime).add(1, 'hour')

// Check end time limit again after adjusting for overlaps
if (endTime.isAfter(dayEndTime)) {
startTime = moment(dayEndTime).subtract(1, 'hour')
endTime = moment(dayEndTime)
Expand Down
8 changes: 2 additions & 6 deletions zmsadmin/js/page/availabilityDay/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,12 +458,8 @@ class AvailabilityPage extends Component {
state.stateChanged = false;

this.setState(state, () => {
Promise.all([
this.getValidationList(),
this.getConflictList()
]).then(() => {
this.setState({ selectedAvailability: null });
});
this.getValidationList();
this.getConflictList();

$('body').scrollTop(0);
});
Expand Down

0 comments on commit e92684e

Please sign in to comment.