count
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user