import type { JSX } from "solid-js";

export type Section = "overview" | "bookings" | "customers" | "zones" | "billing" | "settings" | "analytics";
export type BookingStatus = "confirmed" | "pending" | "cancelled";

export interface KpiData {
  label: string;
  value: number | string;
  change?: string;
  trend?: "up" | "down" | "neutral";
  icon: () => JSX.Element;
}

export const getInitials = (name?: string) =>
  (name ?? "User")
    .split(" ")
    .filter(Boolean)
    .slice(0, 2)
    .map((part) => part[0]?.toUpperCase() ?? "")
    .join("") || "U";

export const getBookingDuration = (startsAt?: string, endsAt?: string) => {
  if (!startsAt || !endsAt) return "60 min";
  const start = new Date(startsAt).getTime();
  const end = new Date(endsAt).getTime();
  if (Number.isNaN(start) || Number.isNaN(end) || end <= start) return "60 min";
  return `${Math.round((end - start) / 60000)} min`;
};
