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

@@ -8,13 +8,12 @@ definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const supabase = useSupabaseClient()
const user = useSupabaseUser()
const toast = useToast()
const {times, projects, profiles, jobs} = storeToRefs(useDataStore())
const {fetchTimes, getTimeTypes} = useDataStore()
const timeTypes = getTimeTypes
const timeTypes = dataStore.getTimeTypes
const timeInfo = ref({
user: "",
start: "",
@@ -100,7 +99,7 @@ const startTime = async () => {
console.log(error)
} else if(data) {
timeInfo.value = data[0]
await fetchTimes()
await dataStore.fetchTimes()
runningTimeInfo.value = times.value.find(time => time.user == user.value.id && !time.end)
}
@@ -128,7 +127,7 @@ const stopStartedTime = async () => {
} else {
toast.add({title: "Zeit erfolgreich gestoppt"})
runningTimeInfo.value = {}
fetchTimes()
dataStore.fetchTimes()
}
}
@@ -149,7 +148,7 @@ const createTime = async () => {
createTimeInfo.value = {}
toast.add({title: "Zeit erfolgreich erstellt"})
showAddTimeModal.value = false
await fetchTimes()
await dataStore.fetchTimes()
}
}
@@ -211,13 +210,13 @@ const selectStartedTime = () => {
label="Projekt:"
>
<USelectMenu
:options="projects"
:options="dataStore.projects"
option-attribute="name"
value-attribute="id"
v-model="runningTimeInfo.projectId"
>
<template #label>
{{ projects.find(project => project.id === runningTimeInfo.projectId) ? projects.find(project => project.id === runningTimeInfo.projectId).name : "Projekt auswählen" }}
{{ dataStore.projects.find(project => project.id === runningTimeInfo.projectId) ? dataStore.projects.find(project => project.id === runningTimeInfo.projectId).name : "Projekt auswählen" }}
</template>
</USelectMenu>
</UFormGroup>
@@ -226,13 +225,13 @@ const selectStartedTime = () => {
label="Job:"
>
<USelectMenu
:options="jobs"
:options="dataStore.jobs"
option-attribute="title"
value-attribute="id"
v-model="runningTimeInfo.job"
>
<template #label>
{{ jobs.find(job => job.id === runningTimeInfo.job) ? jobs.find(job => job.id === runningTimeInfo.job).title : "Job auswählen" }}
{{ dataStore.jobs.find(job => job.id === runningTimeInfo.job) ? dataStore.jobs.find(job => job.id === runningTimeInfo.job).title : "Job auswählen" }}
</template>
</USelectMenu>
</UFormGroup>
@@ -302,13 +301,13 @@ const selectStartedTime = () => {
label="Benutzer:"
>
<USelectMenu
:options="profiles"
:options="dataStore.profiles"
v-model="createTimeInfo.user"
option-attribute="firstName"
value-attribute="id"
>
<template #label>
{{profiles.find(profile => profile.id === createTimeInfo.user) ? profiles.find(profile => profile.id === createTimeInfo.user).firstName : "Benutzer auswählen"}}
{{dataStore.profiles.find(profile => profile.id === createTimeInfo.user) ? dataStore.profiles.find(profile => profile.id === createTimeInfo.user).firstName : "Benutzer auswählen"}}
</template>
</USelectMenu>
</UFormGroup>
@@ -316,13 +315,13 @@ const selectStartedTime = () => {
label="Projekt:"
>
<USelectMenu
:options="projects"
:options="dataStore.projects"
v-model="createTimeInfo.projectId"
option-attribute="name"
value-attribute="id"
>
<template #label>
{{projects.find(project => project.id === createTimeInfo.projectId) ? projects.find(project => project.id === createTimeInfo.projectId).name : "Projekt auswählen"}}
{{dataStore.projects.find(project => project.id === createTimeInfo.projectId) ? dataStore.projects.find(project => project.id === createTimeInfo.projectId).name : "Projekt auswählen"}}
</template>
</USelectMenu>
</UFormGroup>
@@ -330,13 +329,13 @@ const selectStartedTime = () => {
label="Job:"
>
<USelectMenu
:options="jobs"
:options="dataStore.jobs"
option-attribute="title"
value-attribute="id"
v-model="createTimeInfo.job"
>
<template #label>
{{ jobs.find(job => job.id === runningTimeInfo.job) ? jobs.find(job => job.id === runningTimeInfo.job).title : "Job auswählen" }}
{{ dataStore.jobs.find(job => job.id === runningTimeInfo.job) ? dataStore.jobs.find(job => job.id === runningTimeInfo.job).title : "Job auswählen" }}
</template>
</USelectMenu>
</UFormGroup>
@@ -382,7 +381,7 @@ const selectStartedTime = () => {
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Noch keine Einträge' }"
>
<template #user-data="{row}">
{{profiles.find(profile => profile.id === row.user) ? profiles.find(profile => profile.id === row.user).firstName + " " + profiles.find(profile => profile.id === row.user).lastName : row.user }}
{{dataStore.profiles.find(profile => profile.id === row.user) ? dataStore.profiles.find(profile => profile.id === row.user).firstName + " " + profiles.find(profile => profile.id === row.user).lastName : row.user }}
</template>
<template #start-data="{row}">