fix build issue

This commit is contained in:
wass08
2026-02-11 15:47:29 +09:00
parent 2e8b663001
commit 77b00f09d6
4 changed files with 67 additions and 63 deletions
@@ -49,7 +49,7 @@ export async function getPropertyModel(propertyId: string): Promise<ActionResult
.from('properties')
.select('id, owner_id')
.eq('id', propertyId)
.single()
.single<{ id: string; owner_id: string }>()
if (propertyError || !property) {
return {
@@ -77,7 +77,7 @@ export async function getPropertyModel(propertyId: string): Promise<ActionResult
.order('version', { ascending: false })
.order('created_at', { ascending: false })
.limit(1)
.single()
.single<PropertyModel>()
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 {
@@ -21,7 +21,7 @@ export function usePropertyScene() {
const isLoadingProperty = usePropertyStore((state) => state.isLoading)
const lastPropertyIdRef = useRef<string | null>(null)
const saveTimeoutRef = useRef<NodeJS.Timeout>()
const saveTimeoutRef = useRef<NodeJS.Timeout | undefined>(undefined)
const isSavingRef = useRef(false)
const currentPropertyIdRef = useRef<string | null>(null)
@@ -86,7 +86,7 @@ export async function getActiveProperty(): Promise<ActionResult<Property | null>
.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<ActionResult<Property | null>
address:properties_addresses(*)
`)
.eq('id', sessionData.active_property_id)
.single()
.single<Property>()
if (error) {
return {
@@ -143,8 +143,8 @@ export async function setActiveProperty(propertyId: string | null): Promise<Acti
const supabase = await createServerSupabaseClient()
// Update session's active_property_id
const { error } = await supabase
.from('auth_sessions')
const { error } = await (supabase
.from('auth_sessions') as any)
.update({ active_property_id: propertyId })
.eq('user_id', session.user.id)
@@ -188,21 +188,22 @@ export async function createProperty(params: CreatePropertyParams): Promise<Acti
const propertyId = createId('property')
// First, create the address
const { data: address, error: addressError } = await supabase
.from('properties_addresses')
.insert({
id: addressId,
street_number: params.streetNumber,
route: params.route,
city: params.city || '',
state: params.state || '',
postal_code: params.postalCode || '',
country: params.country || 'US',
latitude: params.center[1].toString(),
longitude: params.center[0].toString(),
})
const addressData = {
id: addressId,
street_number: params.streetNumber,
route: params.route,
city: params.city || '',
state: params.state || '',
postal_code: params.postalCode || '',
country: params.country || 'US',
latitude: params.center[1].toString(),
longitude: params.center[0].toString(),
}
const { data: address, error: addressError } = (await (supabase
.from('properties_addresses') as any)
.insert(addressData)
.select()
.single()
.single()) as { data: Property['address'] | null; error: any }
if (addressError || !address) {
return {
@@ -212,23 +213,24 @@ export async function createProperty(params: CreatePropertyParams): Promise<Acti
}
// Create the property
const { data, error } = await supabase
.from('properties')
.insert({
id: propertyId,
name: params.name,
address_id: address.id,
owner_id: session.user.id,
details_json: {
coordinates: params.center,
createdFrom: 'editor-app',
},
})
const propertyData = {
id: propertyId,
name: params.name,
address_id: address.id,
owner_id: session.user.id,
details_json: {
coordinates: params.center,
createdFrom: 'editor-app',
},
}
const { data, error } = (await (supabase
.from('properties') as any)
.insert(propertyData)
.select(`
*,
address:properties_addresses(*)
`)
.single()
.single()) as { data: Property | null; error: any }
if (error) {
return {
@@ -300,12 +302,12 @@ export async function checkPropertyDuplicate(params: {
}
if (data && data.length > 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,
},
}
@@ -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