Open Changes

This commit is contained in:
2025-12-05 11:49:33 +01:00
parent d6badafeb9
commit 407592680a
10 changed files with 1493 additions and 28 deletions

View File

@@ -4,16 +4,24 @@ import { StaffTimeEntry } from '../../types/staff'
export default async function staffTimeRoutes(server: FastifyInstance) {
// ▶ Neue Zeit starten
server.post<{ Body: Pick<StaffTimeEntry, 'started_at' | 'stopped_at' | 'type' | 'description'> }>(
server.post(
'/staff/time',
async (req, reply) => {
const { started_at, stopped_at, type = 'work', description } = req.body
const { started_at, stopped_at, type = 'work', description, user_id } = req.body
const userId = req.user.user_id
const tenantId = req.user.tenant_id
let dataToInsert = {
tenant_id: tenantId,
user_id: user_id ? user_id : userId,
// @ts-ignore
...req.body
}
const { data, error } = await server.supabase
.from('staff_time_entries')
.insert([{ tenant_id: tenantId, user_id: userId, started_at, stopped_at, type, description }])
.insert([dataToInsert])
.select()
.maybeSingle()