minor frontend changes

This commit is contained in:
2026-07-13 09:49:10 -04:00
parent 96a6309ff6
commit a772e47f42
4 changed files with 25 additions and 6 deletions
+2
View File
@@ -445,10 +445,12 @@ def get_schedule_week(start: str | None = None) -> dict[str, Any]:
week_start_date = datetime.strptime(week_start, "%Y-%m-%d").date() week_start_date = datetime.strptime(week_start, "%Y-%m-%d").date()
rows = db.get_schedule_week(week_start, DB_PATH) rows = db.get_schedule_week(week_start, DB_PATH)
all_rows = db.get_schedule_rows_for_latest_version(DB_PATH) all_rows = db.get_schedule_rows_for_latest_version(DB_PATH)
completion_date = max((row.scheduled_date for row in all_rows), default=None)
holiday_dates = db.list_holidays(DB_PATH) holiday_dates = db.list_holidays(DB_PATH)
return { return {
"start_date": week_start, "start_date": week_start,
"items": [_serialize_schedule_row(row) for row in rows], "items": [_serialize_schedule_row(row) for row in rows],
"completion_date": completion_date,
"windows": _build_schedule_windows(week_start_date, all_rows, holiday_dates), "windows": _build_schedule_windows(week_start_date, all_rows, holiday_dates),
} }
+1
View File
@@ -206,6 +206,7 @@ export default function App() {
const data = await api.getScheduleWeek(toKey(start)) const data = await api.getScheduleWeek(toKey(start))
setScheduleData(groupScheduleItems(data.items)) setScheduleData(groupScheduleItems(data.items))
setScheduleWindows(data.windows ?? []) setScheduleWindows(data.windows ?? [])
setCompletionDate(data.completion_date ?? null)
} catch (e) { } catch (e) {
console.error('Failed to fetch schedule:', e) console.error('Failed to fetch schedule:', e)
} }
+21 -5
View File
@@ -59,6 +59,7 @@ export default function Calendar({
windowLookup = new Map(), windowLookup = new Map(),
onWindowSelect, onWindowSelect,
}) { }) {
const DEFAULT_SHIFT_MIN_ROWS = 3
const SLOT_CHROME_PX = 10 const SLOT_CHROME_PX = 10
const TEST_CARD_ROW_HEIGHT_PX = 22 const TEST_CARD_ROW_HEIGHT_PX = 22
const TEST_CARD_ROW_GAP_PX = 2 const TEST_CARD_ROW_GAP_PX = 2
@@ -75,7 +76,11 @@ export default function Calendar({
// weekStart is Monday, so days[0]=Mon ... days[6]=Sun → put Sunday first // weekStart is Monday, so days[0]=Mon ... days[6]=Sun → put Sunday first
const orderedDays = [ ...days.slice(0, 7)] const orderedDays = [ ...days.slice(0, 7)]
const shiftMinRows = useMemo(() => { const shiftMinRows = useMemo(() => {
const minima = { shift2: 1, shift3: 1, nextDayShift1: 1 } const minima = {
shift2: DEFAULT_SHIFT_MIN_ROWS,
shift3: DEFAULT_SHIFT_MIN_ROWS,
nextDayShift1: DEFAULT_SHIFT_MIN_ROWS,
}
for (const date of orderedDays) { for (const date of orderedDays) {
const key = toDateKey(date) const key = toDateKey(date)
@@ -83,16 +88,16 @@ export default function Calendar({
const nextKey = toDateKey(addDays(date, 1)) const nextKey = toDateKey(addDays(date, 1))
const nextDayShift1 = scheduleData[nextKey]?.shift1 ?? [] const nextDayShift1 = scheduleData[nextKey]?.shift1 ?? []
minima.shift2 = Math.max(minima.shift2, shifts.shift2.length || 1) minima.shift2 = Math.max(minima.shift2, shifts.shift2.length || DEFAULT_SHIFT_MIN_ROWS)
minima.shift3 = Math.max(minima.shift3, shifts.shift3.length || 1) minima.shift3 = Math.max(minima.shift3, shifts.shift3.length || DEFAULT_SHIFT_MIN_ROWS)
minima.nextDayShift1 = Math.max(minima.nextDayShift1, nextDayShift1.length || 1) minima.nextDayShift1 = Math.max(minima.nextDayShift1, nextDayShift1.length || DEFAULT_SHIFT_MIN_ROWS)
} }
return minima return minima
}, [orderedDays, scheduleData]) }, [orderedDays, scheduleData])
const slotHeights = useMemo(() => { const slotHeights = useMemo(() => {
const calcSlotHeight = (rows) => { const calcSlotHeight = (rows) => {
const safeRows = Math.max(1, rows || 1) const safeRows = Math.max(DEFAULT_SHIFT_MIN_ROWS, rows || DEFAULT_SHIFT_MIN_ROWS)
const contentHeight = (safeRows * TEST_CARD_ROW_HEIGHT_PX) + ((safeRows - 1) * TEST_CARD_ROW_GAP_PX) const contentHeight = (safeRows * TEST_CARD_ROW_HEIGHT_PX) + ((safeRows - 1) * TEST_CARD_ROW_GAP_PX)
return contentHeight + SLOT_CHROME_PX return contentHeight + SLOT_CHROME_PX
} }
@@ -178,6 +183,17 @@ export default function Calendar({
<span className="absolute left-0 top-0">9AM</span> <span className="absolute left-0 top-0">9AM</span>
<span className="absolute left-0" style={{ top: `${slotHeights.shift2}px` }}>5PM</span> <span className="absolute left-0" style={{ top: `${slotHeights.shift2}px` }}>5PM</span>
<span className="absolute left-0" style={{ top: `${slotHeights.shift2 + slotHeights.shift3}px` }}>12AM</span> <span className="absolute left-0" style={{ top: `${slotHeights.shift2 + slotHeights.shift3}px` }}>12AM</span>
<span
className="absolute right-2 text-[10px] font-bold uppercase tracking-[0.16em] text-gray-600"
style={{
top: `${slotHeights.shift2 + slotHeights.shift3 + (slotHeights.nextDayShift1 / 2)}px`,
transform: 'translateY(-50%) rotate(180deg)',
writingMode: 'vertical-rl',
textOrientation: 'mixed',
}}
>
Next Day
</span>
</div> </div>
</div> </div>
+1 -1
View File
@@ -8,7 +8,7 @@ export default function ShiftSlot({
visible = true, visible = true,
active = false, active = false,
windowDetails = null, windowDetails = null,
minContentRows = 1, minContentRows = 3,
slotHeightPx = null, slotHeightPx = null,
onWindowSelect, onWindowSelect,
}) { }) {