import { defineStore } from "pinia";
import { ref } from "vue";
import { getVehicles } from "../services/vehicles";
export const useVehiclesStore = defineStore('vehicles', () => {
    
    const vehicles = ref([]);

    const fetchVehicles = async(filter) => {
        if(vehicles.value.length <= 0) {
            const resp = await getVehicles(filter);
            console.log(resp.data);
            if(resp !== null) {
                vehicles.value = resp.data;
            }
        }
    }

   return {
        fetchVehicles,
        vehicles
   }
});