From c315f8814e7c322f12b7e17263ba29058ee71571 Mon Sep 17 00:00:00 2001 From: Alexandro Uc Santos Date: Fri, 12 Jan 2024 13:16:55 -0600 Subject: [PATCH] view vehicles --- src/components/CardVehicle.vue | 141 +++++++++++++++++++++++++++ src/components/CreateUserModal.vue | 6 +- src/components/FormLoadModal.vue | 17 ++++ src/components/MakeProposalModal.vue | 4 +- src/services/vehicles.js | 1 + src/stores/vehicles.js | 14 ++- src/views/LocationsView.vue | 2 +- src/views/VehiclesView.vue | 137 ++++++++++++++++++++++++++ 8 files changed, 314 insertions(+), 8 deletions(-) create mode 100644 src/components/CardVehicle.vue diff --git a/src/components/CardVehicle.vue b/src/components/CardVehicle.vue new file mode 100644 index 0000000..aa43607 --- /dev/null +++ b/src/components/CardVehicle.vue @@ -0,0 +1,141 @@ + + + + + \ No newline at end of file diff --git a/src/components/CreateUserModal.vue b/src/components/CreateUserModal.vue index 68014d3..1595d4e 100644 --- a/src/components/CreateUserModal.vue +++ b/src/components/CreateUserModal.vue @@ -206,9 +206,9 @@ import Swal from 'sweetalert2'; v-model="userForm.job_role" > - - - + + +
diff --git a/src/components/FormLoadModal.vue b/src/components/FormLoadModal.vue index 5112474..8fcb3b6 100644 --- a/src/components/FormLoadModal.vue +++ b/src/components/FormLoadModal.vue @@ -129,6 +129,23 @@ }) }) + watch(locationLoadSelected, () => { + console.log(locationLoadSelected); + origin.locationName = locationLoadSelected.value.branch_name; + origin.address = locationLoadSelected.value.address; + origin.state = { state_name: locationLoadSelected.value.state }; + origin.city = { city_name: locationLoadSelected.value.city }; + origin.ref = locationLoadSelected.value.description; + }); + + watch(locationDownloadSelected, () => { + destination.locationName = locationDownloadSelected.value.branch_name; + destination.address = locationDownloadSelected.value.address; + destination.state = { state_name: locationDownloadSelected.value.state }; + destination.city = { city_name: locationDownloadSelected.value.city }; + destination.ref = locationDownloadSelected.value.description; + }); + const getLocations = async() => { loadingLocations.value = true; filterQueryVehicles.value.company = "company="+ localStorage.getItem('id'); diff --git a/src/components/MakeProposalModal.vue b/src/components/MakeProposalModal.vue index 3c26f3a..d7142e6 100644 --- a/src/components/MakeProposalModal.vue +++ b/src/components/MakeProposalModal.vue @@ -50,7 +50,9 @@ const initData = async() => { isLoading.value = true; - await vehiclesStore.fetchVehicles("?company="+ authStore.user.company); + let filterQuery = []; + filterQuery.company = "company="+ authStore.user.company + await vehiclesStore.fetchVehicles(filterQuery); originCoords.value = await geocodeAddress(props.load.origin_formatted_address); destinationCoords.value = await geocodeAddress(props.load.destination_formatted_address); isLoading.value = false; diff --git a/src/services/vehicles.js b/src/services/vehicles.js index 4c82c93..6a8ec69 100644 --- a/src/services/vehicles.js +++ b/src/services/vehicles.js @@ -4,6 +4,7 @@ import api from "../lib/axios"; export const getVehicles = async(filter) => { try { const endpoint = `/vehicles/${filter}`; + console.log('endpoint: ', endpoint); const {data} = await api.get(endpoint); return data; } catch (error) { diff --git a/src/stores/vehicles.js b/src/stores/vehicles.js index cc2345e..65b6762 100644 --- a/src/stores/vehicles.js +++ b/src/stores/vehicles.js @@ -5,9 +5,17 @@ export const useVehiclesStore = defineStore('vehicles', () => { const vehicles = ref([]); - const fetchVehicles = async(filter) => { - if(vehicles.value.length <= 0) { - const resp = await getVehicles(filter); + const fetchVehicles = async(filterQuery, reload = false) => { + let filterArr = Object.values(filterQuery); + + let cleanfilterArr = filterArr.filter(n=>n); + var filterStr = ""; + if(cleanfilterArr.length > 0){ + filterStr ="?"+cleanfilterArr.join("&"); + } + console.log(filterStr); + if(vehicles.value.length <= 0 || reload === true) { + const resp = await getVehicles(filterStr); console.log(resp.data); if(resp !== null) { vehicles.value = resp.data; diff --git a/src/views/LocationsView.vue b/src/views/LocationsView.vue index 5fb5675..9bd5194 100644 --- a/src/views/LocationsView.vue +++ b/src/views/LocationsView.vue @@ -41,7 +41,7 @@ const search = () => { if(query.value.length >= 2){ // filterQuery.value = "company_name[$regex]=" + query.value + "&company_name[$options]=i"; - filterQuery.value.search = "branch_name[$regex]="+ query.value +"&branch_name[$options]=i";; + filterQuery.value.search = "branch_name[$regex]="+ query.value +"&branch_name[$options]=i"; getLocationsWithFilters(filterQuery.value); } diff --git a/src/views/VehiclesView.vue b/src/views/VehiclesView.vue index adb8a67..3ef868c 100644 --- a/src/views/VehiclesView.vue +++ b/src/views/VehiclesView.vue @@ -1,13 +1,150 @@ \ No newline at end of file