feat: add fetch payment fn

This commit is contained in:
Methapon Metanipat 2024-10-30 10:41:44 +07:00
parent 14ab67ccfe
commit aff61a50c4

View file

@ -2,7 +2,7 @@ import { ref } from 'vue';
import { defineStore } from 'pinia';
import { api } from 'src/boot/axios';
import { PaginationResult } from 'src/types';
import { Invoice, InvoicePayload } from './types';
import { Invoice, InvoicePayload, Payment } from './types';
export const usePayment = defineStore('payment-store', () => {
const data = ref<{}[]>([]);
@ -10,9 +10,27 @@ export const usePayment = defineStore('payment-store', () => {
const pageMax = ref<number>(1);
const pageSize = ref<number>(30);
async function getPayment() {}
async function getPayment(id: string) {
const res = await api.get<Payment>(`/payment/${id}`);
async function getPaymentList() {}
if (res.status >= 400) return null;
return res.data;
}
async function getPaymentList(opts?: {
page?: number;
pageSize?: number;
query?: string;
quotationId?: string;
}) {
const res = await api.get<PaginationResult<Payment>>('/payment', {
params: opts,
});
if (res.status >= 400) return null;
return res.data;
}
return {
data,