/**
 * Service customers types (`/customers`).
 *
 * These mirror the backend Prisma schema and the three customers controllers
 * exactly — the backend is the source of truth. Notable constraints baked in
 * here so callers can't get them wrong:
 *
 * - The Admin owns the customers: it creates `WashPackage` rows and the price
 *   range each one may be sold at. A Provider does NOT create services — it
 *   opts into an admin package and picks its own price inside that range
 *   (`ProviderService`). See `Notes/requitements/01_changes.txt`.
 * - The backend runs `ValidationPipe({ forbidNonWhitelisted: true })`, so any
 *   unknown query/body key returns 400. Request types are therefore closed —
 *   don't add convenience fields the API doesn't declare.
 * - Neither list endpoint has a sort parameter (both hardcode
 *   `orderBy: { name: 'asc' }`), which is why the params types have no sort
 *   field and the list columns aren't marked `sortable`.
 * - `isActive` is settable only at the DB level: `UpdateWashPackageDto` has no
 *   `isActive` field and there is no activate/deactivate endpoint, so the UI
 *   reads and filters it but never writes it.
 * - There is no `nameAr`/`descriptionAr` — a package has ONE name and ONE
 *   description, rendered as typed in both languages.
 */

// ─── Shared ──────────────────────────────────────────────────────────────────

/**
 * A customers wash package, as returned raw by the admin and customer endpoints.
 *
 * `icon` is a free-text identifier chosen by the frontend (the backend's own
 * DTO examples are `exterior_wash` / `internal_external_wash`), NOT a URL —
 * see `lib/constants/package-icons.ts` for the identifier → glyph map.
 *
 * Soft delete mangles `name` with a `[DELETED-<timestamp>]` suffix to free the
 * unique constraint, so a row with `isDeleted: true` must never be shown by
 * name. The list endpoints already filter them out.
 */

export interface WashCustomers {
  id: string;
  firstName: string;
  lastName: string;
  email: string;
  phoneNumber: string | null;
  icon: string | null;
  isActive: boolean;
  isDeleted: boolean;
  createdAt: string;
  updatedAt: string;
  data: {
    id: string;
    firstName: string;
    lastName: string;
    email: string;
    phoneNumber: string | null;
    icon: string | null;
    isActive: boolean;
    isDeleted: boolean;
    createdAt: string;
    updatedAt: string;
  } | null;
}

// ─── Admin list ──────────────────────────────────────────────────────────────

/** Query accepted by `GET /users/admin/customers` — every field optional */
export interface AdminCustomersListParams {
  /** Matches `name` only (contains, case-insensitive) */
  search?: string;
  /**
   * Backend reads this as the STRING "true"/"false" (`@IsBooleanString`) — the
   * api layer stringifies it, callers pass a real boolean.
   */
  isActive?: boolean;
  /** 1-based */
  page?: number;
  limit?: number;
}

export interface AdminCustomersListResponse {
  data: WashCustomers[];
  total: number;
  page: number;
  limit: number;
}
