From 3e10fd4c56633c57dd8845f183a72c0d070c8a28 Mon Sep 17 00:00:00 2001 From: wass08 Date: Mon, 16 Feb 2026 14:43:09 +0900 Subject: [PATCH] fix build --- .../community/components/property-grid.tsx | 5 +- .../community/lib/local-storage/hooks.ts | 4 +- .../community/lib/properties/actions.ts | 57 ++++++------- .../community/lib/properties/types.ts | 84 +++++++++++++++++++ 4 files changed, 118 insertions(+), 32 deletions(-) diff --git a/apps/editor/features/community/components/property-grid.tsx b/apps/editor/features/community/components/property-grid.tsx index 21f2800c..61b58f23 100644 --- a/apps/editor/features/community/components/property-grid.tsx +++ b/apps/editor/features/community/components/property-grid.tsx @@ -104,8 +104,9 @@ export function PropertyGrid({ if (result.success && result.data) { // Update with actual values from server - setUserLikes((prev) => ({ ...prev, [propertyId]: result.data.liked })) - setLikeCounts((prev) => ({ ...prev, [propertyId]: result.data.likes })) + const data = result.data + setUserLikes((prev) => ({ ...prev, [propertyId]: data.liked })) + setLikeCounts((prev) => ({ ...prev, [propertyId]: data.likes })) } else { // Revert on error setUserLikes((prev) => ({ ...prev, [propertyId]: wasLiked })) diff --git a/apps/editor/features/community/lib/local-storage/hooks.ts b/apps/editor/features/community/lib/local-storage/hooks.ts index b9258d4b..1be68e5f 100644 --- a/apps/editor/features/community/lib/local-storage/hooks.ts +++ b/apps/editor/features/community/lib/local-storage/hooks.ts @@ -1,6 +1,6 @@ 'use client' -import { initSpatialGridSync, useScene } from '@pascal-app/core' +import { type AnyNodeId, initSpatialGridSync, useScene } from '@pascal-app/core' import { useViewer } from '@pascal-app/viewer' import { useEffect, useRef } from 'react' import useEditor from '@/store/use-editor' @@ -32,7 +32,7 @@ export function useLocalPropertyScene(propertyId?: string) { if (property?.scene_graph) { const { nodes, rootNodeIds } = property.scene_graph - useScene.getState().setScene(nodes, rootNodeIds) + useScene.getState().setScene(nodes, rootNodeIds as AnyNodeId[]) initSpatialGridSync() } else { useScene.getState().clearScene() diff --git a/apps/editor/features/community/lib/properties/actions.ts b/apps/editor/features/community/lib/properties/actions.ts index f424505c..2cb80226 100644 --- a/apps/editor/features/community/lib/properties/actions.ts +++ b/apps/editor/features/community/lib/properties/actions.ts @@ -8,7 +8,7 @@ import { createServerSupabaseClient } from '../database/server' import { getSession } from '../auth/server' import { createId } from '../utils/id-generator' -import type { CreatePropertyParams, Property } from './types' +import type { CreatePropertyParams, Property, Database } from './types' export type ActionResult = { success: boolean @@ -249,7 +249,7 @@ export async function createProperty(params: CreatePropertyParams): Promise } } - if (property.owner_id !== session.user.id) { + if ((property as any).owner_id !== session.user.id) { return { success: false, error: 'Unauthorized', @@ -785,7 +786,7 @@ export async function getUserPropertyLikes( // Convert array to map const likeMap: Record = {} propertyIds.forEach((id) => { - likeMap[id] = likes?.some((like) => like.property_id === id) || false + likeMap[id] = likes?.some((like) => (like as any).property_id === id) || false }) return { @@ -833,10 +834,10 @@ export async function togglePropertyLike( if (existingLike) { // Unlike - remove the like - const { error } = await supabase - .from('property_likes') + const { error } = await (supabase + .from('property_likes') as any) .delete() - .eq('id', existingLike.id) + .eq('id', (existingLike as any).id) if (error) { return { @@ -849,7 +850,7 @@ export async function togglePropertyLike( } else { // Like - add a new like const likeId = createId('like') - const { error } = await supabase.from('property_likes').insert({ + const { error } = await (supabase.from('property_likes') as any).insert({ id: likeId, property_id: propertyId, user_id: userId, @@ -868,11 +869,11 @@ export async function togglePropertyLike( // Get updated like count const { data: likeCount } = await supabase.rpc('get_property_like_count', { property_id: propertyId, - }) + } as any) // Update the property's like count cache - await supabase - .from('properties') + await (supabase + .from('properties') as any) .update({ likes: likeCount || 0 }) .eq('id', propertyId) diff --git a/apps/editor/features/community/lib/properties/types.ts b/apps/editor/features/community/lib/properties/types.ts index 2b142c43..c2a9290f 100644 --- a/apps/editor/features/community/lib/properties/types.ts +++ b/apps/editor/features/community/lib/properties/types.ts @@ -3,6 +3,90 @@ * Isolated from monorepo database schema */ +// Database table row types +export type DbProperty = { + id: string + name: string + owner_id: string + organization_id: string | null + address_id: string + created_at: string + updated_at: string + is_private: boolean + views: number + likes: number + thumbnail_url: string | null +} + +export type DbPropertyAddress = { + id: string + street_number?: string + route?: string + city?: string + state?: string + postal_code?: string + country?: string + latitude?: string + longitude?: string + created_at: string + updated_at: string +} + +export type DbPropertyModel = { + id: string + property_id: string + version: number + scene_graph: any + created_at: string + updated_at: string + deleted_at: string | null +} + +export type DbPropertyLike = { + id: string + property_id: string + user_id: string + created_at: string +} + +// Database schema type for Supabase +export type Database = { + public: { + Tables: { + properties: { + Row: DbProperty + Insert: Omit + Update: Partial> + } + properties_addresses: { + Row: DbPropertyAddress + Insert: Omit + Update: Partial> + } + properties_models: { + Row: DbPropertyModel + Insert: Omit + Update: Partial> + } + property_likes: { + Row: DbPropertyLike + Insert: Omit + Update: Partial> + } + } + Functions: { + increment_property_views: { + Args: { property_id: string } + Returns: undefined + } + get_property_like_count: { + Args: { property_id: string } + Returns: number + } + } + } +} + export type Property = { id: string name: string