// Onboarding screen — register with name + initial + school code const Onboarding = ({ onDone }) => { const t = window.MP_I18N.t; const [firstName, setFirst] = React.useState(''); const [lastInitial, setLI] = React.useState(''); const [schoolCode, setSC] = React.useState(''); const [schoolName, setSN] = React.useState(''); const [grade, setGrade] = React.useState(''); const [err, setErr] = React.useState({}); const [lang, setLang] = React.useState(window.MP_I18N.getLang()); const switchLang = () => { const next = lang === 'es' ? 'en' : 'es'; window.MP_I18N.setLang(next); setLang(next); }; const submit = async () => { const e = {}; if (firstName.trim().length < 2) e.firstName = true; if (lastInitial.trim().length < 1) e.lastInitial = true; if (schoolCode.trim().length < 3) e.schoolCode = true; setErr(e); if (Object.keys(e).length) return; window.MP_SOUND.celebrate(); onDone({ firstName: firstName.trim().slice(0, 20), lastInitial: lastInitial.trim().charAt(0).toUpperCase(), schoolCode: schoolCode.trim().toUpperCase().slice(0, 12), schoolName: schoolName.trim().slice(0, 60), grade, lang }); }; return ( <>
★ MULTIPLIER

{t('welcome')}

{t('tagline')}

setFirst(e.target.value)} placeholder={lang === 'es' ? 'Mateo' : 'Sam'} autoComplete="off" maxLength={20} />
setLI(e.target.value.toUpperCase().slice(0, 1))} placeholder="M" maxLength={1} style={{ textTransform: 'uppercase' }} />
{t('privacy_note')}
setSC(e.target.value.toUpperCase())} placeholder="SOL01" maxLength={12} style={{ textTransform: 'uppercase' }} />
{t('need_school_code')}
setSN(e.target.value)} placeholder={lang === 'es' ? 'Escuela...' : 'School...'} maxLength={60} />
); }; window.Onboarding = Onboarding;