import { clsx, type ClassValue } from "clsx";

export function cn(...inputs: ClassValue[]) {
  return clsx(inputs);
}

export function formatRupiah(amount: number): string {
  return new Intl.NumberFormat("id-ID", {
    style: "currency",
    currency: "IDR",
    minimumFractionDigits: 0,
  }).format(amount);
}

export function formatDate(date: Date | string): string {
  return new Intl.DateTimeFormat("id-ID", {
    dateStyle: "long",
  }).format(new Date(date));
}

export function formatDateRange(
  start: Date | string,
  end?: Date | string | null
): string {
  const startStr = formatDate(start);
  if (!end) return startStr;
  const endStr = formatDate(end);
  return `${startStr} — ${endStr}`;
}
