Changed STore Type and corrected all Pages

Added HistoryDisplay.vue
Added NumberRanges
This commit is contained in:
2023-12-27 21:52:55 +01:00
parent 9e092823e4
commit c41b99f29d
33 changed files with 1094 additions and 812 deletions

View File

@@ -3,17 +3,13 @@ definePageMeta({
middleware: "auth"
})
//
const dataStore = useDataStore()
const supabase = useSupabaseClient()
const route = useRoute()
const router = useRouter()
const toast = useToast()
const id = ref(route.params.id ? route.params.id : null )
//Store
const {vehicles, profiles } = storeToRefs(useDataStore())
const {fetchVehicles, getVehicleById} = useDataStore()
let currentItem = null
@@ -31,7 +27,7 @@ const itemInfo = ref({
//Functions
const setupPage = () => {
if(mode.value === "show" || mode.value === "edit"){
currentItem = getVehicleById(Number(useRoute().params.id))
currentItem = dataStore.getVehicleById(Number(useRoute().params.id))
}
if(mode.value === "edit") itemInfo.value = currentItem
@@ -55,7 +51,7 @@ const createItem = async () => {
name: ""
}
toast.add({title: "Fahrzeug erfolgreich erstellt"})
await fetchVehicles()
await dataStore.fetchVehicles()
router.push(`/vehicles/show/${data[0].id}`)
setupPage()
}
@@ -92,14 +88,10 @@ const updateCustomer = async () => {
type: ""
}
toast.add({title: "Fahrzeug erfolgreich gespeichert"})
fetchVehicles()
dataStore.fetchVehicles()
}
}
setupPage()
</script>
@@ -122,7 +114,7 @@ setupPage()
</template>
Typ: {{currentItem.type}} <br>
Fahrer: {{profiles.find(profile => profile.id === currentItem.driver) ? profiles.find(profile => profile.id === currentItem.driver).fullName : 'Kein Fahrer gewählt'}} <br>
Fahrer: {{dataStore.profiles.find(profile => profile.id === currentItem.driver) ? dataStore.profiles.find(profile => profile.id === currentItem.driver).fullName : 'Kein Fahrer gewählt'}} <br>
@@ -147,7 +139,7 @@ setupPage()
</UCard>
<UCard v-else-if="mode == 'edit' || mode == 'create'" >
<template #header>
<template #header v-if="mode === 'edit'">
{{itemInfo.licensePlate}}
</template>
@@ -180,13 +172,13 @@ setupPage()
>
<USelectMenu
v-model="itemInfo.driver"
:options="profiles"
:options="dataStore.profiles"
option-attribute="fullName"
value-attribute="id"
>
<template #label>
{{profiles.find(profile => profile.id === itemInfo.driver) ? profiles.find(profile => profile.id === itemInfo.driver).fullName : 'Kein Fahrer ausgewählt'}}
{{dataStore.profiles.find(profile => profile.id === itemInfo.driver) ? dataStore.profiles.find(profile => profile.id === itemInfo.driver).fullName : 'Kein Fahrer ausgewählt'}}
</template>
</USelectMenu>
</UFormGroup>