diff --git a/packages/features/src/student.tsx b/packages/features/src/student.tsx index b39dd38..8001045 100644 --- a/packages/features/src/student.tsx +++ b/packages/features/src/student.tsx @@ -9,7 +9,7 @@ import { applyHeartbeat, applyPaymentEvent, clock, COUNTRIES, courseDuration, courseProgress, createOrder, DomainError, effectiveStatus, ET_CITIES, formatDuration, formatMoney, gradeAssessment, isCompleted, isStudentVisible, lessonAccess, owns, publishedLessons, resumePoint, tr, validateLocation, validPassword, } from './domain'; -import { CopyText, Cover, Empty, FeedbackButton, fmtDate, Icon, KitIcon, Logo, Modal, VIMEO_ORIGIN, VIMEO_PLACEHOLDER, Ring, Skeleton, StatusPill } from './ui'; +import { CAT_PHOTOS, CopyText, Cover, coursePhoto, Empty, FeedbackButton, fmtDate, Icon, KitIcon, Logo, Modal, VIMEO_ORIGIN, VIMEO_PLACEHOLDER, Ring, Skeleton, StatusPill } from './ui'; import { PAY_LOGOS } from './payLogos'; const ISSUE_TYPES: IssueType[] = ['BUG', 'PAYMENT', 'VIDEO', 'ACCOUNT', 'CONTENT', 'OTHER']; @@ -253,7 +253,6 @@ function StudentRoutes() { // Hero collage and category photos (apps/demo/public/photos; credits in PHOTO_CREDITS). Decorative, so they don't wait on the catalog. const HERO_PHOTOS = ['habesha-bride.jpg', 'habesha-harari.jpg', 'habesha-trad.jpg', 'habesha-eritrean.jpg', 'hero.jpg', 'habesha-tigray.jpg']; -const CAT_PHOTOS = ['habesha-harari.jpg', 'hero.jpg', 'habesha-trad.jpg', 'habesha-eritrean.jpg']; // The live pill: faces take turns lighting up and it points people to the waitlist (apps/demo/public/waitlist). const FACES = ['habesha-tigray.jpg', 'habesha-harari.jpg', 'habesha-bride.jpg', 'hero.jpg']; const PHOTO_CREDITS: [string, string, string][] = [ @@ -441,7 +440,7 @@ function Catalog({ categorySlug }: { categorySlug?: string }) { function CoursePage({ slug }: { slug?: string }) { const t = useTranslations(); - const { courses, categories, me, locale, nav, catalogLoaded, toast } = useApp(); + const { courses, categories, me, locale, nav, catalogLoaded, toast, ds } = useApp(); const { catName } = useCatalog(); const [tab, setTab] = useState('overview'); const c = courses.find((x) => x.slug === slug); @@ -456,97 +455,111 @@ function CoursePage({ slug }: { slug?: string }) { const pre = c.prerequisiteCourseId ? courses.find((x) => x.id === c.prerequisiteCourseId) : undefined; const preDone = !pre || courseProgress(pre, me).pct === 100; const preview = lessons.find((l) => l.isPreview); + const previews = lessons.filter((l) => l.isPreview).length; const cat = categories.find((k) => k.id === c.categoryId); const chapters = [...c.chapters].sort((a, b) => a.sortOrder - b.sortOrder); const play = mine && r ? `/${locale}/learn/${c.slug}/${r.lesson.id}` : preview ? `/${locale}/learn/${c.slug}/${preview.id}` : null; const playLabel = mine && r ? (done ? t('course.watchAgain') : t('course.continue', { n: r.index + 1 })) : t('course.watchPreview'); const share = () => { navigator.clipboard?.writeText(location.href).then(() => toast(t('course.linkCopied')), () => { /* clipboard blocked */ }); }; const teaches = courses.filter((x) => x.instructorName === c.instructorName && isStudentVisible(x, me)).length; - const tabs: [string, string][] = [['overview', t('course.tabOverview')], ...(text.outcomes?.length ? [['outcomes', t('course.outcomes')] as [string, string]] : []), ['instructor', t('course.tabInstructor')]]; + // No uploaded cover in the demo → a category photo stands in on the preview card. + const photo = c.coverAssetId ? ds.assetUrl(c.coverAssetId) : coursePhoto(c, categories.map((k) => k.id)); + const tabs: [string, string][] = [['overview', t('course.tabOverview')], ['content', t('course.content')], ['instructor', t('course.tabInstructor')]]; + const includes: [string, ReactNode][] = [ + ['globe', LOCALE_NAMES[c.instructionLocale]], + ['video', t('course.lessons', { n: lessons.length })], + ['clock', formatDuration(courseDuration(c))], + ...(previews ? [['play', t('course.previewLessons', { n: previews })] as [string, ReactNode]] : []), + ...(c.assessments?.length ? [['quiz', t('assess.title')] as [string, ReactNode]] : []), + ['shield', t('course.lifetimeAccess')], + ]; return ( -
{text.subtitle}
} -{text.description}
} - {text.audience &&{t('course.audience')}: {text.audience}
} -{t('course.teaches', { n: teaches })}
{text.subtitle || text.description}
} +{text.description}
} + {text.audience &&{t('course.audience')}: {text.audience}
} +{t('course.lessons', { n: lessons.length })} · {formatDuration(courseDuration(c))}
+ {chapters.map((ch, i) => { + const ls = [...ch.lessons].sort((a, b) => a.sortOrder - b.sortOrder).filter((l) => l.isPublished); + if (!ls.length) return null; + const d = ls.filter((l) => isCompleted(me, l.id)).length; + return ( +{t('course.teaches', { n: teaches })}
{err}
} - -{t('checkout.simulated')}
-{err}
} + +{t('checkout.simulated')}
+
{t('auth.sideBody')}
-{t('landing.lead')}
+