refactor: use built in query string instead

This commit is contained in:
Methapon Metanipat 2024-10-24 16:37:05 +07:00
parent a84ad89d12
commit 484bc2b0e5

View file

@ -44,21 +44,15 @@ export const useQuotationStore = defineStore('quotation-store', () => {
return null;
}
async function getQuotationList(opts?: {
async function getQuotationList(params?: {
page?: number;
pageSize?: number;
payCondition?: 'Full' | 'Split' | 'BillFull' | 'BillSplit';
query?: string;
}) {
const params = new URLSearchParams();
for (const [k, v] of Object.entries(opts || {})) {
if (v !== undefined) params.append(k, v.toString());
}
const query = params.toString();
const res = await api.get<PaginationResult<Quotation>>(
`/quotation?${query}`,
);
const res = await api.get<PaginationResult<Quotation>>(`/quotation`, {
params,
});
if (res.status < 400) {
return res.data;
}