import { api } from '../auth/http';

export interface Rate {
  id: string;
  rateType: string;
  appliesTo: string;
  trigger: string;
  containerTypeId: string | null;
  cargoTypeId: string | null;
  tradeDirection: string | null;
  currency: string;
  rateValue: string;
  rateUnit: string;
  status: string;
  proposedByStaffId: string;
  approvedByCeoId: string | null;
  approvedAt: string | null;
  createdAt: string;
  updatedAt: string;
  deletedAt: string | null;
}

export interface RatesListResponse {
  data: Rate[];
  meta: { total: number; page: number; pageSize: number; totalPages: number };
}

export const ratesService = {
  list: (pageSize = 1000) =>
    api.get<RatesListResponse>(`/rates?pageSize=${pageSize}`),
  getByType: (rateType: string) =>
    api.get<RatesListResponse>(`/rates?rateType=${rateType}&pageSize=1000`),
};
