import type { Fragrance, AtUri } from '@/types/lexicon-types' /** * Check if house can be deleted (no fragrances reference it) */ export function canDeleteHouse( houseUri: AtUri, fragrances: Fragrance[] ): { canDelete: boolean; reason?: string; count?: number } { const referencingFragrances = fragrances.filter(f => f.house === houseUri) if (referencingFragrances.length > 0) { return { canDelete: false, reason: `${referencingFragrances.length} fragrance(s) reference this house`, count: referencingFragrances.length } } return { canDelete: true } } /** * Get count of fragrances owned by user that reference a house */ export function getOwnedFragranceCount( houseUri: AtUri, fragrances: Fragrance[], ownerDid: string ): number { return fragrances.filter(f => { const [, , fragDid] = (f.uri || '').split('/') return f.house === houseUri && fragDid === ownerDid }).length } /** * Get all fragrances owned by user that reference a house */ export function getOwnedFragrancesForHouse( houseUri: AtUri, fragrances: Fragrance[], ownerDid: string ): Fragrance[] { return fragrances.filter(f => { const [, , fragDid] = (f.uri || '').split('/') return f.house === houseUri && fragDid === ownerDid }) }