added displayRunningTime.vue

This commit is contained in:
2025-06-01 18:23:01 +02:00
parent 80f05c7029
commit 03231ab3f3
3 changed files with 40 additions and 8 deletions

View File

@@ -7,9 +7,18 @@ const toast = useToast()
const runningTimeInfo = ref({})
const projects = ref([])
const platform = ref("default")
const setupPage = async () => {
runningTimeInfo.value = (await supabase.from("workingtimes").select().eq("profile", profileStore.activeProfile.id).is("endDate", null).single()).data || {}
console.log(runningTimeInfo.value)
runningTimeInfo.value = (await supabase.from("times").select().eq("profile", profileStore.activeProfile.id).is("endDate", null).single()).data || {}
projects.value = (await useSupabaseSelect("projects"))
if(await useCapacitor().getIsPhone()) {
platform.value = "mobile"
}
}
setupPage()
@@ -24,12 +33,12 @@ const startTime = async () => {
profile: profileStore.activeProfile.id,
startDate: dayjs(),
tenant: profileStore.currentTenant,
state: "Im Web gestartet",
state: platform.value === "mobile" ? "In der App gestartet" : "Im Web gestartet",
source: "Dashboard"
}
const {data,error} = await supabase
.from("workingtimes")
.from("times")
.insert([runningTimeInfo.value])
.select()
if(error) {
@@ -38,16 +47,16 @@ const startTime = async () => {
} else if(data) {
toast.add({title: "Zeit erfolgreich gestartet"})
runningTimeInfo.value = data[0]
console.log(runningTimeInfo.value)
//console.log(runningTimeInfo.value)
}
}
const stopStartedTime = async () => {
runningTimeInfo.value.endDate = dayjs()
runningTimeInfo.value.state = "Im Web gestoppt"
runningTimeInfo.value.state = platform.value === "mobile" ? "In der App gestoppt" : "Im Web gestoppt"
const {error,status} = await supabase
.from("workingtimes")
.from("times")
.update(runningTimeInfo.value)
.eq('id',runningTimeInfo.value.id)
@@ -79,6 +88,20 @@ const stopStartedTime = async () => {
v-model="runningTimeInfo.notes"
/>
</UFormGroup>
<UFormGroup
class="mt-2"
label="Projekt:"
>
<USelectMenu
v-model="runningTimeInfo.project"
:options="projects"
searchable
:search-attributes="['name','notes','customer']"
searchable-placeholder="Suche"
value-attribute="id"
option-attribute="name"
/>
</UFormGroup>
<UButton
class="mt-3"
@click="stopStartedTime"
@@ -88,7 +111,7 @@ const stopStartedTime = async () => {
</UButton>
</div>
<div v-else>
<p>Keine Anwesenheit gestartet</p>
<p>Keine Zeit gestartet</p>
<UButton
class="mt-3"
@click="startTime"