mirror of
https://github.com/mokuappio/serverless-invoices.git
synced 2025-10-27 07:51:08 -04:00
Always pass invoice id when updating. When changing team info re-prefill invoice team info.
37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
import InvoiceClientField from '@/store/models/invoice-client-field';
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {},
|
|
mutations: {},
|
|
actions: {
|
|
init() {},
|
|
terminate() {},
|
|
invoiceClientFieldProps(store, payload) {
|
|
return InvoiceClientField.update({
|
|
where: payload.fieldId,
|
|
data: payload.props,
|
|
});
|
|
},
|
|
async updateInvoiceClientField({ dispatch }, payload) {
|
|
await dispatch('invoiceClientFieldProps', payload);
|
|
return dispatch('invoices/updateInvoice', {
|
|
invoiceId: payload.invoiceId,
|
|
}, { root: true });
|
|
},
|
|
async removeInvoiceClientFields(store, invoiceId) {
|
|
return InvoiceClientField.delete(field => field.invoice_id === invoiceId);
|
|
},
|
|
async addInvoiceClientField(store, payload) {
|
|
const field = await InvoiceClientField.createNew();
|
|
await field.$update({
|
|
...payload.props,
|
|
invoice_id: payload.invoiceId,
|
|
});
|
|
},
|
|
async removeInvoiceClientField(store, fieldId) {
|
|
await InvoiceClientField.delete(fieldId);
|
|
},
|
|
},
|
|
};
|