import { defineStore } from 'pinia'; import travelService from 'src/services/travel.service'; export const useTravelStore = defineStore({ id: 'travel', state: () => ({ initialDataLoading: true, travels: [], }), actions: { async init() { await this.fetchAllData(); }, async fetchAllData() { const { data } = await travelService.getTravels(); this.travels = data || []; }, async createTravel(travelData) { const params = { ref: travelData.ref, agencyModeFk: travelData.agencyModeFk.value, warehouseOutFk: travelData.warehouseOutFk.value, warehouseInFk: travelData.warehouseInFk.value, landed: new Date(travelData.landed), shipped: new Date(travelData.shipped), }; return await travelService.createTravel(params); }, }, getters: {}, });