feat(frontend): add delete entry and update standby entry logic
All checks were successful
Docker Build and Publish / build-and-push (push) Successful in 33s
All checks were successful
Docker Build and Publish / build-and-push (push) Successful in 33s
This commit is contained in:
@@ -207,20 +207,25 @@ export const generateStandbyEntries = (startDateStr, endDateStr) => {
|
||||
const start = new Date(Date.UTC(sy, sm - 1, sd, 12, 0, 0));
|
||||
const end = new Date(Date.UTC(ey, em - 1, ed, 12, 0, 0));
|
||||
|
||||
// Check if multi-day range
|
||||
const isMultiDay = start.getTime() !== end.getTime();
|
||||
|
||||
// Loop from start to end
|
||||
for (let d = new Date(start); d <= end; d.setDate(d.getDate() + 1)) {
|
||||
// Create local date object for holiday checking (using getFullYear/getMonth/getDate)
|
||||
// We used UTC above for iteration safety, but need local context or consistent context for day checks.
|
||||
// detectDayType uses local methods.
|
||||
// Let's create a new Date object from the UTC components to treat it as "Local Noon" for checking.
|
||||
// Actually, detectDayType uses .getDay() which is local.
|
||||
// If we want consistency, we should ensure we are checking the "intended" date.
|
||||
// The simplistic approach:
|
||||
const checkDate = new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), 12, 0, 0);
|
||||
|
||||
const dateStr = d.toISOString().split('T')[0];
|
||||
const dayType = detectDayType(checkDate);
|
||||
const maxHours = getMaxStandbyHours(dayType);
|
||||
let maxHours = getMaxStandbyHours(dayType);
|
||||
|
||||
// Standby Logic Update: First and Last day get half value if multi-day
|
||||
// We compare timestamps of the current loop date 'd' with start/end
|
||||
if (isMultiDay) {
|
||||
if (d.getTime() === start.getTime() || d.getTime() === end.getTime()) {
|
||||
maxHours = maxHours / 2;
|
||||
}
|
||||
}
|
||||
|
||||
entries.push({
|
||||
date: dateStr,
|
||||
|
||||
Reference in New Issue
Block a user