import { BookingStatus } from '../../entities/booking.entity';

/**
 * Booking list `status` filter: one status or several comma-separated
 * (Invoices page: "upcoming,ongoing,completed"). Unknown values are
 * dropped, duplicates removed. Empty input → no filter (null); only
 * unknown values → [] (matches nothing).
 */
export function parseStatusFilter(raw: string | null | undefined): string[] | null {
  if (!raw || !raw.trim()) return null;
  const allowed = Object.values(BookingStatus) as string[];
  return [
    ...new Set(
      raw
        .split(',')
        .map((x) => x.trim())
        .filter((x) => allowed.includes(x)),
    ),
  ];
}
