diff --git a/ui/src/router/views/vehicle.vue b/ui/src/router/views/vehicle.vue
index 5b67fc7..4b6f09e 100644
--- a/ui/src/router/views/vehicle.vue
+++ b/ui/src/router/views/vehicle.vue
@@ -81,19 +81,8 @@ export default {
},
},
mounted() {
- axios
- .get(`/api/vehicles/${this.vehicle.id}/fillups`)
- .then((response) => {
- this.fillups = response.data
- })
- .catch((err) => console.log(err))
-
- axios
- .get(`/api/vehicles/${this.vehicle.id}/expenses`)
- .then((response) => {
- this.expenses = response.data
- })
- .catch((err) => console.log(err))
+ this.fetchFillups()
+ this.fetchExpenses()
this.fetchAttachments()
this.fetchVehicleStats()
@@ -108,6 +97,22 @@ export default {
})
.catch((err) => console.log(err))
},
+ fetchFillups() {
+ axios
+ .get(`/api/vehicles/${this.vehicle.id}/fillups`)
+ .then((response) => {
+ this.fillups = response.data
+ })
+ .catch((err) => console.log(err))
+ },
+ fetchExpenses() {
+ axios
+ .get(`/api/vehicles/${this.vehicle.id}/expenses`)
+ .then((response) => {
+ this.expenses = response.data
+ })
+ .catch((err) => console.log(err))
+ },
fetchVehicleStats() {
store
@@ -125,6 +130,30 @@ export default {
})
.catch((err) => console.log(err))
},
+ deleteFillup(fillupId) {
+ var sure = confirm('This will delete this fillup. This step cannot be reversed. Are you sure?')
+ if (sure) {
+ store
+ .dispatch('vehicles/deleteFillupById', { vehicleId: this.vehicle.id, fillupId: fillupId })
+ .then((data) => {
+ this.fetchVehicleStats()
+ this.fetchFillups()
+ })
+ .catch((err) => console.log(err))
+ }
+ },
+ deleteExpense(expenseId) {
+ var sure = confirm('This will delete this expense. This step cannot be reversed. Are you sure?')
+ if (sure) {
+ store
+ .dispatch('vehicles/deleteExpenseById', { vehicleId: this.vehicle.id, expenseId: expenseId })
+ .then((data) => {
+ this.fetchVehicleStats()
+ this.fetchExpenses()
+ })
+ .catch((err) => console.log(err))
+ }
+ },
deleteVehicle() {
var sure = confirm(
'This will delete all the expenses and fillups related with this vehicle as well. This step cannot be reversed. Are you sure?'
@@ -326,6 +355,9 @@ export default {
>
+
+
No Fillups so far
@@ -368,6 +400,9 @@ export default {
>
+
+
No Expenses so far
diff --git a/ui/src/state/modules/vehicles.js b/ui/src/state/modules/vehicles.js
index d78b099..075d29f 100644
--- a/ui/src/state/modules/vehicles.js
+++ b/ui/src/state/modules/vehicles.js
@@ -105,6 +105,12 @@ export const actions = {
return data
})
},
+ deleteFillupById({ commit, state, rootState }, { vehicleId, fillupId }) {
+ return axios.delete(`/api/vehicles/${vehicleId}/fillups/${fillupId}`).then((response) => {
+ const data = response.data
+ return data
+ })
+ },
fetchExpenseById({ commit, state, rootState }, { vehicleId, expenseId }) {
return axios.get(`/api/vehicles/${vehicleId}/expenses/${expenseId}`).then((response) => {
const data = response.data
@@ -112,6 +118,12 @@ export const actions = {
return data
})
},
+ deleteExpenseById({ commit, state, rootState }, { vehicleId, expenseId }) {
+ return axios.delete(`/api/vehicles/${vehicleId}/expenses/${expenseId}`).then((response) => {
+ const data = response.data
+ return data
+ })
+ },
fetchAttachmentsByVehicleId({ commit, state, rootState }, { vehicleId }) {
return axios.get(`/api/vehicles/${vehicleId}/attachments`).then((response) => {
const data = response.data