feat: add ref type for data

This commit is contained in:
Methapon Metanipat 2024-10-30 11:03:59 +07:00
parent 22307ed2fb
commit f149aa15ed

View file

@ -6,16 +6,14 @@ import { Invoice, InvoicePayload, Payment, Receipt } from './types';
import { manageAttachment } from '../utils'; import { manageAttachment } from '../utils';
export const usePayment = defineStore('payment-store', () => { export const usePayment = defineStore('payment-store', () => {
const data = ref<{}[]>([]); const data = ref<Payment[]>([]);
const page = ref<number>(1); const page = ref<number>(1);
const pageMax = ref<number>(1); const pageMax = ref<number>(1);
const pageSize = ref<number>(30); const pageSize = ref<number>(30);
async function getPayment(id: string) { async function getPayment(id: string) {
const res = await api.get<Payment>(`/payment/${id}`); const res = await api.get<Payment>(`/payment/${id}`);
if (res.status >= 400) return null; if (res.status >= 400) return null;
return res.data; return res.data;
} }
@ -28,9 +26,7 @@ export const usePayment = defineStore('payment-store', () => {
const res = await api.get<PaginationResult<Payment>>('/payment', { const res = await api.get<PaginationResult<Payment>>('/payment', {
params: opts, params: opts,
}); });
if (res.status >= 400) return null; if (res.status >= 400) return null;
return res.data; return res.data;
} }
@ -67,7 +63,7 @@ export const usePayment = defineStore('payment-store', () => {
}); });
export const useReceipt = defineStore('receipt-store', () => { export const useReceipt = defineStore('receipt-store', () => {
const data = ref<{}[]>([]); const data = ref<Receipt[]>([]);
const page = ref<number>(1); const page = ref<number>(1);
const pageMax = ref<number>(1); const pageMax = ref<number>(1);
const pageSize = ref<number>(30); const pageSize = ref<number>(30);
@ -91,7 +87,6 @@ export const useReceipt = defineStore('receipt-store', () => {
}); });
if (res.status >= 400) return null; if (res.status >= 400) return null;
return res.data; return res.data;
} }
@ -131,7 +126,6 @@ export const useInvoice = defineStore('invoice-store', () => {
}); });
if (res.status >= 400) return null; if (res.status >= 400) return null;
return res.data; return res.data;
} }