'use client'; import React, { useState } from 'react'; import { useProofing } from './ProofingContext'; export function ProofingModal() { const proofing = useProofing(); const [copiedState, setCopiedState] = useState<'none' | 'link' | 'list'>('none'); if (!proofing || !proofing.isModalOpen) return null; const { favorites, isModalOpen, setIsModalOpen, getProofingUrl, getFormattedList, clearFavorites, allowMailto, } = proofing; const handleCopyLink = () => { const url = getProofingUrl(); navigator.clipboard.writeText(url).then(() => { setCopiedState('link'); setTimeout(() => setCopiedState('none'), 2000); }); }; const handleCopyList = () => { const list = getFormattedList(); navigator.clipboard.writeText(list).then(() => { setCopiedState('list'); setTimeout(() => setCopiedState('none'), 2000); }); }; const handleMailto = () => { const subject = encodeURIComponent(`Photo Selection (${favorites.size} items)`); const body = encodeURIComponent( `Hello,\n\nHere is my photo selection:\n\n${getFormattedList()}\n\nShare Link: ${getProofingUrl()}\n\nBest regards,`, ); window.location.href = `mailto:?subject=${subject}&body=${body}`; }; return (
You have selected {favorites.size} photo{favorites.size === 1 ? '' : 's'}. Choose an export option below to share your selection: