From 4a3561bcb5bc868d80689c82f5ad39acb22765ec Mon Sep 17 00:00:00 2001 From: kirukib Date: Tue, 20 Oct 2026 14:16:11 +0300 Subject: [PATCH] feat: menu sheet, first-visit language picker, social sign-in, profile progress, history page - Header keeps logo, links, bell/avatar or Get started; theme, language and feedback move into a menu sheet (native dialog) with large numbered links - First visit asks for a language, prompt shown in all four - Sign-in: Google / Apple / Telegram / Facebook buttons (simulated, like the phone code) - One footer on every page (compact variant removed) - Profile: identity header, stats, per-course progress with Continue and the lesson/quiz list, recent activity; /progress now opens the profile - History page: dated timeline of lessons, purchases and reports Co-Authored-By: Claude Opus 5.5 --- packages/features/src/student.tsx | 198 +++++++++++++++++++++++------- packages/features/src/styles.css | 86 ++++++++++++- packages/i18n/messages/am.json | 22 +++- packages/i18n/messages/en.json | 22 +++- packages/i18n/messages/om.json | 22 +++- packages/i18n/messages/ti.json | 22 +++- tools/preview/smoke.mjs | 1 + 7 files changed, 322 insertions(+), 51 deletions(-) diff --git a/packages/features/src/student.tsx b/packages/features/src/student.tsx index 2861517..bf7ca1e 100644 --- a/packages/features/src/student.tsx +++ b/packages/features/src/student.tsx @@ -71,6 +71,8 @@ export function StudentApp() { const section = route[1] ?? ''; const unread = signedIn ? inbox.filter((n) => !n.readAt).length : 0; const mainRef = useRef(null); + const sheet = useRef(null); + const closeSheet = () => sheet.current?.close(); const [scrolled, setScrolled] = useState(false); useEffect(() => { const on = () => setScrolled(scrollY > 24); @@ -80,7 +82,7 @@ export function StudentApp() { const go = (p: string) => nav(`/${locale}${p}`); const tabs: [string, string, string][] = [['', 'home', t('nav.home')], ['courses', 'grid', t('nav.courses')], ['my', 'book', t('nav.myCourses')], ['help', 'help', t('nav.help')], ['profile', 'user', t('nav.profile')]]; const links = tabs.filter(([p]) => p !== 'profile' && (p !== 'my' || signedIn)); - const current = (s: string) => (s === section || (s === 'courses' && (section === 'course')) || (s === 'my' && section === 'progress') ? 'page' : undefined); + const current = (s: string) => (s === section || (s === 'courses' && (section === 'course')) || (s === 'profile' && (section === 'progress' || section === 'history')) ? 'page' : undefined); return (
@@ -91,18 +93,33 @@ export function StudentApp() { {links.map(([p, , label]) => )}
- mainRef.current} /> - - {signedIn ? <> : <> } +
+ {/* Menu sheet: the main links set large, then the preferences that used to crowd the header. */} + { if (e.target === sheet.current) closeSheet(); }}> +
+
+ +
+
{t('common.theme')}
+
{t('common.language')}
+
{t('common.feedback')} mainRef.current} />
+
+

{t('help.telegram')}{settings.supportPhone}

+
+
+
{settings.maintenanceBanner &&
{settings.maintenanceBanner}
} @@ -127,6 +144,33 @@ function LangPick() { ); } +// First visit: ask for a language before anything else. Shown in every language, since we don't know theirs yet. +const LANG_PROMPT: Record = { en: 'Choose your language', am: 'ቋንቋ ይምረጡ', om: 'Afaan filadhu', ti: 'ቋንቋ ምረጽ' }; +function LangWelcome() { + const { locale, setLocale } = useApp(); + const ref = useRef(null); + useEffect(() => { + let seen = true; + try { seen = !!localStorage.getItem('lms.langChosen'); } catch { /* storage blocked: don't nag */ } + if (!seen) ref.current?.showModal(); + }, []); + const pick = (l: Locale) => { + try { localStorage.setItem('lms.langChosen', '1'); } catch {} + if (l !== locale) setLocale(l); + ref.current?.close(); + }; + return ( + pick(locale)}> + +
+ +

{LANG_PROMPT.en}

{LOCALES.filter((l) => l !== 'en').map((l) => {LANG_PROMPT[l]})}

+
{LOCALES.map((l) => )}
+
+
+ ); +} + // The choice lives in localStorage; apps/demo/app/layout.tsx applies it before first paint. function ThemeToggle({ label }: { label: string }) { const [dark, setDark] = useState(false); @@ -159,7 +203,7 @@ function UserMenu() {
{name}{(me?.phone || me?.email) && {me?.phone || me?.email}}
- +
@@ -171,19 +215,7 @@ function Footer() { const t = useTranslations(); const { settings, locale, nav, categories, courses, signedIn, me, route } = useApp(); // Big marketing footer on the landing page and catalog only; app screens get one quiet line (audit 2026-10-16, Q1). - const full = (route[1] === undefined && !signedIn) || route[1] === 'courses'; const langs = ; - if (!full) return ( -
-
- © {new Date().getFullYear()} {settings.brandName} - {t('help.telegram')} - {settings.supportPhone} -
{langs}
-
-

{t.rich('footer.poweredBy', { name: () => Yaltopia Tech })}

-
- ); const go = (p: string) => nav(`/${locale}${p}`); const kit: [string, string][] = [['foundation', 'kit1'], ['brush', 'kit2'], ['brow', 'kit3'], ['lipstick', 'kit4']]; return ( @@ -203,7 +235,7 @@ function Footer() {

{t('nav.courses')}

{categories.filter((c) => c.isActive).map((c) => )}

{t('footer.learn')}

- {signedIn && } + {signedIn && } {t('footer.waitlist')}
@@ -254,7 +286,8 @@ function StudentRoutes() { case 'pay': return ; case 'orders': return ; case 'my': return ; - case 'progress': return ; + case 'progress': return ; // progress lives on the profile + case 'history': return ; case 'notifications': return ; case 'help': return ; case 'profile': return ; @@ -1024,22 +1057,47 @@ function MyCourses() { ); } -function MyProgress() { - const t = useTranslations(); - const { me, courses, locale, nav } = useApp(); - const mine = courses.filter((c) => owns(me, c.id) && !c.isTest); +// Everything a student did, newest first: lessons finished or started, purchases, reports. +type Activity = { at: string; icon: string; text: string; link?: string }; +function activity(me: Student, courses: Course[], locale: Locale, t: ReturnType): Activity[] { + const out: Activity[] = []; + for (const [lid, pr] of Object.entries(me.progress ?? {})) { + const c = courses.find((x) => x.id === pr.courseId); + const l = c?.chapters.flatMap((ch) => ch.lessons).find((x) => x.id === lid); + if (!c || !l) continue; + out.push({ at: pr.completedAt ?? pr.updatedAt, icon: pr.completedAt ? 'check' : 'play', text: t(pr.completedAt ? 'history.done' : 'history.watched', { lesson: lessonTitle(l, locale), course: ct(c, locale).title }), link: `/${locale}/learn/${c.slug}/${lid}` }); + } + for (const o of Object.values(me.orders ?? {})) { + const c = courses.find((x) => x.id === o.courseId); + if (o.paidAt && c) out.push({ at: o.paidAt, icon: 'cart', text: t('history.paid', { course: ct(c, locale).title }), link: `/${locale}/course/${c.slug}` }); + } + for (const i of Object.values(me.issues ?? {})) out.push({ at: i.createdAt, icon: 'flag', text: t('history.report', { subject: i.subject }), link: `/${locale}/help` }); + return out.sort((a, b) => b.at.localeCompare(a.at)); +} + +function Timeline({ items, grouped }: { items: Activity[]; grouped?: boolean }) { + const { nav } = useApp(); return ( -
-

{t('my.progressTitle')}

- {!mine.length && nav(`/${locale}/courses`)}>{t('landing.browse')}}>{t('my.empty')}} - {mine.map((c) => ( -
-

{ct(c, locale).title}

-
- {[...c.chapters].sort((a, b) => a.sortOrder - b.sortOrder).map((ch) =>

{tr(ch.translations, locale)?.title}

{ch.lessons.filter((l) => l.isPublished).sort((a, b) => a.sortOrder - b.sortOrder).map((l) => )}
)} - {!!c.assessments?.length &&

{t('assess.title')}

{c.assessments.map((a) => )}
} -
- ))} +
    {items.map((a, k) =>
  1. + {grouped && (k === 0 || fmtDate(items[k - 1].at) !== fmtDate(a.at)) &&

    {fmtDate(a.at)}

    } + +
  2. )}
+ ); +} + +function History() { + const t = useTranslations(); + const { me, courses, locale } = useApp(); + if (!me) return null; + const items = activity(me, courses, locale, t); + return ( +
+

{t('history.title')}

{t('history.lead')}

+ {items.length ? : {t('history.empty')}}
); } @@ -1175,10 +1233,9 @@ function SignIn() {
{!viewer?.id ? {t('auth.noIdentity')} : step === 'start' ?
{ e.preventDefault(); send(); }}>

{t('auth.welcome')}

{t('auth.welcomeLead')}

- {me && !me.deletedAt && <> - -
{t('auth.or')}
- } + {me && !me.deletedAt && } + { if (me && !me.deletedAt) { signIn(); nav(`/${locale}`); } else setStep('setup'); }} /> +
{t('auth.or')}

{mode === 'phone' ? t('auth.phoneTitle') : t('auth.emailTitle')}

{mode === 'phone' ? (