// import { apiClient } from '@/lib/axios';
import { api as apiClient } from "../auth/http";


export interface Container {
  id: string;
  containerNumber: string;
  containerTypeId: string;
  wagonId: string | null;
  position: number | null;
  tareWeight: number;
  maxGrossWeight: number;
  sealNumber?: string;
  status: string;
}

export const containerService = {
  getAll: () => apiClient.get<Container[]>('/containers'),
  getById: (id: string) => apiClient.get<Container>(`/containers/${id}`),
  getByWagon: (wagonId: string) => apiClient.get<Container[]>(`/containers?wagonId=${wagonId}`),
  create: (data: Partial<Container>) => apiClient.post('/containers', data),
  update: (id: string, data: Partial<Container>) => apiClient.patch(`/containers/${id}`, data),
  delete: (id: string) => apiClient.delete(`/containers/${id}`),
  assignToWagon: (containerId: string, wagonId: string, position?: number) =>
    apiClient.post(`/containers/${containerId}/assign-wagon`, { wagonId, position }),
  unassign: (containerId: string) => apiClient.post(`/containers/${containerId}/unassign-wagon`),
};
