diff --git a/components/MainNav.vue b/components/MainNav.vue
index 0910382..75586b3 100644
--- a/components/MainNav.vue
+++ b/components/MainNav.vue
@@ -126,7 +126,7 @@ const links = computed(() => {
children: [
... profileStore.ownTenant.features.timeTracking ? [{
label: "Zeiterfassung",
- to: "/employees/timetracking",
+ to: "/times",
icon: "i-heroicons-clock"
}] : [],
... profileStore.ownTenant.features.workingTimeTracking ? [{
@@ -319,6 +319,10 @@ const links = computed(() => {
label: "Projekttypen",
to: "/projecttypes",
icon: "i-heroicons-clipboard-document-list"
+ },{
+ label: "Export",
+ to: "/export",
+ icon: "i-heroicons-clipboard-document-list"
}
]
}
diff --git a/pages/employees/timetracking.vue b/pages/times/index.vue
similarity index 73%
rename from pages/employees/timetracking.vue
rename to pages/times/index.vue
index 3bbd807..5e56d29 100644
--- a/pages/employees/timetracking.vue
+++ b/pages/times/index.vue
@@ -15,7 +15,7 @@ const user = useSupabaseUser()
const toast = useToast()
-const timeTypes = dataStore.getTimeTypes
+const timeTypes = profileStore.ownTenant.timeConfig.timeTypes
const timeInfo = ref({
profile: "",
startDate: "",
@@ -28,9 +28,21 @@ const timeInfo = ref({
const filterUser = ref(profileStore.activeProfile.id || "")
const times = ref([])
+const runningTimeInfo = ref({})
+const showConfigTimeModal = ref(false)
+const configTimeMode = ref("create")
const setup = async () => {
- times.value = await useSupabaseSelect("times","*, profile(*)")
+ times.value = await useSupabaseSelect("times","*, profile(*), project(id, name)")
+
+ runningTimeInfo.value = (await supabase
+ .from("times")
+ .select()
+ .eq("tenant", profileStore.currentTenant)
+ .eq("profile", profileStore.activeProfile.id)
+ .is("endDate",null)
+ .single()).data
+
}
setup()
@@ -60,7 +72,7 @@ const itemInfo = ref({
start: new Date(),
end: "",
notes: null,
- projectId: null,
+ project: null,
type: null,
state: "Entwurf"
})
@@ -87,10 +99,6 @@ const columns = [
key:"type",
label:"Typ",
},
- {
- key: "duration",
- label: "Dauer",
- },
{
key: "project",
label: "Projekt",
@@ -101,16 +109,14 @@ const columns = [
}
]
-const runningTimeInfo = ref({})
-const showConfigTimeModal = ref(false)
-const configTimeMode = ref("create")
+
const startTime = async () => {
console.log("started")
timeInfo.value.profile = profileStore.activeProfile.id
- timeInfo.value.start = new Date().toISOString()
+ timeInfo.value.startDate = dayjs()
timeInfo.value.tenant = profileStore.currentTenant
const {data,error} = await supabase
@@ -120,45 +126,34 @@ const startTime = async () => {
if(error) {
console.log(error)
+ toast.add({title: "Fehler beim starten der Zeit",color:"rose"})
} else if(data) {
- //timeInfo.value = data[0]
- await dataStore.fetchTimes()
- runningTimeInfo.value = dataStore.times.find(time => time.profile === profileStore.activeProfile.id && !time.end)
+ toast.add({title: "Zeit erfolgreich gestartet"})
+ runningTimeInfo.value = data[0]
}
}
const stopStartedTime = async () => {
- console.log(runningTimeInfo.value)
+ runningTimeInfo.value.endDate = dayjs()
+ runningTimeInfo.value.state = "Im Web gestoppt"
- runningTimeInfo.value.end = new Date().toISOString()
-
- const mapNumRange = (num, inMin, inMax, outMin, outMax) =>
- ((num - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
-
- runningTimeInfo.value.duration = Math.round(mapNumRange(Math.abs(new Date(runningTimeInfo.value.end) - new Date(runningTimeInfo.value.start))/1000/60,0,60,0,1)*100)/100
const {data,error} = await supabase
.from("times")
.update(runningTimeInfo.value)
.eq('id',runningTimeInfo.value.id)
.select()
- console.log(data)
if(error) {
console.log(error)
} else {
toast.add({title: "Zeit erfolgreich gestoppt"})
- runningTimeInfo.value = {}
- dataStore.fetchTimes()
+ runningTimeInfo.value = null
+ setup()
}
}
-if(times.value.find(time => time.profile == profileStore.activeProfile.id && !time.end)) {
- runningTimeInfo.value = times.value.find(time => time.profile == profileStore.activeProfile.id && !time.end)
-}
-
-
const createTime = async () => {
const {data,error} = await supabase
.from("times")
@@ -224,13 +219,13 @@ const setState = async (newState) => {