import type { WarehouseLocationRecord } from "@/types/master-data";

type SerializableWarehouseLocation = {
  id: bigint;
  warehouseId: bigint;
  warehouse: { name: string };
  code: string;
  name: string;
  locationType: string | null;
  status: string;
  createdAt: Date;
  updatedAt: Date;
};

export function serializeWarehouseLocation(
  location: SerializableWarehouseLocation
): WarehouseLocationRecord {
  return {
    id: location.id.toString(),
    warehouse_id: location.warehouseId.toString(),
    warehouse_name: location.warehouse.name,
    code: location.code,
    name: location.name,
    location_type: location.locationType,
    status: location.status,
    created_at: location.createdAt.toISOString(),
    updated_at: location.updatedAt.toISOString()
  };
}
