// agreement.jsx — Song Submission Agreement gate. // Shown BEFORE a user can upload any audio for evaluation (feed peer-rating // OR paid coach review). The user must view the agreement PDF and tick // "I have read and agree"; the acceptance is persisted to Supabase via // window.LAUNCH_USER.acceptSongAgreement (see user.jsx / song-agreement.sql). // // Reusable across screens — render inline when an upload is attempted without // consent: window.LAUNCH_AGREEMENT.SongAgreementGate({ theme, onClose, onAccepted }) const { useState: useStateAgr } = React; const { DisplayHeading: DisplayHeadingAgr } = window.LAUNCH_SCREENS_1; function SongAgreementGate({ theme, onClose, onAccepted }) { const U = window.LAUNCH_USER; const url = (U && U.songAgreementUrl) ? U.songAgreementUrl() : 'documents/Song_Submission_Agreement_Launch.pdf'; const version = (U && U.songAgreementVersion) ? U.songAgreementVersion() : ''; const [opened, setOpened] = useStateAgr(false); // did they open/scroll the doc? const [checked, setChecked] = useStateAgr(false); // ticked "I agree" const [busy, setBusy] = useStateAgr(false); const [err, setErr] = useStateAgr(null); const canAgree = opened && checked && !busy; const confirm = async () => { if (!canAgree) return; setBusy(true); setErr(null); const res = U && U.acceptSongAgreement ? await U.acceptSongAgreement() : { error: 'Unavailable' }; setBusy(false); if (res && res.ok) { onAccepted && onAccepted(); } else { setErr((res && res.error) || 'Could not save your agreement. Try again.'); } }; return (