BETA for new DB
This commit is contained in:
@@ -138,7 +138,7 @@ export const useEntities = (
|
||||
) => {
|
||||
if (!idToEq) return null
|
||||
|
||||
const res = await useNuxtApp().$api(withInformation ? `/api/resource/${relation}/${idToEq}/${withInformation}` : `/api/resource/${relation}/${idToEq}`, {
|
||||
const res = await useNuxtApp().$api(withInformation ? `/api/resource/${relation}/${idToEq}` : `/api/resource/${relation}/${idToEq}`, {
|
||||
method: "GET",
|
||||
params: { select }
|
||||
})
|
||||
|
||||
@@ -5,4 +5,21 @@ export const useFormatDuration = (durationInMinutes:number,) => {
|
||||
const mins = Math.floor(durationInMinutes % 60)
|
||||
|
||||
return `${String(hrs).padStart(2, "0")}:${String(mins).padStart(2, "0")}`
|
||||
}
|
||||
|
||||
export const useFormatDurationDays = (start,end) => {
|
||||
const startDate = useNuxtApp().$dayjs(start);
|
||||
const endDate = useNuxtApp().$dayjs(end);
|
||||
|
||||
if(startDate.isBefore(endDate)){
|
||||
// inkl. beider Tage → +1
|
||||
const days = endDate.diff(startDate, "day") + 1;
|
||||
|
||||
return days + " Tag" + (days > 1 ? "e" : "");
|
||||
} else {
|
||||
const days = startDate.diff(endDate, "day") + 1;
|
||||
|
||||
return days + " Tag" + (days > 1 ? "e" : "");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@ interface StaffTimeEntry {
|
||||
|
||||
export function useStaffTime() {
|
||||
const { $api } = useNuxtApp()
|
||||
const auth = useAuthStore()
|
||||
|
||||
|
||||
|
||||
@@ -46,9 +47,17 @@ export function useStaffTime() {
|
||||
}
|
||||
|
||||
async function approve(id: string) {
|
||||
return await $api<StaffTimeEntry>(`/api/staff/time/${id}`, {
|
||||
const auth = useAuthStore()
|
||||
const now = useNuxtApp().$dayjs().toISOString()
|
||||
|
||||
return await $api(`/api/staff/time/${id}`, {
|
||||
method: 'PUT',
|
||||
body: { state: 'approved' },
|
||||
body: {
|
||||
state: 'approved',
|
||||
//@ts-ignore
|
||||
approved_by: auth.user.id,
|
||||
approved_at: now,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user