Fix #53
This commit is contained in:
@@ -22,7 +22,7 @@ export default async function staffTimeRoutes(server: FastifyInstance) {
|
|||||||
|
|
||||||
server.post("/staff/time/event", async (req, reply) => {
|
server.post("/staff/time/event", async (req, reply) => {
|
||||||
try {
|
try {
|
||||||
const userId = req.user.user_id
|
const actorId = req.user.user_id;
|
||||||
const tenantId = req.user.tenant_id
|
const tenantId = req.user.tenant_id
|
||||||
|
|
||||||
const body = req.body as any
|
const body = req.body as any
|
||||||
@@ -35,17 +35,15 @@ export default async function staffTimeRoutes(server: FastifyInstance) {
|
|||||||
|
|
||||||
const dataToInsert = {
|
const dataToInsert = {
|
||||||
tenant_id: tenantId,
|
tenant_id: tenantId,
|
||||||
user_id: userId,
|
user_id: body.user_id,
|
||||||
actortype: "user",
|
actortype: "user",
|
||||||
actoruser_id: userId,
|
actoruser_id: actorId,
|
||||||
eventtime: normalizeDate(body.eventtime),
|
eventtime: normalizeDate(body.eventtime),
|
||||||
eventtype: body.eventtype,
|
eventtype: body.eventtype,
|
||||||
source: "WEB",
|
source: "WEB",
|
||||||
payload: body.payload // Payload (z.B. Description) mit speichern
|
payload: body.payload // Payload (z.B. Description) mit speichern
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(dataToInsert)
|
|
||||||
|
|
||||||
const [created] = await server.db
|
const [created] = await server.db
|
||||||
.insert(stafftimeevents)
|
.insert(stafftimeevents)
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
|
|||||||
@@ -103,7 +103,8 @@ async function onSubmit(event: FormSubmitEvent<any>) {
|
|||||||
start: startIso, // Die eingegebene Startzeit
|
start: startIso, // Die eingegebene Startzeit
|
||||||
end: endIso, // Die eingegebene Endzeit (oder null)
|
end: endIso, // Die eingegebene Endzeit (oder null)
|
||||||
type: state.type,
|
type: state.type,
|
||||||
description: state.description
|
description: state.description,
|
||||||
|
user_id: props.defaultUserId
|
||||||
})
|
})
|
||||||
|
|
||||||
toast.add({ title: 'Zeit manuell erfasst', color: 'green' })
|
toast.add({ title: 'Zeit manuell erfasst', color: 'green' })
|
||||||
@@ -131,6 +132,8 @@ async function onSubmit(event: FormSubmitEvent<any>) {
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
{{props}}
|
||||||
|
|
||||||
<UForm :schema="schema" :state="state" class="space-y-4" @submit="onSubmit">
|
<UForm :schema="schema" :state="state" class="space-y-4" @submit="onSubmit">
|
||||||
|
|
||||||
<UFormGroup label="Typ" name="type">
|
<UFormGroup label="Typ" name="type">
|
||||||
|
|||||||
@@ -91,15 +91,18 @@ export const useStaffTime = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 🆕 NEU: Manuellen Eintrag erstellen (Vergangenheit oder Zeitraum)
|
// 🆕 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
|
// 1. Start Event senden
|
||||||
// Wir nutzen den dynamischen Typ (work_start, vacation_start etc.)
|
// Wir nutzen den dynamischen Typ (work_start, vacation_start etc.)
|
||||||
|
console.log(data)
|
||||||
|
|
||||||
await $api('/api/staff/time/event', {
|
await $api('/api/staff/time/event', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: {
|
body: {
|
||||||
eventtype: `${data.type}_start`,
|
eventtype: `${data.type}_start`,
|
||||||
eventtime: data.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',
|
method: 'POST',
|
||||||
body: {
|
body: {
|
||||||
eventtype: `${data.type}_end`,
|
eventtype: `${data.type}_end`,
|
||||||
eventtime: data.end
|
eventtime: data.end,
|
||||||
|
payload: { description: data.description },
|
||||||
|
user_id: data.user_id,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user