Fix #53
Some checks failed
Build and Push Docker Images / build-backend (push) Successful in 33s
Build and Push Docker Images / build-frontend (push) Has been cancelled

This commit is contained in:
2026-01-13 14:24:04 +01:00
parent 32b4c40e11
commit 267648074c
3 changed files with 15 additions and 9 deletions

View File

@@ -22,7 +22,7 @@ export default async function staffTimeRoutes(server: FastifyInstance) {
server.post("/staff/time/event", async (req, reply) => {
try {
const userId = req.user.user_id
const actorId = req.user.user_id;
const tenantId = req.user.tenant_id
const body = req.body as any
@@ -35,17 +35,15 @@ export default async function staffTimeRoutes(server: FastifyInstance) {
const dataToInsert = {
tenant_id: tenantId,
user_id: userId,
user_id: body.user_id,
actortype: "user",
actoruser_id: userId,
actoruser_id: actorId,
eventtime: normalizeDate(body.eventtime),
eventtype: body.eventtype,
source: "WEB",
payload: body.payload // Payload (z.B. Description) mit speichern
}
console.log(dataToInsert)
const [created] = await server.db
.insert(stafftimeevents)
//@ts-ignore

View File

@@ -103,7 +103,8 @@ async function onSubmit(event: FormSubmitEvent<any>) {
start: startIso, // Die eingegebene Startzeit
end: endIso, // Die eingegebene Endzeit (oder null)
type: state.type,
description: state.description
description: state.description,
user_id: props.defaultUserId
})
toast.add({ title: 'Zeit manuell erfasst', color: 'green' })
@@ -131,6 +132,8 @@ async function onSubmit(event: FormSubmitEvent<any>) {
</div>
</template>
{{props}}
<UForm :schema="schema" :state="state" class="space-y-4" @submit="onSubmit">
<UFormGroup label="Typ" name="type">

View File

@@ -91,15 +91,18 @@ export const useStaffTime = () => {
}
// 🆕 NEU: Manuellen Eintrag erstellen (Vergangenheit oder Zeitraum)
const createEntry = async (data: { start: string, end: string | null, type: string, description: string }) => {
const createEntry = async (data: { start: string, end: string | null, type: string, description: string, user_id: string }) => {
// 1. Start Event senden
// Wir nutzen den dynamischen Typ (work_start, vacation_start etc.)
console.log(data)
await $api('/api/staff/time/event', {
method: 'POST',
body: {
eventtype: `${data.type}_start`,
eventtime: data.start,
payload: { description: data.description }
payload: { description: data.description },
user_id: data.user_id,
}
})
@@ -109,7 +112,9 @@ export const useStaffTime = () => {
method: 'POST',
body: {
eventtype: `${data.type}_end`,
eventtime: data.end
eventtime: data.end,
payload: { description: data.description },
user_id: data.user_id,
}
})
}