This commit is contained in:
2026-07-23 18:13:48 +03:30
parent a5ac1d6a24
commit 2599eac261
10 changed files with 224 additions and 72 deletions
+19 -2
View File
@@ -6,15 +6,27 @@ import type {
InvoiceType,
UpdatePreInvoiceType,
} from "../types/Types";
import type { InvoiceConfirmStatus } from "../enum/InvoiceEnum";
export type GetInvoicesParams = {
page?: number;
statuses?: InvoiceConfirmStatus[];
};
export const createInvoice = async (params: CreatePreInvoiceType) => {
const { data } = await axios.post("/admin/invoice", params);
return data;
};
export const getInvoice = async (page = 1): Promise<GetInvoiceResponseType> => {
export const getInvoice = async (
params: GetInvoicesParams = {},
): Promise<GetInvoiceResponseType> => {
const { page = 1, statuses } = params;
const { data } = await axios.get<GetInvoiceResponseType>("/admin/invoice", {
params: { page },
params: {
page,
...(statuses?.length ? { statuses: statuses.join(",") } : {}),
},
});
return data;
};
@@ -35,3 +47,8 @@ export const updateInvoice = async (id: string, params: UpdatePreInvoiceType) =>
const { data } = await axios.patch(`/admin/invoice/${id}`, params);
return data;
};
export const archiveInvoice = async (id: string) => {
const { data } = await axios.patch(`/admin/invoice/${id}/archive`);
return data;
};