From aff61a50c49b7ff60b9b4be8bc80f78d73a5ef74 Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Wed, 30 Oct 2024 10:41:44 +0700 Subject: [PATCH] feat: add fetch payment fn --- src/stores/payment/index.ts | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/stores/payment/index.ts b/src/stores/payment/index.ts index ff649e3c..8dc433d0 100644 --- a/src/stores/payment/index.ts +++ b/src/stores/payment/index.ts @@ -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(1); const pageSize = ref(30); - async function getPayment() {} + async function getPayment(id: string) { + const res = await api.get(`/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>('/payment', { + params: opts, + }); + + if (res.status >= 400) return null; + + return res.data; + } return { data,