a a vibe-coded abomination experiment of a fragrance review platform built on the atmosphere. drydown.social
at main 49 lines 1.3 kB view raw
1import type { Fragrance, AtUri } from '@/types/lexicon-types' 2 3/** 4 * Check if house can be deleted (no fragrances reference it) 5 */ 6export function canDeleteHouse( 7 houseUri: AtUri, 8 fragrances: Fragrance[] 9): { canDelete: boolean; reason?: string; count?: number } { 10 const referencingFragrances = fragrances.filter(f => f.house === houseUri) 11 12 if (referencingFragrances.length > 0) { 13 return { 14 canDelete: false, 15 reason: `${referencingFragrances.length} fragrance(s) reference this house`, 16 count: referencingFragrances.length 17 } 18 } 19 20 return { canDelete: true } 21} 22 23/** 24 * Get count of fragrances owned by user that reference a house 25 */ 26export function getOwnedFragranceCount( 27 houseUri: AtUri, 28 fragrances: Fragrance[], 29 ownerDid: string 30): number { 31 return fragrances.filter(f => { 32 const [, , fragDid] = (f.uri || '').split('/') 33 return f.house === houseUri && fragDid === ownerDid 34 }).length 35} 36 37/** 38 * Get all fragrances owned by user that reference a house 39 */ 40export function getOwnedFragrancesForHouse( 41 houseUri: AtUri, 42 fragrances: Fragrance[], 43 ownerDid: string 44): Fragrance[] { 45 return fragrances.filter(f => { 46 const [, , fragDid] = (f.uri || '').split('/') 47 return f.house === houseUri && fragDid === ownerDid 48 }) 49}