// Static mock data shared across user, driver, admin shells.
// No persistence; edits are local component state only.

export type ServiceKey = "remorquage" | "assistance" | "carburant" | "concessionnaire";

export type RequestStatus = "en_recherche" | "en_route" | "arrive" | "termine" | "annule";

export type Request = {
  id: string;
  service: ServiceKey;
  vehicle: string;
  plate: string;
  address: string;
  wilaya: string;
  price: number; // DZD
  status: RequestStatus;
  createdAt: string;
  clientName: string;
  clientPhone: string;
  driverId?: string;
  rated?: boolean;
  rating?: number;
};

export type Driver = {
  id: string;
  name: string;
  phone: string;
  rating: number;
  plate: string;
  truck: "plateau" | "treuil";
  status: "en_ligne" | "hors_ligne" | "en_mission";
  verified: "verifie" | "en_attente" | "refuse";
  wilaya: string;
  jobs: number;
};

export type User = {
  id: string;
  name: string;
  phone: string;
  wilaya: string;
  createdAt: string;
  requests: number;
};

export type SupportCall = {
  id: string;
  phone: string;
  wilaya: string;
  reason: string;
  createdAt: string;
  handled: boolean;
};

export type Report = {
  id: string;
  requestId: string;
  clientName: string;
  reason: string;
  createdAt: string;
  handled: boolean;
};

export const SERVICES: { key: ServiceKey; fr: string; ar: string; category: "urgence" | "logistique" }[] = [
  { key: "remorquage", fr: "Remorquage", ar: "قطر السيارة", category: "urgence" },
  { key: "assistance", fr: "Assistance routière", ar: "النجدة على الطريق", category: "urgence" },
  { key: "carburant", fr: "Ravitaillement carburant", ar: "توصيل الوقود", category: "urgence" },
  { key: "concessionnaire", fr: "Transport concessionnaire", ar: "نقل من الوكيل", category: "logistique" },
];

export const WILAYAS = ["Alger", "Oran", "Constantine", "Annaba", "Blida", "Sétif", "Béjaïa", "Tizi Ouzou"];

export const DRIVERS: Driver[] = [
  { id: "d1", name: "Karim Bencheikh", phone: "0555 12 34 56", rating: 4.9, plate: "16-00123-115", truck: "plateau", status: "en_ligne", verified: "verifie", wilaya: "Alger", jobs: 342 },
  { id: "d2", name: "Mohamed Amine", phone: "0661 22 33 44", rating: 4.7, plate: "31-11908-116", truck: "treuil", status: "en_mission", verified: "verifie", wilaya: "Oran", jobs: 187 },
  { id: "d3", name: "Yacine Belkacem", phone: "0770 55 66 77", rating: 4.8, plate: "25-99087-117", truck: "plateau", status: "hors_ligne", verified: "verifie", wilaya: "Constantine", jobs: 96 },
  { id: "d4", name: "Sofiane Mahdi", phone: "0555 88 99 00", rating: 0, plate: "16-45632-118", truck: "treuil", status: "hors_ligne", verified: "en_attente", wilaya: "Blida", jobs: 0 },
  { id: "d5", name: "Rachid Khelifi", phone: "0661 11 22 33", rating: 3.9, plate: "23-77812-116", truck: "plateau", status: "hors_ligne", verified: "refuse", wilaya: "Annaba", jobs: 12 },
];

export const REQUESTS: Request[] = [
  { id: "r1001", service: "remorquage", vehicle: "Renault Symbol 2018", plate: "16-11223-115", address: "Rue Didouche Mourad", wilaya: "Alger", price: 4500, status: "en_route", createdAt: "il y a 12 min", clientName: "Amina L.", clientPhone: "0555 44 55 66", driverId: "d2" },
  { id: "r1000", service: "assistance", vehicle: "Peugeot 208 2020", plate: "16-22334-115", address: "Cité 5 Juillet, Oran", wilaya: "Oran", price: 2200, status: "termine", createdAt: "hier, 18:40", clientName: "Karim B.", clientPhone: "0770 22 11 33", driverId: "d1", rated: true, rating: 5 },
  { id: "r999", service: "carburant", vehicle: "Dacia Logan 2016", plate: "25-77812-116", address: "Autoroute Est, sortie Rouiba", wilaya: "Alger", price: 1800, status: "termine", createdAt: "23/11, 09:12", clientName: "Nassim T.", clientPhone: "0661 33 22 11", driverId: "d1", rated: false },
  { id: "r998", service: "remorquage", vehicle: "Hyundai i10 2019", plate: "31-11908-116", address: "Front de mer, Annaba", wilaya: "Annaba", price: 6000, status: "en_recherche", createdAt: "à l'instant", clientName: "Farid K.", clientPhone: "0555 11 22 33" },
  { id: "r997", service: "concessionnaire", vehicle: "Fiat Doblo 2024", plate: "16-99887-124", address: "Kia Motors → Kouba", wilaya: "Alger", price: 8500, status: "termine", createdAt: "20/11, 14:00", clientName: "Concession Kia", clientPhone: "0770 00 11 22", driverId: "d3", rated: true, rating: 4 },
];

export const USERS: User[] = [
  { id: "u1", name: "Amina Larbi", phone: "0555 44 55 66", wilaya: "Alger", createdAt: "12/2024", requests: 4 },
  { id: "u2", name: "Karim Bouraoui", phone: "0770 22 11 33", wilaya: "Oran", createdAt: "10/2024", requests: 7 },
  { id: "u3", name: "Nassim Talbi", phone: "0661 33 22 11", wilaya: "Alger", createdAt: "01/2025", requests: 2 },
  { id: "u4", name: "Farid Kaci", phone: "0555 11 22 33", wilaya: "Annaba", createdAt: "03/2026", requests: 1 },
];

export const SUPPORT_CALLS: SupportCall[] = [
  { id: "s1", phone: "0555 66 77 88", wilaya: "Tizi Ouzou", reason: "Aucun chauffeur trouvé — remorquage", createdAt: "il y a 4 min", handled: false },
  { id: "s2", phone: "0770 44 55 22", wilaya: "Béjaïa", reason: "Aucun chauffeur trouvé — carburant", createdAt: "il y a 22 min", handled: false },
  { id: "s3", phone: "0661 99 88 77", wilaya: "Sétif", reason: "Question tarif", createdAt: "hier", handled: true },
];

export const REPORTS: Report[] = [
  { id: "rp1", requestId: "r999", clientName: "Nassim T.", reason: "Surfacturation par rapport à l'estimation", createdAt: "il y a 1h", handled: false },
  { id: "rp2", requestId: "r997", clientName: "Concession Kia", reason: "Retard de 45 min", createdAt: "hier", handled: true },
];

export const KPIS = {
  activeRequests: 3,
  driversOnline: 12,
  jobsToday: 47,
  revenueDZD: 214500,
};

export const serviceLabel = (k: ServiceKey, t: (fr: string, ar: string) => string) => {
  const s = SERVICES.find((x) => x.key === k)!;
  return t(s.fr, s.ar);
};

export const statusLabel = (s: RequestStatus, t: (fr: string, ar: string) => string) => {
  const map: Record<RequestStatus, [string, string]> = {
    en_recherche: ["Recherche chauffeur", "البحث عن سائق"],
    en_route: ["En route", "في الطريق"],
    arrive: ["Arrivé", "وصل"],
    termine: ["Terminé", "منجز"],
    annule: ["Annulé", "ملغى"],
  };
  const [fr, ar] = map[s];
  return t(fr, ar);
};
