

export interface MockUser {
  id: number;
  name: string;
  email: string;
  colonia: string;
  routeId: string;
}

/**
 * Lista de usuarios para el demo. Es mutable porque cuando un user nuevo
 * se registra desde la app, se agrega aquí en memoria (con RUTA-01 default).
 * En Bloque B1 (domicilios) cada user elegirá su colonia real.
 */
export const users: MockUser[] = [
  { id: 1, name: "Ana López",      email: "ana@test.com",   colonia: "Zona Centro",     routeId: "RUTA-01" },
  { id: 2, name: "Carlos Pérez",   email: "carlos@test.com",colonia: "Las Arboledas",   routeId: "RUTA-01" },
  { id: 3, name: "María Ruiz",     email: "maria@test.com", colonia: "Trojes",          routeId: "RUTA-13" },
  { id: 4, name: "Jorge Martínez", email: "jorge@test.com", colonia: "San Juanico",     routeId: "RUTA-03" },
  { id: 5, name: "Laura Díaz",     email: "laura@test.com", colonia: "Los Olivos",      routeId: "RUTA-04" },
  { id: 6, name: "Pedro Sánchez",  email: "pedro@test.com", colonia: "Rancho Seco",     routeId: "RUTA-05" },
  { id: 7, name: "Sofía Gómez",    email: "sofia@test.com", colonia: "Las Insurgentes", routeId: "RUTA-12" },
];

export const DEFAULT_ROUTE_ID = "RUTA-01";
export const DEFAULT_COLONIA = "Zona Centro";

/** Agrega un user al mock (idempotente por id). */
export const upsertUser = (user: MockUser): void => {
  const existing = users.findIndex((u) => u.id === user.id);
  if (existing >= 0) {
    users[existing] = user;
  } else {
    users.push(user);
  }
};
