refactor: add start date and end date
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 9s

This commit is contained in:
Thanaphon Frappet 2025-03-12 15:16:27 +07:00
parent db9a1d7056
commit 3dbbc4f98c
2 changed files with 109 additions and 17 deletions

View file

@ -37,8 +37,13 @@ export async function downloadReportQuotation() {
);
}
export async function getReportQuotation() {
const res = await api.get<ReportQuotation[]>(`/${ENDPOINT}/quotation`);
export async function getReportQuotation(params?: {
startDate: string | Date;
endDate: string | Date;
}) {
const res = await api.get<ReportQuotation[]>(`/${ENDPOINT}/quotation`, {
params,
});
if (res.status < 400) {
res.data;
return res.data;
@ -53,8 +58,11 @@ export async function downloadReportInvoice() {
);
}
export async function getReportInvoice() {
const res = await api.get<Report[]>(`/${ENDPOINT}/invoice`);
export async function getReportInvoice(params?: {
startDate: string | Date;
endDate: string | Date;
}) {
const res = await api.get<Report[]>(`/${ENDPOINT}/invoice`, { params });
if (res.status < 400) {
return res.data;
}
@ -68,8 +76,11 @@ export async function downloadReportReceipt() {
);
}
export async function getReportReceipt() {
const res = await api.get<Report[]>(`/${ENDPOINT}/receipt`);
export async function getReportReceipt(params?: {
startDate: string | Date;
endDate: string | Date;
}) {
const res = await api.get<Report[]>(`/${ENDPOINT}/receipt`, { params });
if (res.status < 400) {
return res.data;
}
@ -85,8 +96,11 @@ export async function downloadReportSale(
);
}
export async function getReportSale() {
const res = await api.get<ReportSale>(`/${ENDPOINT}/sale`);
export async function getReportSale(params?: {
startDate: string | Date;
endDate: string | Date;
}) {
const res = await api.get<ReportSale>(`/${ENDPOINT}/sale`, { params });
if (res.status < 400) {
return res.data;
@ -101,8 +115,13 @@ export async function downloadReportProduct() {
);
}
export async function getReportProduct() {
const res = await api.get<ReportProduct[]>(`/${ENDPOINT}/product`);
export async function getReportProduct(params?: {
startDate: string | Date;
endDate: string | Date;
}) {
const res = await api.get<ReportProduct[]>(`/${ENDPOINT}/product`, {
params,
});
if (res.status < 400) {
return res.data;
}