adjust panel iot page to match dashboard-cpsp page

This commit is contained in:
Alberto-Audrix committed 2026-10-05 15:10:53 +07:00
1 parent b5ee6b87f0
commit 04678ef773
2 files changed
+319 -209

No files matched your search

+28
View File
@@ -57,6 +57,34 @@ export function inclusiveDayCount(startIso: string, endIso: string): number {
return Math.max(1, cycleDayForDate(startIso, endIso) + 1);
}
/** Inclusive upper date for open cycles (null end_date) without producing NaN day math. */
export function resolveCycleBoundDate(cycle: {
start_date: string;
end_date?: string | null;
soft_end_date?: string | null;
visible_through_date?: string | null;
total_days?: number;
}): string {
if (cycle.end_date) return cycle.end_date;
if (cycle.soft_end_date) return cycle.soft_end_date;
if (cycle.visible_through_date) return cycle.visible_through_date;
if (cycle.total_days != null && cycle.total_days > 0) {
return addDaysIso(cycle.start_date, Math.max(cycle.total_days - 1, 0));
}
return todayIso();
}
/** 0-based last day index from start → bound date (safe when end_date is null). */
export function cycleLastDayIndex(cycle: {
start_date: string;
end_date?: string | null;
soft_end_date?: string | null;
visible_through_date?: string | null;
total_days?: number;
}): number {
return cycleDayForDate(cycle.start_date, resolveCycleBoundDate(cycle));
}
export type CycleStatusUi = 'active' | 'pending_close' | 'closed';
export function resolveCycleStatus(cycle: {