import { TryOnFigure } from './TryOnFigure'; import { tryOnFilename } from './share'; import { useShareAction } from './useShareAction'; import { formatTryOnDate } from './dateLabels'; import type { TryOnHistoryItem } from '../types'; import type { WidgetTranslations } from '../i18n'; interface GalleryViewProps { items: TryOnHistoryItem[]; onBack: () => void; onDelete: (id: string) => void; t: WidgetTranslations['gallery']; shareT: WidgetTranslations['share']; /** Injected by tests so the date labels are deterministic. */ now?: Date; } /** * Everything the shopper has tried on, on this device. * * The Shopify original put an add-to-cart on every row. Here each row links * back to the item instead: this is a demo where nothing is for sale, and a * cart button would contradict the banner at the top of the page. The way * back to the product is the point. */ export function GalleryView({ items, onBack, onDelete, t, shareT, now }: GalleryViewProps) { const { notice, share } = useShareAction(shareT); const handleShare = (item: TryOnHistoryItem) => { void share({ image: item.resultImage, filename: tryOnFilename(item.productTitle), title: item.productTitle || t.title, url: item.productUrl, }); }; return (
{t.emptyMessage}
{notice.text}
)}{t.privacyNote}
> )}