// DEPLOY_CONFIG: {"triggers": [{"name": "fetch_product_details_proxy", "on": "collection.add", "collection": "product_link_requests", "actions": [{"type": "email", "to": "backend-proxy@deplixo.local", "subject": "Proxy request to fetch product details", "body": "When a user pastes a product link, call the external product API server-side, store the response, and return sanitized product details to the client. This avoids CORS and keeps the external API client-exposed data hidden."}]}]} import { useEffect, useMemo, useState } from 'react'; import { useCollection, useIdentity, share } from '@deplixo/sdk'; import { RegistryList } from './components/RegistryList.jsx'; import { RegistryDetail } from './components/RegistryDetail.jsx'; import { AddRegistry } from './components/AddRegistry.jsx'; import { AddItem } from './components/AddItem.jsx'; import { GuestView } from './components/GuestView.jsx'; function App() { const [view, setView] = useState('list'); const [activeRegistry, setActiveRegistry] = useState(null); const [showAddRegistry, setShowAddRegistry] = useState(false); const [showAddItem, setShowAddItem] = useState(false); const [editingItem, setEditingItem] = useState(null); const [guestRegistryId, setGuestRegistryId] = useState(null); const [shareRegistry, setShareRegistry] = useState(null); const [shareCopied, setShareCopied] = useState(false); const registries = useCollection('registries', { personal: true }); const items = useCollection('registry_items', { personal: true }); const openRegistry = (reg) => { setActiveRegistry(reg); setView('detail'); setGuestRegistryId(null); }; const openGuestView = (regId) => { setGuestRegistryId(regId); setView('guest'); setActiveRegistry(null); }; const goHome = () => { setView('list'); setActiveRegistry(null); setGuestRegistryId(null); setShareRegistry(null); setShareCopied(false); }; const getShareUrl = (registryId) => { if (typeof window === 'undefined') return ''; return `${window.location.origin}${window.location.pathname}?registry=${encodeURIComponent(registryId)}`; }; const copyShareUrl = async (registryId) => { const url = getShareUrl(registryId); try { await navigator.clipboard.writeText(url); setShareCopied(true); window.setTimeout(() => setShareCopied(false), 2000); } catch { window.prompt('Copy this registry link', url); } }; const openShare = (reg) => { setShareRegistry(reg); setShareCopied(false); }; useEffect(() => { const params = new URLSearchParams(window.location.search); const registryId = params.get('registry'); if (!registryId || !registries?.items) return; const matched = registries.items.find((reg) => String(reg.id) === String(registryId)); if (matched) { setActiveRegistry(matched); setView('detail'); } else { setGuestRegistryId(registryId); setView('guest'); } }, [registries?.items]); return (
{view !== 'list' && ( )}

🎁 Gift Registry

Create & share wishlists for any occasion

{view === 'list' && ( setShowAddRegistry(true)} onGuestView={openGuestView} onShare={openShare} /> )} {view === 'detail' && activeRegistry && ( { setEditingItem(null); setShowAddItem(true); }} onEditItem={(item) => { setEditingItem(item); setShowAddItem(true); }} onGuestView={() => openGuestView(activeRegistry.id)} onShare={() => openShare(activeRegistry)} /> )} {view === 'guest' && guestRegistryId && ( )}
{showAddRegistry && ( setShowAddRegistry(false)} onCreated={(reg) => { setShowAddRegistry(false); openRegistry(reg); }} /> )} {showAddItem && activeRegistry && ( { setShowAddItem(false); setEditingItem(null); }} /> )} {shareRegistry && (
setShareRegistry(null)}>
e.stopPropagation()}>

Share Registry

Anyone with this link can open the registry guest view.

)}
); } ReactDOM.createRoot(document.getElementById("root")).render();