import { apiFetch } from "../lib/api";

export interface Colonia {
  colonia: string;
  routeId: string;
  horarioEstimado: string;
}

export interface MyAddress {
  colonia: string;
  routeId: string;
  horarioEstimado: string | null;
}

export const listColonias = () =>
  apiFetch<Colonia[]>("/api/addresses/colonias");

export const getMyAddress = () =>
  apiFetch<MyAddress>("/api/addresses/me");

export const setMyAddress = (colonia: string, street?: string) =>
  apiFetch<MyAddress>("/api/addresses/me", {
    method: "PUT",
    body: JSON.stringify({ colonia, street }),
  });
