This commit is contained in:
2026-07-23 18:47:40 +03:30
parent 2599eac261
commit b9bc80acf1
3 changed files with 413 additions and 247 deletions
+33 -1
View File
@@ -7,10 +7,22 @@ import type {
UpdatePreInvoiceType,
} from "../types/Types";
import type { InvoiceConfirmStatus } from "../enum/InvoiceEnum";
import type { BaseResponse } from "@/shared/types/Types";
export type GetInvoicesParams = {
page?: number;
statuses?: InvoiceConfirmStatus[];
search?: string | null;
from?: string | null;
to?: string | null;
};
export type GetInvoiceTabCountsParams = Omit<GetInvoicesParams, "page" | "statuses">;
export type InvoiceTabCountsResponseType = {
pending: number;
confirmed: number;
archived: number;
};
export const createInvoice = async (params: CreatePreInvoiceType) => {
@@ -21,16 +33,36 @@ export const createInvoice = async (params: CreatePreInvoiceType) => {
export const getInvoice = async (
params: GetInvoicesParams = {},
): Promise<GetInvoiceResponseType> => {
const { page = 1, statuses } = params;
const { page = 1, statuses, search, from, to } = params;
const { data } = await axios.get<GetInvoiceResponseType>("/admin/invoice", {
params: {
page,
...(statuses?.length ? { statuses: statuses.join(",") } : {}),
...(search ? { search } : {}),
...(from ? { from } : {}),
...(to ? { to } : {}),
},
});
return data;
};
export const getInvoiceTabCounts = async (
params: GetInvoiceTabCountsParams = {},
): Promise<InvoiceTabCountsResponseType> => {
const { search, from, to } = params;
const { data } = await axios.get<BaseResponse<InvoiceTabCountsResponseType>>(
"/admin/invoice/tab-counts",
{
params: {
...(search ? { search } : {}),
...(from ? { from } : {}),
...(to ? { to } : {}),
},
},
);
return data.data;
};
export const getInvoiceById = async (id: string) => {
const { data } = await axios.get<{ data: InvoiceType }>(`/admin/invoice/${id}`);
return data;