fix: correcao do organization_id e sanitizacao de valores na criacao de esquemas de pintura

This commit is contained in:
2026-08-28 11:12:50 +00:00
parent 2c9fe42d2a
commit dce4c04fa4
6 changed files with 105 additions and 26 deletions
+6 -3
View File
@@ -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();