diff --git a/apps/editor/features/community/lib/models/actions.ts b/apps/editor/features/community/lib/models/actions.ts index e33c28a1..1d0b5bcc 100644 --- a/apps/editor/features/community/lib/models/actions.ts +++ b/apps/editor/features/community/lib/models/actions.ts @@ -49,7 +49,7 @@ export async function getPropertyModel(propertyId: string): Promise() if (propertyError || !property) { return { @@ -77,7 +77,7 @@ export async function getPropertyModel(propertyId: string): Promise() console.log('[getPropertyModel] Query result:', { propertyId, @@ -149,7 +149,7 @@ export async function savePropertyModel( .from('properties') .select('id, owner_id, name') .eq('id', propertyId) - .single() + .single<{ id: string; owner_id: string; name: string }>() if (propertyError || !property) { return { @@ -175,19 +175,20 @@ export async function savePropertyModel( .order('version', { ascending: false }) .order('created_at', { ascending: false }) .limit(1) - .single() + .single<{ id: string; version: number }>() if (existingModel) { // Update existing model - const { data: updatedModel, error: updateError } = await supabase - .from('properties_models') - .update({ - scene_graph: sceneGraph as any, - updated_at: new Date().toISOString(), - }) + const updateData = { + scene_graph: sceneGraph, + updated_at: new Date().toISOString(), + } + const { data: updatedModel, error: updateError } = (await (supabase + .from('properties_models') as any) + .update(updateData) .eq('id', existingModel.id) .select() - .single() + .single()) as { data: PropertyModel | null; error: any } if (updateError) { return { @@ -205,18 +206,19 @@ export async function savePropertyModel( // Create new model const modelId = createId('model') - const { data: newModel, error: createError } = await supabase - .from('properties_models') - .insert({ - id: modelId, - property_id: propertyId, - name: `${property.name} - Editor`, - version: 1, - draft: true, - scene_graph: sceneGraph as any, - }) + const insertData = { + id: modelId, + property_id: propertyId, + name: `${property.name} - Editor`, + version: 1, + draft: true, + scene_graph: sceneGraph, + } + const { data: newModel, error: createError } = (await (supabase + .from('properties_models') as any) + .insert(insertData) .select() - .single() + .single()) as { data: PropertyModel | null; error: any } if (createError) { return { diff --git a/apps/editor/features/community/lib/models/hooks.ts b/apps/editor/features/community/lib/models/hooks.ts index 1dc3102e..3109aeeb 100644 --- a/apps/editor/features/community/lib/models/hooks.ts +++ b/apps/editor/features/community/lib/models/hooks.ts @@ -21,7 +21,7 @@ export function usePropertyScene() { const isLoadingProperty = usePropertyStore((state) => state.isLoading) const lastPropertyIdRef = useRef(null) - const saveTimeoutRef = useRef() + const saveTimeoutRef = useRef(undefined) const isSavingRef = useRef(false) const currentPropertyIdRef = useRef(null) diff --git a/apps/editor/features/community/lib/properties/actions.ts b/apps/editor/features/community/lib/properties/actions.ts index 403a1a3c..81f3c5f0 100644 --- a/apps/editor/features/community/lib/properties/actions.ts +++ b/apps/editor/features/community/lib/properties/actions.ts @@ -86,7 +86,7 @@ export async function getActiveProperty(): Promise .from('auth_sessions') .select('active_property_id') .eq('user_id', session.user.id) - .single() + .single<{ active_property_id: string | null }>() if (sessionError || !sessionData?.active_property_id) { return { @@ -103,7 +103,7 @@ export async function getActiveProperty(): Promise address:properties_addresses(*) `) .eq('id', sessionData.active_property_id) - .single() + .single() if (error) { return { @@ -143,8 +143,8 @@ export async function setActiveProperty(propertyId: string | null): Promise 0) { - const existingProperty = data[0] as Property + const existingProperty = data[0] as unknown as Property return { success: true, data: { isDuplicate: true, - isUserProperty: existingProperty.ownerId === session.user.id, + isUserProperty: existingProperty.owner_id === session.user.id, existingProperty, }, } diff --git a/apps/editor/features/community/lib/properties/types.ts b/apps/editor/features/community/lib/properties/types.ts index 4d6721b8..393f583a 100644 --- a/apps/editor/features/community/lib/properties/types.ts +++ b/apps/editor/features/community/lib/properties/types.ts @@ -6,18 +6,18 @@ export type Property = { id: string name: string - ownerId: string - organizationId: string | null - addressId: string - createdAt: Date - updatedAt: Date + owner_id: string + organization_id: string | null + address_id: string + created_at: string + updated_at: string address: { id: string - streetNumber?: string + street_number?: string route?: string city?: string state?: string - postalCode?: string + postal_code?: string country?: string latitude?: string longitude?: string