"use client"; import { useState } from "react"; import type { AllocationConflictCheckResult } from "@nexus/shared"; const INITIAL_ROWS_SHOWN = 5; interface ConflictWarningPanelProps { result: AllocationConflictCheckResult; isLoading: boolean; acknowledged: boolean; onAcknowledge: (v: boolean) => void; } export function ConflictWarningPanel({ result, isLoading, acknowledged, onAcknowledge, }: ConflictWarningPanelProps) { const [showAllDays, setShowAllDays] = useState(false); if (isLoading) { return (
Checking availability…
); } const hasAny = result.isOverbooking || result.hasVacationOverlap; if (!hasAny) return null; const conflictDays = result.overbooking?.conflictDays ?? []; const visibleDays = showAllDays ? conflictDays : conflictDays.slice(0, INITIAL_ROWS_SHOWN); const hiddenCount = conflictDays.length - INITIAL_ROWS_SHOWN; return (
{/* ── Overbooking ─────────────────────────────────────────────── */} {result.isOverbooking && result.overbooking && (

⚠ Overbooking on {result.overbooking.totalConflictDays} day {result.overbooking.totalConflictDays !== 1 ? "s" : ""} (up to{" "} {result.overbooking.maxOverbookPercent}% over capacity)

The resource already has allocations that exceed their daily capacity on the following days. You can still save — check the box below to confirm.

{/* Day-by-day table */}
{visibleDays.map((day) => ( ))}
Date Capacity Booked New Over
{day.date} {day.availableHours}h {day.existingHours}h {day.requestedHours}h +{day.overageHours.toFixed(1)}h
{hiddenCount > 0 && ( )} {/* Acknowledgment checkbox */}
)} {/* ── Vacation overlap ─────────────────────────────────────────── */} {result.hasVacationOverlap && (

ℹ Resource has approved leave during this period

Vacation days are excluded from billable hours and daily cost calculations.

)}
); }