Open Changes
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user