// Utility to calculate order status based on current state
export function calculateOrderStatus(event) {
  // Check explicit statuses first
  if (event.status === "CANCELLED" || event.status === "CANCELLED") {
    return "CANCELLED";
  }
  
  if (event.status === "DRAFT") {
    return "DRAFT";
  }
  
  if (event.status === "COMPLETED") {
    return "COMPLETED";
  }
  
  // Calculate status based on staffing
  const requested = event.requested || 0;
  const assigned = event.assigned_staff?.length || 0;
  
  if (requested === 0) {
    return "DRAFT"; // No staff requested yet
  }
  
  if (assigned === 0) {
    return "PENDING"; // Awaiting assignment
  }
  
  if (assigned < requested) {
    return "PARTIAL"; // Partially staffed
  }
  
  if (assigned >= requested) {
    return "CONFIRMED"; // Fully staffed
  }

  return "PENDING";
}