import { request } from "./http"; export interface PriceList { id: number; name: string; valid_from: string | null; valid_to: string | null; is_default: boolean; } export interface PriceListListResponse { data: PriceList[]; } export interface PriceListResponse { data: PriceList; } export interface CreatePriceListPayload { name: string; valid_from?: string | null; valid_to?: string | null; is_default?: boolean; } export interface UpdatePriceListPayload extends Partial { id: number; } export const PriceListService = { async getAllPriceLists(): Promise { return await request({ url: "/api/price-lists", method: "get", }); }, async getPriceList(id: number): Promise { return await request({ url: `/api/price-lists/${id}`, method: "get", }); }, async createPriceList( payload: CreatePriceListPayload ): Promise { return await request({ url: "/api/price-lists", method: "post", data: payload, }); }, async updatePriceList( payload: UpdatePriceListPayload ): Promise { const { id, ...updateData } = payload; return await request({ url: `/api/price-lists/${id}`, method: "put", data: updateData, }); }, async deletePriceList( id: number ): Promise<{ success?: boolean; message: string }> { return await request<{ success?: boolean; message: string }>({ url: `/api/price-lists/${id}`, method: "delete", }); }, }; export default PriceListService;