// 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 ( <>
{t('tagline')}