import { useState } from 'react'; import { TryOnFigure } from './TryOnFigure'; import { tryOnFilename } from './share'; import { useShareAction } from './useShareAction'; import type { WidgetTranslations } from '../i18n'; interface DemoResultViewProps { resultImage: string; originalClothingImage?: string; productTitle?: string; /** Product page, used by the share fallbacks. */ productUrl?: string; onTryAnother: () => void; onClose: () => void; t: WidgetTranslations['result']; shareT: WidgetTranslations['share']; } /** * The demo's result screen. The merchant one (`components/ResultView`) is left * untouched on purpose, so nothing here can regress a real storefront. * * Two differences: the garment sits on the render as a thumbnail, so fidelity * can be judged without switching screens, and Download became Share. Share * hands the file to the OS where that exists and quietly saves it where it does * not, so the render still never leaves the device either way. */ export function DemoResultView({ resultImage, originalClothingImage, productTitle, productUrl, onTryAnother, onClose, t, shareT, }: DemoResultViewProps) { const [viewMode, setViewMode] = useState<'result' | 'compare'>('result'); const { notice, share } = useShareAction(shareT); const handleShare = () => { void share({ image: resultImage, filename: tryOnFilename(productTitle), title: productTitle || t.toggleResult, url: productUrl, }); }; return (
{notice.text}
)} {productTitle && (