fix: correcao do organization_id e sanitizacao de valores na criacao de esquemas de pintura
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
import { supabase } from '../config/supabase.js';
|
||||
|
||||
export const createInspection = async (data: any & { organizationId?: string, createdBy?: string }) => {
|
||||
const DEFAULT_ORG_ID = 'e47e6210-4879-4e5b-bf21-9285d2713123';
|
||||
|
||||
export const createInspection = async (data: any) => {
|
||||
const orgId = data.organization_id || data.organizationId || DEFAULT_ORG_ID;
|
||||
const { data: inspection, error } = await supabase
|
||||
.from('inspections')
|
||||
.insert({
|
||||
...data,
|
||||
date: data.date ? new Date(data.date).toISOString() : null,
|
||||
organization_id: data.organizationId,
|
||||
created_by: data.createdBy
|
||||
organization_id: orgId,
|
||||
created_by: data.createdBy || data.created_by
|
||||
})
|
||||
.select()
|
||||
.single();
|
||||
|
||||
Reference in New Issue
Block a user