"use client"; import { X } from "lucide-react"; import { useEffect } from "react"; import { CharacterLayerPreview } from "@/components/character/character-layer-preview"; import { ParallaxRoomBackground } from "@/components/pet/parallax-room-background"; import { Button } from "@/components/ui/button"; import type { AvatarCustomization } from "@/lib/avatar-customization-storage"; import { buildShopItemPreviewCustomization } from "@/lib/shop-preview"; import type { ShopItemRecord } from "@/lib/shop-catalog"; import { normalizeRoomBackgroundId, type RoomBackgroundId, } from "@/lib/room-backgrounds"; type ShopItemPreviewModalProps = { item: ShopItemRecord | null; baseCustomization: AvatarCustomization; coins: number | null; owned: boolean; equipped: boolean; canAfford: boolean; isPending: boolean; onClose: () => void; onPurchase: () => void; onEquipToggle: () => void; }; export function ShopItemPreviewModal({ item, baseCustomization, coins, owned, equipped, canAfford, isPending, onClose, onPurchase, onEquipToggle, }: ShopItemPreviewModalProps) { useEffect(() => { if (!item) { return; } const handleKeyDown = (event: KeyboardEvent) => { if (event.key === "Escape") { onClose(); } }; window.addEventListener("keydown", handleKeyDown); return () => { window.removeEventListener("keydown", handleKeyDown); }; }, [item, onClose]); if (!item) { return null; } const previewCustomization = buildShopItemPreviewCustomization( baseCustomization, item, ); const roomId = normalizeRoomBackgroundId( previewCustomization.roomBackground, ) as RoomBackgroundId; return (
event.stopPropagation()} >

Preview on your pet

{item.name}

Preview only — nothing is purchased or equipped until you confirm.

Price {item.price} points
{owned ? ( ) : ( <> {!canAfford && coins !== null ? (

You need {item.price - coins} more points to buy this item. Keep completing habits to earn more.

) : null} )}
); }