Files
InvoiceShelf/resources/scripts/customer/stores/payment.js
Darko Gjorgjijoski 3ceb08bc31 Upgrade Pinia from v2 to v3 (#596)
Migrate all 37 store definitions from the deprecated object-with-id
signature to the string-id-first signature required by Pinia 3:

  defineStore({ id: 'name', ... }) → defineStore('name', { ... })
2026-04-02 16:12:11 +02:00

75 lines
1.9 KiB
JavaScript
Vendored

import { handleError } from '@/scripts/customer/helpers/error-handling'
const { defineStore } = window.pinia
import http from '@/scripts/http'
export const usePaymentStore = defineStore('customerPaymentStore', {
state: () => ({
payments: [],
selectedViewPayment: [],
totalPayments: 0,
}),
actions: {
fetchPayments(params, slug) {
return new Promise((resolve, reject) => {
http
.get(`/api/v1/${slug}/customer/payments`, { params })
.then((response) => {
this.payments = response.data.data
this.totalPayments = response.data.meta.paymentTotalCount
resolve(response)
})
.catch((err) => {
handleError(err)
reject(err)
})
})
},
fetchViewPayment(params, slug) {
return new Promise((resolve, reject) => {
http
.get(`/api/v1/${slug}/customer/payments/${params.id}`)
.then((response) => {
this.selectedViewPayment = response.data.data
resolve(response)
})
.catch((err) => {
handleError(err)
reject(err)
})
})
},
searchPayment(params, slug) {
return new Promise((resolve, reject) => {
http
.get(`/api/v1/${slug}/customer/payments`, { params })
.then((response) => {
this.payments = response.data
resolve(response)
})
.catch((err) => {
handleError(err)
reject(err)
})
})
},
fetchPaymentModes(params, slug) {
return new Promise((resolve, reject) => {
http
.get(`/api/v1/${slug}/customer/payment-method`, { params })
.then((response) => {
resolve(response)
})
.catch((err) => {
handleError(err)
reject(err)
})
})
},
},
})