feat: Phase 0 Claude-hosted demo of the e-learning platform
Spec v1.2, Logosmental-based design direction and tokens, pnpm monorepo (apps/demo, packages/data|features|i18n|db/seed), student + admin screens in 4 locales, simulated ArifPay checkout on the real order state machine, artifact inline/check tools, domain rule checks and UI audit fixes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
node_modules
|
||||||
|
.next
|
||||||
|
out
|
||||||
|
dist
|
||||||
|
*.tsbuildinfo
|
||||||
|
.env*
|
||||||
|
!.env.example
|
||||||
29
README.md
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
# MakeUp Academy — e-learning platform
|
||||||
|
|
||||||
|
Video courses for makeup artists in Amharic, Afaan Oromoo, Tigrinya and English. Students pay once per course (Telebirr / CBE Birr through ArifPay) and keep it for life.
|
||||||
|
|
||||||
|
- **Spec:** [`SPEC.md`](SPEC.md) is the single source of truth. Read it before writing code.
|
||||||
|
- **Design:** [`design/inspo/README.md`](design/inspo/README.md) (Logosmental reference), [`design/tokens.json`](design/tokens.json), [`design/audit-2026-10-06.md`](design/audit-2026-10-06.md).
|
||||||
|
- **Live demo (Phase 0, Claude-hosted):** https://claude.ai/artifact/Rv2YqqccDs9GtAWbzHUCHE. It's private, so ask the owner for access. Payments, SMS and email are simulated.
|
||||||
|
|
||||||
|
## Layout
|
||||||
|
|
||||||
|
| Path | What |
|
||||||
|
|---|---|
|
||||||
|
| `apps/demo` | Next.js 15 static export, inlined into one HTML file and published as the Claude artifact (SPEC §18) |
|
||||||
|
| `packages/features` | All student and admin screens, plus `domain.ts` (payments, access, progress, dashboard rules) |
|
||||||
|
| `packages/data` | `DataSource` interface + `ClaudeDbDataSource`. Production adds `ApiDataSource` |
|
||||||
|
| `packages/i18n` | Message catalogs. `om` and `ti` are drafts that need a translator |
|
||||||
|
| `packages/db/seed` | Demo seed (fictional sample students are marked `isSample`) |
|
||||||
|
| `tools/` | `artifact-inline`, `artifact-check`, `i18n-check`, and `preview/` (local runtime mock + click-everything smoke test) |
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npx -y pnpm@9 install
|
||||||
|
npx -y pnpm@9 run demo:build # next build → dist/demo.html → offline network check
|
||||||
|
npx -y pnpm@9 test # domain rules (payments, entitlement, progress, dashboard)
|
||||||
|
npx -y pnpm@9 run i18n:check # every locale has every key
|
||||||
|
```
|
||||||
|
|
||||||
|
Phases 1–3 (Fastify API, Postgres, ArifPay, R2 video) haven't started yet. They wait on decisions D1, D2 and D8 in SPEC §17.
|
||||||
24
apps/demo/app/layout.tsx
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
import type { ReactNode } from 'react';
|
||||||
|
import { readFileSync } from 'node:fs';
|
||||||
|
import { join } from 'node:path';
|
||||||
|
|
||||||
|
export const metadata = { title: 'MakeUp Academy', description: 'Claude-hosted demo of the e-learning platform (SPEC §18).' };
|
||||||
|
|
||||||
|
// Inlined at build time instead of `import '…css'`: an imported stylesheet is re-requested by React's
|
||||||
|
// stylesheet hoisting at hydration, which the artifact CSP blocks. apps/web and apps/admin import it normally.
|
||||||
|
const css = readFileSync(join(process.cwd(), '../../packages/features/src/styles.css'), 'utf8');
|
||||||
|
|
||||||
|
export default function RootLayout({ children }: { children: ReactNode }) {
|
||||||
|
return (
|
||||||
|
<html lang="am">
|
||||||
|
<head>
|
||||||
|
{/* next/font emits separate files, so fonts come from Google Fonts (allowed by the artifact CSP, §18.5) */}
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="" />
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&family=Noto+Sans+Ethiopic:wght@400;700&family=Noto+Serif+Ethiopic:wght@500;700&display=swap" />
|
||||||
|
<style dangerouslySetInnerHTML={{ __html: css }} />
|
||||||
|
</head>
|
||||||
|
<body>{children}</body>
|
||||||
|
</html>
|
||||||
|
);
|
||||||
|
}
|
||||||
9
apps/demo/app/page.tsx
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
'use client';
|
||||||
|
import { ClaudeDbDataSource } from '@lms/data';
|
||||||
|
import { Platform } from '@lms/features';
|
||||||
|
|
||||||
|
const makeDs = () => new ClaudeDbDataSource();
|
||||||
|
|
||||||
|
export default function Page() {
|
||||||
|
return <Platform dataSource={makeDs} />;
|
||||||
|
}
|
||||||
6
apps/demo/next-env.d.ts
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
/// <reference types="next" />
|
||||||
|
/// <reference types="next/image-types/global" />
|
||||||
|
/// <reference path="./.next/types/routes.d.ts" />
|
||||||
|
|
||||||
|
// NOTE: This file should not be edited
|
||||||
|
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
||||||
14
apps/demo/next.config.mjs
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
// apps/demo/next.config.mjs — Appendix A.1
|
||||||
|
export default {
|
||||||
|
output: 'export',
|
||||||
|
images: { unoptimized: true },
|
||||||
|
trailingSlash: false,
|
||||||
|
transpilePackages: ['@lms/data', '@lms/features', '@lms/i18n'],
|
||||||
|
webpack: (config, { isServer }) => {
|
||||||
|
if (!isServer) {
|
||||||
|
config.optimization.splitChunks = false; // one client bundle, no lazy chunks
|
||||||
|
config.optimization.runtimeChunk = false;
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
},
|
||||||
|
};
|
||||||
9
apps/demo/package.json
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"name": "demo", "private": true,
|
||||||
|
"scripts": { "dev": "next dev", "build": "next build" },
|
||||||
|
"dependencies": {
|
||||||
|
"next": "15.5.27", "react": "19.3.0", "react-dom": "19.3.0", "next-intl": "4.14.9",
|
||||||
|
"@lms/data": "workspace:*", "@lms/features": "workspace:*", "@lms/i18n": "workspace:*"
|
||||||
|
},
|
||||||
|
"devDependencies": { "@types/react": "^19", "@types/react-dom": "^19", "@types/node": "^22", "typescript": "^5.6.0" }
|
||||||
|
}
|
||||||
2
apps/demo/tsconfig.json
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
{ "extends": "../../tsconfig.base.json", "compilerOptions": { "plugins": [{ "name": "next" }], "allowJs": false, "incremental": true },
|
||||||
|
"include": ["next-env.d.ts", "app", "../../packages/*/src", ".next/types/**/*.ts"], "exclude": ["node_modules"] }
|
||||||
29
design/audit-2026-10-06.md
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
# UI audit — 2026-10-06 (demo v1 → v2)
|
||||||
|
|
||||||
|
**Method:** I took screenshots of 17 screens with seed data loaded, at 390 px and 1280–1366 px wide, in light and dark mode. I reviewed them against `design/inspo/README.md` (Logosmental) and SPEC §11, using the Design plugin's critique and accessibility checklist. An Inspo MCP wasn't connected, so none was used.
|
||||||
|
|
||||||
|
## Fixed in v2
|
||||||
|
|
||||||
|
| # | Finding | Severity | Fix |
|
||||||
|
|---|---|---|---|
|
||||||
|
| 1 | The Orders page crashed because the seeded orders had no `id` | Critical | Seed now writes `id`. The live db was reseeded |
|
||||||
|
| 2 | A finished course still said "Continue lesson 1" | Critical (L3: misleading action) | It now shows "Course completed" with a "Watch again" button, and the Continue card prefers unfinished courses |
|
||||||
|
| 3 | English headings and the whole admin panel rendered in the Ethiopic serif (the CSS matched the `<html lang="am">` ancestor) | Moderate | Headings now match on the element's own language. The admin panel is `lang="en"`, and `<html lang>` follows the route |
|
||||||
|
| 4 | Pages scrolled sideways at 390 px (header actions, admin stat grid) | Moderate | Header actions sit on one row (the admin link moved to the footer on phones), stat grid uses `minmax(0,1fr)` |
|
||||||
|
| 5 | Landing hero was text-only, leaving half the desktop screen empty | Moderate | Added a two-column hero with a featured course card (free preview CTA) and three facts: languages, lifetime access, free previews |
|
||||||
|
| 6 | Every cover showed the same glyph "የ", the first letter of most Amharic titles | Moderate | Covers set the course title in Ge'ez serif, which is the §11.2 identity. Phones use compact thumbnails without text |
|
||||||
|
| 7 | Home on a phone was 3.6k px tall: owned courses repeated under Featured and New | Moderate | Owned courses are no longer repeated. Phones use compact course rows (§11.2) |
|
||||||
|
| 8 | The floating "Leave feedback" button covered content | Moderate | Moved into the header and the admin top bar. On phones it shows the icon only |
|
||||||
|
| 9 | Curriculum editor: each lesson was about 210 px tall, too long for a 20-lesson course (§1.1 goal 5) | Moderate | One compact row per lesson. Notes open on demand |
|
||||||
|
| 10 | Landing had no footer and no way to reach support | Minor | Footer with categories, Telegram, support phone, Help and the language list |
|
||||||
|
| 11 | Demo banner sat in the content area | Minor | Moved to a slim strip above the header |
|
||||||
|
| 12 | Neutral definition notes on stat cards were colored green | Minor | Color now marks status only |
|
||||||
|
| 13 | The flagged seed order showed as "Expired" | Minor | The flagged order now keeps its future expiry, so it reads as pending and flagged |
|
||||||
|
|
||||||
|
## Open, not fixed
|
||||||
|
|
||||||
|
- **Typographic covers duplicate the title shown right below them on desktop cards.** Real cover photos from the client fix this (L14: assets go to `design/assets`).
|
||||||
|
- **Payment "logos" are text chips with a colored square.** They need the official Telebirr and CBE Birr marks from the client.
|
||||||
|
- **The Atkinson Hyperlegible zero has a slash** (`2Ø26`). This is intentional in the font, for legibility, but the client may want to confirm it.
|
||||||
|
- **Several `btn-sm` controls are 34 px tall.** That passes WCAG 2.2 AA (24 px) but is under the 44 px comfortable size. Recheck the player controls on a real phone.
|
||||||
|
- **The Afaan Oromoo and Tigrinya catalogs are drafts.** They need a translator before UAT.
|
||||||
74
design/inspo/README.md
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
# Inspiration board
|
||||||
|
|
||||||
|
Read this before any UI task (SPEC "How to work" step 4). Each entry says what to take, and what not to take.
|
||||||
|
|
||||||
|
## 1. Logosmental LMS — https://logosmental-lms.vercel.app/
|
||||||
|
|
||||||
|
Screenshots of the reference are in `logosmental/` (captured 2026-10-06). It is a Yaltopia Education demo with the same admin shell we need, so it's the main reference for **admin layout** and **course structure presentation**.
|
||||||
|
|
||||||
|
### Admin (`admin.png`, `admin-content.png`, `admin-users.png`, `admin-notifications.png`, `admin-analytics.png`)
|
||||||
|
|
||||||
|
Take:
|
||||||
|
- **Shell.** A fixed left sidebar about 270 px wide, collapsible. Nav is grouped under small section labels (Overview / People / Learning / Operations). The active item is a filled ink icon tile plus a right-edge bar. The current admin and role are shown at the top right and as a card at the bottom of the sidebar. Content sits on a light grey canvas and cards are white. The footer is one quiet line.
|
||||||
|
- **Page header.** A small section label, then a large page title, then a one-line description that says what the page is for. The primary action ("Create course") sits top right, and there's only one per page.
|
||||||
|
- **Stat cards.** Label, big number, an icon tile, then a divider and a one-line context note ("Needs attention" in red, "+5 this week" in green). 3–4 per row. This is the pattern for the §10.3 dashboard cards. The context line is where each card's spec definition gets surfaced.
|
||||||
|
- **Filter bar.** Search box plus labelled selects in one white bar above the table, then a line like "Showing 8 of 8 users". Use it for Students, Orders and Issues.
|
||||||
|
- **Tables.** Uppercase column headers, generous row height, the name as a link, and small tinted status pills (ACTIVE / INVITED / SUSPENDED).
|
||||||
|
- **Content page.** Courses are grouped by category. Each course is a card containing its chapters (number, title, one-line "why", and lesson count on the right), with a status pill top right. This gives a readable overview of the whole catalog in one scroll. It's the model for our Courses list, with the editor (§10.4) one click deeper.
|
||||||
|
- **Notifications.** History items are cards with title, body, audience · date, and channel chips (IN_APP / EMAIL / SMS). Our version adds the table, filters and delivery detail the spec requires (L8).
|
||||||
|
- **"Switch account"** at the sidebar bottom maps to our demo "View as" role switcher (§18.2).
|
||||||
|
|
||||||
|
Don't take:
|
||||||
|
- **The "Roles" and "Team" pages as editable role builders.** Roles are fixed (L11). Show the §10.1 matrix read-only, if at all.
|
||||||
|
- **Dashboard charts fixed to "Last 7 days".** Our dashboard uses the global time filter (§10.3, L6). Trends belong on Analytics, not on the Dashboard.
|
||||||
|
- **Content-specific metrics** (Reflections, Practices). Use the §10.3 card definitions.
|
||||||
|
|
||||||
|
### Course page (`course.png`)
|
||||||
|
|
||||||
|
Take:
|
||||||
|
- **The hero:** level · brand label, a big title, the one-sentence promise, a "who it's for" line, a meta row (hours · chapters), and one primary CTA.
|
||||||
|
- **"What you'll be able to do"**: 3 numbered outcomes. This needs an `outcomes` field on the course (see "Spec gaps" below).
|
||||||
|
- **"Your learning journey"**: chapters as a vertical numbered timeline. Each chapter card shows "Why it matters." + 2 bullet goals + "Open lesson". This is the cleaner execution of our curriculum list. For us, each lesson row also shows duration, lock state, and a preview badge (§5.4).
|
||||||
|
- **A closing CTA band:** "Ready when you are — Start with chapter 1, about 25 minutes."
|
||||||
|
|
||||||
|
### Lesson player (`lesson.png`)
|
||||||
|
|
||||||
|
Take:
|
||||||
|
- **A focused top bar** with Back, the course title and close. The marketing nav is hidden while learning.
|
||||||
|
- **A left "Course content" panel:** a progress block ("00 of 02 lessons completed" + bar), then collapsible chapters with lesson rows (icon, title, duration). The current lesson is highlighted. Below 1024 px it collapses under the video.
|
||||||
|
- **Video card** with the chapter label + lesson title above it.
|
||||||
|
- **A tabs card under the video.** We ship only tabs that work (L3): *Lesson notes* (lesson description) for now. Transcript and Resources stay hidden behind flags until they exist.
|
||||||
|
|
||||||
|
Don't take:
|
||||||
|
- **Reading, quiz and assignment lesson types.** These are out of scope (§1.3).
|
||||||
|
- **The Learners and Discuss tabs.** Chat is out of scope.
|
||||||
|
- **The Vimeo embed.** We use our own player (§5.7).
|
||||||
|
|
||||||
|
## Token plan (C0-01)
|
||||||
|
|
||||||
|
Keep the §11.2 palette and type, since it's provisional client branding. Borrow Logosmental's *structure*, not its colours. The table below is the mapping, and the values live in `../tokens.json`.
|
||||||
|
|
||||||
|
| Logosmental | Ours |
|
||||||
|
|---|---|
|
||||||
|
| navy `#1a3d66` (primary, active nav, headings) | `ink` `#1B2340` |
|
||||||
|
| sky wash `#e8f1f9` (icon tiles, active row) | `mist` `#EEF1F6` |
|
||||||
|
| grey canvas | `canvas` `#F5F6F8` (admin background only) |
|
||||||
|
| red badge / "needs attention" | `alert` `#C2362B` |
|
||||||
|
| green trend text | `success` `#2E7D5B` |
|
||||||
|
| Barlow Condensed (display) | Noto Serif Ethiopic (Ge'ez) / Atkinson Hyperlegible (Latin) |
|
||||||
|
| — | `accent` `#F2B705`: progress, "Continue", focus ring only |
|
||||||
|
|
||||||
|
Principles:
|
||||||
|
1. One primary action per screen.
|
||||||
|
2. Every stat card and section header carries a one-line "what this means".
|
||||||
|
3. Content is grouped by hierarchy (Category → Course → Chapter → Lesson) visually, not just in data.
|
||||||
|
4. Student pages are quiet and give Ge'ez titles room. Admin is dense but uses the same tokens.
|
||||||
|
|
||||||
|
Logosmental uses uppercase section labels everywhere. §11.2 says to avoid all-caps eyebrows. **Compromise:** small uppercase labels are allowed **in admin only** (sidebar groups, stat card labels, table headers), where they aid scanning. They're never used on student pages, and never on Ge'ez text, which has no case.
|
||||||
|
|
||||||
|
## Spec gaps this reference exposed
|
||||||
|
|
||||||
|
Add these to §6 once confirmed. They're demo-safe as optional fields:
|
||||||
|
- `CourseTranslation.outcomes: string[]` — "What you'll be able to do".
|
||||||
|
- `CourseTranslation.audience: string?` — "Who it's for".
|
||||||
|
- `ChapterTranslation.summary: string?` — the "Why it matters" line.
|
||||||
BIN
design/inspo/logosmental/admin-analytics.png
Normal file
|
After Width: | Height: | Size: 212 KiB |
BIN
design/inspo/logosmental/admin-content.png
Normal file
|
After Width: | Height: | Size: 209 KiB |
BIN
design/inspo/logosmental/admin-notifications.png
Normal file
|
After Width: | Height: | Size: 200 KiB |
BIN
design/inspo/logosmental/admin-users.png
Normal file
|
After Width: | Height: | Size: 224 KiB |
BIN
design/inspo/logosmental/admin.png
Normal file
|
After Width: | Height: | Size: 236 KiB |
BIN
design/inspo/logosmental/course.png
Normal file
|
After Width: | Height: | Size: 428 KiB |
BIN
design/inspo/logosmental/lesson.png
Normal file
|
After Width: | Height: | Size: 581 KiB |
24
design/tokens.json
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"color": {
|
||||||
|
"ink": "#1B2340",
|
||||||
|
"inkMuted": "#5B6275",
|
||||||
|
"paper": "#FFFFFF",
|
||||||
|
"canvas": "#F5F6F8",
|
||||||
|
"mist": "#EEF1F6",
|
||||||
|
"line": "#E3E6EC",
|
||||||
|
"accent": "#F2B705",
|
||||||
|
"success": "#2E7D5B",
|
||||||
|
"alert": "#C2362B"
|
||||||
|
},
|
||||||
|
"font": {
|
||||||
|
"latin": "'Atkinson Hyperlegible', system-ui, sans-serif",
|
||||||
|
"ethiopicSans": "'Noto Sans Ethiopic', 'Atkinson Hyperlegible', sans-serif",
|
||||||
|
"ethiopicSerif": "'Noto Serif Ethiopic', serif"
|
||||||
|
},
|
||||||
|
"fontSize": { "sm": "14px", "base": "16px", "lg": "20px", "xl": "25px", "2xl": "31px", "3xl": "39px" },
|
||||||
|
"lineHeight": { "latin": 1.5, "ethiopic": 1.7 },
|
||||||
|
"space": { "1": "4px", "2": "8px", "3": "12px", "4": "16px", "6": "24px", "8": "32px", "12": "48px" },
|
||||||
|
"radius": { "sm": "8px", "md": "12px", "lg": "16px", "pill": "999px" },
|
||||||
|
"shadow": { "card": "0 1px 2px rgba(27,35,64,.06)" },
|
||||||
|
"layout": { "sidebar": "272px", "contentMax": "1200px", "readingMax": "70ch", "gutter": "16px" }
|
||||||
|
}
|
||||||
12
package.json
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"name": "makeup-lms",
|
||||||
|
"private": true,
|
||||||
|
"packageManager": "pnpm@9.15.9",
|
||||||
|
"scripts": {
|
||||||
|
"demo:build": "pnpm --filter demo build && node tools/artifact-inline.mjs apps/demo/out dist/demo.html && node tools/artifact-check.mjs dist/demo.html",
|
||||||
|
"test": "node packages/features/src/domain.check.ts",
|
||||||
|
"typecheck": "pnpm -r exec tsc --noEmit",
|
||||||
|
"i18n:check": "node tools/i18n-check.mjs"
|
||||||
|
},
|
||||||
|
"devDependencies": { "jsdom": "^26.1.0", "typescript": "^5.6.0" }
|
||||||
|
}
|
||||||
10
packages/data/package.json
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"name": "@lms/data",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"private": true,
|
||||||
|
"main": "src/index.ts",
|
||||||
|
"types": "src/index.ts",
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/react": "^19"
|
||||||
|
}
|
||||||
|
}
|
||||||
217
packages/data/src/index.ts
Normal file
|
|
@ -0,0 +1,217 @@
|
||||||
|
// Domain types (field names follow SPEC §6) and the DataSource seam (§18.5).
|
||||||
|
// Screens only talk to DataSource; the demo passes ClaudeDbDataSource, production will pass ApiDataSource.
|
||||||
|
|
||||||
|
export type Locale = 'en' | 'am' | 'om' | 'ti';
|
||||||
|
export const LOCALES: Locale[] = ['am', 'en', 'om', 'ti'];
|
||||||
|
export type Currency = 'ETB' | 'USD';
|
||||||
|
export type AdminRole = 'SUPER_ADMIN' | 'CONTENT_MANAGER' | 'SUPPORT_AGENT' | 'FINANCE' | 'ANALYST';
|
||||||
|
export type CourseStatus = 'DRAFT' | 'PUBLISHED' | 'ARCHIVED';
|
||||||
|
export type VideoStatus = 'NONE' | 'UPLOADING' | 'PROCESSING' | 'READY' | 'FAILED';
|
||||||
|
export type OrderStatus = 'PENDING' | 'PAID' | 'FAILED' | 'EXPIRED' | 'CANCELLED' | 'REFUNDED';
|
||||||
|
export type IssueStatus = 'OPEN' | 'IN_PROGRESS' | 'RESOLVED' | 'CLOSED';
|
||||||
|
export type IssueType = 'BUG' | 'PAYMENT' | 'VIDEO' | 'ACCOUNT' | 'CONTENT' | 'OTHER';
|
||||||
|
export type Channel = 'IN_APP' | 'EMAIL' | 'SMS';
|
||||||
|
export type UserStatus = 'PENDING' | 'ACTIVE' | 'DEACTIVATED';
|
||||||
|
|
||||||
|
export type Tr<T> = Partial<Record<Locale, T>>;
|
||||||
|
|
||||||
|
export interface Category {
|
||||||
|
id: string; slug: string; sortOrder: number; isActive: boolean;
|
||||||
|
translations: Tr<{ name: string }>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Lesson {
|
||||||
|
id: string; sortOrder: number; isPreview: boolean; isPublished: boolean;
|
||||||
|
durationSec: number; videoAssetId?: string | null; videoStatus: VideoStatus;
|
||||||
|
translations: Tr<{ title: string; description?: string }>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Chapter {
|
||||||
|
id: string; sortOrder: number;
|
||||||
|
translations: Tr<{ title: string; summary?: string }>;
|
||||||
|
lessons: Lesson[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Course {
|
||||||
|
id: string; slug: string; categoryId: string; instructorName: string; instructionLocale: Locale;
|
||||||
|
coverAssetId?: string | null; coverTone?: string;
|
||||||
|
status: CourseStatus; isFeatured: boolean; isTest: boolean; sequentialLessons: boolean;
|
||||||
|
prerequisiteCourseId?: string | null; publishedAt?: string | null; createdAt: string; updatedAt: string;
|
||||||
|
translations: Tr<{ title: string; subtitle?: string; description: string; audience?: string; outcomes?: string[] }>;
|
||||||
|
prices: Partial<Record<Currency, number>>; // integer minor units
|
||||||
|
chapters: Chapter[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Settings {
|
||||||
|
brandName: string; supportPhone: string; telegramLink: string; supportEmail: string;
|
||||||
|
sessionLimit: number; maintenanceBanner: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PaymentEvent { type: string; at: string; note?: string; amountMinor?: number; currency?: Currency }
|
||||||
|
|
||||||
|
export interface Order {
|
||||||
|
id: string; courseId: string; currency: Currency; amountMinor: number;
|
||||||
|
provider: 'ARIFPAY' | 'MANUAL'; method: string; status: OrderStatus;
|
||||||
|
idempotencyKey: string; failureReason?: string | null; flaggedReason?: string | null;
|
||||||
|
paidAt?: string | null; expiresAt: string; createdAt: string; updatedAt: string;
|
||||||
|
events: PaymentEvent[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Enrollment { courseId: string; source: 'PURCHASE' | 'ADMIN_GRANT' | 'FREE'; orderId?: string | null; grantedByAdminId?: string | null; revokedAt?: string | null; createdAt: string }
|
||||||
|
|
||||||
|
export interface LessonProgress { courseId: string; positionSec: number; maxPositionSec: number; completedAt?: string | null; updatedAt: string }
|
||||||
|
|
||||||
|
export interface Issue {
|
||||||
|
id: string; type: IssueType; subject: string; description: string; status: IssueStatus;
|
||||||
|
screenshotAssetId?: string | null; assignedToId?: string | null; resolutionNote?: string | null;
|
||||||
|
reportedByAdminId?: string | null; createdAt: string; updatedAt: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Student {
|
||||||
|
id: string; name: string; phone?: string; email?: string; country: string; city: string;
|
||||||
|
locale: Locale; status: UserStatus; createdAt: string; updatedAt: string; lastActiveAt?: string;
|
||||||
|
createdByAdminId?: string | null; deletedAt?: string | null; isSample?: boolean;
|
||||||
|
notificationPrefs?: Record<string, Partial<Record<Channel, boolean>>>;
|
||||||
|
enrollments: Record<string, Enrollment>;
|
||||||
|
orders: Record<string, Order>;
|
||||||
|
progress: Record<string, LessonProgress>;
|
||||||
|
issues: Record<string, Issue>;
|
||||||
|
watchSec?: Record<string, number>; // 'YYYY-MM' → seconds watched (Analytics watch hours)
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InboxItem { id: string; type: string; title: string; body: string; link?: string | null; readAt?: string | null; createdAt: string }
|
||||||
|
|
||||||
|
export interface Campaign {
|
||||||
|
id: string; createdById: string; channels: Channel[];
|
||||||
|
audience: { type: 'ALL' | 'COURSE_BUYERS' | 'USERS' | 'CITY'; courseId?: string; userIds?: string[]; city?: string };
|
||||||
|
content: Tr<{ title: string; body: string }>;
|
||||||
|
status: 'DRAFT' | 'SCHEDULED' | 'SENT' | 'FAILED'; scheduledAt?: string | null; sentAt?: string | null; createdAt: string;
|
||||||
|
system?: boolean;
|
||||||
|
deliveries: Partial<Record<Channel, { sent: number; failed: number; pending: number; failedUserIds?: string[] }>>;
|
||||||
|
recipientCount: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AuditEntry { id: string; adminId: string; action: string; entity: string; entityId: string; before?: unknown; after?: unknown; createdAt: string }
|
||||||
|
|
||||||
|
export interface Viewer { id: string | null; name: string; avatarUrl: string; isOwner: boolean; canEdit: boolean }
|
||||||
|
|
||||||
|
export type Unsub = () => void;
|
||||||
|
|
||||||
|
/** Everything a screen may ask of the backend. */
|
||||||
|
export interface DataSource {
|
||||||
|
readonly kind: 'claude-db' | 'api';
|
||||||
|
viewer(): Promise<Viewer>;
|
||||||
|
/** Display names for stored user ids (never store names). */
|
||||||
|
names(ids: string[]): Promise<Record<string, string>>;
|
||||||
|
watchCategories(cb: (c: Category[]) => void): Unsub;
|
||||||
|
watchCourses(cb: (c: Course[]) => void): Unsub;
|
||||||
|
watchSettings(cb: (s: Settings | null) => void): Unsub;
|
||||||
|
watchStudent(id: string, cb: (s: Student | null) => void): Unsub;
|
||||||
|
watchStudents(cb: (s: Student[]) => void): Unsub; // admin only
|
||||||
|
watchInbox(studentId: string, cb: (items: InboxItem[]) => void): Unsub;
|
||||||
|
watchCampaigns(cb: (c: Campaign[]) => void): Unsub;
|
||||||
|
watchAudit(cb: (a: AuditEntry[]) => void): Unsub;
|
||||||
|
saveStudent(s: Student): Promise<void>;
|
||||||
|
/** Deep-merge patch: nested objects merge, so a student and an admin can touch different keys of one doc. */
|
||||||
|
patchStudent(id: string, patch: Record<string, unknown>): Promise<void>;
|
||||||
|
saveCourse(c: Course): Promise<void>;
|
||||||
|
deleteCourse(id: string): Promise<void>;
|
||||||
|
saveCategory(c: Category): Promise<void>;
|
||||||
|
deleteCategory(id: string): Promise<void>;
|
||||||
|
saveSettings(s: Settings): Promise<void>;
|
||||||
|
addInbox(studentId: string, item: InboxItem): Promise<void>;
|
||||||
|
patchInbox(studentId: string, id: string, patch: Partial<InboxItem>): Promise<void>;
|
||||||
|
saveCampaign(c: Campaign): Promise<void>;
|
||||||
|
addAudit(a: AuditEntry): Promise<void>;
|
||||||
|
/** null when uploads aren't available to this viewer. */
|
||||||
|
uploads(): Promise<null | { upload(file: Blob): Promise<{ id: string; url: string }> }>;
|
||||||
|
assetUrl(id: string): string;
|
||||||
|
download(filename: string, data: string): Promise<boolean>;
|
||||||
|
/** Opens the reviewer comment composer pinned to an element; false when unavailable. */
|
||||||
|
feedback(el: Element): Promise<boolean>;
|
||||||
|
feedbackAvailable(): Promise<boolean>;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- Claude db implementation
|
||||||
|
|
||||||
|
type AnyFn = (...a: any[]) => any; // runtime namespaces are untyped here; see artifact-capabilities d.ts
|
||||||
|
interface ClaudeRuntime { use(name: string): Promise<any> }
|
||||||
|
declare global { interface Window { claude?: ClaudeRuntime } }
|
||||||
|
|
||||||
|
const use = (name: string): Promise<any> =>
|
||||||
|
typeof window !== 'undefined' && window.claude?.use ? window.claude.use(name).catch(() => null) : Promise.resolve(null);
|
||||||
|
|
||||||
|
const data = <T,>(snap: { docs: { id: string; data(): unknown }[] }) => snap.docs.map((d) => ({ ...(d.data() as object), id: d.id }) as T);
|
||||||
|
|
||||||
|
/** Watch helper: subscribes once the db namespace resolves; returns a sync unsubscribe. */
|
||||||
|
function watch(build: (db: any) => { onSnapshot: AnyFn }, next: (snap: any) => void, onMissing?: () => void): Unsub {
|
||||||
|
let unsub: Unsub | null = null; let dead = false;
|
||||||
|
use('db').then((db) => {
|
||||||
|
if (dead) return;
|
||||||
|
if (!db) { onMissing?.(); return; }
|
||||||
|
try { unsub = build(db).onSnapshot(next, (e: { code: string }) => console.warn('db watch ended', e.code)); }
|
||||||
|
catch (e) { console.warn(e); onMissing?.(); }
|
||||||
|
});
|
||||||
|
return () => { dead = true; unsub?.(); };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function db(): Promise<any> {
|
||||||
|
const d = await use('db');
|
||||||
|
if (!d) throw Object.assign(new Error('Saving is not available in this view.'), { code: 'not_granted' });
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
const clean = <T,>(o: T): T => JSON.parse(JSON.stringify(o)); // strips undefined; db bodies are plain JSON
|
||||||
|
|
||||||
|
export class ClaudeDbDataSource implements DataSource {
|
||||||
|
readonly kind = 'claude-db' as const;
|
||||||
|
async viewer(): Promise<Viewer> {
|
||||||
|
const u = await use('user');
|
||||||
|
if (!u) return { id: null, name: '', avatarUrl: '', isOwner: false, canEdit: false };
|
||||||
|
const me = await u.me();
|
||||||
|
return { id: me.id, name: me.name, avatarUrl: me.avatarUrl, isOwner: me.isOwner, canEdit: me.canEdit };
|
||||||
|
}
|
||||||
|
async names(ids: string[]) {
|
||||||
|
const u = await use('user');
|
||||||
|
if (!u || !ids.length) return {};
|
||||||
|
const ps = await u.profiles(ids);
|
||||||
|
return Object.fromEntries(ids.map((id) => [id, ps[id]?.name || '']));
|
||||||
|
}
|
||||||
|
watchCategories(cb: (c: Category[]) => void) { return watch((d) => d.collection('categories'), (s) => cb(data<Category>(s)), () => cb([])); }
|
||||||
|
watchCourses(cb: (c: Course[]) => void) { return watch((d) => d.collection('courses'), (s) => cb(data<Course>(s)), () => cb([])); }
|
||||||
|
watchSettings(cb: (s: Settings | null) => void) { return watch((d) => d.doc('settings/app'), (s) => cb(s.exists ? (s.data() as Settings) : null), () => cb(null)); }
|
||||||
|
watchStudent(id: string, cb: (s: Student | null) => void) { return watch((d) => d.doc(`students/${id}`), (s) => cb(s.exists ? ({ ...s.data(), id } as Student) : null), () => cb(null)); }
|
||||||
|
watchStudents(cb: (s: Student[]) => void) { return watch((d) => d.collection('students'), (s) => cb(data<Student>(s)), () => cb([])); }
|
||||||
|
watchInbox(id: string, cb: (i: InboxItem[]) => void) { return watch((d) => d.collection(`students/${id}/inbox`).orderBy('createdAt', 'desc').limit(100), (s) => cb(data<InboxItem>(s)), () => cb([])); }
|
||||||
|
watchCampaigns(cb: (c: Campaign[]) => void) { return watch((d) => d.collection('campaigns').orderBy('createdAt', 'desc').limit(200), (s) => cb(data<Campaign>(s)), () => cb([])); }
|
||||||
|
watchAudit(cb: (a: AuditEntry[]) => void) { return watch((d) => d.collection('audit').orderBy('createdAt', 'desc').limit(500), (s) => cb(data<AuditEntry>(s)), () => cb([])); }
|
||||||
|
async saveStudent(s: Student) { await (await db()).doc(`students/${s.id}`).set(clean(s)); }
|
||||||
|
async patchStudent(id: string, patch: Record<string, unknown>) { await (await db()).doc(`students/${id}`).update(clean(patch)); }
|
||||||
|
async saveCourse(c: Course) { await (await db()).doc(`courses/${c.id}`).set(clean(c)); }
|
||||||
|
async deleteCourse(id: string) { await (await db()).doc(`courses/${id}`).delete(); }
|
||||||
|
async saveCategory(c: Category) { await (await db()).doc(`categories/${c.id}`).set(clean(c)); }
|
||||||
|
async deleteCategory(id: string) { await (await db()).doc(`categories/${id}`).delete(); }
|
||||||
|
async saveSettings(s: Settings) { await (await db()).doc('settings/app').set(clean(s)); }
|
||||||
|
async addInbox(studentId: string, item: InboxItem) { await (await db()).doc(`students/${studentId}/inbox/${item.id}`).set(clean(item)); }
|
||||||
|
async patchInbox(studentId: string, id: string, patch: Partial<InboxItem>) { await (await db()).doc(`students/${studentId}/inbox/${id}`).update(clean(patch)); }
|
||||||
|
async saveCampaign(c: Campaign) { await (await db()).doc(`campaigns/${c.id}`).set(clean(c)); }
|
||||||
|
async addAudit(a: AuditEntry) { await (await db()).doc(`audit/${a.id}`).set(clean(a)); }
|
||||||
|
async uploads() {
|
||||||
|
const a = await use('assets');
|
||||||
|
return a ? { upload: async (f: Blob) => { const r = await a.upload(f); return { id: r.id, url: r.url }; } } : null;
|
||||||
|
}
|
||||||
|
assetUrl(id: string) { return `/_blob/${id}`; }
|
||||||
|
async download(filename: string, body: string) {
|
||||||
|
const d = await use('downloads');
|
||||||
|
if (!d) return false;
|
||||||
|
try { await d.save({ filename, data: body }); return true; } catch { return false; }
|
||||||
|
}
|
||||||
|
async feedbackAvailable() { return !!(await use('comments')); }
|
||||||
|
async feedback(el: Element) {
|
||||||
|
const c = await use('comments');
|
||||||
|
if (!c) return false;
|
||||||
|
try { await c.openComposer({ element: el }); return true; } catch { return false; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const newId = (prefix = '') => prefix + Date.now().toString(36) + Math.random().toString(36).slice(2, 8);
|
||||||
1
packages/data/tsconfig.json
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{ "extends": "../../tsconfig.base.json", "include": ["src", "messages"] }
|
||||||
133
packages/db/seed/demo-seed.mjs
Normal file
|
|
@ -0,0 +1,133 @@
|
||||||
|
// Demo seed (C0-06). Writes one JSON file per document into <outDir>/<collection>/<id>.json, shaped like SPEC §6
|
||||||
|
// so C0-08 can feed the same data into the Prisma seed. Usage: node packages/db/seed/demo-seed.mjs <outDir>
|
||||||
|
// Om/Ti text is draft — needs translator review. Students marked isSample are fictional test records.
|
||||||
|
import fs from 'fs'; import path from 'path';
|
||||||
|
const out = process.argv[2] || 'dist/seed';
|
||||||
|
const put = (col, id, body) => { fs.mkdirSync(path.join(out, col), { recursive: true }); fs.writeFileSync(path.join(out, col, id + '.json'), JSON.stringify({ ...body, id }, null, 1)); };
|
||||||
|
|
||||||
|
put('settings', 'app', { brandName: 'MakeUp Academy', supportPhone: '+251 911 234 567', telegramLink: 'https://t.me/makeupacademy_demo', supportEmail: 'support@makeup-academy.example', sessionLimit: 2, maintenanceBanner: '' });
|
||||||
|
|
||||||
|
const cats = [
|
||||||
|
['cat-fundamentals', 'fundamentals', { en: 'Makeup fundamentals', am: 'የሜካፕ መሠረታዊ ነገሮች', om: "Bu'uura meekaappii", ti: 'መሰረታዊ ሜካፕ' }],
|
||||||
|
['cat-bridal', 'bridal-events', { en: 'Bridal & events', am: 'ሙሽራና ልዩ ዝግጅቶች', om: 'Fuudhaa fi heerumaa fi sirnoota', ti: 'መርዓን በዓላትን' }],
|
||||||
|
['cat-skin', 'skin-care', { en: 'Skin care', am: 'የቆዳ እንክብካቤ', om: 'Kunuunsa gogaa', ti: 'ክንክን ቆርበት' }],
|
||||||
|
];
|
||||||
|
cats.forEach(([id, slug, n], i) => put('categories', id, { slug, sortOrder: i + 1, isActive: true, translations: Object.fromEntries(Object.entries(n).map(([l, name]) => [l, { name }])) }));
|
||||||
|
|
||||||
|
const L = (id, min, t, opts = {}) => ({ id, sortOrder: 0, isPreview: false, isPublished: true, durationSec: min * 60, videoAssetId: null, videoStatus: 'READY', translations: t, ...opts });
|
||||||
|
const tt = (en, am, om, ti, d) => ({ en: { title: en, description: d?.en }, am: { title: am, description: d?.am }, om: { title: om }, ti: { title: ti } });
|
||||||
|
const ch = (id, t, s, lessons) => ({ id, sortOrder: 0, translations: Object.fromEntries(Object.entries(t).map(([l, title]) => [l, { title, summary: s[l] }])), lessons: lessons.map((x, i) => ({ ...x, sortOrder: i + 1 })) });
|
||||||
|
const order = (c) => ({ ...c, chapters: c.chapters.map((x, i) => ({ ...x, sortOrder: i + 1 })) });
|
||||||
|
const base = { coverAssetId: null, isFeatured: false, isTest: false, sequentialLessons: false, prerequisiteCourseId: null, createdAt: '2026-01-05T08:00:00.000Z' };
|
||||||
|
|
||||||
|
put('courses', 'crs-foundations', order({ ...base, slug: 'makeup-foundations', categoryId: 'cat-fundamentals', instructorName: 'Meron Tesfaye', instructionLocale: 'am', coverTone: 'rose', status: 'PUBLISHED', isFeatured: true, publishedAt: '2026-01-10T08:00:00.000Z', updatedAt: '2026-09-02T08:00:00.000Z', prices: { ETB: 120000 },
|
||||||
|
translations: {
|
||||||
|
en: { title: 'Makeup foundations', subtitle: 'Skin prep, base and color for every Ethiopian skin tone.', audience: 'Beginners and self-taught artists who want a solid, clean base.', description: 'Start from the skin up. You will learn to read undertones, choose and blend foundation for deep and medium skin, and build a soft everyday look that lasts through an Addis afternoon.', outcomes: ['Match foundation to warm, neutral and olive undertones', 'Blend a seamless base that photographs well', 'Finish a full everyday look in 20 minutes'] },
|
||||||
|
am: { title: 'የሜካፕ መሠረታዊ ትምህርት', subtitle: 'ለሁሉም የኢትዮጵያ የቆዳ ቀለሞች የቆዳ ዝግጅት፣ ፋውንዴሽንና ቀለም።', audience: 'ጠንካራ መሠረት ለሚፈልጉ ጀማሪዎችና በራሳቸው ለተማሩ ባለሙያዎች።', description: 'ከቆዳው ይጀምሩ። የቆዳ ቀለም መሠረትን ማንበብ፣ ፋውንዴሽን መምረጥና ማዋሃድ፣ እንዲሁም ቀኑን ሙሉ የሚቆይ የዕለት ሜካፕ መሥራት ይማራሉ።', outcomes: ['ፋውንዴሽንን ከቆዳ ቀለም ጋር ማዛመድ', 'በፎቶ ላይ ጥሩ የሚታይ ፋውንዴሽን ማዋሃድ', 'ሙሉ የዕለት ሜካፕ በ20 ደቂቃ መጨረስ'] },
|
||||||
|
om: { title: "Bu'uura meekaappii", description: 'Gogaa irraa jalqabi. Bifa gogaa dubbisuu, foundation filachuu fi walmakuu, akkasumas meekaappii guyyaa guyyaa barattu.' },
|
||||||
|
ti: { title: 'መሰረታዊ ሜካፕ', description: 'ካብ ቆርበት ጀምር። ሕብሪ ቆርበት ምንባብ፣ ፋውንዴሽን ምምራጽን ምውህሃድን፣ ናይ መዓልቲ ሜካፕ ክትሰርሕ ትማሃር።' },
|
||||||
|
},
|
||||||
|
chapters: [
|
||||||
|
ch('ch-f1', { en: 'Know your skin', am: 'ቆዳዎን ይወቁ', om: 'Gogaa kee beeki', ti: 'ቆርበትካ ፍለጥ' }, { en: 'Every good look starts with reading the skin in front of you.', am: 'ጥሩ ሜካፕ የሚጀምረው ፊትዎ ያለውን ቆዳ በማንበብ ነው።' }, [
|
||||||
|
L('les-f1', 9, tt('Undertones in daylight', 'የቆዳ ቀለም መሠረት በቀን ብርሃን', 'Bifa gogaa ifa guyyaatiin', 'ሕብሪ ቆርበት ብብርሃን መዓልቲ', { en: 'Use a white sheet and window light to read warm, neutral and olive undertones.', am: 'ነጭ ወረቀትና የመስኮት ብርሃን ተጠቅመው የቆዳ ቀለም መሠረትን ያንብቡ።' }), { isPreview: true }),
|
||||||
|
L('les-f2', 12, tt('Prep for oily and dry skin', 'ለቅባታማና ደረቅ ቆዳ ዝግጅት', 'Qophii gogaa cooma qabuu fi gogaa', 'ምድላው ንዘይታውን ደረቕን ቆርበት')),
|
||||||
|
]),
|
||||||
|
ch('ch-f2', { en: 'Base that lasts', am: 'የሚቆይ ፋውንዴሽን', om: 'Bu\'uura turu', ti: 'ዝጸንሕ መሰረት' }, { en: 'Heat and long days are the real test of a base.', am: 'ሙቀትና ረጅም ቀን የፋውንዴሽን እውነተኛ ፈተና ናቸው።' }, [
|
||||||
|
L('les-f3', 14, tt('Choosing foundation shades', 'የፋውንዴሽን ቀለም መምረጥ', 'Bifa foundation filachuu', 'ሕብሪ ፋውንዴሽን ምምራጽ')),
|
||||||
|
L('les-f4', 11, tt('Blending with brush and sponge', 'በብሩሽና በስፖንጅ ማዋሃድ', 'Bursii fi isponjiitiin walmakuu', 'ብብሩሽን ስፖንጅን ምውህሃድ')),
|
||||||
|
L('les-f5', 8, tt('Setting for an all-day finish', 'ቀኑን ሙሉ እንዲቆይ ማድረግ', 'Guyyaa guutuu akka turu gochuu', 'ንምሉእ መዓልቲ ንክጸንሕ')),
|
||||||
|
]),
|
||||||
|
ch('ch-f3', { en: 'The everyday look', am: 'የዕለት ሜካፕ', om: 'Meekaappii guyyaa guyyaa', ti: 'ናይ መዓልቲ ሜካፕ' }, { en: 'Put it together: a 20-minute look for work or church.', am: 'ሁሉንም በአንድ ላይ፦ ለሥራ ወይም ለቤተ ክርስቲያን የ20 ደቂቃ ሜካፕ።' }, [
|
||||||
|
L('les-f6', 10, tt('Brows that frame the face', 'ፊትን የሚያሳምር ቅንድብ', 'Hiddii fuula miidhagsu', 'ገጽ ዘጸባብቕ ቅንድብ')),
|
||||||
|
L('les-f7', 15, tt('Full look, start to finish', 'ሙሉ ሜካፕ ከመጀመሪያ እስከ መጨረሻ', 'Meekaappii guutuu jalqaba hanga dhumaatti', 'ምሉእ ሜካፕ ካብ መጀመርታ ክሳብ መወዳእታ')),
|
||||||
|
]),
|
||||||
|
] }));
|
||||||
|
|
||||||
|
put('courses', 'crs-bridal', order({ ...base, slug: 'bridal-makeup', categoryId: 'cat-bridal', instructorName: 'Hanna Bekele', instructionLocale: 'am', coverTone: 'plum', status: 'PUBLISHED', isFeatured: true, sequentialLessons: true, prerequisiteCourseId: 'crs-foundations', publishedAt: '2026-03-01T08:00:00.000Z', updatedAt: '2026-08-20T08:00:00.000Z', prices: { ETB: 250000 },
|
||||||
|
translations: {
|
||||||
|
en: { title: 'Bridal makeup for Ethiopian weddings', subtitle: 'From the melse to the reception: looks that survive a 14-hour day.', audience: 'Artists who finished Makeup foundations and want to take bridal bookings.', description: 'Plan, test and deliver bridal looks for traditional and modern ceremonies. Includes a client consultation script and a kit checklist.', outcomes: ['Run a bridal trial and consultation', 'Create long-wear looks for habesha kemis and white gowns', 'Touch up efficiently between ceremonies'] },
|
||||||
|
am: { title: 'የሙሽራ ሜካፕ ለኢትዮጵያ ሠርግ', subtitle: 'ከመልስ እስከ ግብዣ፦ 14 ሰዓት የሚቆይ ሜካፕ።', audience: 'የመሠረታዊ ትምህርቱን ጨርሰው የሙሽራ ሥራ መቀበል ለሚፈልጉ ባለሙያዎች።', description: 'ለባህላዊና ዘመናዊ ሠርጎች የሙሽራ ሜካፕ ማቀድ፣ መሞከርና መሥራት። የደንበኛ ምክክር መመሪያና የዕቃ ዝርዝር ይጨምራል።', outcomes: ['የሙሽራ ሙከራና ምክክር ማካሄድ', 'ለሀበሻ ቀሚስና ለነጭ ቬሎ የሚቆይ ሜካፕ መሥራት', 'በሥነ ሥርዓቶች መካከል በፍጥነት ማስተካከል'] },
|
||||||
|
om: { title: 'Meekaappii misirroo cidha Itoophiyaaf', description: 'Meekaappii misirroo sirna aadaa fi ammayyaaf karoorsuu, yaaluu fi hojjechuu.' },
|
||||||
|
ti: { title: 'ሜካፕ መርዓት ንመርዓ ኢትዮጵያ', description: 'ንባህላውን ዘመናውን መርዓታት ሜካፕ መርዓት ምውጣን፣ ምፍታንን ምስራሕን።' },
|
||||||
|
},
|
||||||
|
chapters: [
|
||||||
|
ch('ch-b1', { en: 'Consultation and trial', am: 'ምክክርና ሙከራ', om: 'Mari\'achuu fi yaalii', ti: 'ምምኽኻርን ፈተነን' }, { en: 'Most bridal problems are solved before the wedding day.', am: 'አብዛኛው የሙሽራ ችግር የሚፈታው ከሠርጉ ቀን በፊት ነው።' }, [
|
||||||
|
L('les-b1', 10, tt('The consultation script', 'የምክክር መመሪያ', 'Qajeelfama mari\'achuu', 'መምርሒ ምምኽኻር'), { isPreview: true }),
|
||||||
|
L('les-b2', 16, tt('Running a bridal trial', 'የሙሽራ ሙከራ ማካሄድ', 'Yaalii misirroo gaggeessuu', 'ፈተነ መርዓት ምክያድ')),
|
||||||
|
]),
|
||||||
|
ch('ch-b2', { en: 'Long-wear techniques', am: 'ረጅም ጊዜ የሚቆይ ዘዴ', om: 'Tooftaa yeroo dheeraa turu', ti: 'ንነዊሕ ግዜ ዝጸንሕ ሜላ' }, { en: 'Heat, tears and flash photography: plan for all three.', am: 'ሙቀት፣ እንባና የካሜራ ብልጭታ፦ ለሦስቱም ያቅዱ።' }, [
|
||||||
|
L('les-b3', 18, tt('Traditional look for habesha kemis', 'ለሀበሻ ቀሚስ ባህላዊ ሜካፕ', 'Meekaappii aadaa kemis habashaaf', 'ባህላዊ ሜካፕ ንሓበሻ ክዳን')),
|
||||||
|
L('les-b4', 17, tt('Modern look for the white gown', 'ለነጭ ቬሎ ዘመናዊ ሜካፕ', 'Meekaappii ammayyaa uffata adiif', 'ዘመናዊ ሜካፕ ንጻዕዳ ቬሎ')),
|
||||||
|
L('les-b5', 9, tt('Touch-ups between ceremonies', 'በሥነ ሥርዓቶች መካከል ማስተካከል', 'Sirnoota gidduutti sirreessuu', 'ኣብ መንጎ ስነ ስርዓታት ምዕራይ'), { isPublished: false, videoStatus: 'PROCESSING' }),
|
||||||
|
]),
|
||||||
|
] }));
|
||||||
|
|
||||||
|
put('courses', 'crs-skin', order({ ...base, slug: 'skin-prep-and-care', categoryId: 'cat-skin', instructorName: 'Dr. Selam Alemu', instructionLocale: 'en', coverTone: 'sage', status: 'PUBLISHED', publishedAt: '2026-05-15T08:00:00.000Z', updatedAt: '2026-07-01T08:00:00.000Z', prices: { ETB: 80000 },
|
||||||
|
translations: {
|
||||||
|
en: { title: 'Skin prep and care', subtitle: 'What artists should know about skin before any makeup touches it.', audience: 'Artists and clients who want healthier skin under makeup.', description: 'Hyperpigmentation, sun, sensitivity and hygiene: a dermatologist explains what to do, what to avoid and when to refer a client.', outcomes: ['Spot skin conditions that need a doctor', 'Build a simple prep routine for clients', 'Keep your kit hygienic between clients'] },
|
||||||
|
am: { title: 'የቆዳ ዝግጅትና እንክብካቤ', subtitle: 'ሜካፕ ከመቀባቱ በፊት ባለሙያዎች ስለ ቆዳ ማወቅ ያለባቸው።', description: 'የቆዳ መጥቆር፣ ፀሐይ፣ ስሜታዊነትና ንጽሕና፦ የቆዳ ሐኪም ምን ማድረግ፣ ምን መራቅ እንዳለብዎና መቼ ደንበኛን ወደ ሐኪም መላክ እንዳለብዎ ያስረዳሉ።', outcomes: ['ሐኪም የሚያስፈልጋቸውን የቆዳ ችግሮች መለየት', 'ለደንበኞች ቀላል የቆዳ ዝግጅት', 'በደንበኞች መካከል ዕቃዎችን ንጹሕ ማድረግ'] },
|
||||||
|
om: { title: 'Qophii fi kunuunsa gogaa', description: "Ogeessi gogaa waan hojjechuu fi irraa fagaachuu qabdu ibsa." },
|
||||||
|
ti: { title: 'ምድላውን ክንክንን ቆርበት', description: 'ሓኪም ቆርበት እንታይ ክትገብርን ካብ እንታይ ክትርሕቕን ከም ዘለካ ይገልጽ።' },
|
||||||
|
},
|
||||||
|
chapters: [
|
||||||
|
ch('ch-s1', { en: 'Healthy skin first', am: 'መጀመሪያ ጤናማ ቆዳ', om: 'Duraan gogaa fayyaa', ti: 'ቅድም ጥዑይ ቆርበት' }, { en: 'Makeup sits better on skin that is cared for.', am: 'ሜካፕ በተንከባከቡት ቆዳ ላይ የተሻለ ይቀመጣል።' }, [
|
||||||
|
L('les-s1', 12, tt('Hyperpigmentation and sun', 'የቆዳ መጥቆርና ፀሐይ', 'Gurraachummaa gogaa fi aduu', 'ምጽላም ቆርበትን ጸሓይን'), { isPreview: true }),
|
||||||
|
L('les-s2', 10, tt('Kit hygiene between clients', 'በደንበኞች መካከል የዕቃ ንጽሕና', 'Qulqullina meeshaa maamiltoota gidduutti', 'ጽሬት ናውቲ ኣብ መንጎ ዓማዊል')),
|
||||||
|
]),
|
||||||
|
] }));
|
||||||
|
|
||||||
|
put('courses', 'crs-business', order({ ...base, slug: 'crs-business', categoryId: 'cat-fundamentals', instructorName: 'Meron Tesfaye', instructionLocale: 'am', coverTone: 'sand', status: 'DRAFT', publishedAt: null, updatedAt: '2026-09-20T08:00:00.000Z', prices: {},
|
||||||
|
translations: { en: { title: 'Building a makeup business', description: 'Pricing, bookings and social media for freelance artists.' }, am: { title: 'የሜካፕ ሥራ መገንባት', description: 'ለግል ባለሙያዎች ዋጋ አወጣጥ፣ ቀጠሮና ማኅበራዊ ሚዲያ።' } },
|
||||||
|
chapters: [ch('ch-x1', { en: 'Pricing your work' }, {}, [L('les-x1', 12, { en: { title: 'What to charge in Addis' } }, { isPublished: false, videoStatus: 'NONE' })])] }));
|
||||||
|
|
||||||
|
put('courses', 'crs-test', order({ ...base, slug: 'payment-test', categoryId: 'cat-fundamentals', instructorName: 'Staff', instructionLocale: 'en', coverTone: 'ink', status: 'PUBLISHED', isTest: true, publishedAt: '2026-02-01T08:00:00.000Z', updatedAt: '2026-02-01T08:00:00.000Z', prices: { ETB: 100 },
|
||||||
|
translations: { en: { title: 'Payment test (staff only)', description: 'Real-money payment check at the provider minimum. Hidden from students and stats (L7).' } },
|
||||||
|
chapters: [ch('ch-t1', { en: 'Test' }, {}, [L('les-t1', 1, { en: { title: 'Test lesson' } })])] }));
|
||||||
|
|
||||||
|
// ---- fictional sample students so the admin dashboard has something to show
|
||||||
|
const people = [
|
||||||
|
['Abebech G.', '+251911000101', '', 'ET', 'Addis Ababa', 'am', '2026-01-14'],
|
||||||
|
['Tigist M.', '+251911000102', 'tigist@example.com', 'ET', 'Hawassa', 'am', '2026-02-03'],
|
||||||
|
['Lensa D.', '+251911000103', '', 'ET', 'Adama', 'om', '2026-03-22'],
|
||||||
|
['Mahlet K.', '', 'mahlet@example.com', 'US', 'Washington DC', 'en', '2026-04-09'],
|
||||||
|
['Saba H.', '+251911000105', '', 'ET', 'Mekelle', 'ti', '2026-05-18'],
|
||||||
|
['Rahel T.', '+251911000106', 'rahel@example.com', 'ET', 'Bahir Dar', 'am', '2026-06-30'],
|
||||||
|
['Bethlehem A.', '+251911000107', '', 'ET', 'Addis Ababa', 'am', '2026-08-11'],
|
||||||
|
['Hiwot Y.', '', 'hiwot@example.com', 'SE', 'Stockholm', 'en', '2026-09-04'],
|
||||||
|
];
|
||||||
|
const price = { 'crs-foundations': 120000, 'crs-bridal': 250000, 'crs-skin': 80000, 'crs-test': 100 };
|
||||||
|
const t = (d, h = 9) => new Date(`${d}T${String(h).padStart(2, '0')}:00:00.000Z`).toISOString();
|
||||||
|
const addDays = (d, n) => new Date(Date.parse(d + 'T00:00:00Z') + n * 864e5).toISOString().slice(0, 10);
|
||||||
|
const plan = [
|
||||||
|
[['crs-foundations', 'PAID', 'TELEBIRR'], ['crs-bridal', 'PAID', 'TELEBIRR']],
|
||||||
|
[['crs-foundations', 'PAID', 'CBE_BIRR'], ['crs-skin', 'PAID', 'TELEBIRR']],
|
||||||
|
[['crs-foundations', 'PAID', 'TELEBIRR']],
|
||||||
|
[['crs-skin', 'REFUNDED', 'CBE_BIRR'], ['crs-foundations', 'FAILED', 'TELEBIRR']],
|
||||||
|
[['crs-foundations', 'PAID', 'TELEBIRR'], ['crs-bridal', 'FLAGGED', 'TELEBIRR']],
|
||||||
|
[['crs-skin', 'PAID', 'CBE_BIRR']],
|
||||||
|
[['crs-foundations', 'PENDING', 'TELEBIRR']],
|
||||||
|
[],
|
||||||
|
];
|
||||||
|
const lessonsOf = { 'crs-foundations': ['les-f1', 'les-f2', 'les-f3', 'les-f4', 'les-f5', 'les-f6', 'les-f7'], 'crs-bridal': ['les-b1', 'les-b2', 'les-b3', 'les-b4'], 'crs-skin': ['les-s1', 'les-s2'] };
|
||||||
|
people.forEach(([name, phone, email, country, city, locale, joined], i) => {
|
||||||
|
const id = `sample-${i + 1}`;
|
||||||
|
const s = { name, phone, email, country, city, locale, status: i === 5 ? 'DEACTIVATED' : 'ACTIVE', createdAt: t(joined), updatedAt: t(joined), lastActiveAt: t(addDays(joined, 20)), isSample: true, enrollments: {}, orders: {}, progress: {}, issues: {}, watchSec: {} };
|
||||||
|
plan[i].forEach(([courseId, st, method], k) => {
|
||||||
|
const day = addDays(joined, 1 + k * 15); const oid = `ord-s${i + 1}-${k + 1}`; const created = t(day, 10);
|
||||||
|
const o = { id: oid, courseId, currency: 'ETB', amountMinor: price[courseId], provider: 'ARIFPAY', method, status: st === 'FLAGGED' ? 'PENDING' : st, idempotencyKey: 'seed-' + oid, failureReason: st === 'FAILED' ? 'Insufficient balance (simulated)' : null, flaggedReason: st === 'FLAGGED' ? 'Amount mismatch: got ETB 250, expected ETB 2,500' : null, paidAt: st === 'PAID' || st === 'REFUNDED' ? t(day, 11) : null, expiresAt: st === 'PENDING' || st === 'FLAGGED' ? '2027-01-01T00:00:00.000Z' : t(day, 11), createdAt: created, updatedAt: created,
|
||||||
|
events: [{ type: 'order.created', at: created }, ...(st === 'PAID' || st === 'REFUNDED' ? [{ type: 'provider.paid', at: t(day, 11), amountMinor: price[courseId], currency: 'ETB' }] : []), ...(st === 'REFUNDED' ? [{ type: 'admin.refunded', at: t(addDays(day, 3)) }] : []), ...(st === 'FAILED' ? [{ type: 'provider.failed', at: t(day, 11) }] : []), ...(st === 'FLAGGED' ? [{ type: 'provider.paid', at: t(day, 11), amountMinor: 25000, currency: 'ETB' }] : [])] };
|
||||||
|
s.orders[oid] = o;
|
||||||
|
if (st === 'PAID') {
|
||||||
|
s.enrollments[courseId] = { courseId, source: 'PURCHASE', orderId: oid, createdAt: t(day, 11), revokedAt: null };
|
||||||
|
const ls = lessonsOf[courseId]; const done = Math.max(1, Math.round(ls.length * [1, .6, .3, .5, .8, .2, .4, 0][i]));
|
||||||
|
ls.slice(0, done).forEach((lid, j) => { const at = t(addDays(day, 2 + j * 3), 18); s.progress[lid] = { courseId, positionSec: 600, maxPositionSec: 600, completedAt: at, updatedAt: at }; });
|
||||||
|
const ym = day.slice(0, 7); s.watchSec[ym] = (s.watchSec[ym] ?? 0) + done * 620;
|
||||||
|
}
|
||||||
|
if (st === 'REFUNDED') s.enrollments[courseId] = { courseId, source: 'PURCHASE', orderId: oid, createdAt: t(day, 11), revokedAt: t(addDays(day, 3)) };
|
||||||
|
});
|
||||||
|
if (i === 1) s.issues['iss-s2'] = { id: 'iss-s2', type: 'VIDEO', subject: 'Lesson stops on mobile data', description: 'The blending lesson stops every minute on Ethio Telecom 4G in Hawassa.', status: 'OPEN', createdAt: t('2026-09-25', 14), updatedAt: t('2026-09-25', 14) };
|
||||||
|
if (i === 4) s.issues['iss-s5'] = { id: 'iss-s5', type: 'PAYMENT', subject: 'Paid but bridal course is locked', description: 'Telebirr shows ETB 250 taken but the course did not open.', status: 'IN_PROGRESS', createdAt: t('2026-06-05', 9), updatedAt: t('2026-06-06', 9) };
|
||||||
|
if (i === 0) s.issues['iss-s1'] = { id: 'iss-s1', type: 'ACCOUNT', subject: 'Change my phone number', description: 'I have a new Safaricom number.', status: 'RESOLVED', resolutionNote: 'Updated on your profile.', createdAt: t('2026-03-02', 9), updatedAt: t('2026-03-03', 9) };
|
||||||
|
put('students', id, s);
|
||||||
|
});
|
||||||
|
console.log('seed written to', out);
|
||||||
22
packages/features/package.json
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"name": "@lms/features",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"main": "src/index.tsx",
|
||||||
|
"types": "src/index.tsx",
|
||||||
|
"dependencies": {
|
||||||
|
"@lms/data": "workspace:*",
|
||||||
|
"@lms/i18n": "workspace:*"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^19",
|
||||||
|
"next-intl": "^4"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"react": "19.3.0",
|
||||||
|
"next-intl": "4.14.9",
|
||||||
|
"@types/react": "^19",
|
||||||
|
"@types/node": "^22"
|
||||||
|
}
|
||||||
|
}
|
||||||
1092
packages/features/src/admin.tsx
Normal file
82
packages/features/src/domain.check.ts
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
// Runnable check for the money/access rules: `pnpm test`. Test IDs from SPEC §13.2.
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import type { Course, Student } from '@lms/data';
|
||||||
|
import { applyHeartbeat, applyPaymentEvent, createOrder, dashboardMetrics, effectiveStatus, isStudentVisible, lessonAccess, publishProblems, validateLocation, validPassword } from './domain.ts';
|
||||||
|
|
||||||
|
const lesson = (id: string, extra = {}) => ({ id, sortOrder: Number(id.slice(-1)), isPreview: false, isPublished: true, durationSec: 100, videoStatus: 'READY' as const, translations: { en: { title: id } }, ...extra });
|
||||||
|
const course = (id: string, extra: Partial<Course> = {}): Course => ({
|
||||||
|
id, slug: id, categoryId: 'cat', instructorName: 'I', instructionLocale: 'am', status: 'PUBLISHED', isFeatured: false, isTest: false,
|
||||||
|
sequentialLessons: false, createdAt: '2026-01-01T00:00:00Z', updatedAt: '2026-01-01T00:00:00Z', coverTone: 'rose',
|
||||||
|
translations: { en: { title: id, description: 'd' } }, prices: { ETB: 120000 },
|
||||||
|
chapters: [{ id: id + 'ch', sortOrder: 1, translations: { en: { title: 'c' } }, lessons: [lesson(id + 'l1', { isPreview: true }), lesson(id + 'l2'), lesson(id + 'l3')] }],
|
||||||
|
...extra,
|
||||||
|
});
|
||||||
|
const student = (): Student => ({ id: 's', name: 'S', country: 'ET', city: 'Adama', locale: 'am', status: 'ACTIVE', createdAt: '2026-03-01T00:00:00Z', updatedAt: '', enrollments: {}, orders: {}, progress: {}, issues: {} });
|
||||||
|
const merge = (s: Student, patch: Record<string, any> | null): Student => {
|
||||||
|
if (!patch) return s;
|
||||||
|
const out: any = structuredClone(s);
|
||||||
|
for (const [k, v] of Object.entries(patch)) for (const [id, body] of Object.entries(v as object)) out[k][id] = { ...(out[k][id] ?? {}), ...body };
|
||||||
|
return out;
|
||||||
|
};
|
||||||
|
|
||||||
|
const A = course('a'), B = course('b', { prerequisiteCourseId: 'a', sequentialLessons: true });
|
||||||
|
let s = student();
|
||||||
|
const now = new Date('2026-05-10T10:00:00Z');
|
||||||
|
|
||||||
|
// SEC-07 / preview
|
||||||
|
assert.deepEqual(lessonAccess(A, A.chapters[0].lessons[1], s, [A, B]), { ok: false, reason: 'COURSE_NOT_OWNED' });
|
||||||
|
assert.deepEqual(lessonAccess(A, A.chapters[0].lessons[0], s, [A, B]), { ok: true });
|
||||||
|
|
||||||
|
// PAY-01, PAY-09 idempotency
|
||||||
|
const o = createOrder(s, A, 'TELEBIRR', 'k1', now, 'o1');
|
||||||
|
assert.equal(o.status, 'PENDING'); assert.equal(o.amountMinor, 120000);
|
||||||
|
s = merge(s, { orders: { o1: o } });
|
||||||
|
assert.equal(createOrder(s, A, 'TELEBIRR', 'k1', now, 'o2').id, 'o1');
|
||||||
|
|
||||||
|
// PAY-05 amount mismatch → flagged, not unlocked
|
||||||
|
const mismatch = merge(s, applyPaymentEvent(s, 'o1', { status: 'PAID', amountMinor: 10, currency: 'ETB' }, now));
|
||||||
|
assert.ok(mismatch.orders.o1.flaggedReason); assert.equal(mismatch.orders.o1.status, 'PENDING'); assert.ok(!mismatch.enrollments.a);
|
||||||
|
|
||||||
|
// PAY-02 paid + enrollment together; PAY-03 duplicate is a no-op
|
||||||
|
s = merge(s, applyPaymentEvent(s, 'o1', { status: 'PAID', amountMinor: 120000, currency: 'ETB' }, now));
|
||||||
|
assert.equal(s.orders.o1.status, 'PAID'); assert.equal(s.enrollments.a.orderId, 'o1');
|
||||||
|
assert.equal(applyPaymentEvent(s, 'o1', { status: 'PAID', amountMinor: 120000, currency: 'ETB' }, now), null);
|
||||||
|
|
||||||
|
// PAY-08 owned course
|
||||||
|
assert.throws(() => createOrder(s, A, 'TELEBIRR', 'k2', now, 'o3'), /ALREADY_OWNED/);
|
||||||
|
|
||||||
|
// PAY-10 expiry
|
||||||
|
assert.equal(effectiveStatus({ ...o, status: 'PENDING' }, now.getTime() + 31 * 60_000), 'EXPIRED');
|
||||||
|
|
||||||
|
// CRS-05 prerequisite, CRS-06 sequential
|
||||||
|
s = merge(s, { enrollments: { b: { courseId: 'b', source: 'ADMIN_GRANT', createdAt: '' } } });
|
||||||
|
assert.deepEqual(lessonAccess(B, B.chapters[0].lessons[1], s, [A, B]), { ok: false, reason: 'PREREQUISITE_REQUIRED' });
|
||||||
|
for (const l of A.chapters[0].lessons) s = merge(s, { progress: { [l.id]: applyHeartbeat(undefined, 'a', 95, 100, now.toISOString()) } });
|
||||||
|
assert.deepEqual(lessonAccess(B, B.chapters[0].lessons[2], s, [A, B]), { ok: false, reason: 'LESSON_LOCKED' });
|
||||||
|
|
||||||
|
// PRG-01 stale heartbeat, PRG-02 90%
|
||||||
|
const p1 = applyHeartbeat(undefined, 'a', 80, 100, 't');
|
||||||
|
assert.equal(p1.completedAt, null);
|
||||||
|
assert.equal(applyHeartbeat(p1, 'a', 10, 100, 't').maxPositionSec, 80);
|
||||||
|
assert.equal(applyHeartbeat(p1, 'a', 90, 100, 't2').completedAt, 't2');
|
||||||
|
|
||||||
|
// CRS-04 test courses hidden; CRS-01 checklist
|
||||||
|
assert.equal(isStudentVisible(course('t', { isTest: true })), false);
|
||||||
|
assert.deepEqual(publishProblems(course('x', { prices: {} })), ['ETB price']);
|
||||||
|
|
||||||
|
// DSH-01..03: period filter, refunds excluded, currencies separate; test course excluded
|
||||||
|
const T = course('t', { isTest: true });
|
||||||
|
s = merge(s, { orders: {
|
||||||
|
o9: { ...o, id: 'o9', status: 'REFUNDED', paidAt: '2026-05-01T00:00:00Z' },
|
||||||
|
o8: { ...o, id: 'o8', courseId: 't', status: 'PAID', paidAt: '2026-05-01T00:00:00Z' },
|
||||||
|
o7: { ...o, id: 'o7', currency: 'USD', amountMinor: 2500, status: 'PAID', paidAt: '2025-05-01T00:00:00Z' } } });
|
||||||
|
const m = dashboardMetrics([s], [A, B, T], { kind: 'year', year: 2026 });
|
||||||
|
assert.deepEqual(m.revenue, { ETB: 120000, USD: 0 });
|
||||||
|
assert.deepEqual(dashboardMetrics([s], [A, B, T], { kind: 'all' }).revenue, { ETB: 120000, USD: 2500 });
|
||||||
|
|
||||||
|
// L4, L5
|
||||||
|
assert.ok(validPassword('abcdefgh')); assert.ok(!validPassword('short'));
|
||||||
|
assert.equal(validateLocation('ET', 'Nairobi'), 'CITY_NOT_IN_LIST');
|
||||||
|
assert.equal(validateLocation('KE', 'Nairobi'), null);
|
||||||
|
|
||||||
|
console.log('domain checks: all passed');
|
||||||
254
packages/features/src/domain.ts
Normal file
|
|
@ -0,0 +1,254 @@
|
||||||
|
// Pure business rules shared by demo and production screens. No React, no I/O.
|
||||||
|
import type { Course, Currency, Lesson, LessonProgress, Locale, Order, OrderStatus, Student, Tr, AdminRole } from '@lms/data';
|
||||||
|
|
||||||
|
export const ORDER_TTL_MS = 30 * 60 * 1000;
|
||||||
|
export const COMPLETE_AT = 0.9;
|
||||||
|
|
||||||
|
/** Translation fallback (§6): requested locale → en → first available. */
|
||||||
|
export function tr<T>(t: Tr<T> | undefined, loc: Locale): T | undefined {
|
||||||
|
if (!t) return undefined;
|
||||||
|
return t[loc] ?? t.en ?? (Object.values(t)[0] as T | undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatMoney(minor: number, currency: Currency): string {
|
||||||
|
const major = minor / 100;
|
||||||
|
if (currency === 'USD') return '$' + major.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
||||||
|
return 'ETB ' + major.toLocaleString('en-US', { maximumFractionDigits: major % 1 ? 2 : 0 });
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatDuration(sec: number): string {
|
||||||
|
const h = Math.floor(sec / 3600), m = Math.round((sec % 3600) / 60);
|
||||||
|
return h ? `${h} h ${m} min` : `${m} min`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const clock = (sec: number) => `${Math.floor(sec / 60)}:${String(Math.floor(sec % 60)).padStart(2, '0')}`;
|
||||||
|
|
||||||
|
export const publishedLessons = (c: Course): Lesson[] =>
|
||||||
|
[...c.chapters].sort((a, b) => a.sortOrder - b.sortOrder)
|
||||||
|
.flatMap((ch) => [...ch.lessons].sort((a, b) => a.sortOrder - b.sortOrder).filter((l) => l.isPublished));
|
||||||
|
|
||||||
|
export const courseDuration = (c: Course) => publishedLessons(c).reduce((s, l) => s + l.durationSec, 0);
|
||||||
|
|
||||||
|
/** L7: test courses never reach students or stats. Archived courses stay visible only to owners. */
|
||||||
|
export function isStudentVisible(c: Course, s?: Student | null): boolean {
|
||||||
|
if (c.isTest) return false;
|
||||||
|
if (c.status === 'PUBLISHED') return true;
|
||||||
|
return c.status === 'ARCHIVED' && !!s && owns(s, c.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const owns = (s: Student | null | undefined, courseId: string) => {
|
||||||
|
const e = s?.enrollments?.[courseId];
|
||||||
|
return !!e && !e.revokedAt;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const isCompleted = (s: Student | null | undefined, lessonId: string) => !!s?.progress?.[lessonId]?.completedAt;
|
||||||
|
|
||||||
|
export function courseProgress(c: Course, s: Student | null | undefined): { done: number; total: number; pct: number } {
|
||||||
|
const ls = publishedLessons(c);
|
||||||
|
const done = ls.filter((l) => isCompleted(s, l.id)).length;
|
||||||
|
return { done, total: ls.length, pct: ls.length ? Math.round((done / ls.length) * 100) : 0 };
|
||||||
|
}
|
||||||
|
|
||||||
|
export const courseCompleted = (c: Course, s: Student | null | undefined) => {
|
||||||
|
const p = courseProgress(c, s);
|
||||||
|
return p.total > 0 && p.done === p.total;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type AccessDenied = 'COURSE_NOT_OWNED' | 'LESSON_LOCKED' | 'PREREQUISITE_REQUIRED' | 'COMING_SOON' | 'ACCOUNT_DEACTIVATED';
|
||||||
|
|
||||||
|
/** Entitlement (§9.3 step 2), in the order the API checks it. */
|
||||||
|
export function lessonAccess(course: Course, lesson: Lesson, s: Student | null | undefined, all: Course[]): { ok: true } | { ok: false; reason: AccessDenied } {
|
||||||
|
if (s?.status === 'DEACTIVATED') return { ok: false, reason: 'ACCOUNT_DEACTIVATED' };
|
||||||
|
if (lesson.videoStatus === 'UPLOADING' || lesson.videoStatus === 'PROCESSING' || lesson.videoStatus === 'FAILED') return { ok: false, reason: 'COMING_SOON' };
|
||||||
|
if (lesson.isPreview) return { ok: true };
|
||||||
|
if (!owns(s, course.id)) return { ok: false, reason: 'COURSE_NOT_OWNED' };
|
||||||
|
const pre = course.prerequisiteCourseId && all.find((c) => c.id === course.prerequisiteCourseId);
|
||||||
|
if (pre && !courseCompleted(pre, s)) return { ok: false, reason: 'PREREQUISITE_REQUIRED' };
|
||||||
|
if (course.sequentialLessons) {
|
||||||
|
const ls = publishedLessons(course);
|
||||||
|
const i = ls.findIndex((l) => l.id === lesson.id);
|
||||||
|
if (i > 0 && !isCompleted(s, ls[i - 1].id)) return { ok: false, reason: 'LESSON_LOCKED' };
|
||||||
|
}
|
||||||
|
return { ok: true };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** First lesson the student hasn't finished, for "Continue lesson N". */
|
||||||
|
export function resumePoint(c: Course, s: Student | null | undefined): { lesson: Lesson; index: number } | null {
|
||||||
|
const ls = publishedLessons(c);
|
||||||
|
if (!ls.length) return null;
|
||||||
|
const i = ls.findIndex((l) => !isCompleted(s, l.id));
|
||||||
|
const index = i === -1 ? 0 : i;
|
||||||
|
return { lesson: ls[index], index };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Heartbeat (§5.8): keep the max position; stale heartbeats never move progress back (PRG-01). */
|
||||||
|
export function applyHeartbeat(prev: LessonProgress | undefined, courseId: string, positionSec: number, durationSec: number, now: string): LessonProgress {
|
||||||
|
const max = Math.max(prev?.maxPositionSec ?? 0, positionSec);
|
||||||
|
const done = prev?.completedAt ?? (durationSec > 0 && max >= durationSec * COMPLETE_AT ? now : null);
|
||||||
|
return { courseId, positionSec, maxPositionSec: max, completedAt: done, updatedAt: now };
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- orders (§8.3)
|
||||||
|
|
||||||
|
export class DomainError extends Error { code: string; constructor(code: string) { super(code); this.code = code; } }
|
||||||
|
|
||||||
|
export function effectiveStatus(o: Order, now = Date.now()): OrderStatus {
|
||||||
|
return o.status === 'PENDING' && Date.parse(o.expiresAt) < now ? 'EXPIRED' : o.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** PAY-08 / PAY-09: no order for an owned course; same idempotency key returns the same order. */
|
||||||
|
export function createOrder(s: Student, c: Course, method: string, idempotencyKey: string, now: Date, id: string): Order {
|
||||||
|
if (owns(s, c.id)) throw new DomainError('ALREADY_OWNED');
|
||||||
|
const existing = Object.values(s.orders ?? {}).find((o) => o.idempotencyKey === idempotencyKey);
|
||||||
|
if (existing) return existing;
|
||||||
|
const amount = c.prices.ETB;
|
||||||
|
if (amount == null) throw new DomainError('PRICE_NOT_SET');
|
||||||
|
const iso = now.toISOString();
|
||||||
|
return {
|
||||||
|
id, courseId: c.id, currency: 'ETB', amountMinor: amount, provider: 'ARIFPAY', method, status: 'PENDING',
|
||||||
|
idempotencyKey, expiresAt: new Date(now.getTime() + ORDER_TTL_MS).toISOString(), createdAt: iso, updatedAt: iso,
|
||||||
|
events: [{ type: 'order.created', at: iso }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A verified provider event (webhook or reconcile) → student-doc patch.
|
||||||
|
* PAID + Enrollment come back in ONE patch (one write = the demo's transaction), idempotent (PAY-02/03),
|
||||||
|
* amount/currency mismatch flags without unlocking (PAY-05).
|
||||||
|
*/
|
||||||
|
export function applyPaymentEvent(s: Student, orderId: string, ev: { status: 'PAID' | 'FAILED'; amountMinor: number; currency: Currency; reason?: string }, now: Date): Record<string, unknown> | null {
|
||||||
|
const o = s.orders?.[orderId];
|
||||||
|
if (!o) return null;
|
||||||
|
const iso = now.toISOString();
|
||||||
|
if (effectiveStatus(o, now.getTime()) !== 'PENDING') return null; // already settled: duplicate events are no-ops
|
||||||
|
const events = [...o.events, { type: `provider.${ev.status.toLowerCase()}`, at: iso, amountMinor: ev.amountMinor, currency: ev.currency }];
|
||||||
|
if (ev.status === 'PAID' && (ev.amountMinor !== o.amountMinor || ev.currency !== o.currency)) {
|
||||||
|
return { orders: { [orderId]: { flaggedReason: `Amount mismatch: got ${formatMoney(ev.amountMinor, ev.currency)}, expected ${formatMoney(o.amountMinor, o.currency)}`, events, updatedAt: iso } } };
|
||||||
|
}
|
||||||
|
if (ev.status === 'FAILED') {
|
||||||
|
return { orders: { [orderId]: { status: 'FAILED', failureReason: ev.reason ?? 'Payment was declined', events, updatedAt: iso } } };
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
orders: { [orderId]: { status: 'PAID', paidAt: iso, events, updatedAt: iso } },
|
||||||
|
enrollments: { [o.courseId]: { courseId: o.courseId, source: 'PURCHASE', orderId, createdAt: iso, revokedAt: null } },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- dashboard + analytics (§10.3)
|
||||||
|
|
||||||
|
export type Period = { kind: 'all' } | { kind: 'year'; year: number } | { kind: 'month'; year: number; month: number }; // month 1-12
|
||||||
|
|
||||||
|
export function inPeriod(iso: string | null | undefined, p: Period): boolean {
|
||||||
|
if (!iso) return false;
|
||||||
|
if (p.kind === 'all') return true;
|
||||||
|
const d = new Date(iso);
|
||||||
|
if (d.getUTCFullYear() !== p.year) return false;
|
||||||
|
return p.kind === 'year' || d.getUTCMonth() + 1 === p.month;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PaidRow { student: Student; order: Order; course?: Course }
|
||||||
|
|
||||||
|
export function paidOrders(students: Student[], courses: Course[]): PaidRow[] {
|
||||||
|
const byId = new Map(courses.map((c) => [c.id, c]));
|
||||||
|
return students.flatMap((s) => Object.values(s.orders ?? {}).map((order) => ({ student: s, order, course: byId.get(order.courseId) })))
|
||||||
|
.filter((r) => !r.course?.isTest && (r.order.status === 'PAID' || r.order.status === 'REFUNDED'));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function dashboardMetrics(students: Student[], courses: Course[], p: Period, now = Date.now()) {
|
||||||
|
const real = students.filter((s) => !s.deletedAt);
|
||||||
|
const rows = paidOrders(real, courses).filter((r) => inPeriod(r.order.paidAt, p));
|
||||||
|
const revenue: Record<Currency, number> = { ETB: 0, USD: 0 };
|
||||||
|
for (const r of rows) if (r.order.status === 'PAID') revenue[r.order.currency] += r.order.amountMinor; // refunded → not counted (DSH-03); never summed across currencies (DSH-02)
|
||||||
|
const allOrders = real.flatMap((s) => Object.values(s.orders ?? {}));
|
||||||
|
const lessons = courses.flatMap((c) => c.chapters.flatMap((ch) => ch.lessons));
|
||||||
|
return {
|
||||||
|
totalStudents: real.filter((s) => (s.status === 'ACTIVE' || s.status === 'DEACTIVATED') && inPeriod(s.createdAt, p)).length,
|
||||||
|
activeStudents: real.filter((s) => Object.values(s.progress ?? {}).some((pr) => inPeriod(pr.updatedAt, p))).length,
|
||||||
|
payingStudents: new Set(rows.filter((r) => r.order.status === 'PAID').map((r) => r.student.id)).size,
|
||||||
|
revenue,
|
||||||
|
ordersNeedingAttention: allOrders.filter((o) => (o.status === 'PENDING' && effectiveStatus(o, now) === 'PENDING' && now - Date.parse(o.createdAt) > 10 * 60_000) || !!o.flaggedReason && o.status === 'PENDING').length,
|
||||||
|
videosProcessing: lessons.filter((l) => l.videoStatus === 'PROCESSING' || l.videoStatus === 'UPLOADING').length,
|
||||||
|
videosFailed: lessons.filter((l) => l.videoStatus === 'FAILED').length,
|
||||||
|
openIssues: real.flatMap((s) => Object.values(s.issues ?? {})).filter((i) => i.status === 'OPEN' || i.status === 'IN_PROGRESS').length,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function analytics(students: Student[], courses: Course[], year: number) {
|
||||||
|
const real = students.filter((s) => !s.deletedAt);
|
||||||
|
const months = Array.from({ length: 12 }, (_, i) => i + 1);
|
||||||
|
const rows = paidOrders(real, courses).filter((r) => r.order.status === 'PAID');
|
||||||
|
const revenueByMonth = months.map((m) => rows.filter((r) => inPeriod(r.order.paidAt, { kind: 'month', year, month: m }) && r.order.currency === 'ETB').reduce((s, r) => s + r.order.amountMinor, 0));
|
||||||
|
const newStudentsByMonth = months.map((m) => real.filter((s) => inPeriod(s.createdAt, { kind: 'month', year, month: m })).length);
|
||||||
|
const visible = courses.filter((c) => !c.isTest);
|
||||||
|
const perCourse = visible.map((c) => {
|
||||||
|
const enrolled = real.filter((s) => owns(s, c.id));
|
||||||
|
return {
|
||||||
|
course: c,
|
||||||
|
revenue: rows.filter((r) => r.order.courseId === c.id && r.order.currency === 'ETB' && inPeriod(r.order.paidAt, { kind: 'year', year })).reduce((s, r) => s + r.order.amountMinor, 0),
|
||||||
|
enrollments: enrolled.length,
|
||||||
|
completionRate: enrolled.length ? Math.round((enrolled.filter((s) => courseCompleted(c, s)).length / enrolled.length) * 100) : 0,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const methodSplit: Record<string, number> = {};
|
||||||
|
for (const r of rows) if (inPeriod(r.order.paidAt, { kind: 'year', year })) methodSplit[r.order.method] = (methodSplit[r.order.method] ?? 0) + 1;
|
||||||
|
const watchSec = real.reduce((s, st) => s + Object.entries(st.watchSec ?? {}).filter(([k]) => k.startsWith(String(year))).reduce((a, [, v]) => a + v, 0), 0);
|
||||||
|
return {
|
||||||
|
revenueByMonth, newStudentsByMonth, methodSplit,
|
||||||
|
topByRevenue: [...perCourse].sort((a, b) => b.revenue - a.revenue).slice(0, 5),
|
||||||
|
topByEnrollments: [...perCourse].sort((a, b) => b.enrollments - a.enrollments).slice(0, 5),
|
||||||
|
completion: perCourse,
|
||||||
|
publishedVideos: visible.filter((c) => c.status === 'PUBLISHED').flatMap(publishedLessons).length,
|
||||||
|
watchHours: Math.round(watchSec / 360) / 10,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- publish checklist (§10.4)
|
||||||
|
|
||||||
|
export function publishProblems(c: Course): string[] {
|
||||||
|
const p: string[] = [];
|
||||||
|
if (!c.translations.en?.title?.trim()) p.push('English title');
|
||||||
|
if (!c.translations.en?.description?.trim()) p.push('English description');
|
||||||
|
if (!c.coverAssetId && !c.coverTone) p.push('Cover image');
|
||||||
|
if (!publishedLessons(c).some((l) => l.videoStatus === 'READY')) p.push('At least one published lesson with a ready video');
|
||||||
|
if (c.prices.ETB == null) p.push('ETB price');
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const missingLocales = (t: Tr<unknown>): Locale[] => (['en', 'am', 'om', 'ti'] as Locale[]).filter((l) => !t[l]);
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- roles (§10.1)
|
||||||
|
|
||||||
|
export type Area = 'dashboard' | 'analytics' | 'courses' | 'categories' | 'students' | 'orders' | 'notifications' | 'issues' | 'settings' | 'admins' | 'audit';
|
||||||
|
|
||||||
|
export const ROLE_AREAS: Record<AdminRole, Area[]> = {
|
||||||
|
SUPER_ADMIN: ['dashboard', 'analytics', 'courses', 'categories', 'students', 'orders', 'notifications', 'issues', 'settings', 'admins', 'audit'],
|
||||||
|
CONTENT_MANAGER: ['dashboard', 'courses', 'categories', 'notifications', 'issues'],
|
||||||
|
SUPPORT_AGENT: ['dashboard', 'courses', 'categories', 'students', 'orders', 'notifications', 'issues'],
|
||||||
|
FINANCE: ['dashboard', 'analytics', 'courses', 'categories', 'students', 'orders', 'issues'],
|
||||||
|
ANALYST: ['dashboard', 'analytics', 'courses', 'categories', 'orders'],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const can = {
|
||||||
|
editContent: (r: AdminRole) => r === 'SUPER_ADMIN' || r === 'CONTENT_MANAGER',
|
||||||
|
editPrices: (r: AdminRole) => r === 'SUPER_ADMIN' || r === 'FINANCE',
|
||||||
|
manageStudents: (r: AdminRole) => r === 'SUPER_ADMIN' || r === 'SUPPORT_AGENT',
|
||||||
|
refund: (r: AdminRole) => r === 'SUPER_ADMIN' || r === 'FINANCE',
|
||||||
|
seeRevenue: (r: AdminRole) => r !== 'SUPPORT_AGENT' && r !== 'CONTENT_MANAGER',
|
||||||
|
manageIssues: (r: AdminRole) => r === 'SUPER_ADMIN' || r === 'SUPPORT_AGENT',
|
||||||
|
};
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- L5 location
|
||||||
|
|
||||||
|
export const ET_CITIES = ['Addis Ababa', 'Adama', 'Arba Minch', 'Bahir Dar', 'Bishoftu', 'Debre Birhan', 'Debre Markos', 'Dessie', 'Dire Dawa', 'Gambela', 'Gondar', 'Harar', 'Hawassa', 'Hosaena', 'Jijiga', 'Jimma', 'Kombolcha', 'Mekelle', 'Nekemte', 'Semera', 'Shashemene', 'Sodo', 'Woldia'];
|
||||||
|
export const COUNTRIES: [string, string][] = [['ET', 'Ethiopia'], ['US', 'United States'], ['GB', 'United Kingdom'], ['CA', 'Canada'], ['DE', 'Germany'], ['SE', 'Sweden'], ['NO', 'Norway'], ['AE', 'United Arab Emirates'], ['SA', 'Saudi Arabia'], ['IL', 'Israel'], ['KE', 'Kenya'], ['ZA', 'South Africa'], ['AU', 'Australia'], ['OTHER', 'Other']];
|
||||||
|
|
||||||
|
/** USR-01/02: Ethiopia → city from the list; elsewhere → any non-empty text. */
|
||||||
|
export function validateLocation(country: string, city: string): string | null {
|
||||||
|
if (!country) return 'COUNTRY_REQUIRED';
|
||||||
|
if (!city.trim()) return 'CITY_REQUIRED';
|
||||||
|
if (country === 'ET' && !ET_CITIES.includes(city)) return 'CITY_NOT_IN_LIST';
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** L4: 8–128 chars, no composition rules. */
|
||||||
|
export const validPassword = (p: string) => p.length >= 8 && p.length <= 128;
|
||||||
29
packages/features/src/index.tsx
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
'use client';
|
||||||
|
import { useEffect, useMemo } from 'react';
|
||||||
|
import { NextIntlClientProvider } from 'next-intl';
|
||||||
|
import type { DataSource } from '@lms/data';
|
||||||
|
import { messages } from '@lms/i18n';
|
||||||
|
import { AppProvider, useApp } from './store';
|
||||||
|
import { StudentApp } from './student';
|
||||||
|
import { AdminApp } from './admin';
|
||||||
|
|
||||||
|
export * from './domain';
|
||||||
|
export { AppProvider, useApp } from './store';
|
||||||
|
|
||||||
|
function Router() {
|
||||||
|
const { route, locale } = useApp();
|
||||||
|
const msgs = route[0] === 'admin' ? messages.en : messages[locale];
|
||||||
|
useEffect(() => { document.documentElement.lang = route[0] === 'admin' ? 'en' : locale; }, [route, locale]);
|
||||||
|
return (
|
||||||
|
<NextIntlClientProvider locale={route[0] === 'admin' ? 'en' : locale} messages={msgs} timeZone="Africa/Addis_Ababa"
|
||||||
|
onError={() => { /* missing keys fall back to the key; i18n:check catches them in CI */ }}>
|
||||||
|
{route[0] === 'admin' ? <AdminApp /> : <StudentApp />}
|
||||||
|
</NextIntlClientProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The whole platform behind one DataSource. Demo passes ClaudeDbDataSource; production will pass ApiDataSource. */
|
||||||
|
export function Platform({ dataSource }: { dataSource: () => DataSource }) {
|
||||||
|
const ds = useMemo(dataSource, [dataSource]);
|
||||||
|
return <AppProvider ds={ds}><Router /></AppProvider>;
|
||||||
|
}
|
||||||
184
packages/features/src/store.tsx
Normal file
|
|
@ -0,0 +1,184 @@
|
||||||
|
'use client';
|
||||||
|
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from 'react';
|
||||||
|
import type { AdminRole, AuditEntry, Campaign, Category, Course, DataSource, InboxItem, Locale, Settings, Student, Viewer } from '@lms/data';
|
||||||
|
import { LOCALES, newId } from '@lms/data';
|
||||||
|
import { messages } from '@lms/i18n';
|
||||||
|
|
||||||
|
export const DEFAULT_SETTINGS: Settings = { brandName: 'MakeUp Academy', supportPhone: '+251 911 000 000', telegramLink: 'https://t.me/', supportEmail: 'support@example.com', sessionLimit: 2, maintenanceBanner: '' };
|
||||||
|
|
||||||
|
const store = {
|
||||||
|
get(k: string) { try { return localStorage.getItem('lms.' + k); } catch { return null; } },
|
||||||
|
set(k: string, v: string | null) { try { v == null ? localStorage.removeItem('lms.' + k) : localStorage.setItem('lms.' + k, v); } catch { /* per-viewer convenience only */ } },
|
||||||
|
};
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- hash router
|
||||||
|
|
||||||
|
export function parseRoute(hash: string): string[] {
|
||||||
|
return hash.replace(/^#\/?/, '').split('/').filter(Boolean).map(decodeURIComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Ctx {
|
||||||
|
ds: DataSource;
|
||||||
|
viewer: Viewer | null;
|
||||||
|
ready: boolean;
|
||||||
|
categories: Category[]; courses: Course[]; settings: Settings; catalogLoaded: boolean;
|
||||||
|
me: Student | null; meLoaded: boolean; signedIn: boolean;
|
||||||
|
inbox: InboxItem[];
|
||||||
|
locale: Locale; setLocale(l: Locale): void;
|
||||||
|
route: string[]; nav(path: string): void;
|
||||||
|
toast(msg: string): void;
|
||||||
|
/** Serialized writes: the db wants one write at a time per document. */
|
||||||
|
write(fn: () => Promise<void>, okMsg?: string): Promise<boolean>;
|
||||||
|
signIn(): void; signOut(): void;
|
||||||
|
adminRole: AdminRole; setAdminRole(r: AdminRole): void;
|
||||||
|
audit(action: string, entity: string, entityId: string, before?: unknown, after?: unknown): Promise<void>;
|
||||||
|
notify(studentId: string, item: Omit<InboxItem, 'id' | 'createdAt'>): Promise<void>;
|
||||||
|
msg(loc: Locale, key: string, vars?: Record<string, string | number>): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const AppCtx = createContext<Ctx | null>(null);
|
||||||
|
export const useApp = () => { const c = useContext(AppCtx); if (!c) throw new Error('AppProvider missing'); return c; };
|
||||||
|
|
||||||
|
/** Message lookup outside React components (system notifications are written in the student's language). */
|
||||||
|
export function lookup(loc: Locale, key: string, vars: Record<string, string | number> = {}): string {
|
||||||
|
const get = (l: Locale) => key.split('.').reduce<any>((o, k) => o?.[k], messages[l]);
|
||||||
|
const raw: string = get(loc) ?? get('en') ?? key;
|
||||||
|
return raw.replace(/\{(\w+)(?:, plural,[^{}]*(?:\{[^{}]*\}[^{}]*)*)?\}/g, (_m, k) => String(vars[k] ?? ''));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function AppProvider({ ds, children }: { ds: DataSource; children: ReactNode }) {
|
||||||
|
const [viewer, setViewer] = useState<Viewer | null>(null);
|
||||||
|
const [ready, setReady] = useState(false);
|
||||||
|
const [categories, setCategories] = useState<Category[]>([]);
|
||||||
|
const [courses, setCourses] = useState<Course[]>([]);
|
||||||
|
const [settings, setSettings] = useState<Settings | null>(null);
|
||||||
|
const [catalogLoaded, setCatalogLoaded] = useState(false);
|
||||||
|
const [me, setMe] = useState<Student | null>(null);
|
||||||
|
const [meLoaded, setMeLoaded] = useState(false);
|
||||||
|
const [inbox, setInbox] = useState<InboxItem[]>([]);
|
||||||
|
const [route, setRoute] = useState<string[]>([]);
|
||||||
|
const [locale, setLocaleState] = useState<Locale>('am');
|
||||||
|
const [toastMsg, setToastMsg] = useState<string | null>(null);
|
||||||
|
const [signedOut, setSignedOut] = useState(false);
|
||||||
|
const [adminRole, setAdminRoleState] = useState<AdminRole>('SUPER_ADMIN');
|
||||||
|
const chain = useRef<Promise<unknown>>(Promise.resolve());
|
||||||
|
const toastTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||||
|
|
||||||
|
// initial route + locale (client only)
|
||||||
|
useEffect(() => {
|
||||||
|
const r = parseRoute(location.hash);
|
||||||
|
const saved = store.get('locale') as Locale | null;
|
||||||
|
const loc = (LOCALES as string[]).includes(r[0]) ? (r[0] as Locale) : saved && LOCALES.includes(saved) ? saved : 'am';
|
||||||
|
setLocaleState(loc);
|
||||||
|
setRoute(r.length ? r : [loc]);
|
||||||
|
setSignedOut(store.get('signedOut') === '1');
|
||||||
|
const role = store.get('viewAs') as AdminRole | null;
|
||||||
|
if (role) setAdminRoleState(role);
|
||||||
|
const onHash = () => setRoute(parseRoute(location.hash));
|
||||||
|
addEventListener('hashchange', onHash); addEventListener('popstate', onHash);
|
||||||
|
return () => { removeEventListener('hashchange', onHash); removeEventListener('popstate', onHash); };
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let alive = true;
|
||||||
|
ds.viewer().then((v) => { if (alive) { setViewer(v); setReady(true); } });
|
||||||
|
let gotCourses = false, gotCats = false;
|
||||||
|
const done = () => { if (gotCourses && gotCats) setCatalogLoaded(true); };
|
||||||
|
const u1 = ds.watchCourses((c) => { setCourses(c); gotCourses = true; done(); });
|
||||||
|
const u2 = ds.watchCategories((c) => { setCategories([...c].sort((a, b) => a.sortOrder - b.sortOrder)); gotCats = true; done(); });
|
||||||
|
const u3 = ds.watchSettings(setSettings);
|
||||||
|
return () => { alive = false; u1(); u2(); u3(); };
|
||||||
|
}, [ds]);
|
||||||
|
|
||||||
|
const uid = viewer?.id ?? null;
|
||||||
|
useEffect(() => {
|
||||||
|
if (!ready) return;
|
||||||
|
if (!uid) { setMeLoaded(true); return; }
|
||||||
|
const u1 = ds.watchStudent(uid, (s) => { setMe(s); setMeLoaded(true); });
|
||||||
|
const u2 = ds.watchInbox(uid, setInbox);
|
||||||
|
return () => { u1(); u2(); };
|
||||||
|
}, [ds, uid, ready]);
|
||||||
|
|
||||||
|
const nav = useCallback((path: string) => {
|
||||||
|
const r = parseRoute(path);
|
||||||
|
setRoute(r);
|
||||||
|
try { if (location.hash !== '#' + path) history.pushState(null, '', '#' + path); } catch { /* sandboxed history: state already updated */ }
|
||||||
|
try { scrollTo({ top: 0 }); } catch { /* jsdom */ }
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const toast = useCallback((m: string) => {
|
||||||
|
setToastMsg(m);
|
||||||
|
if (toastTimer.current) clearTimeout(toastTimer.current);
|
||||||
|
toastTimer.current = setTimeout(() => setToastMsg(null), 3200);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const msg = useCallback((loc: Locale, key: string, vars?: Record<string, string | number>) => lookup(loc, key, vars), []);
|
||||||
|
|
||||||
|
const write = useCallback((fn: () => Promise<void>, okMsg?: string) => {
|
||||||
|
const p = chain.current.then(fn).then(() => { if (okMsg) toast(okMsg); return true; }, (e) => {
|
||||||
|
console.warn(e); toast(e?.code === 'not_granted' || e?.code === 'invalid_argument' ? lookup(locale, 'common.readOnly') : lookup(locale, 'common.saveFailed'));
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
chain.current = p;
|
||||||
|
return p;
|
||||||
|
}, [toast, locale]);
|
||||||
|
|
||||||
|
const setLocale = useCallback((l: Locale) => {
|
||||||
|
setLocaleState(l); store.set('locale', l);
|
||||||
|
setRoute((r) => {
|
||||||
|
const next = (LOCALES as string[]).includes(r[0]) ? [l, ...r.slice(1)] : r;
|
||||||
|
try { history.replaceState(null, '', '#/' + next.join('/')); } catch { /* ignore */ }
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
if (me && me.locale !== l && !me.deletedAt) write(() => ds.patchStudent(me.id, { locale: l }));
|
||||||
|
}, [me, ds, write]);
|
||||||
|
|
||||||
|
const audit = useCallback(async (action: string, entity: string, entityId: string, before?: unknown, after?: unknown) => {
|
||||||
|
const entry: AuditEntry = { id: newId('a_'), adminId: uid ?? 'unknown', action, entity, entityId, before: before ?? null, after: after ?? null, createdAt: new Date().toISOString() };
|
||||||
|
await ds.addAudit(entry);
|
||||||
|
}, [ds, uid]);
|
||||||
|
|
||||||
|
const notify = useCallback(async (studentId: string, item: Omit<InboxItem, 'id' | 'createdAt'>) => {
|
||||||
|
await ds.addInbox(studentId, { ...item, id: newId('n_'), createdAt: new Date().toISOString(), readAt: null });
|
||||||
|
}, [ds]);
|
||||||
|
|
||||||
|
const value: Ctx = {
|
||||||
|
ds, viewer, ready, categories, courses, settings: settings ?? DEFAULT_SETTINGS, catalogLoaded,
|
||||||
|
me, meLoaded, signedIn: !!me && !me.deletedAt && !signedOut, inbox,
|
||||||
|
locale, setLocale, route, nav, toast, write,
|
||||||
|
signIn: () => { store.set('signedOut', null); setSignedOut(false); },
|
||||||
|
signOut: () => { store.set('signedOut', '1'); setSignedOut(true); },
|
||||||
|
adminRole: viewer?.isOwner ? adminRole : 'SUPER_ADMIN',
|
||||||
|
setAdminRole: (r) => { setAdminRoleState(r); store.set('viewAs', r); },
|
||||||
|
audit, notify, msg,
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AppCtx.Provider value={value}>
|
||||||
|
{children}
|
||||||
|
{toastMsg && <div className="toast" role="status">{toastMsg}</div>}
|
||||||
|
</AppCtx.Provider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- admin data (subscribed only inside admin)
|
||||||
|
|
||||||
|
interface AdminData { students: Student[]; campaigns: Campaign[]; auditLog: AuditEntry[]; loaded: boolean }
|
||||||
|
const AdminCtx = createContext<AdminData>({ students: [], campaigns: [], auditLog: [], loaded: false });
|
||||||
|
export const useAdminData = () => useContext(AdminCtx);
|
||||||
|
|
||||||
|
export function AdminDataProvider({ children }: { children: ReactNode }) {
|
||||||
|
const { ds } = useApp();
|
||||||
|
const [students, setStudents] = useState<Student[]>([]);
|
||||||
|
const [campaigns, setCampaigns] = useState<Campaign[]>([]);
|
||||||
|
const [auditLog, setAudit] = useState<AuditEntry[]>([]);
|
||||||
|
const [loaded, setLoaded] = useState(false);
|
||||||
|
useEffect(() => {
|
||||||
|
const u1 = ds.watchStudents((s) => { setStudents(s); setLoaded(true); });
|
||||||
|
const u2 = ds.watchCampaigns(setCampaigns);
|
||||||
|
const u3 = ds.watchAudit(setAudit);
|
||||||
|
return () => { u1(); u2(); u3(); };
|
||||||
|
}, [ds]);
|
||||||
|
const value = useMemo(() => ({ students, campaigns, auditLog, loaded }), [students, campaigns, auditLog, loaded]);
|
||||||
|
return <AdminCtx.Provider value={value}>{children}</AdminCtx.Provider>;
|
||||||
|
}
|
||||||
962
packages/features/src/student.tsx
Normal file
|
|
@ -0,0 +1,962 @@
|
||||||
|
'use client';
|
||||||
|
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from 'react';
|
||||||
|
import { useTranslations } from 'next-intl';
|
||||||
|
import type { Course, Issue, IssueType, Lesson, Locale, Order, Student } from '@lms/data';
|
||||||
|
import { LOCALES, newId } from '@lms/data';
|
||||||
|
import { LOCALE_NAMES, DRAFT_LOCALES } from '@lms/i18n';
|
||||||
|
import { lookup, useApp } from './store';
|
||||||
|
import {
|
||||||
|
applyHeartbeat, applyPaymentEvent, clock, COUNTRIES, courseDuration, courseProgress, createOrder, DomainError, effectiveStatus,
|
||||||
|
ET_CITIES, formatDuration, formatMoney, isCompleted, isStudentVisible, lessonAccess, owns, publishedLessons, resumePoint, tr, validateLocation, validPassword,
|
||||||
|
} from './domain';
|
||||||
|
import { CopyText, Cover, Empty, FeedbackButton, fmtDate, Icon, Modal, Ring, Skeleton, StatusPill } from './ui';
|
||||||
|
|
||||||
|
const ISSUE_TYPES: IssueType[] = ['BUG', 'PAYMENT', 'VIDEO', 'ACCOUNT', 'CONTENT', 'OTHER'];
|
||||||
|
const METHODS = [{ id: 'TELEBIRR', name: 'Telebirr' }, { id: 'CBE_BIRR', name: 'CBE Birr' }];
|
||||||
|
const methodName = (id: string) => METHODS.find((m) => m.id === id)?.name ?? id;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- helpers
|
||||||
|
|
||||||
|
function useCatalog() {
|
||||||
|
const { courses, categories, me, locale } = useApp();
|
||||||
|
const visible = useMemo(() => courses.filter((c) => isStudentVisible(c, me)).sort((a, b) => (b.publishedAt ?? '').localeCompare(a.publishedAt ?? '')), [courses, me]);
|
||||||
|
const catName = useCallback((id: string) => tr(categories.find((c) => c.id === id)?.translations, locale)?.name ?? '', [categories, locale]);
|
||||||
|
return { visible, catName };
|
||||||
|
}
|
||||||
|
|
||||||
|
const ct = (c: Course, l: Locale) => tr(c.translations, l) ?? { title: c.slug, description: '' };
|
||||||
|
const lessonTitle = (l: Lesson, loc: Locale) => tr(l.translations, loc)?.title ?? '';
|
||||||
|
const lessonNumber = (c: Course, id: string) => publishedLessons(c).findIndex((l) => l.id === id) + 1;
|
||||||
|
|
||||||
|
function CourseCard({ c }: { c: Course }) {
|
||||||
|
const { locale, nav, me } = useApp();
|
||||||
|
const t = useTranslations();
|
||||||
|
const { catName } = useCatalog();
|
||||||
|
const p = courseProgress(c, me);
|
||||||
|
const mine = owns(me, c.id);
|
||||||
|
return (
|
||||||
|
<button className="ccard" onClick={() => nav(`/${locale}/course/${c.slug}`)}>
|
||||||
|
<Cover course={c} locale={locale} badge={<span className="pill">{catName(c.categoryId)}</span>} />
|
||||||
|
<h3>{ct(c, locale).title}</h3>
|
||||||
|
<span className="meta">{c.instructorName} · {t('course.lessons', { n: p.total })} · {formatDuration(courseDuration(c))}</span>
|
||||||
|
{mine ? <div className="bar" aria-label={`${p.pct}%`}><i style={{ width: `${p.pct}%` }} /></div>
|
||||||
|
: c.prices.ETB != null && <strong className="num">{formatMoney(c.prices.ETB, 'ETB')}</strong>}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function SignInGate({ children }: { children: ReactNode }) {
|
||||||
|
const { signedIn, meLoaded, ready } = useApp();
|
||||||
|
if (!ready || !meLoaded) return <Skeleton h={160} n={2} />;
|
||||||
|
return signedIn ? <>{children}</> : <SignIn />;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- shell
|
||||||
|
|
||||||
|
export function StudentApp() {
|
||||||
|
const t = useTranslations();
|
||||||
|
const app = useApp();
|
||||||
|
const { route, locale, nav, signedIn, inbox, viewer, settings, setLocale } = app;
|
||||||
|
const section = route[1] ?? '';
|
||||||
|
const unread = signedIn ? inbox.filter((n) => !n.readAt).length : 0;
|
||||||
|
const mainRef = useRef<HTMLElement>(null);
|
||||||
|
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 current = (s: string) => (s === section || (s === 'courses' && (section === 'course')) || (s === 'my' && section === 'progress') ? 'page' : undefined);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div lang={locale}>
|
||||||
|
<div className="demo-strip">{t('common.demoBanner')}</div>
|
||||||
|
<header className="s-top">
|
||||||
|
<div className="s-top-in">
|
||||||
|
<button className="brand" onClick={() => go('')}><span className="brand-mark" aria-hidden>ሜ</span><span>{settings.brandName}</span></button>
|
||||||
|
<nav className="s-nav" aria-label="Main">
|
||||||
|
{tabs.slice(0, 4).map(([p, , label]) => <button key={p} aria-current={current(p)} onClick={() => go(p ? '/' + p : '')}>{label}</button>)}
|
||||||
|
</nav>
|
||||||
|
<div className="s-actions">
|
||||||
|
<FeedbackButton label={t('common.feedback')} target={() => mainRef.current} />
|
||||||
|
<label className="sr-only" htmlFor="lang">{t('common.language')}</label>
|
||||||
|
<select id="lang" className="lang-select" value={locale} onChange={(e) => setLocale(e.target.value as Locale)}>
|
||||||
|
{LOCALES.map((l) => <option key={l} value={l}>{LOCALE_NAMES[l]}{(DRAFT_LOCALES as readonly string[]).includes(l) ? ' (draft)' : ''}</option>)}
|
||||||
|
</select>
|
||||||
|
{signedIn ? <>
|
||||||
|
<button className="icon-btn" aria-label={`${t('nav.notifications')}${unread ? ` (${unread})` : ''}`} onClick={() => go('/notifications')}><Icon name="bell" />{unread > 0 && <span className="dot">{unread}</span>}</button>
|
||||||
|
<button className="icon-btn" aria-label={t('nav.profile')} onClick={() => go('/profile')}>{viewer?.avatarUrl ? <img src={viewer.avatarUrl} alt="" width={30} height={30} style={{ borderRadius: '50%' }} /> : <Icon name="user" />}</button>
|
||||||
|
</> : <button className="btn btn-sm" onClick={() => go('/signin')}>{t('nav.signIn')}</button>}
|
||||||
|
{viewer?.canEdit && <button className="btn btn-ghost btn-sm hide-sm" onClick={() => nav('/admin')}>{t('nav.admin')}</button>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<main className="s-main" ref={mainRef}>
|
||||||
|
{settings.maintenanceBanner && <div className="banner small" role="status">{settings.maintenanceBanner}</div>}
|
||||||
|
<StudentRoutes />
|
||||||
|
</main>
|
||||||
|
<Footer />
|
||||||
|
<nav className="s-tabs" aria-label="Main">
|
||||||
|
{tabs.map(([p, icon, label]) => <button key={p} aria-current={current(p)} onClick={() => go(p ? '/' + p : '')}><Icon name={icon} size={22} />{label}</button>)}
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Footer() {
|
||||||
|
const t = useTranslations();
|
||||||
|
const { settings, locale, nav, setLocale, categories, viewer } = useApp();
|
||||||
|
return (
|
||||||
|
<footer className="foot">
|
||||||
|
<div className="foot-in">
|
||||||
|
<div className="stack-sm"><strong style={{ color: 'var(--ink)' }}>{settings.brandName}</strong><p>{t('landing.footer')}</p></div>
|
||||||
|
<div className="stack-sm"><h3>{t('nav.courses')}</h3>{categories.filter((c) => c.isActive).map((c) => <button key={c.id} onClick={() => nav(`/${locale}/courses/${c.slug}`)}>{tr(c.translations, locale)?.name}</button>)}</div>
|
||||||
|
<div className="stack-sm"><h3>{t('help.contact')}</h3>
|
||||||
|
<a href={settings.telegramLink} target="_blank" rel="noreferrer">{t('help.telegram')}</a>
|
||||||
|
<span className="num">{t('help.call')}: {settings.supportPhone}</span>
|
||||||
|
<button onClick={() => nav(`/${locale}/help`)}>{t('nav.help')}</button>
|
||||||
|
{viewer?.canEdit && <button onClick={() => nav('/admin')}>{t('nav.admin')}</button>}
|
||||||
|
</div>
|
||||||
|
<div className="stack-sm"><h3>{t('common.language')}</h3>{LOCALES.map((l) => <button key={l} lang={l} aria-current={l === locale} onClick={() => setLocale(l)}>{LOCALE_NAMES[l]}</button>)}</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function StudentRoutes() {
|
||||||
|
const { route, signedIn } = useApp();
|
||||||
|
const [, s, a, b] = route;
|
||||||
|
switch (s) {
|
||||||
|
case undefined: return signedIn ? <Home /> : <Landing />;
|
||||||
|
case 'courses': return <Catalog categorySlug={a} />;
|
||||||
|
case 'course': return <CoursePage slug={a} />;
|
||||||
|
case 'learn': return <Player slug={a} lessonId={b} />;
|
||||||
|
case 'checkout': return <SignInGate><Checkout slug={a} /></SignInGate>;
|
||||||
|
case 'pay': return <SignInGate><ProviderSim orderId={a} /></SignInGate>;
|
||||||
|
case 'orders': return <SignInGate><OrderStatusPage orderId={a} /></SignInGate>;
|
||||||
|
case 'my': return <SignInGate><MyCourses /></SignInGate>;
|
||||||
|
case 'progress': return <SignInGate><MyProgress /></SignInGate>;
|
||||||
|
case 'notifications': return <SignInGate><Inbox /></SignInGate>;
|
||||||
|
case 'help': return <Help />;
|
||||||
|
case 'profile': return <SignInGate><Profile /></SignInGate>;
|
||||||
|
case 'signin': return signedIn ? <Home /> : <SignIn />;
|
||||||
|
default: return <Landing />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- landing + home
|
||||||
|
|
||||||
|
function Landing() {
|
||||||
|
const t = useTranslations();
|
||||||
|
const { locale, nav, catalogLoaded, categories } = useApp();
|
||||||
|
const { visible } = useCatalog();
|
||||||
|
const featured = [...visible.filter((c) => c.isFeatured), ...visible.filter((c) => !c.isFeatured)].slice(0, 3);
|
||||||
|
const lead = featured[0];
|
||||||
|
const preview = lead && publishedLessons(lead).find((l) => l.isPreview);
|
||||||
|
const minPrice = Math.min(...visible.map((c) => c.prices.ETB ?? Infinity));
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<section className="hero">
|
||||||
|
<div className="hero-copy">
|
||||||
|
<h1>{t('landing.title')}</h1>
|
||||||
|
<p className="lead">{t('landing.lead')}</p>
|
||||||
|
<div className="row">
|
||||||
|
<button className="btn btn-accent" onClick={() => nav(`/${locale}/courses`)}>{t('landing.browse')}</button>
|
||||||
|
<button className="btn btn-ghost" onClick={() => nav(`/${locale}/signin`)}>{t('landing.start')}</button>
|
||||||
|
</div>
|
||||||
|
<ul className="facts">{['fact1', 'fact2', 'fact3'].map((k) => <li key={k}><Icon name="check" size={16} />{t(`landing.${k}`)}</li>)}</ul>
|
||||||
|
</div>
|
||||||
|
{!catalogLoaded ? <Skeleton h={320} /> : lead ? (
|
||||||
|
<div className="hero-card">
|
||||||
|
<Cover course={lead} locale={locale} />
|
||||||
|
<div className="row-between"><strong style={{ fontSize: 'var(--fs-lg)' }}>{ct(lead, locale).title}</strong>{lead.prices.ETB != null && <span className="num" style={{ fontWeight: 700 }}>{formatMoney(lead.prices.ETB, 'ETB')}</span>}</div>
|
||||||
|
<span className="small muted">{t('course.by', { name: lead.instructorName })} · {t('course.lessons', { n: publishedLessons(lead).length })} · {formatDuration(courseDuration(lead))}</span>
|
||||||
|
<button className="btn btn-block" onClick={() => nav(preview ? `/${locale}/learn/${lead.slug}/${preview.id}` : `/${locale}/course/${lead.slug}`)}><Icon name="play" size={16} />{preview ? t('course.watchPreview') : ct(lead, locale).title}</button>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</section>
|
||||||
|
<section className="stack">
|
||||||
|
<div className="section-h"><h2>{t('landing.featured')}</h2>{Number.isFinite(minPrice) && <span className="small muted num">{t('landing.from', { price: formatMoney(minPrice, 'ETB') })}</span>}</div>
|
||||||
|
{!catalogLoaded ? <Skeleton h={220} /> : featured.length ? <div className="grid-cards">{featured.map((c) => <CourseCard key={c.id} c={c} />)}</div> : <Empty>{t('catalog.emptyCategory')}</Empty>}
|
||||||
|
{categories.length > 0 && <div className="chips">{categories.filter((c) => c.isActive).map((c) => <button key={c.id} className="chip" onClick={() => nav(`/${locale}/courses/${c.slug}`)}>{tr(c.translations, locale)?.name}</button>)}</div>}
|
||||||
|
</section>
|
||||||
|
<section className="stack">
|
||||||
|
<h2 style={{ fontSize: 'var(--fs-xl)' }}>{t('landing.howTitle')}</h2>
|
||||||
|
<ol className="steps" style={{ padding: 0, margin: 0 }}><li>{t('landing.how1')}</li><li>{t('landing.how2')}</li><li>{t('landing.how3')}</li></ol>
|
||||||
|
<h3 style={{ fontSize: 'var(--fs-lg)', marginTop: 8 }}>{t('landing.payTitle')}</h3>
|
||||||
|
<div className="pay-logos">{METHODS.map((m) => <span key={m.id} className="pay-logo"><i />{m.name}</span>)}</div>
|
||||||
|
</section>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Home() {
|
||||||
|
const t = useTranslations();
|
||||||
|
const { me, locale, nav, categories, catalogLoaded } = useApp();
|
||||||
|
const { visible } = useCatalog();
|
||||||
|
if (!catalogLoaded) return <Skeleton h={200} n={2} />;
|
||||||
|
const mine = visible.filter((c) => owns(me, c.id));
|
||||||
|
const last = Object.values(me?.progress ?? {}).sort((a, b) => b.updatedAt.localeCompare(a.updatedAt))[0];
|
||||||
|
const unfinished = mine.filter((c) => courseProgress(c, me).pct < 100);
|
||||||
|
const cont = (last && unfinished.find((c) => c.id === last.courseId)) || unfinished[0] || (last && mine.find((c) => c.id === last.courseId)) || mine[0];
|
||||||
|
const others = visible.filter((c) => !owns(me, c.id));
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<h1 style={{ fontSize: 'var(--fs-2xl)' }}>{t('home.hello', { name: me?.name.split(' ')[0] ?? '' })}</h1>
|
||||||
|
{cont ? <ContinueCard c={cont} /> : <Empty action={<button className="btn" onClick={() => nav(`/${locale}/courses`)}>{t('landing.browse')}</button>}>{t('home.emptyMine')}</Empty>}
|
||||||
|
{mine.length > 1 && <section className="stack"><div className="section-h"><h2>{t('nav.myCourses')}</h2><button className="link" onClick={() => nav(`/${locale}/my`)}>{t('my.viewProgress')}</button></div><div className="grid-cards">{mine.map((c) => <CourseCard key={c.id} c={c} />)}</div></section>}
|
||||||
|
<section className="stack">
|
||||||
|
<div className="section-h"><h2>{t('home.categories')}</h2></div>
|
||||||
|
<div className="chips">{categories.filter((c) => c.isActive).map((c) => <button key={c.id} className="chip" onClick={() => nav(`/${locale}/courses/${c.slug}`)}>{tr(c.translations, locale)?.name}</button>)}</div>
|
||||||
|
</section>
|
||||||
|
{others.length > 0 && <section className="stack"><div className="section-h"><h2>{others.some((c) => c.isFeatured) ? t('home.featured') : t('home.new')}</h2><button className="link" onClick={() => nav(`/${locale}/courses`)}>{t('catalog.title')}</button></div><div className="grid-cards">{[...others.filter((c) => c.isFeatured), ...others.filter((c) => !c.isFeatured)].slice(0, 4).map((c) => <CourseCard key={c.id} c={c} />)}</div></section>}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ContinueCard({ c }: { c: Course }) {
|
||||||
|
const t = useTranslations();
|
||||||
|
const { me, locale, nav } = useApp();
|
||||||
|
const p = courseProgress(c, me);
|
||||||
|
const r = resumePoint(c, me);
|
||||||
|
return (
|
||||||
|
<section className="continue" aria-label={t('home.continue')}>
|
||||||
|
<Cover course={c} locale={locale} />
|
||||||
|
<div className="stack-sm">
|
||||||
|
<span className="small" style={{ opacity: .8 }}>{t('home.continue')}</span>
|
||||||
|
<h2 style={{ fontSize: 'var(--fs-xl)' }}>{ct(c, locale).title}</h2>
|
||||||
|
{r && <p style={{ opacity: .85 }}>{r.index + 1}. {lessonTitle(r.lesson, locale)}</p>}
|
||||||
|
<div className="bar"><i style={{ width: `${p.pct}%` }} /></div>
|
||||||
|
<span className="small num" style={{ opacity: .8 }}>{t('my.lessonsDone', { done: p.done, total: p.total })}</span>
|
||||||
|
{r && <div><button className="btn btn-accent" onClick={() => nav(`/${locale}/learn/${c.slug}/${r.lesson.id}`)}><Icon name="play" size={16} />{p.pct === 100 ? t('course.watchAgain') : t('course.continue', { n: r.index + 1 })}</button></div>}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- catalog + search
|
||||||
|
|
||||||
|
function Catalog({ categorySlug }: { categorySlug?: string }) {
|
||||||
|
const t = useTranslations();
|
||||||
|
const { categories, locale, nav, catalogLoaded } = useApp();
|
||||||
|
const { visible, catName } = useCatalog();
|
||||||
|
const [q, setQ] = useState('');
|
||||||
|
const [dq, setDq] = useState('');
|
||||||
|
useEffect(() => { const id = setTimeout(() => setDq(q.trim().toLowerCase()), 300); return () => clearTimeout(id); }, [q]);
|
||||||
|
const cat = categories.find((c) => c.slug === categorySlug);
|
||||||
|
const list = visible.filter((c) => (!cat || c.categoryId === cat.id) && (!dq || [
|
||||||
|
...Object.values(c.translations).map((x) => x?.title ?? ''), c.instructorName,
|
||||||
|
...Object.values(categories.find((k) => k.id === c.categoryId)?.translations ?? {}).map((x) => x?.name ?? ''),
|
||||||
|
].some((s) => s.toLowerCase().includes(dq))));
|
||||||
|
return (
|
||||||
|
<section className="stack">
|
||||||
|
<h1 style={{ fontSize: 'var(--fs-2xl)' }}>{cat ? catName(cat.id) : t('catalog.title')}</h1>
|
||||||
|
<label className="field"><span className="sr-only">{t('catalog.search')}</span>
|
||||||
|
<input id="search" className="input" type="search" placeholder={t('catalog.search')} value={q} onChange={(e) => setQ(e.target.value)} />
|
||||||
|
</label>
|
||||||
|
<div className="chips" role="group">
|
||||||
|
<button className="chip" aria-pressed={!cat} onClick={() => nav(`/${locale}/courses`)}>{t('catalog.all')}</button>
|
||||||
|
{categories.filter((c) => c.isActive).map((c) => <button key={c.id} className="chip" aria-pressed={cat?.id === c.id} onClick={() => nav(`/${locale}/courses/${c.slug}`)}>{tr(c.translations, locale)?.name}</button>)}
|
||||||
|
</div>
|
||||||
|
{!catalogLoaded ? <Skeleton h={220} n={2} /> : list.length ? <>
|
||||||
|
<p className="muted small" aria-live="polite">{t('catalog.count', { n: list.length })}</p>
|
||||||
|
<div className="grid-cards">{list.map((c) => <CourseCard key={c.id} c={c} />)}</div>
|
||||||
|
</> : <Empty action={dq ? <button className="btn btn-ghost" onClick={() => setQ('')}>{t('catalog.all')}</button> : undefined}>{dq ? t('catalog.empty', { q }) : t('catalog.emptyCategory')}</Empty>}
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- course page (Logosmental structure)
|
||||||
|
|
||||||
|
function CoursePage({ slug }: { slug?: string }) {
|
||||||
|
const t = useTranslations();
|
||||||
|
const { courses, me, locale, nav, catalogLoaded } = useApp();
|
||||||
|
const { catName } = useCatalog();
|
||||||
|
const c = courses.find((x) => x.slug === slug);
|
||||||
|
if (!catalogLoaded) return <Skeleton h={260} n={2} />;
|
||||||
|
if (!c || !isStudentVisible(c, me)) return <Empty action={<button className="btn" onClick={() => nav(`/${locale}/courses`)}>{t('catalog.title')}</button>}>{t('course.notFound')}</Empty>;
|
||||||
|
const text = ct(c, locale);
|
||||||
|
const mine = owns(me, c.id);
|
||||||
|
const lessons = publishedLessons(c);
|
||||||
|
const r = resumePoint(c, me);
|
||||||
|
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 first = lessons[0];
|
||||||
|
const chapters = [...c.chapters].sort((a, b) => a.sortOrder - b.sortOrder);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<section className="c-hero">
|
||||||
|
<div className="stack">
|
||||||
|
<div className="row"><span className="pill">{catName(c.categoryId)}</span>{c.status === 'ARCHIVED' && <StatusPill status="ARCHIVED" />}</div>
|
||||||
|
<h1>{text.title}</h1>
|
||||||
|
{text.subtitle && <p style={{ fontSize: 'var(--fs-lg)', color: 'var(--ink-2)' }}>{text.subtitle}</p>}
|
||||||
|
{text.audience && <p className="small"><strong>{t('course.audience')}: </strong>{text.audience}</p>}
|
||||||
|
<p className="small muted num">{t('course.by', { name: c.instructorName })} · {t('course.lessons', { n: lessons.length })} · {formatDuration(courseDuration(c))} · {t('course.taughtIn', { lang: LOCALE_NAMES[c.instructionLocale] })} · {t('course.updated', { date: fmtDate(c.updatedAt) })}</p>
|
||||||
|
{pre && !preDone && <div className="banner">{t('course.prereq', { title: ct(pre, locale).title })} <button className="link" onClick={() => nav(`/${locale}/course/${pre.slug}`)}>{t('course.prereqLink', { title: ct(pre, locale).title })}</button></div>}
|
||||||
|
{text.description && <p style={{ maxWidth: '68ch', whiteSpace: 'pre-line' }}>{text.description}</p>}
|
||||||
|
</div>
|
||||||
|
<aside className="card buybox" aria-label={text.title}>
|
||||||
|
<Cover course={c} locale={locale} />
|
||||||
|
{mine ? <>
|
||||||
|
<span className="pill pill-ok" style={{ alignSelf: 'flex-start' }}><Icon name="check" size={14} />{courseProgress(c, me).pct === 100 ? t('course.completed') : t('course.owned')}</span>
|
||||||
|
<div className="bar"><i style={{ width: `${courseProgress(c, me).pct}%` }} /></div>
|
||||||
|
{r && <button className={`btn btn-block ${courseProgress(c, me).pct === 100 ? 'btn-ghost' : 'btn-accent'}`} onClick={() => nav(`/${locale}/learn/${c.slug}/${r.lesson.id}`)}>{courseProgress(c, me).pct === 100 ? t('course.watchAgain') : t('course.continue', { n: r.index + 1 })}</button>}
|
||||||
|
</> : <>
|
||||||
|
{c.prices.ETB != null && <div><div className="price num">{formatMoney(c.prices.ETB, 'ETB')}</div><p className="small muted">{t('checkout.lifetime')}</p></div>}
|
||||||
|
<button className="btn btn-accent btn-block" disabled={c.status !== 'PUBLISHED' || c.prices.ETB == null} onClick={() => nav(`/${locale}/checkout/${c.slug}`)}>{t('course.buy', { price: formatMoney(c.prices.ETB ?? 0, 'ETB') })}</button>
|
||||||
|
{preview && <button className="btn btn-ghost btn-block" onClick={() => nav(`/${locale}/learn/${c.slug}/${preview.id}`)}><Icon name="play" size={16} />{t('course.watchPreview')}</button>}
|
||||||
|
</>}
|
||||||
|
{c.sequentialLessons && <p className="small muted">{t('course.sequential')}</p>}
|
||||||
|
</aside>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
{!!text.outcomes?.length && (
|
||||||
|
<section className="stack">
|
||||||
|
<h2 style={{ fontSize: 'var(--fs-xl)' }}>{t('course.outcomes')}</h2>
|
||||||
|
<ol className="outcomes">{text.outcomes.map((o, i) => <li key={i}>{o}</li>)}</ol>
|
||||||
|
</section>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<section className="stack">
|
||||||
|
<h2 style={{ fontSize: 'var(--fs-xl)' }}>{t('course.content')}</h2>
|
||||||
|
<ol className="journey">
|
||||||
|
{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 chDone = ls.every((l) => isCompleted(me, l.id));
|
||||||
|
const chText = tr(ch.translations, locale);
|
||||||
|
return (
|
||||||
|
<li key={ch.id}>
|
||||||
|
<span className={`node ${chDone ? 'done' : ''}`} aria-hidden>{chDone ? <Icon name="check" size={16} /> : i + 1}</span>
|
||||||
|
<div className="card stack-sm" style={{ padding: 16 }}>
|
||||||
|
<h3 style={{ fontSize: 'var(--fs-lg)' }}>{chText?.title}</h3>
|
||||||
|
{chText?.summary && <p className="small" style={{ color: 'var(--ink-2)' }}>{chText.summary}</p>}
|
||||||
|
<div>{ls.map((l) => <LessonRow key={l.id} c={c} l={l} />)}</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</ol>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
{first && !mine && (
|
||||||
|
<section className="continue" style={{ gridTemplateColumns: '1fr' }}>
|
||||||
|
<div className="row-between">
|
||||||
|
<div><h2 style={{ fontSize: 'var(--fs-lg)' }}>{t('course.ready')}</h2><p style={{ opacity: .85 }}>{t('course.readyBody', { min: Math.max(1, Math.round(first.durationSec / 60)) })}</p></div>
|
||||||
|
<button className="btn btn-accent" onClick={() => nav(preview ? `/${locale}/learn/${c.slug}/${preview.id}` : `/${locale}/checkout/${c.slug}`)}>{preview ? t('course.watchPreview') : t('course.buy', { price: formatMoney(c.prices.ETB ?? 0, 'ETB') })}</button>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function LessonRow({ c, l, current }: { c: Course; l: Lesson; current?: boolean }) {
|
||||||
|
const t = useTranslations();
|
||||||
|
const { me, courses, locale, nav } = useApp();
|
||||||
|
const access = lessonAccess(c, l, me, courses);
|
||||||
|
const done = isCompleted(me, l.id);
|
||||||
|
const n = lessonNumber(c, l.id);
|
||||||
|
return (
|
||||||
|
<button className="lesson-row" aria-current={current} onClick={() => nav(`/${locale}/learn/${c.slug}/${l.id}`)}>
|
||||||
|
<span className={`ic ${done ? 'done' : ''}`}>{done ? <Icon name="check" size={14} /> : access.ok ? <Icon name="play" size={12} /> : <Icon name="lock" size={14} />}</span>
|
||||||
|
<span className="grow"><span style={{ display: 'block', fontWeight: 700 }}>{n}. {lessonTitle(l, locale)}</span>
|
||||||
|
<span className="small muted num">{clock(l.durationSec)}{l.isPreview && !owns(me, c.id) ? ` · ${t('course.preview')}` : ''}{!access.ok && access.reason === 'COMING_SOON' ? ` · ${t('course.comingSoon')}` : ''}</span></span>
|
||||||
|
<Icon name="chevron" size={16} />
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- player
|
||||||
|
|
||||||
|
function Player({ slug, lessonId }: { slug?: string; lessonId?: string }) {
|
||||||
|
const t = useTranslations();
|
||||||
|
const { courses, me, locale, nav, catalogLoaded, signedIn, viewer } = useApp();
|
||||||
|
const c = courses.find((x) => x.slug === slug);
|
||||||
|
const lessons = c ? publishedLessons(c) : [];
|
||||||
|
const lesson = lessons.find((l) => l.id === lessonId);
|
||||||
|
if (!catalogLoaded) return <Skeleton h={320} />;
|
||||||
|
if (!c || !lesson || !isStudentVisible(c, me)) return <Empty action={<button className="btn" onClick={() => nav(`/${locale}/courses`)}>{t('catalog.title')}</button>}>{t('course.notFound')}</Empty>;
|
||||||
|
const access = lessonAccess(c, lesson, signedIn ? me : null, courses);
|
||||||
|
const p = courseProgress(c, me);
|
||||||
|
const idx = lessons.indexOf(lesson);
|
||||||
|
const next = lessons[idx + 1];
|
||||||
|
const notes = tr(lesson.translations, locale)?.description;
|
||||||
|
const chapter = c.chapters.find((ch) => ch.lessons.some((l) => l.id === lesson.id));
|
||||||
|
return (
|
||||||
|
<div className="stack">
|
||||||
|
<div className="row-between">
|
||||||
|
<button className="btn btn-quiet" onClick={() => nav(`/${locale}/course/${c.slug}`)}><Icon name="back" size={16} />{t('player.back')}</button>
|
||||||
|
<span className="small muted">{ct(c, locale).title}</span>
|
||||||
|
</div>
|
||||||
|
<div className="p-wrap">
|
||||||
|
<div className="stack">
|
||||||
|
<div className="stack-sm">
|
||||||
|
<span className="small muted">{tr(chapter?.translations, locale)?.title}</span>
|
||||||
|
<h1 style={{ fontSize: 'var(--fs-xl)' }}>{idx + 1}. {lessonTitle(lesson, locale)}</h1>
|
||||||
|
</div>
|
||||||
|
{access.ok ? <VideoPanel key={lesson.id} c={c} lesson={lesson} next={next} /> : (
|
||||||
|
<div className="screen"><div className="sim">
|
||||||
|
<Icon name="lock" size={36} />
|
||||||
|
<p>{t(`player.${access.reason}`)}</p>
|
||||||
|
{access.reason === 'COURSE_NOT_OWNED' && <button className="btn btn-accent" onClick={() => nav(signedIn ? `/${locale}/checkout/${c.slug}` : `/${locale}/signin`)}>{t('course.buy', { price: formatMoney(c.prices.ETB ?? 0, 'ETB') })}</button>}
|
||||||
|
{access.reason === 'LESSON_LOCKED' && idx > 0 && <button className="btn btn-accent" onClick={() => nav(`/${locale}/learn/${c.slug}/${lessons[idx - 1].id}`)}>{idx}. {lessonTitle(lessons[idx - 1], locale)}</button>}
|
||||||
|
{access.reason === 'PREREQUISITE_REQUIRED' && <button className="btn btn-accent" onClick={() => { const pre = courses.find((x) => x.id === c.prerequisiteCourseId); if (pre) nav(`/${locale}/course/${pre.slug}`); }}>{t('course.prereqLink', { title: ct(courses.find((x) => x.id === c.prerequisiteCourseId) ?? c, locale).title })}</button>}
|
||||||
|
{access.reason === 'ACCOUNT_DEACTIVATED' && <button className="btn btn-accent" onClick={() => nav(`/${locale}/help`)}>{t('nav.help')}</button>}
|
||||||
|
</div></div>
|
||||||
|
)}
|
||||||
|
<div className="card stack-sm">
|
||||||
|
<h2 style={{ fontSize: 'var(--fs-lg)' }}>{t('player.notes')}</h2>
|
||||||
|
<p style={{ whiteSpace: 'pre-line', color: 'var(--ink-2)' }}>{notes || ct(c, locale).subtitle || ct(c, locale).description}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<aside className="card p-side p-side-order stack-sm" aria-label={t('player.contents')}>
|
||||||
|
<h2 style={{ fontSize: 'var(--fs-lg)' }}>{t('course.content')}</h2>
|
||||||
|
{owns(me, c.id) && <div className="panel stack-sm" style={{ padding: 14 }}>
|
||||||
|
<span className="small num">{t('player.progress', { done: p.done, total: p.total })}</span>
|
||||||
|
<div className="bar"><i style={{ width: `${p.pct}%` }} /></div>
|
||||||
|
</div>}
|
||||||
|
{[...c.chapters].sort((a, b) => a.sortOrder - b.sortOrder).map((ch) => {
|
||||||
|
const ls = [...ch.lessons].sort((a, b) => a.sortOrder - b.sortOrder).filter((l) => l.isPublished);
|
||||||
|
return ls.length ? <div key={ch.id}><p className="small" style={{ fontWeight: 700, padding: '10px 4px 4px' }}>{tr(ch.translations, locale)?.title}</p>{ls.map((l) => <LessonRow key={l.id} c={c} l={l} current={l.id === lesson.id} />)}</div> : null;
|
||||||
|
})}
|
||||||
|
</aside>
|
||||||
|
</div>
|
||||||
|
{viewer && !viewer.id && <p className="small muted">{t('auth.noIdentity')}</p>}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function VideoPanel({ c, lesson, next }: { c: Course; lesson: Lesson; next?: Lesson }) {
|
||||||
|
const t = useTranslations();
|
||||||
|
const { me, locale, nav, ds, write, signedIn, viewer } = useApp();
|
||||||
|
const dur = lesson.durationSec || 1;
|
||||||
|
const saved = me?.progress?.[lesson.id];
|
||||||
|
const [pos, setPos] = useState(() => (saved && !saved.completedAt ? Math.min(saved.positionSec, dur - 5) : 0));
|
||||||
|
const [playing, setPlaying] = useState(false);
|
||||||
|
const [rate, setRate] = useState(1);
|
||||||
|
const conn = typeof navigator !== 'undefined' ? (navigator as any).connection : undefined;
|
||||||
|
const [saver, setSaver] = useState<boolean>(() => !!conn && (conn.saveData || /2g|3g/.test(conn.effectiveType ?? '')));
|
||||||
|
const [quality, setQuality] = useState('auto');
|
||||||
|
const [justDone, setJustDone] = useState(false);
|
||||||
|
const videoRef = useRef<HTMLVideoElement>(null);
|
||||||
|
const screenRef = useRef<HTMLDivElement>(null);
|
||||||
|
const posRef = useRef(pos); posRef.current = pos;
|
||||||
|
const sentAt = useRef(pos); // position at last heartbeat, for watch-time accounting
|
||||||
|
const meRef = useRef(me); meRef.current = me;
|
||||||
|
const canSave = signedIn && !!me;
|
||||||
|
|
||||||
|
const heartbeat = useCallback(() => {
|
||||||
|
const s = meRef.current;
|
||||||
|
if (!canSave || !s) return;
|
||||||
|
const now = new Date().toISOString();
|
||||||
|
const position = Math.floor(posRef.current);
|
||||||
|
const prev = s.progress?.[lesson.id];
|
||||||
|
const hb = applyHeartbeat(prev, c.id, position, dur, now);
|
||||||
|
const delta = Math.max(0, position - sentAt.current);
|
||||||
|
sentAt.current = position;
|
||||||
|
if (prev && prev.positionSec === hb.positionSec && prev.completedAt === hb.completedAt && !delta) return; // only write on change
|
||||||
|
const ym = now.slice(0, 7);
|
||||||
|
if (hb.completedAt && !prev?.completedAt) setJustDone(true);
|
||||||
|
write(() => ds.patchStudent(s.id, { progress: { [lesson.id]: hb }, lastActiveAt: now, watchSec: { [ym]: (s.watchSec?.[ym] ?? 0) + Math.min(delta, 60) } }));
|
||||||
|
}, [canSave, c.id, dur, lesson.id, ds, write]);
|
||||||
|
|
||||||
|
// simulated playback clock when no video is uploaded
|
||||||
|
useEffect(() => {
|
||||||
|
if (!playing || lesson.videoAssetId) return;
|
||||||
|
const id = setInterval(() => setPos((p) => { const n = Math.min(dur, p + 0.25 * rate); if (n >= dur) setPlaying(false); return n; }), 250);
|
||||||
|
return () => clearInterval(id);
|
||||||
|
}, [playing, rate, dur, lesson.videoAssetId]);
|
||||||
|
// heartbeat every 15 s while playing, and on pause / leave (§5.8)
|
||||||
|
useEffect(() => { if (!playing) { heartbeat(); return; } const id = setInterval(heartbeat, 15000); return () => clearInterval(id); }, [playing, heartbeat]);
|
||||||
|
useEffect(() => {
|
||||||
|
const vis = () => document.visibilityState === 'hidden' && heartbeat();
|
||||||
|
addEventListener('visibilitychange', vis); addEventListener('pagehide', heartbeat);
|
||||||
|
return () => { removeEventListener('visibilitychange', vis); removeEventListener('pagehide', heartbeat); heartbeat(); };
|
||||||
|
}, [heartbeat]);
|
||||||
|
useEffect(() => { const v = videoRef.current; if (v) v.playbackRate = rate; }, [rate]);
|
||||||
|
|
||||||
|
const toggle = () => {
|
||||||
|
const v = videoRef.current;
|
||||||
|
if (v) { v.paused ? v.play().catch(() => setPlaying(false)) : v.pause(); return; }
|
||||||
|
if (pos >= dur) setPos(0);
|
||||||
|
setPlaying((p) => !p);
|
||||||
|
};
|
||||||
|
const seek = (to: number) => { const n = Math.max(0, Math.min(dur, to)); setPos(n); if (videoRef.current) videoRef.current.currentTime = n; };
|
||||||
|
const full = () => { screenRef.current?.requestFullscreen?.().catch(() => { /* not allowed in this frame */ }); };
|
||||||
|
const onKey = (e: React.KeyboardEvent) => {
|
||||||
|
if ((e.target as HTMLElement).tagName === 'SELECT' || (e.target as HTMLElement).tagName === 'INPUT') return;
|
||||||
|
if (e.key === ' ') { e.preventDefault(); toggle(); } else if (e.key === 'ArrowLeft') seek(pos - 10); else if (e.key === 'ArrowRight') seek(pos + 10); else if (e.key === 'f') full(); else if (e.key === 'm' && videoRef.current) videoRef.current.muted = !videoRef.current.muted;
|
||||||
|
};
|
||||||
|
const mark = (me?.phone || me?.email || viewer?.name || 'student').replace(/^(.{3}).*(.{2})$/, '$1•••$2');
|
||||||
|
const done = isCompleted(me, lesson.id) || justDone;
|
||||||
|
const pct = courseProgress(c, me).pct;
|
||||||
|
return (
|
||||||
|
<div className="stack">
|
||||||
|
<div className="screen" ref={screenRef} tabIndex={0} onKeyDown={onKey} aria-label={lessonTitle(lesson, locale)}>
|
||||||
|
{lesson.videoAssetId ? (
|
||||||
|
<video ref={videoRef} src={ds.assetUrl(lesson.videoAssetId)} playsInline preload="metadata"
|
||||||
|
onLoadedMetadata={(e) => { if (pos) e.currentTarget.currentTime = pos; }}
|
||||||
|
onTimeUpdate={(e) => setPos(e.currentTarget.currentTime)} onPlay={() => setPlaying(true)} onPause={() => setPlaying(false)} onEnded={() => setPlaying(false)} />
|
||||||
|
) : (
|
||||||
|
<div className="sim" onClick={toggle}>
|
||||||
|
<h2>{lessonTitle(lesson, locale)}</h2>
|
||||||
|
<p className="small muted">{t('player.demoVideo')}</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{canSave && <span className="wm" aria-hidden>{mark}</span>}
|
||||||
|
<div className="controls">
|
||||||
|
<input type="range" min={0} max={dur} step={1} value={Math.floor(pos)} onChange={(e) => seek(Number(e.target.value))} aria-label={`${clock(pos)} / ${clock(dur)}`} />
|
||||||
|
<div className="row">
|
||||||
|
<button onClick={toggle} aria-label={playing ? t('player.pause') : t('player.play')}><Icon name={playing ? 'pause' : 'play'} size={16} /></button>
|
||||||
|
<button onClick={() => seek(pos - 10)} aria-label={t('player.back10')}>−10</button>
|
||||||
|
<button onClick={() => seek(pos + 10)} aria-label={t('player.fwd10')}>+10</button>
|
||||||
|
<span className="small num" style={{ color: '#fff' }}>{clock(pos)} / {clock(dur)}</span>
|
||||||
|
<span className="grow" />
|
||||||
|
<label className="sr-only" htmlFor="speed">{t('player.speed')}</label>
|
||||||
|
<select id="speed" value={rate} onChange={(e) => setRate(Number(e.target.value))}>{[0.75, 1, 1.25, 1.5, 2].map((r) => <option key={r} value={r}>{r}×</option>)}</select>
|
||||||
|
<label className="sr-only" htmlFor="quality">{t('player.quality')}</label>
|
||||||
|
<select id="quality" value={quality} onChange={(e) => setQuality(e.target.value)}>
|
||||||
|
<option value="auto">Auto{saver ? ' (≤360p)' : ''}</option>{['240p', '360p', '480p', '720p'].map((q) => <option key={q} value={q} disabled={saver && (q === '480p' || q === '720p')}>{q}</option>)}
|
||||||
|
</select>
|
||||||
|
<button aria-pressed={saver} onClick={() => { setSaver((s) => !s); if (!saver && (quality === '480p' || quality === '720p')) setQuality('360p'); }}>{t('player.dataSaver')}: {saver ? 'on' : 'off'}</button>
|
||||||
|
<button onClick={full} aria-label={t('player.fullscreen')}><Icon name="expand" size={16} /></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{done && (
|
||||||
|
<div className="done-flash" role="status"><Ring pct={pct} /><span className="grow">{t('player.completed')}</span>
|
||||||
|
{next && <button className="btn btn-sm" onClick={() => nav(`/${locale}/learn/${c.slug}/${next.id}`)}>{t('player.next')}</button>}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{!done && next && <div><button className="btn btn-ghost btn-sm" onClick={() => nav(`/${locale}/learn/${c.slug}/${next.id}`)}>{t('player.next')}<Icon name="chevron" size={14} /></button></div>}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- checkout (simulated ArifPay, §8.3 state machine)
|
||||||
|
|
||||||
|
function Checkout({ slug }: { slug?: string }) {
|
||||||
|
const t = useTranslations();
|
||||||
|
const { courses, me, locale, nav, ds, write } = useApp();
|
||||||
|
const c = courses.find((x) => x.slug === slug);
|
||||||
|
const [method, setMethod] = useState('TELEBIRR');
|
||||||
|
const key = useRef(newId('idem_')); // one key per checkout screen: double clicks reuse it (PAY-09)
|
||||||
|
const [busy, setBusy] = useState(false);
|
||||||
|
const [err, setErr] = useState('');
|
||||||
|
if (!c || !me) return <Empty>{t('course.notFound')}</Empty>;
|
||||||
|
if (owns(me, c.id)) return <Empty action={<button className="btn" onClick={() => nav(`/${locale}/course/${c.slug}`)}>{ct(c, locale).title}</button>}>{t('checkout.alreadyOwned')}</Empty>;
|
||||||
|
const start = async () => {
|
||||||
|
setBusy(true); setErr('');
|
||||||
|
try {
|
||||||
|
const o = createOrder(me, c, method, key.current, new Date(), newId('ord_'));
|
||||||
|
const ok = me.orders?.[o.id] ? true : await write(() => ds.patchStudent(me.id, { orders: { [o.id]: o } }));
|
||||||
|
if (ok) nav(`/${locale}/pay/${o.id}`);
|
||||||
|
} catch (e) { setErr(e instanceof DomainError && e.code === 'ALREADY_OWNED' ? t('checkout.alreadyOwned') : String((e as Error).message)); }
|
||||||
|
setBusy(false);
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<section className="stack" style={{ maxWidth: 560 }}>
|
||||||
|
<h1 style={{ fontSize: 'var(--fs-2xl)' }}>{t('checkout.title')}</h1>
|
||||||
|
<div className="card row" style={{ flexWrap: 'nowrap' }}>
|
||||||
|
<div style={{ width: 110, flex: 'none' }}><Cover course={c} locale={locale} /></div>
|
||||||
|
<div className="grow stack-sm"><strong>{ct(c, locale).title}</strong><span className="small muted">{t('checkout.lifetime')}</span></div>
|
||||||
|
</div>
|
||||||
|
<fieldset className="stack-sm" style={{ border: 0, padding: 0, margin: 0 }}>
|
||||||
|
<legend className="sr-only">{t('checkout.title')}</legend>
|
||||||
|
{METHODS.map((m) => (
|
||||||
|
<label key={m.id} className="card check" style={{ padding: 16, alignItems: 'center' }}>
|
||||||
|
<input type="radio" name="method" value={m.id} checked={method === m.id} onChange={() => setMethod(m.id)} />
|
||||||
|
<span className="grow" style={{ fontWeight: 700 }}>{m.name}</span><span className="pill">ArifPay</span>
|
||||||
|
</label>
|
||||||
|
))}
|
||||||
|
</fieldset>
|
||||||
|
<div className="row-between"><span>{t('checkout.total')}</span><strong className="price num">{formatMoney(c.prices.ETB ?? 0, 'ETB')}</strong></div>
|
||||||
|
{err && <p className="err" role="alert">{err}</p>}
|
||||||
|
<button className="btn btn-accent btn-block" disabled={busy} onClick={start}>{t('checkout.pay', { method: methodName(method) })}</button>
|
||||||
|
<p className="small muted">{t('checkout.simulated')}</p>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Stands in for ArifPay's hosted page. The unlock still goes through applyPaymentEvent — the same rule the webhook uses — never the return URL. */
|
||||||
|
function ProviderSim({ orderId }: { orderId?: string }) {
|
||||||
|
const t = useTranslations();
|
||||||
|
const { me, courses, locale, nav, ds, write, notify } = useApp();
|
||||||
|
const o = orderId ? me?.orders?.[orderId] : undefined;
|
||||||
|
if (!o || !me) return <Empty>{t('course.notFound')}</Empty>;
|
||||||
|
const c = courses.find((x) => x.id === o.courseId);
|
||||||
|
const settle = (status: 'PAID' | 'FAILED') => {
|
||||||
|
nav(`/${locale}/orders/${o.id}`);
|
||||||
|
// the "webhook" lands a moment later, like the real provider callback
|
||||||
|
setTimeout(async () => {
|
||||||
|
const fresh = me;
|
||||||
|
const patch = applyPaymentEvent(fresh, o.id, { status, amountMinor: o.amountMinor, currency: o.currency, reason: `Declined by ${methodName(o.method)} (simulated)` }, new Date());
|
||||||
|
if (!patch) return;
|
||||||
|
const ok = await write(() => ds.patchStudent(me.id, patch));
|
||||||
|
if (ok && status === 'PAID' && c) {
|
||||||
|
await write(() => notify(me.id, { type: 'PAYMENT', title: lookup(me.locale, 'system.paidTitle'), body: lookup(me.locale, 'system.paidBody', { title: ct(c, me.locale).title, price: formatMoney(o.amountMinor, o.currency) }), link: `/${me.locale}/course/${c.slug}` }));
|
||||||
|
}
|
||||||
|
}, 1800);
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<section className="stack" style={{ maxWidth: 480, margin: '0 auto', width: '100%' }}>
|
||||||
|
<div className="card stack">
|
||||||
|
<span className="pill pill-warn" style={{ alignSelf: 'flex-start' }}>{t('checkout.simulated')}</span>
|
||||||
|
<h1 style={{ fontSize: 'var(--fs-xl)' }}>{t('checkout.providerTitle', { method: methodName(o.method) })}</h1>
|
||||||
|
<p className="muted">{t('checkout.providerBody')}</p>
|
||||||
|
<dl className="kv"><dt>{t('checkout.total')}</dt><dd className="num">{formatMoney(o.amountMinor, o.currency)}</dd><dt>Order</dt><dd>{o.id}</dd></dl>
|
||||||
|
{effectiveStatus(o) === 'PENDING' ? <>
|
||||||
|
<button className="btn btn-accent btn-block" onClick={() => settle('PAID')}>{t('checkout.approve', { price: formatMoney(o.amountMinor, o.currency) })}</button>
|
||||||
|
<button className="btn btn-ghost btn-block" onClick={() => settle('FAILED')}>{t('checkout.decline')}</button>
|
||||||
|
<button className="btn btn-quiet btn-block" onClick={() => nav(`/${locale}/orders/${o.id}`)}>{t('checkout.leave')}</button>
|
||||||
|
</> : <button className="btn btn-block" onClick={() => nav(`/${locale}/orders/${o.id}`)}>{t('checkout.orderTitle', { id: '' })}</button>}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function OrderStatusPage({ orderId }: { orderId?: string }) {
|
||||||
|
const t = useTranslations();
|
||||||
|
const { me, courses, locale, nav, ds, write } = useApp();
|
||||||
|
const [now, setNow] = useState(Date.now());
|
||||||
|
useEffect(() => { const id = setInterval(() => setNow(Date.now()), 3000); return () => clearInterval(id); }, []); // re-check every 3 s (§5.5)
|
||||||
|
const o = orderId ? me?.orders?.[orderId] : undefined;
|
||||||
|
if (!o || !me) return <Empty>{t('course.notFound')}</Empty>;
|
||||||
|
const c = courses.find((x) => x.id === o.courseId);
|
||||||
|
const status = effectiveStatus(o, now);
|
||||||
|
const first = c && publishedLessons(c)[0];
|
||||||
|
return (
|
||||||
|
<section className="stack" style={{ maxWidth: 560 }}>
|
||||||
|
<span className="small muted">{t('checkout.orderTitle', { id: o.id })}</span>
|
||||||
|
<h1 style={{ fontSize: 'var(--fs-2xl)' }}>{c ? ct(c, locale).title : ''}</h1>
|
||||||
|
<div className="row"><StatusPill status={status} label={t(`status.${status}`)} /><span className="num">{formatMoney(o.amountMinor, o.currency)} · {methodName(o.method)}</span></div>
|
||||||
|
{status === 'PENDING' && <div className="card stack-sm" aria-live="polite">
|
||||||
|
<p>{now - Date.parse(o.createdAt) > 180_000 ? t('checkout.stillWaiting') : t('checkout.pending', { method: methodName(o.method) })}</p>
|
||||||
|
<div className="bar"><i style={{ width: '40%' }} /></div>
|
||||||
|
<div className="row"><button className="btn btn-ghost btn-sm" onClick={() => nav(`/${locale}/pay/${o.id}`)}>{t('checkout.pay', { method: methodName(o.method) })}</button>
|
||||||
|
<button className="btn btn-quiet btn-sm" onClick={() => write(() => ds.patchStudent(me.id, { orders: { [o.id]: { status: 'CANCELLED', updatedAt: new Date().toISOString(), events: [...o.events, { type: 'order.cancelled', at: new Date().toISOString() }] } } }))}>{t('common.cancel')}</button></div>
|
||||||
|
</div>}
|
||||||
|
{status === 'PAID' && <div className="card stack" aria-live="polite"><div className="done-flash"><Icon name="check" />{t('checkout.paid')}</div>
|
||||||
|
{c && first && <button className="btn btn-accent" onClick={() => nav(`/${locale}/learn/${c.slug}/${first.id}`)}>{t('checkout.start')}</button>}</div>}
|
||||||
|
{status === 'FAILED' && <div className="card stack"><p className="err">{t('checkout.failed')}</p>{o.failureReason && <p className="small">{t('checkout.failedReason', { reason: o.failureReason })}</p>}
|
||||||
|
{c && <button className="btn" onClick={() => nav(`/${locale}/checkout/${c.slug}`)}>{t('checkout.tryAgain')}</button>}</div>}
|
||||||
|
{(status === 'EXPIRED' || status === 'CANCELLED') && <div className="card stack"><p>{status === 'EXPIRED' ? t('checkout.expired') : t('checkout.cancelled')}</p>
|
||||||
|
{c && <button className="btn" onClick={() => nav(`/${locale}/checkout/${c.slug}`)}>{t('checkout.tryAgain')}</button>}</div>}
|
||||||
|
{status === 'REFUNDED' && <div className="card"><p>{t('status.REFUNDED')}</p></div>}
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- my courses + progress
|
||||||
|
|
||||||
|
function MyCourses() {
|
||||||
|
const t = useTranslations();
|
||||||
|
const { me, courses, locale, nav } = useApp();
|
||||||
|
const mine = courses.filter((c) => owns(me, c.id) && !c.isTest);
|
||||||
|
return (
|
||||||
|
<section className="stack">
|
||||||
|
<div className="row-between"><h1 style={{ fontSize: 'var(--fs-2xl)' }}>{t('my.title')}</h1>{mine.length > 0 && <button className="btn btn-ghost btn-sm" onClick={() => nav(`/${locale}/progress`)}>{t('my.viewProgress')}</button>}</div>
|
||||||
|
{mine.length ? <div className="stack">{mine.map((c) => {
|
||||||
|
const p = courseProgress(c, me); const r = resumePoint(c, me);
|
||||||
|
return (
|
||||||
|
<div key={c.id} className="card row" style={{ alignItems: 'center' }}>
|
||||||
|
<div style={{ width: 120, flex: 'none' }}><Cover course={c} locale={locale} /></div>
|
||||||
|
<div className="grow stack-sm"><strong>{ct(c, locale).title}</strong><div className="bar"><i style={{ width: `${p.pct}%` }} /></div><span className="small muted num">{t('my.lessonsDone', { done: p.done, total: p.total })}</span></div>
|
||||||
|
{r && <button className={`btn btn-sm ${p.pct === 100 ? 'btn-ghost' : 'btn-accent'}`} onClick={() => nav(`/${locale}/learn/${c.slug}/${r.lesson.id}`)}>{p.pct === 100 ? t('course.watchAgain') : t('my.resume')}</button>}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}</div> : <Empty action={<button className="btn" onClick={() => nav(`/${locale}/courses`)}>{t('landing.browse')}</button>}>{t('my.empty')}</Empty>}
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function MyProgress() {
|
||||||
|
const t = useTranslations();
|
||||||
|
const { me, courses, locale, nav } = useApp();
|
||||||
|
const mine = courses.filter((c) => owns(me, c.id) && !c.isTest);
|
||||||
|
return (
|
||||||
|
<section className="stack">
|
||||||
|
<h1 style={{ fontSize: 'var(--fs-2xl)' }}>{t('my.progressTitle')}</h1>
|
||||||
|
{!mine.length && <Empty action={<button className="btn" onClick={() => nav(`/${locale}/courses`)}>{t('landing.browse')}</button>}>{t('my.empty')}</Empty>}
|
||||||
|
{mine.map((c) => (
|
||||||
|
<div key={c.id} className="card stack-sm">
|
||||||
|
<div className="row"><Ring pct={courseProgress(c, me).pct} /><div className="grow"><h2 style={{ fontSize: 'var(--fs-lg)' }}>{ct(c, locale).title}</h2></div>
|
||||||
|
<button className="btn btn-ghost btn-sm" onClick={() => nav(`/${locale}/course/${c.slug}`)}>{t('course.content')}</button></div>
|
||||||
|
{[...c.chapters].sort((a, b) => a.sortOrder - b.sortOrder).map((ch) => <div key={ch.id}><p className="small" style={{ fontWeight: 700, padding: '8px 4px 2px' }}>{tr(ch.translations, locale)?.title}</p>{ch.lessons.filter((l) => l.isPublished).sort((a, b) => a.sortOrder - b.sortOrder).map((l) => <LessonRow key={l.id} c={c} l={l} />)}</div>)}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- notifications inbox
|
||||||
|
|
||||||
|
function Inbox() {
|
||||||
|
const t = useTranslations();
|
||||||
|
const { inbox, me, ds, write, nav } = useApp();
|
||||||
|
if (!me) return null;
|
||||||
|
const unread = inbox.filter((n) => !n.readAt);
|
||||||
|
const read = (id: string) => write(() => ds.patchInbox(me.id, id, { readAt: new Date().toISOString() }));
|
||||||
|
return (
|
||||||
|
<section className="stack" style={{ maxWidth: 720 }}>
|
||||||
|
<div className="row-between"><h1 style={{ fontSize: 'var(--fs-2xl)' }}>{t('notif.title')}</h1>
|
||||||
|
{unread.length > 0 && <button className="btn btn-ghost btn-sm" onClick={async () => { for (const n of unread) await read(n.id); }}>{t('notif.markAll')}</button>}</div>
|
||||||
|
{inbox.length ? <div>{inbox.map((n) => (
|
||||||
|
<div key={n.id} className="notif-item">
|
||||||
|
<span className={n.readAt ? 'read-dot' : 'unread-dot'} aria-label={n.readAt ? undefined : 'unread'} />
|
||||||
|
<div className="grow stack-sm"><strong>{n.title}</strong><p style={{ color: 'var(--ink-2)' }}>{n.body}</p><span className="small muted">{fmtDate(n.createdAt)}</span></div>
|
||||||
|
<div className="stack-sm">
|
||||||
|
{n.link && <button className="btn btn-sm" onClick={() => { if (!n.readAt) read(n.id); nav(n.link!); }}>{t('notif.open')}</button>}
|
||||||
|
{!n.readAt && !n.link && <button className="btn btn-ghost btn-sm" onClick={() => read(n.id)}><Icon name="check" size={14} /></button>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}</div> : <Empty>{t('notif.empty')}</Empty>}
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- help + issues (L9)
|
||||||
|
|
||||||
|
function Help() {
|
||||||
|
const t = useTranslations();
|
||||||
|
const { settings, me, signedIn, ds, write, locale, nav } = useApp();
|
||||||
|
const [type, setType] = useState<IssueType>('BUG');
|
||||||
|
const [subject, setSubject] = useState('');
|
||||||
|
const [desc, setDesc] = useState('');
|
||||||
|
const [shot, setShot] = useState<File | null>(null);
|
||||||
|
const [err, setErr] = useState('');
|
||||||
|
const [uploader, setUploader] = useState<Awaited<ReturnType<typeof ds.uploads>>>(null);
|
||||||
|
useEffect(() => { ds.uploads().then(setUploader); }, [ds]);
|
||||||
|
const submit = async (e: React.FormEvent) => {
|
||||||
|
e.preventDefault(); setErr('');
|
||||||
|
if (!me) return;
|
||||||
|
if (!subject.trim() || !desc.trim()) { setErr(t('help.required')); return; }
|
||||||
|
if (shot && shot.size > 5 * 1024 * 1024) { setErr(t('help.screenshotTooBig')); return; }
|
||||||
|
let screenshotAssetId: string | null = null;
|
||||||
|
if (shot && uploader) { try { screenshotAssetId = (await uploader.upload(shot)).id; } catch { /* report still goes without the image */ } }
|
||||||
|
const now = new Date().toISOString();
|
||||||
|
const issue: Issue = { id: newId('iss_'), type, subject: subject.trim(), description: desc.trim(), status: 'OPEN', screenshotAssetId, createdAt: now, updatedAt: now };
|
||||||
|
if (await write(() => ds.patchStudent(me.id, { issues: { [issue.id]: issue } }), t('help.sent'))) { setSubject(''); setDesc(''); setShot(null); }
|
||||||
|
};
|
||||||
|
const tel = settings.supportPhone.replace(/[^\d+]/g, '');
|
||||||
|
const mine = Object.values(me?.issues ?? {}).sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
||||||
|
return (
|
||||||
|
<section className="two-col">
|
||||||
|
<div className="stack">
|
||||||
|
<h1 style={{ fontSize: 'var(--fs-2xl)' }}>{t('help.title')}</h1>
|
||||||
|
<div className="faq"><h2 style={{ fontSize: 'var(--fs-lg)' }}>{t('help.faq')}</h2>
|
||||||
|
{[1, 2, 3].map((i) => <details key={i}><summary>{t(`help.q${i}`)}</summary><p>{t(`help.a${i}`)}</p></details>)}
|
||||||
|
</div>
|
||||||
|
<div className="card stack-sm"><h2 style={{ fontSize: 'var(--fs-lg)' }}>{t('help.contact')}</h2>
|
||||||
|
<a className="btn btn-ghost" href={settings.telegramLink} target="_blank" rel="noreferrer"><Icon name="send" size={16} />{t('help.telegram')}</a>
|
||||||
|
<div className="row"><a className="btn btn-ghost grow" href={`tel:${tel}`}><Icon name="phone" size={16} />{t('help.call')}: <span className="num">{settings.supportPhone}</span></a><CopyText text={settings.supportPhone} copyLabel={t('help.copy')} copiedLabel={t('help.copied')} /></div>
|
||||||
|
<div className="row"><span className="grow small">{settings.supportEmail}</span><CopyText text={settings.supportEmail} copyLabel={t('help.copy')} copiedLabel={t('help.copied')} /></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="stack">
|
||||||
|
{signedIn ? <form className="card stack" onSubmit={submit}>
|
||||||
|
<h2 style={{ fontSize: 'var(--fs-lg)' }}>{t('help.report')}</h2>
|
||||||
|
<label className="field"><span>{t('help.type')}</span><select id="itype" className="input" value={type} onChange={(e) => setType(e.target.value as IssueType)}>{ISSUE_TYPES.map((x) => <option key={x} value={x}>{t(`issueType.${x}`)}</option>)}</select></label>
|
||||||
|
<label className="field"><span>{t('help.subject')}</span><input id="isubject" className="input" value={subject} onChange={(e) => setSubject(e.target.value)} maxLength={120} /></label>
|
||||||
|
<label className="field"><span>{t('help.description')}</span><textarea id="idesc" className="input" value={desc} onChange={(e) => setDesc(e.target.value)} maxLength={2000} /></label>
|
||||||
|
{uploader && <label className="field"><span>{t('help.screenshot')}</span><input id="ishot" type="file" accept="image/png,image/jpeg,image/webp" onChange={(e) => setShot(e.target.files?.[0] ?? null)} /></label>}
|
||||||
|
{err && <p className="err" role="alert">{err}</p>}
|
||||||
|
<button className="btn btn-accent">{t('help.submit')}</button>
|
||||||
|
</form> : <div className="card stack-sm"><h2 style={{ fontSize: 'var(--fs-lg)' }}>{t('help.report')}</h2><button className="btn" onClick={() => nav(`/${locale}/signin`)}>{t('nav.signIn')}</button></div>}
|
||||||
|
{signedIn && <div className="card stack-sm"><h2 style={{ fontSize: 'var(--fs-lg)' }}>{t('help.mine')}</h2>
|
||||||
|
{mine.length ? mine.map((i) => <div key={i.id} className="row-between" style={{ borderTop: '1px solid var(--line)', paddingTop: 10 }}>
|
||||||
|
<div className="grow"><strong>{i.subject}</strong><p className="small muted">{t(`issueType.${i.type}`)} · {fmtDate(i.createdAt)}</p>{i.resolutionNote && <p className="small">{i.resolutionNote}</p>}</div>
|
||||||
|
<StatusPill status={i.status} label={t(`status.${i.status}`)} /></div>) : <p className="muted">{t('help.noReports')}</p>}
|
||||||
|
</div>}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- sign in (simulated OTP) + profile setup
|
||||||
|
|
||||||
|
function SignIn() {
|
||||||
|
const t = useTranslations();
|
||||||
|
const { viewer, me, ready, signIn, nav, locale } = useApp();
|
||||||
|
const [mode, setMode] = useState<'phone' | 'email'>('phone');
|
||||||
|
const [phone, setPhone] = useState('');
|
||||||
|
const [email, setEmail] = useState('');
|
||||||
|
const [pw, setPw] = useState('');
|
||||||
|
const [step, setStep] = useState<'start' | 'code' | 'setup'>('start');
|
||||||
|
const [code, setCode] = useState('');
|
||||||
|
const [entered, setEntered] = useState('');
|
||||||
|
const [tries, setTries] = useState(5);
|
||||||
|
const [wait, setWait] = useState(0);
|
||||||
|
const [err, setErr] = useState('');
|
||||||
|
useEffect(() => { if (wait <= 0) return; const id = setTimeout(() => setWait((w) => w - 1), 1000); return () => clearTimeout(id); }, [wait]);
|
||||||
|
if (!ready) return <Skeleton h={200} />;
|
||||||
|
if (!viewer?.id) return <Empty>{t('auth.noIdentity')}</Empty>;
|
||||||
|
const target = mode === 'phone' ? `+251 ${phone}` : email;
|
||||||
|
const send = () => {
|
||||||
|
setErr('');
|
||||||
|
if (mode === 'phone' && !/^\d{9}$/.test(phone.replace(/\s/g, ''))) { setErr(t('auth.phoneInvalid')); return; }
|
||||||
|
if (mode === 'email' && !/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(email)) { setErr(t('auth.emailInvalid')); return; }
|
||||||
|
if (mode === 'email' && !validPassword(pw)) { setErr(t('auth.passwordShort')); return; }
|
||||||
|
setCode(String(Math.floor(100000 + Math.random() * 900000))); setTries(5); setEntered(''); setWait(60); setStep('code');
|
||||||
|
};
|
||||||
|
const verify = (e: React.FormEvent) => {
|
||||||
|
e.preventDefault(); setErr('');
|
||||||
|
if (tries <= 0) { setErr(t('auth.locked')); return; }
|
||||||
|
if (entered !== code) { const left = tries - 1; setTries(left); setErr(left ? t('auth.wrongCode', { n: left }) : t('auth.locked')); return; }
|
||||||
|
if (me && !me.deletedAt) { signIn(); nav(`/${locale}`); } else setStep('setup');
|
||||||
|
};
|
||||||
|
if (step === 'setup') return <ProfileSetup phone={mode === 'phone' ? `+251${phone.replace(/\s/g, '')}` : undefined} email={mode === 'email' ? email : undefined} />;
|
||||||
|
return (
|
||||||
|
<section className="stack" style={{ maxWidth: 440, margin: '0 auto', width: '100%' }}>
|
||||||
|
{step === 'start' ? <form className="card stack" onSubmit={(e) => { e.preventDefault(); send(); }}>
|
||||||
|
<h1 style={{ fontSize: 'var(--fs-xl)' }}>{mode === 'phone' ? t('auth.phoneTitle') : t('auth.emailTitle')}</h1>
|
||||||
|
{mode === 'phone' ? (
|
||||||
|
<label className="field"><span>{t('auth.phoneLabel')}</span>
|
||||||
|
<div className="row" style={{ flexWrap: 'nowrap' }}><span className="pill" style={{ padding: '10px 12px' }}>+251</span><input id="phone" className="input" inputMode="numeric" autoComplete="tel-national" placeholder="9XX XXX XXX" value={phone} onChange={(e) => setPhone(e.target.value)} /></div>
|
||||||
|
</label>
|
||||||
|
) : <>
|
||||||
|
<label className="field"><span>{t('auth.emailLabel')}</span><input id="email" className="input" type="email" autoComplete="email" value={email} onChange={(e) => setEmail(e.target.value)} /></label>
|
||||||
|
<label className="field"><span>{t('auth.passwordLabel')}</span><input id="pw" className="input" type="password" autoComplete="new-password" value={pw} onChange={(e) => setPw(e.target.value)} /><span className="hint">{t('auth.passwordHint')}</span></label>
|
||||||
|
</>}
|
||||||
|
{err && <p className="err" role="alert">{err}</p>}
|
||||||
|
<button className="btn btn-accent btn-block">{t('auth.sendCode')}</button>
|
||||||
|
<button type="button" className="link" onClick={() => { setMode(mode === 'phone' ? 'email' : 'phone'); setErr(''); }}>{mode === 'phone' ? t('auth.useEmail') : t('auth.usePhone')}</button>
|
||||||
|
</form> : <form className="card stack" onSubmit={verify}>
|
||||||
|
<h1 style={{ fontSize: 'var(--fs-xl)' }}>{t('auth.codeTitle')}</h1>
|
||||||
|
<p>{t('auth.codeSent', { target })}</p>
|
||||||
|
<p className="banner"><strong>{t('auth.demoCode', { code })}</strong></p>
|
||||||
|
<label className="field"><span className="sr-only">{t('auth.codeTitle')}</span><input id="otp" className="input otp" inputMode="numeric" autoComplete="one-time-code" maxLength={6} value={entered} onChange={(e) => setEntered(e.target.value.replace(/\D/g, ''))} /></label>
|
||||||
|
{err && <p className="err" role="alert">{err}</p>}
|
||||||
|
<button className="btn btn-accent btn-block" disabled={entered.length !== 6 || tries <= 0}>{t('auth.verify')}</button>
|
||||||
|
<button type="button" className="btn btn-ghost btn-block" disabled={wait > 0} onClick={send}>{wait > 0 ? t('auth.resendIn', { s: wait }) : t('auth.resend')}</button>
|
||||||
|
<button type="button" className="link" onClick={() => setStep('start')}>{t('common.back')}</button>
|
||||||
|
</form>}
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function LocationFields({ country, city, onCountry, onCity, labels }: { country: string; city: string; onCountry(v: string): void; onCity(v: string): void; labels: { country: string; city: string; pick: string; type: string } }) {
|
||||||
|
return <>
|
||||||
|
<label className="field"><span>{labels.country}</span>
|
||||||
|
<select id="country" className="input" value={country} onChange={(e) => { onCountry(e.target.value); onCity(''); }}>{COUNTRIES.map(([code, name]) => <option key={code} value={code}>{name}</option>)}</select></label>
|
||||||
|
<label className="field"><span>{labels.city}</span>
|
||||||
|
{country === 'ET'
|
||||||
|
? <select id="city" className="input" value={city} onChange={(e) => onCity(e.target.value)}><option value="">{labels.pick}</option>{ET_CITIES.map((c) => <option key={c} value={c}>{c}</option>)}</select>
|
||||||
|
: <input id="city" className="input" placeholder={labels.type} value={city} onChange={(e) => onCity(e.target.value)} />}
|
||||||
|
</label>
|
||||||
|
</>;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ProfileSetup({ phone, email }: { phone?: string; email?: string }) {
|
||||||
|
const t = useTranslations();
|
||||||
|
const { viewer, ds, write, locale, setLocale, signIn, nav } = useApp();
|
||||||
|
const [name, setName] = useState(viewer?.name ?? '');
|
||||||
|
const [country, setCountry] = useState('ET');
|
||||||
|
const [city, setCity] = useState('');
|
||||||
|
const [lang, setLang] = useState<Locale>(locale);
|
||||||
|
const [err, setErr] = useState('');
|
||||||
|
const save = async (e: React.FormEvent) => {
|
||||||
|
e.preventDefault(); setErr('');
|
||||||
|
if (!name.trim()) { setErr(t('setup.nameRequired')); return; }
|
||||||
|
const locErr = validateLocation(country, city);
|
||||||
|
if (locErr) { setErr(t(`setup.${locErr}`)); return; }
|
||||||
|
const now = new Date().toISOString();
|
||||||
|
const s: Student = { id: viewer!.id!, name: name.trim(), phone, email, country, city: city.trim(), locale: lang, status: 'ACTIVE', createdAt: now, updatedAt: now, lastActiveAt: now, enrollments: {}, orders: {}, progress: {}, issues: {}, watchSec: {} };
|
||||||
|
if (await write(() => ds.saveStudent(s))) { signIn(); if (lang !== locale) setLocale(lang); nav(`/${lang}`); }
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<section className="stack" style={{ maxWidth: 480, margin: '0 auto', width: '100%' }}>
|
||||||
|
<form className="card stack" onSubmit={save}>
|
||||||
|
<h1 style={{ fontSize: 'var(--fs-xl)' }}>{t('setup.title')}</h1>
|
||||||
|
<label className="field"><span>{t('setup.name')}</span><input id="name" className="input" autoComplete="name" value={name} onChange={(e) => setName(e.target.value)} /></label>
|
||||||
|
<LocationFields country={country} city={city} onCountry={setCountry} onCity={setCity} labels={{ country: t('setup.country'), city: t('setup.city'), pick: t('setup.cityPick'), type: t('setup.cityType') }} />
|
||||||
|
<label className="field"><span>{t('setup.language')}</span><select id="slang" className="input" value={lang} onChange={(e) => setLang(e.target.value as Locale)}>{LOCALES.map((l) => <option key={l} value={l}>{LOCALE_NAMES[l]}</option>)}</select></label>
|
||||||
|
{err && <p className="err" role="alert">{err}</p>}
|
||||||
|
<button className="btn btn-accent btn-block">{t('setup.save')}</button>
|
||||||
|
</form>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- profile (§5.11)
|
||||||
|
|
||||||
|
const NOTIF_TYPES = ['PAYMENT', 'NEW_LESSON', 'ISSUE', 'ANNOUNCEMENT'] as const;
|
||||||
|
|
||||||
|
function Profile() {
|
||||||
|
const t = useTranslations();
|
||||||
|
const { me, ds, write, courses, locale, setLocale, signOut, nav } = useApp();
|
||||||
|
const [name, setName] = useState(me?.name ?? '');
|
||||||
|
const [phone, setPhone] = useState(me?.phone ?? '');
|
||||||
|
const [email, setEmail] = useState(me?.email ?? '');
|
||||||
|
const [country, setCountry] = useState(me?.country ?? 'ET');
|
||||||
|
const [city, setCity] = useState(me?.city ?? '');
|
||||||
|
const [err, setErr] = useState('');
|
||||||
|
const [receipt, setReceipt] = useState<Order | null>(null);
|
||||||
|
const [confirmDelete, setConfirmDelete] = useState(false);
|
||||||
|
if (!me) return null;
|
||||||
|
const save = async (e: React.FormEvent) => {
|
||||||
|
e.preventDefault(); setErr('');
|
||||||
|
if (!name.trim()) { setErr(t('setup.nameRequired')); return; }
|
||||||
|
const locErr = validateLocation(country, city);
|
||||||
|
if (locErr) { setErr(t(`setup.${locErr}`)); return; }
|
||||||
|
await write(() => ds.patchStudent(me.id, { name: name.trim(), phone, email, country, city: city.trim(), updatedAt: new Date().toISOString() }), t('common.saved'));
|
||||||
|
};
|
||||||
|
const pref = (type: string, ch: 'EMAIL' | 'SMS') => me.notificationPrefs?.[type]?.[ch] !== false;
|
||||||
|
const orders = Object.values(me.orders ?? {}).sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
||||||
|
const courseTitle = (id: string) => { const c = courses.find((x) => x.id === id); return c ? ct(c, locale).title : id; };
|
||||||
|
return (
|
||||||
|
<section className="stack">
|
||||||
|
<h1 style={{ fontSize: 'var(--fs-2xl)' }}>{t('profile.title')}</h1>
|
||||||
|
<div className="two-col">
|
||||||
|
<form className="card stack" onSubmit={save}>
|
||||||
|
<h2 style={{ fontSize: 'var(--fs-lg)' }}>{t('profile.details')}</h2>
|
||||||
|
<label className="field"><span>{t('setup.name')}</span><input id="pname" className="input" value={name} onChange={(e) => setName(e.target.value)} /></label>
|
||||||
|
<label className="field"><span>{t('profile.phone')}</span><input id="pphone" className="input" inputMode="tel" value={phone} onChange={(e) => setPhone(e.target.value)} /></label>
|
||||||
|
<label className="field"><span>{t('profile.email')}</span><input id="pemail" className="input" type="email" value={email} onChange={(e) => setEmail(e.target.value)} /></label>
|
||||||
|
<LocationFields country={country} city={city} onCountry={setCountry} onCity={setCity} labels={{ country: t('setup.country'), city: t('setup.city'), pick: t('setup.cityPick'), type: t('setup.cityType') }} />
|
||||||
|
<label className="field"><span>{t('common.language')}</span><select id="plang" className="input" value={locale} onChange={(e) => setLocale(e.target.value as Locale)}>{LOCALES.map((l) => <option key={l} value={l}>{LOCALE_NAMES[l]}</option>)}</select></label>
|
||||||
|
{err && <p className="err" role="alert">{err}</p>}
|
||||||
|
<button className="btn">{t('common.save')}</button>
|
||||||
|
</form>
|
||||||
|
<div className="stack">
|
||||||
|
<div className="card stack-sm">
|
||||||
|
<h2 style={{ fontSize: 'var(--fs-lg)' }}>{t('profile.prefs')}</h2>
|
||||||
|
<p className="small muted">{t('profile.prefsNote')}</p>
|
||||||
|
<div className="tbl-wrap" style={{ border: 0 }}><table className="tbl"><thead><tr><th></th><th>{t('channel.EMAIL')}</th><th>{t('channel.SMS')}</th></tr></thead><tbody>
|
||||||
|
{NOTIF_TYPES.map((type) => <tr key={type}><td>{t(`notifType.${type}`)}</td>{(['EMAIL', 'SMS'] as const).map((ch) => <td key={ch}>
|
||||||
|
<input type="checkbox" aria-label={`${t(`notifType.${type}`)} · ${t(`channel.${ch}`)}`} checked={type === 'PAYMENT' || pref(type, ch)} disabled={type === 'PAYMENT'}
|
||||||
|
onChange={(e) => write(() => ds.patchStudent(me.id, { notificationPrefs: { [type]: { [ch]: e.target.checked } } }))} style={{ width: 20, height: 20, accentColor: 'var(--ink)' }} /></td>)}</tr>)}
|
||||||
|
</tbody></table></div>
|
||||||
|
</div>
|
||||||
|
<div className="card stack-sm">
|
||||||
|
<h2 style={{ fontSize: 'var(--fs-lg)' }}>{t('profile.sessions')}</h2>
|
||||||
|
<div className="row-between"><span><Icon name="shield" size={16} /> {t('profile.thisDevice')}</span><button className="btn btn-ghost btn-sm" onClick={() => { signOut(); nav(`/${locale}`); }}>{t('profile.signOutSession')}</button></div>
|
||||||
|
</div>
|
||||||
|
<div className="card stack-sm">
|
||||||
|
<h2 style={{ fontSize: 'var(--fs-lg)' }}>{t('profile.purchases')}</h2>
|
||||||
|
{orders.length ? orders.map((o) => <div key={o.id} className="row-between" style={{ borderTop: '1px solid var(--line)', paddingTop: 10 }}>
|
||||||
|
<div className="grow"><strong>{courseTitle(o.courseId)}</strong><p className="small muted num">{fmtDate(o.createdAt)} · {formatMoney(o.amountMinor, o.currency)}</p></div>
|
||||||
|
<StatusPill status={effectiveStatus(o)} label={t(`status.${effectiveStatus(o)}`)} />
|
||||||
|
<button className="btn btn-ghost btn-sm" onClick={() => effectiveStatus(o) === 'PAID' || o.status === 'REFUNDED' ? setReceipt(o) : nav(`/${locale}/orders/${o.id}`)}>{t('notif.open')}</button>
|
||||||
|
</div>) : <p className="muted">{t('profile.noPurchases')}</p>}
|
||||||
|
</div>
|
||||||
|
<div className="card stack-sm">
|
||||||
|
<h2 style={{ fontSize: 'var(--fs-lg)' }}>{t('profile.delete')}</h2>
|
||||||
|
{confirmDelete ? <>
|
||||||
|
<p className="small">{t('profile.deleteBody')}</p>
|
||||||
|
<div className="row"><button className="btn btn-danger btn-sm" onClick={async () => { if (await write(() => ds.patchStudent(me.id, { deletedAt: new Date().toISOString(), status: 'DEACTIVATED' }), t('profile.deleted'))) nav(`/${locale}`); }}>{t('profile.deleteConfirm')}</button>
|
||||||
|
<button className="btn btn-ghost btn-sm" onClick={() => setConfirmDelete(false)}>{t('common.cancel')}</button></div>
|
||||||
|
</> : <button className="btn btn-ghost btn-sm" style={{ alignSelf: 'flex-start' }} onClick={() => setConfirmDelete(true)}>{t('profile.delete')}</button>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{receipt && <Modal title={t('checkout.orderTitle', { id: receipt.id })} onClose={() => setReceipt(null)}>
|
||||||
|
<dl className="kv">
|
||||||
|
<dt>{t('nav.courses')}</dt><dd>{courseTitle(receipt.courseId)}</dd>
|
||||||
|
<dt>{t('checkout.total')}</dt><dd className="num">{formatMoney(receipt.amountMinor, receipt.currency)}</dd>
|
||||||
|
<dt>ArifPay</dt><dd>{methodName(receipt.method)}</dd>
|
||||||
|
<dt>{t(`status.${receipt.status}`)}</dt><dd>{fmtDate(receipt.paidAt)}</dd>
|
||||||
|
</dl>
|
||||||
|
<button className="btn" onClick={() => setReceipt(null)}>{t('common.close')}</button>
|
||||||
|
</Modal>}
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
328
packages/features/src/styles.css
Normal file
|
|
@ -0,0 +1,328 @@
|
||||||
|
/* Layout: student = quiet single column with Ge'ez titles given room; admin = Logosmental-style sidebar shell, dense tables.
|
||||||
|
Tokens mirror design/tokens.json (§11.3). Components never use raw colors. */
|
||||||
|
:root {
|
||||||
|
--ink: #1B2340; --ink-2: #4A5268; --ink-3: #6B7286;
|
||||||
|
--paper: #FFFFFF; --canvas: #F5F6F8; --mist: #EEF1F6; --line: #E1E5EC;
|
||||||
|
--accent: #F2B705; --accent-ink: #1B2340; --accent-soft: #FDF3D2;
|
||||||
|
--success: #2E7D5B; --success-soft: #E3F1EA; --alert: #C2362B; --alert-soft: #FBE8E6;
|
||||||
|
--info-soft: #E7EDF8; --on-ink: #FFFFFF;
|
||||||
|
--tone-rose: #E9D3CF; --tone-clay: #E8D8C4; --tone-plum: #DCD3E6; --tone-sand: #F1E7CF; --tone-sage: #D7E4DA; --tone-ink: #D5D9E4;
|
||||||
|
--f-latin: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
|
||||||
|
--f-eth: 'Noto Sans Ethiopic', 'Atkinson Hyperlegible', system-ui, sans-serif;
|
||||||
|
--f-serif: 'Noto Serif Ethiopic', 'Noto Sans Ethiopic', Georgia, serif;
|
||||||
|
--fs-sm: 14px; --fs-base: 16px; --fs-lg: 20px; --fs-xl: 25px; --fs-2xl: 31px; --fs-3xl: 39px;
|
||||||
|
--r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-pill: 999px;
|
||||||
|
--shadow: 0 1px 2px rgba(27, 35, 64, .06), 0 1px 1px rgba(27, 35, 64, .03);
|
||||||
|
--shadow-pop: 0 12px 32px rgba(27, 35, 64, .16);
|
||||||
|
color-scheme: light;
|
||||||
|
}
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root:not([data-theme="light"]) {
|
||||||
|
--ink: #E8EBF3; --ink-2: #B9BFCE; --ink-3: #8F96A8;
|
||||||
|
--paper: #171C2C; --canvas: #10141F; --mist: #222940; --line: #2C3450;
|
||||||
|
--accent: #F5C53A; --accent-ink: #171C2C; --accent-soft: #3A321A;
|
||||||
|
--success: #5CC08F; --success-soft: #173328; --alert: #F0776B; --alert-soft: #3B1C1A;
|
||||||
|
--info-soft: #1F2A45; --on-ink: #171C2C;
|
||||||
|
--tone-rose: #3A2A2C; --tone-clay: #3A3226; --tone-plum: #302A3D; --tone-sand: #38331F; --tone-sage: #22342A; --tone-ink: #262D45;
|
||||||
|
color-scheme: dark;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
:root[data-theme="dark"] {
|
||||||
|
--ink: #E8EBF3; --ink-2: #B9BFCE; --ink-3: #8F96A8;
|
||||||
|
--paper: #171C2C; --canvas: #10141F; --mist: #222940; --line: #2C3450;
|
||||||
|
--accent: #F5C53A; --accent-ink: #171C2C; --accent-soft: #3A321A;
|
||||||
|
--success: #5CC08F; --success-soft: #173328; --alert: #F0776B; --alert-soft: #3B1C1A;
|
||||||
|
--info-soft: #1F2A45; --on-ink: #171C2C;
|
||||||
|
--tone-rose: #3A2A2C; --tone-clay: #3A3226; --tone-plum: #302A3D; --tone-sand: #38331F; --tone-sage: #22342A; --tone-ink: #262D45;
|
||||||
|
color-scheme: dark;
|
||||||
|
}
|
||||||
|
|
||||||
|
* { box-sizing: border-box; }
|
||||||
|
html, body { margin: 0; }
|
||||||
|
body { background: var(--paper); color: var(--ink); font: var(--fs-base)/1.5 var(--f-latin); -webkit-font-smoothing: antialiased; }
|
||||||
|
:lang(am), :lang(ti), .eth { font-family: var(--f-eth); line-height: 1.7; }
|
||||||
|
h1, h2, h3, h4 { margin: 0; line-height: 1.25; text-wrap: balance; font-weight: 700; }
|
||||||
|
h1:lang(am), h1:lang(ti), h2:lang(am), h2:lang(ti), .serif { font-family: var(--f-serif); line-height: 1.45; }
|
||||||
|
p { margin: 0; }
|
||||||
|
a { color: inherit; }
|
||||||
|
button, input, select, textarea { font: inherit; color: inherit; }
|
||||||
|
img, video { max-width: 100%; display: block; }
|
||||||
|
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
|
||||||
|
.num { font-variant-numeric: tabular-nums; }
|
||||||
|
.muted { color: var(--ink-3); }
|
||||||
|
.small { font-size: var(--fs-sm); }
|
||||||
|
.stack { display: flex; flex-direction: column; gap: 16px; }
|
||||||
|
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
|
||||||
|
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
|
||||||
|
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
|
||||||
|
.grow { flex: 1; min-width: 0; }
|
||||||
|
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
||||||
|
|
||||||
|
/* ---------- buttons, inputs ---------- */
|
||||||
|
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: var(--r-pill); border: 1px solid transparent; background: var(--ink); color: var(--on-ink); font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; }
|
||||||
|
.btn:hover { filter: brightness(1.12); }
|
||||||
|
.btn[disabled] { opacity: .45; cursor: not-allowed; filter: none; }
|
||||||
|
.btn-accent { background: var(--accent); color: var(--accent-ink); }
|
||||||
|
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
|
||||||
|
.btn-ghost:hover { background: var(--mist); filter: none; }
|
||||||
|
.btn-quiet { background: transparent; color: var(--ink); padding: 0 10px; min-height: 36px; }
|
||||||
|
.btn-quiet:hover { background: var(--mist); filter: none; }
|
||||||
|
.btn-danger { background: var(--alert); color: var(--on-ink); }
|
||||||
|
.btn-sm { min-height: 34px; padding: 0 12px; font-size: var(--fs-sm); }
|
||||||
|
.btn-block { width: 100%; }
|
||||||
|
.link { background: none; border: 0; padding: 0; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-weight: 700; }
|
||||||
|
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
|
||||||
|
.field > span { font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2); }
|
||||||
|
.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--mist); }
|
||||||
|
textarea.input { min-height: 110px; resize: vertical; }
|
||||||
|
.input:focus { border-color: var(--ink-3); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
|
||||||
|
.hint { font-size: var(--fs-sm); color: var(--ink-3); }
|
||||||
|
.err { font-size: var(--fs-sm); color: var(--alert); font-weight: 700; }
|
||||||
|
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
|
||||||
|
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--ink); }
|
||||||
|
.otp { letter-spacing: .5em; font-size: var(--fs-xl); text-align: center; font-variant-numeric: tabular-nums; }
|
||||||
|
|
||||||
|
/* ---------- pills, cards ---------- */
|
||||||
|
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 700; background: var(--mist); color: var(--ink-2); white-space: nowrap; }
|
||||||
|
.pill-ok { background: var(--success-soft); color: var(--success); }
|
||||||
|
.pill-warn { background: var(--accent-soft); color: var(--ink); }
|
||||||
|
.pill-bad { background: var(--alert-soft); color: var(--alert); }
|
||||||
|
.pill-info { background: var(--info-soft); color: var(--ink); }
|
||||||
|
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; min-width: 0; }
|
||||||
|
.panel { background: var(--mist); border-radius: var(--r-lg); padding: 20px; }
|
||||||
|
.banner { padding: 12px 16px; border-radius: var(--r-md); background: var(--accent-soft); font-size: var(--fs-sm); }
|
||||||
|
.banner-bad { background: var(--alert-soft); color: var(--alert); }
|
||||||
|
.banner-ok { background: var(--success-soft); color: var(--success); }
|
||||||
|
.empty { padding: 32px 20px; text-align: center; color: var(--ink-2); border: 1px dashed var(--line); border-radius: var(--r-lg); display: flex; flex-direction: column; gap: 14px; align-items: center; }
|
||||||
|
.skel { background: linear-gradient(90deg, var(--mist), var(--line), var(--mist)); background-size: 200% 100%; animation: skel 1.2s infinite; border-radius: var(--r-md); }
|
||||||
|
@keyframes skel { to { background-position: -200% 0; } }
|
||||||
|
.bar { height: 6px; border-radius: var(--r-pill); background: var(--mist); overflow: hidden; }
|
||||||
|
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .6s ease; }
|
||||||
|
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--on-ink); padding: 12px 18px; border-radius: var(--r-md); box-shadow: var(--shadow-pop); z-index: 50; max-width: calc(100% - 32px); font-weight: 700; }
|
||||||
|
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
|
||||||
|
.tab { background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--ink-3); font-weight: 700; border-bottom: 3px solid transparent; white-space: nowrap; }
|
||||||
|
.tab[aria-selected="true"] { color: var(--ink); border-color: var(--accent); }
|
||||||
|
.seg { display: inline-flex; background: var(--mist); border-radius: var(--r-pill); padding: 3px; gap: 2px; flex-wrap: wrap; }
|
||||||
|
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: var(--r-pill); cursor: pointer; font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2); }
|
||||||
|
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
|
||||||
|
.modal-back { position: fixed; inset: 0; background: rgba(16, 20, 31, .5); display: grid; place-items: center; padding: 16px; z-index: 40; }
|
||||||
|
.modal { background: var(--paper); border-radius: var(--r-lg); padding: 24px; width: min(560px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--shadow-pop); display: flex; flex-direction: column; gap: 16px; }
|
||||||
|
.feedback-btn { white-space: nowrap; }
|
||||||
|
@media (max-width: 700px) { .feedback-btn .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } .feedback-btn { padding: 0; width: 36px; } }
|
||||||
|
.demo-strip { background: var(--accent-soft); color: var(--ink); font-size: 12px; text-align: center; padding: 4px 16px; }
|
||||||
|
|
||||||
|
/* ---------- student shell ---------- */
|
||||||
|
.s-top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--paper); border-bottom: 1px solid var(--line); }
|
||||||
|
.s-top-in { max-width: 1120px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; }
|
||||||
|
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; background: none; border: 0; cursor: pointer; padding: 0; }
|
||||||
|
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--ink); color: var(--accent); display: grid; place-items: center; font-family: var(--f-serif); font-size: 19px; }
|
||||||
|
.s-nav { display: none; gap: 4px; }
|
||||||
|
.s-nav button { background: none; border: 0; padding: 8px 12px; border-radius: var(--r-pill); cursor: pointer; font-weight: 700; color: var(--ink-2); }
|
||||||
|
.s-nav button[aria-current="page"] { background: var(--mist); color: var(--ink); }
|
||||||
|
.icon-btn { position: relative; width: 44px; height: 44px; border-radius: var(--r-pill); border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--ink); }
|
||||||
|
.icon-btn:hover { background: var(--mist); }
|
||||||
|
.dot { position: absolute; top: 6px; right: 4px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--alert); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }
|
||||||
|
.s-main { max-width: 1120px; margin: 0 auto; padding: 24px 16px 120px; display: flex; flex-direction: column; gap: 40px; }
|
||||||
|
.s-tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--paper); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); padding-bottom: env(safe-area-inset-bottom, 0px); }
|
||||||
|
.s-tabs button { background: none; border: 0; padding: 8px 2px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 700; color: var(--ink-3); cursor: pointer; }
|
||||||
|
.s-tabs button[aria-current="page"] { color: var(--ink); }
|
||||||
|
.s-tabs button[aria-current="page"] svg { color: var(--ink); background: var(--accent-soft); border-radius: var(--r-pill); }
|
||||||
|
@media (min-width: 900px) { .s-nav { display: flex; } .s-tabs { display: none; } .s-main { padding-bottom: 64px; } }
|
||||||
|
.lang-select { border: 1px solid var(--line); background: var(--paper); border-radius: var(--r-pill); padding: 6px 10px; font-size: var(--fs-sm); font-weight: 700; }
|
||||||
|
|
||||||
|
.section-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
|
||||||
|
.section-h h2 { font-size: var(--fs-xl); }
|
||||||
|
.hero { display: grid; gap: 32px; padding: 8px 0; align-items: center; }
|
||||||
|
@media (min-width: 900px) { .hero { grid-template-columns: 1.15fr 1fr; padding: 24px 0 8px; } }
|
||||||
|
.hero h1 { font-size: clamp(31px, 6vw, 52px); max-width: 16ch; }
|
||||||
|
.hero-copy { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
|
||||||
|
.facts { display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 0; margin: 0; font-size: var(--fs-sm); color: var(--ink-2); }
|
||||||
|
.facts li { list-style: none; display: flex; align-items: center; gap: 8px; }
|
||||||
|
.facts li svg { color: var(--success); }
|
||||||
|
.hero-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow-pop); min-width: 0; }
|
||||||
|
.hero-card .cover { aspect-ratio: 4 / 3; }
|
||||||
|
.foot { border-top: 1px solid var(--line); margin-top: 24px; padding: 32px 16px calc(96px + env(safe-area-inset-bottom, 0px)); }
|
||||||
|
.foot-in { max-width: 1120px; margin: 0 auto; display: grid; gap: 24px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); font-size: var(--fs-sm); color: var(--ink-2); }
|
||||||
|
.foot-in h3 { font-size: var(--fs-sm); color: var(--ink); margin-bottom: 8px; }
|
||||||
|
.foot-in .stack-sm button, .foot-in .stack-sm a { text-align: left; background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
|
||||||
|
@media (min-width: 900px) { .foot { padding-bottom: 32px; } }
|
||||||
|
.hero p.lead { font-size: var(--fs-lg); color: var(--ink-2); max-width: 46ch; }
|
||||||
|
.steps { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); counter-reset: s; }
|
||||||
|
.steps li { list-style: none; display: flex; gap: 12px; align-items: flex-start; padding: 16px; background: var(--mist); border-radius: var(--r-md); }
|
||||||
|
.steps li::before { counter-increment: s; content: counter(s); flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--on-ink); display: grid; place-items: center; font-weight: 700; }
|
||||||
|
.pay-logos { display: flex; gap: 10px; flex-wrap: wrap; }
|
||||||
|
.pay-logo { padding: 10px 16px; border-radius: var(--r-md); border: 1px solid var(--line); font-weight: 700; display: flex; align-items: center; gap: 8px; }
|
||||||
|
.pay-logo i { width: 12px; height: 12px; border-radius: 3px; background: var(--accent); }
|
||||||
|
|
||||||
|
/* course cards */
|
||||||
|
.cover { position: relative; border-radius: var(--r-md); aspect-ratio: 16 / 10; overflow: hidden; display: flex; align-items: flex-end; padding: 14px; background: var(--tone-ink); max-width: 100%; }
|
||||||
|
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
|
||||||
|
.cover { flex-direction: column; justify-content: space-between; align-items: flex-start; gap: 8px; }
|
||||||
|
.cover .ttl { position: relative; font-family: var(--f-serif); font-weight: 700; font-size: clamp(18px, 2.4vw, 26px); line-height: 1.35; color: var(--ink); opacity: .82; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; max-width: 92%; order: 2; }
|
||||||
|
.cover .pill { position: relative; order: 1; background: var(--paper); }
|
||||||
|
.cover.has-img .ttl { display: none; }
|
||||||
|
.tone-rose { background: var(--tone-rose); } .tone-clay { background: var(--tone-clay); } .tone-plum { background: var(--tone-plum); }
|
||||||
|
.tone-sand { background: var(--tone-sand); } .tone-sage { background: var(--tone-sage); } .tone-ink { background: var(--tone-ink); }
|
||||||
|
.grid-cards { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
|
||||||
|
.ccard { display: flex; flex-direction: column; gap: 10px; text-align: left; background: none; border: 0; padding: 0; cursor: pointer; min-width: 0; }
|
||||||
|
.ccard h3 { font-size: var(--fs-lg); }
|
||||||
|
.ccard:hover h3 { text-decoration: underline; text-underline-offset: 4px; }
|
||||||
|
.ccard .meta { font-size: var(--fs-sm); color: var(--ink-3); }
|
||||||
|
.continue { display: grid; gap: 20px; grid-template-columns: 1fr; padding: 20px; border-radius: var(--r-lg); background: var(--ink); color: var(--on-ink); }
|
||||||
|
.continue .bar { background: rgba(255, 255, 255, .18); }
|
||||||
|
@media (min-width: 720px) { .continue { grid-template-columns: 260px 1fr; align-items: center; } }
|
||||||
|
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
|
||||||
|
.chip { flex: none; border: 1px solid var(--line); background: var(--paper); padding: 8px 14px; border-radius: var(--r-pill); cursor: pointer; font-weight: 700; color: var(--ink-2); }
|
||||||
|
.chip[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
|
||||||
|
|
||||||
|
/* course page */
|
||||||
|
.c-hero { display: grid; gap: 24px; }
|
||||||
|
@media (min-width: 900px) { .c-hero { grid-template-columns: 1fr 360px; align-items: start; } }
|
||||||
|
.c-hero h1 { font-size: clamp(31px, 5vw, 44px); }
|
||||||
|
.buybox { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 14px; }
|
||||||
|
.price { font-size: var(--fs-2xl); font-weight: 700; }
|
||||||
|
.outcomes { display: grid; gap: 12px; padding: 0; margin: 0; counter-reset: o; }
|
||||||
|
.outcomes li { list-style: none; display: flex; gap: 12px; align-items: flex-start; }
|
||||||
|
.outcomes li::before { counter-increment: o; content: counter(o); flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--on-ink); display: grid; place-items: center; font-size: var(--fs-sm); font-weight: 700; }
|
||||||
|
.journey { display: flex; flex-direction: column; gap: 16px; padding: 0; margin: 0; }
|
||||||
|
.journey > li { list-style: none; display: grid; grid-template-columns: 36px 1fr; gap: 14px; }
|
||||||
|
.journey .node { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--ink); display: grid; place-items: center; font-weight: 700; background: var(--paper); }
|
||||||
|
.journey .node.done { background: var(--success); border-color: var(--success); color: #fff; }
|
||||||
|
.lesson-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-top: 1px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; cursor: pointer; color: inherit; }
|
||||||
|
.lesson-row:hover { background: var(--mist); }
|
||||||
|
.lesson-row[aria-current="true"] { background: var(--accent-soft); }
|
||||||
|
.lesson-row .ic { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--mist); color: var(--ink-2); }
|
||||||
|
.lesson-row .ic.done { background: var(--success-soft); color: var(--success); }
|
||||||
|
|
||||||
|
/* player */
|
||||||
|
.p-wrap { display: grid; gap: 20px; }
|
||||||
|
@media (min-width: 1024px) { .p-wrap { grid-template-columns: 340px 1fr; align-items: start; } .p-side { position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow: auto; } .p-side-order { order: -1; } }
|
||||||
|
.screen { position: relative; background: #0D111C; color: #fff; border-radius: var(--r-lg); overflow: hidden; aspect-ratio: 16 / 9; max-width: 100%; }
|
||||||
|
.screen video { width: 100%; height: 100%; object-fit: contain; background: #000; }
|
||||||
|
.screen .sim { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px; padding: 24px; text-align: center; background: radial-gradient(circle at 30% 20%, #2A3356, #0D111C 70%); }
|
||||||
|
.screen .sim h2 { font-family: var(--f-serif); font-size: clamp(22px, 4vw, 36px); color: #fff; }
|
||||||
|
.screen .sim .muted { color: #B9BFCE; }
|
||||||
|
.wm { position: absolute; font-size: 12px; color: rgba(255, 255, 255, .28); pointer-events: none; user-select: none; animation: wm 40s linear infinite alternate; font-variant-numeric: tabular-nums; }
|
||||||
|
@keyframes wm { 0% { left: 6%; top: 10%; } 33% { left: 60%; top: 30%; } 66% { left: 20%; top: 70%; } 100% { left: 70%; top: 80%; } }
|
||||||
|
.controls { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; background: linear-gradient(transparent, rgba(0, 0, 0, .75)); }
|
||||||
|
.controls .row { gap: 6px; }
|
||||||
|
.controls button, .controls select { background: rgba(255, 255, 255, .12); color: #fff; border: 0; border-radius: var(--r-sm); min-height: 36px; min-width: 36px; padding: 0 10px; cursor: pointer; font-size: var(--fs-sm); font-weight: 700; }
|
||||||
|
.controls select option { color: #000; }
|
||||||
|
.controls input[type="range"] { width: 100%; accent-color: var(--accent); }
|
||||||
|
.ring { width: 56px; height: 56px; }
|
||||||
|
.ring circle { fill: none; stroke-width: 6; }
|
||||||
|
.ring .bg { stroke: var(--mist); }
|
||||||
|
.ring .fg { stroke: var(--success); stroke-linecap: round; transition: stroke-dashoffset 1s ease; transform: rotate(-90deg); transform-origin: center; }
|
||||||
|
.done-flash { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--r-md); background: var(--success-soft); color: var(--success); font-weight: 700; }
|
||||||
|
|
||||||
|
.faq details { border-bottom: 1px solid var(--line); padding: 14px 0; }
|
||||||
|
.faq summary { cursor: pointer; font-weight: 700; }
|
||||||
|
.faq p { margin-top: 8px; color: var(--ink-2); }
|
||||||
|
.notif-item { display: flex; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); }
|
||||||
|
.notif-item.unread { }
|
||||||
|
.notif-item .unread-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; margin-top: 8px; }
|
||||||
|
.notif-item .read-dot { width: 10px; flex: none; }
|
||||||
|
.two-col { display: grid; gap: 24px; }
|
||||||
|
@media (min-width: 900px) { .two-col { grid-template-columns: 1fr 1fr; align-items: start; } }
|
||||||
|
|
||||||
|
/* ---------- admin shell (Logosmental structure) ---------- */
|
||||||
|
.a-shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; background: var(--canvas); }
|
||||||
|
@media (min-width: 1024px) { .a-shell { grid-template-columns: 264px 1fr; } }
|
||||||
|
.a-side { background: var(--paper); border-right: 1px solid var(--line); padding: 16px 12px; display: none; flex-direction: column; gap: 14px; position: sticky; top: 0; height: 100vh; overflow: auto; }
|
||||||
|
.a-side.open { display: flex; position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 35; box-shadow: var(--shadow-pop); }
|
||||||
|
@media (min-width: 1024px) { .a-side { display: flex; } .a-side.open { position: sticky; width: auto; box-shadow: none; } .a-menu { display: none !important; } }
|
||||||
|
.a-group { display: flex; flex-direction: column; gap: 2px; }
|
||||||
|
.a-group-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 0 10px 4px; font-weight: 700; }
|
||||||
|
.a-link { display: flex; align-items: center; gap: 12px; padding: 6px 10px; border-radius: var(--r-md); background: none; border: 0; cursor: pointer; text-align: left; font-weight: 700; color: var(--ink-2); width: 100%; position: relative; }
|
||||||
|
.a-link .tile { width: 32px; height: 32px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--mist); color: var(--ink-2); flex: none; }
|
||||||
|
.a-link:hover { background: var(--mist); }
|
||||||
|
.a-link[aria-current="page"] { background: var(--mist); color: var(--ink); }
|
||||||
|
.a-link[aria-current="page"] .tile { background: var(--ink); color: var(--on-ink); }
|
||||||
|
.a-link[aria-current="page"]::after { content: ''; position: absolute; right: 6px; top: 12px; bottom: 12px; width: 3px; border-radius: 2px; background: var(--ink); }
|
||||||
|
.a-link .count { margin-left: auto; margin-right: 10px; background: var(--alert); color: #fff; font-size: 11px; border-radius: 9px; min-width: 20px; height: 20px; display: grid; place-items: center; padding: 0 5px; }
|
||||||
|
.a-me { margin-top: auto; padding: 12px; border-radius: var(--r-md); background: var(--ink); color: var(--on-ink); display: flex; flex-direction: column; gap: 8px; }
|
||||||
|
.a-me select { background: rgba(255, 255, 255, .12); color: inherit; border: 0; border-radius: var(--r-sm); padding: 6px 8px; font-size: var(--fs-sm); }
|
||||||
|
.a-me select option { color: #000; }
|
||||||
|
.a-top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 15; }
|
||||||
|
.a-main { padding: 24px 16px 96px; display: flex; flex-direction: column; gap: 24px; min-width: 0; max-width: 1280px; width: 100%; margin: 0 auto; }
|
||||||
|
@media (min-width: 720px) { .a-main { padding: 28px 28px 96px; } }
|
||||||
|
.a-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
|
||||||
|
.a-head .eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; }
|
||||||
|
.a-head h1 { font-size: var(--fs-2xl); }
|
||||||
|
.a-head p { color: var(--ink-2); }
|
||||||
|
.stats { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
|
||||||
|
@media (max-width: 600px) { .stats { grid-template-columns: 1fr 1fr; gap: 10px; } .stat { padding: 14px 14px 10px; } .stat .val { font-size: var(--fs-xl); } .stat .note { font-size: 12px; } }
|
||||||
|
.stat { background: var(--paper); border-radius: var(--r-lg); padding: 18px 18px 14px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); border: 1px solid var(--line); }
|
||||||
|
.stat .lbl { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
|
||||||
|
.stat .now { white-space: nowrap; }
|
||||||
|
.stat .val { font-size: var(--fs-2xl); font-weight: 700; font-variant-numeric: tabular-nums; }
|
||||||
|
.stat .note { border-top: 1px solid var(--line); padding-top: 10px; font-size: var(--fs-sm); color: var(--ink-3); }
|
||||||
|
.stat .note.bad { color: var(--alert); } .stat .note.ok { color: var(--success); }
|
||||||
|
.stat .now { font-size: 10px; background: var(--mist); color: var(--ink-2); padding: 2px 6px; border-radius: 6px; letter-spacing: .04em; }
|
||||||
|
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px; }
|
||||||
|
.filters .field { flex: 1 1 160px; }
|
||||||
|
.filters .field.search { flex: 2 1 240px; }
|
||||||
|
.filters .input { min-height: 40px; padding: 8px 10px; background: var(--paper); }
|
||||||
|
.tbl-wrap { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); overflow-x: auto; }
|
||||||
|
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
|
||||||
|
.tbl th { text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); padding: 12px 14px; background: var(--canvas); white-space: nowrap; }
|
||||||
|
.tbl td { padding: 12px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
|
||||||
|
.tbl tr.click { cursor: pointer; }
|
||||||
|
.tbl tr.click:hover td { background: var(--mist); }
|
||||||
|
.tbl .r { text-align: right; }
|
||||||
|
.a-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
|
||||||
|
.a-card h2 { font-size: var(--fs-lg); }
|
||||||
|
.a-grid-2 { display: grid; gap: 16px; }
|
||||||
|
@media (min-width: 1000px) { .a-grid-2 { grid-template-columns: 1.4fr 1fr; align-items: start; } .a-grid-2.even { grid-template-columns: 1fr 1fr; } }
|
||||||
|
.chapter-box { border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--canvas); }
|
||||||
|
.lesson-edit { display: grid; gap: 10px; grid-template-columns: 1fr; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px; }
|
||||||
|
@media (min-width: 900px) { .lesson-edit { grid-template-columns: 1fr auto; align-items: center; } }
|
||||||
|
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: var(--fs-sm); }
|
||||||
|
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
|
||||||
|
.timeline { display: flex; flex-direction: column; gap: 0; padding: 0; margin: 0; }
|
||||||
|
.timeline li { list-style: none; display: grid; grid-template-columns: 14px 1fr; gap: 12px; padding-bottom: 14px; position: relative; }
|
||||||
|
.timeline li::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--ink); margin-top: 6px; }
|
||||||
|
.timeline li::after { content: ''; position: absolute; left: 4px; top: 18px; bottom: 0; width: 2px; background: var(--line); }
|
||||||
|
.timeline li:last-child::after { display: none; }
|
||||||
|
.chart { width: 100%; height: auto; display: block; }
|
||||||
|
.chart text { fill: var(--ink-3); font-size: 11px; font-family: var(--f-latin); }
|
||||||
|
.chart .grid { stroke: var(--line); }
|
||||||
|
.chart .barfill { fill: var(--ink); }
|
||||||
|
.chart .barfill.hl { fill: var(--accent); }
|
||||||
|
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) 3fr auto; gap: 10px; align-items: center; font-size: var(--fs-sm); }
|
||||||
|
.hbar .track { height: 10px; background: var(--mist); border-radius: var(--r-pill); overflow: hidden; }
|
||||||
|
.hbar .track i { display: block; height: 100%; background: var(--ink); border-radius: inherit; }
|
||||||
|
.matrix td, .matrix th { text-align: center; } .matrix td:first-child, .matrix th:first-child { text-align: left; }
|
||||||
|
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
|
||||||
|
.brand > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
|
||||||
|
.s-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; flex-wrap: nowrap; }
|
||||||
|
@media (max-width: 600px) { .lang-select { max-width: 96px; } .s-top-in { gap: 8px; } .hide-sm { display: none !important; } }
|
||||||
|
@media (max-width: 380px) { .brand > span:last-child { display: none; } }
|
||||||
|
/* compact course rows on phones (§11.2: catalog cards are compact; the Continue card stays wide) */
|
||||||
|
@media (max-width: 599px) {
|
||||||
|
.grid-cards { grid-template-columns: 1fr; gap: 14px; }
|
||||||
|
.ccard { display: grid; grid-template-columns: 104px 1fr; gap: 2px 14px; align-items: start; }
|
||||||
|
.ccard .cover { grid-row: 1 / span 4; aspect-ratio: 1; padding: 8px; }
|
||||||
|
.ccard .cover .ttl { font-size: 13px; -webkit-line-clamp: 4; }
|
||||||
|
.ccard .cover .pill { display: none; }
|
||||||
|
.ccard h3 { font-size: var(--fs-base); }
|
||||||
|
}
|
||||||
|
/* curriculum editor: one compact row per lesson */
|
||||||
|
.lesson-line { display: grid; gap: 8px 10px; grid-template-columns: 28px minmax(0, 1fr) 76px; align-items: center; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; }
|
||||||
|
.lesson-line .tools { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
|
||||||
|
.lesson-line .notes { grid-column: 2 / -1; }
|
||||||
|
@media (min-width: 1100px) { .lesson-line { grid-template-columns: 28px minmax(0, 1fr) 76px auto; } .lesson-line .tools { grid-column: auto; justify-content: flex-end; } }
|
||||||
|
.lesson-line .input { min-height: 38px; padding: 6px 10px; }
|
||||||
|
.lesson-line .check { font-size: var(--fs-sm); align-items: center; }
|
||||||
|
/* audit fixes: no sideways scroll at 360–400px */
|
||||||
|
@media (max-width: 600px) { .stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .stat { min-width: 0; } .stat .lbl { flex-wrap: wrap; letter-spacing: .03em; } .stat .lbl span { overflow-wrap: anywhere; } }
|
||||||
|
@media (max-width: 440px) { .brand > span:last-child { display: none; } .lang-select { max-width: 92px; } }
|
||||||
|
.cover .ttl { margin-top: auto; }
|
||||||
|
.hero-card .cover { aspect-ratio: 16 / 10; }
|
||||||
|
.hero-card .cover .ttl { font-size: clamp(24px, 3.2vw, 36px); }
|
||||||
|
.ccard .cover { aspect-ratio: 16 / 9; }
|
||||||
|
@media (max-width: 599px) { .ccard .cover .ttl { display: none; } }
|
||||||
|
/* touch targets: 40px minimum everywhere, 44px on touch screens */
|
||||||
|
.btn-sm { min-height: 40px; }
|
||||||
|
@media (pointer: coarse) { .btn-sm, .controls button, .controls select { min-height: 44px; min-width: 44px; } .lesson-row { min-height: 56px; } }
|
||||||
|
.pay-logo { gap: 10px; }
|
||||||
140
packages/features/src/ui.tsx
Normal file
|
|
@ -0,0 +1,140 @@
|
||||||
|
'use client';
|
||||||
|
import { useEffect, useRef, useState, type ReactNode } from 'react';
|
||||||
|
import type { Course, Locale } from '@lms/data';
|
||||||
|
import { useApp } from './store';
|
||||||
|
import { tr } from './domain';
|
||||||
|
|
||||||
|
const PATHS: Record<string, string> = {
|
||||||
|
home: 'M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z',
|
||||||
|
grid: 'M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z',
|
||||||
|
book: 'M4 5a2 2 0 0 1 2-2h13v16H6a2 2 0 0 0-2 2zM4 21V5M8 7h7',
|
||||||
|
help: 'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM9.5 9a2.5 2.5 0 1 1 3.5 2.3c-.6.3-1 .9-1 1.6V14M12 17.5v.01',
|
||||||
|
user: 'M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM4 21a8 8 0 0 1 16 0',
|
||||||
|
bell: 'M6 8a6 6 0 1 1 12 0c0 7 3 8 3 8H3s3-1 3-8M10 20a2 2 0 0 0 4 0',
|
||||||
|
search: 'M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14zM20 20l-4-4',
|
||||||
|
play: 'M7 4v16l13-8z',
|
||||||
|
pause: 'M7 4h4v16H7zM13 4h4v16h-4z',
|
||||||
|
lock: 'M6 11h12v10H6zM8 11V7a4 4 0 0 1 8 0v4',
|
||||||
|
check: 'M5 12l5 5 9-10',
|
||||||
|
chevron: 'M9 6l6 6-6 6',
|
||||||
|
back: 'M15 6l-6 6 6 6',
|
||||||
|
x: 'M6 6l12 12M18 6L6 18',
|
||||||
|
chart: 'M4 20V10M10 20V4M16 20v-7M22 20H2',
|
||||||
|
users: 'M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM2 21a7 7 0 0 1 14 0M16 3.5a4 4 0 0 1 0 7.5M22 21a7 7 0 0 0-4-6.3',
|
||||||
|
cart: 'M3 4h2l2.4 11h11L21 8H6M9 20a1 1 0 1 0 0-.01M18 20a1 1 0 1 0 0-.01',
|
||||||
|
send: 'M22 2L11 13M22 2l-7 20-4-9-9-4z',
|
||||||
|
flag: 'M5 21V4M5 4h11l-2 4 2 4H5',
|
||||||
|
cog: 'M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1.1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1.1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z',
|
||||||
|
shield: 'M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6z',
|
||||||
|
list: 'M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01',
|
||||||
|
tag: 'M3 12V3h9l9 9-9 9zM7.5 7.5h.01',
|
||||||
|
menu: 'M4 6h16M4 12h16M4 18h16',
|
||||||
|
upload: 'M12 16V4M7 9l5-5 5 5M4 20h16',
|
||||||
|
plus: 'M12 5v14M5 12h14',
|
||||||
|
up: 'M6 15l6-6 6 6',
|
||||||
|
down: 'M6 9l6 6 6-6',
|
||||||
|
download: 'M12 4v12M7 11l5 5 5-5M4 20h16',
|
||||||
|
phone: 'M5 4h4l2 5-2.5 1.5a11 11 0 0 0 5 5L15 13l5 2v4a2 2 0 0 1-2 2A16 16 0 0 1 3 6a2 2 0 0 1 2-2',
|
||||||
|
chat: 'M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12z',
|
||||||
|
rewind: 'M11 19l-9-7 9-7zM22 19l-9-7 9-7z',
|
||||||
|
forward: 'M13 19l9-7-9-7zM2 19l9-7-9-7z',
|
||||||
|
expand: 'M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5',
|
||||||
|
comment: 'M4 4h16v12H8l-4 4z',
|
||||||
|
};
|
||||||
|
|
||||||
|
export function Icon({ name, size = 20, label }: { name: keyof typeof PATHS | string; size?: number; label?: string }) {
|
||||||
|
return (
|
||||||
|
<svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden={label ? undefined : true} role={label ? 'img' : undefined} aria-label={label}>
|
||||||
|
<path d={PATHS[name] ?? ''} />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const TONES = ['rose', 'clay', 'plum', 'sand', 'sage', 'ink'];
|
||||||
|
|
||||||
|
export function Cover({ course, locale, badge }: { course: Course; locale: Locale; badge?: ReactNode }) {
|
||||||
|
const { ds } = useApp();
|
||||||
|
// No image → the title itself, set in Ge'ez serif, is the cover (§11.2: the script is the visual identity).
|
||||||
|
// Shows the title in the other script from the page's language, so the cover adds a second language instead of repeating the card title.
|
||||||
|
const other = locale === 'am' || locale === 'ti' ? 'en' : 'am';
|
||||||
|
const title = course.translations[other]?.title ?? tr(course.translations, locale)?.title ?? '';
|
||||||
|
const tone = course.coverTone && TONES.includes(course.coverTone) ? course.coverTone : 'ink';
|
||||||
|
return (
|
||||||
|
<div className={`cover tone-${tone} ${course.coverAssetId ? 'has-img' : ''}`}>
|
||||||
|
{course.coverAssetId && <img src={ds.assetUrl(course.coverAssetId)} alt="" />}
|
||||||
|
{badge}
|
||||||
|
<span className="ttl" lang={other} aria-hidden>{title}</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Empty({ children, action }: { children: ReactNode; action?: ReactNode }) {
|
||||||
|
return <div className="empty"><p>{children}</p>{action}</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Skeleton({ h = 120, n = 1 }: { h?: number; n?: number }) {
|
||||||
|
return <div className="stack" aria-busy="true" aria-live="polite">{Array.from({ length: n }, (_, i) => <div key={i} className="skel" style={{ height: h }} />)}</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Modal({ title, onClose, children }: { title: string; onClose(): void; children: ReactNode }) {
|
||||||
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
|
useEffect(() => {
|
||||||
|
const k = (e: KeyboardEvent) => e.key === 'Escape' && onClose();
|
||||||
|
addEventListener('keydown', k);
|
||||||
|
ref.current?.querySelector<HTMLElement>('input,select,textarea,button')?.focus();
|
||||||
|
return () => removeEventListener('keydown', k);
|
||||||
|
}, [onClose]);
|
||||||
|
return (
|
||||||
|
<div className="modal-back" onClick={(e) => e.target === e.currentTarget && onClose()}>
|
||||||
|
<div className="modal" role="dialog" aria-modal="true" aria-label={title} ref={ref}>
|
||||||
|
<div className="row-between"><h2 style={{ fontSize: 'var(--fs-lg)' }}>{title}</h2><button className="icon-btn" onClick={onClose} aria-label="Close"><Icon name="x" /></button></div>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Ring({ pct, size = 56 }: { pct: number; size?: number }) {
|
||||||
|
const r = 24, c = 2 * Math.PI * r;
|
||||||
|
return (
|
||||||
|
<svg className="ring" width={size} height={size} viewBox="0 0 56 56" role="img" aria-label={`${pct}%`}>
|
||||||
|
<circle className="bg" cx="28" cy="28" r={r} />
|
||||||
|
<circle className="fg" cx="28" cy="28" r={r} strokeDasharray={c} strokeDashoffset={c * (1 - pct / 100)} />
|
||||||
|
<text x="28" y="32" textAnchor="middle" fontSize="13" fontWeight="700" fill="currentColor">{pct}%</text>
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const PILL_KIND: Record<string, string> = {
|
||||||
|
PAID: 'ok', ACTIVE: 'ok', PUBLISHED: 'ok', RESOLVED: 'ok', READY: 'ok', SENT: 'ok',
|
||||||
|
PENDING: 'warn', OPEN: 'warn', IN_PROGRESS: 'info', DRAFT: 'info', PROCESSING: 'info', UPLOADING: 'info', SCHEDULED: 'info',
|
||||||
|
FAILED: 'bad', EXPIRED: 'bad', DEACTIVATED: 'bad', CANCELLED: '', REFUNDED: 'info', ARCHIVED: '', CLOSED: '', NONE: '',
|
||||||
|
};
|
||||||
|
export function StatusPill({ status, label }: { status: string; label?: string }) {
|
||||||
|
const k = PILL_KIND[status];
|
||||||
|
return <span className={`pill ${k ? 'pill-' + k : ''}`}>{label ?? status.replace(/_/g, ' ').toLowerCase().replace(/^./, (c) => c.toUpperCase())}</span>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** "Leave feedback" — opens a Claude comment pinned to the current screen (§18.6). Hidden when comments are unavailable. */
|
||||||
|
export function FeedbackButton({ label, target }: { label: string; target: () => Element | null }) {
|
||||||
|
const { ds } = useApp();
|
||||||
|
const [ok, setOk] = useState(false);
|
||||||
|
useEffect(() => { ds.feedbackAvailable().then(setOk); }, [ds]);
|
||||||
|
if (!ok) return null;
|
||||||
|
return <button className="btn btn-accent btn-sm feedback-btn" aria-label={label} title={label} onClick={() => { const el = target(); if (el) ds.feedback(el); }}><Icon name="comment" size={16} /><span className="lbl">{label}</span></button>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function CopyText({ text, copyLabel, copiedLabel }: { text: string; copyLabel: string; copiedLabel: string }) {
|
||||||
|
const [done, setDone] = useState(false);
|
||||||
|
return (
|
||||||
|
<button className="btn btn-ghost btn-sm" onClick={() => {
|
||||||
|
navigator.clipboard?.writeText(text).then(() => setDone(true), () => setDone(false));
|
||||||
|
}}>{done ? copiedLabel : copyLabel}</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gregorian, en-GB digits in every locale for the demo; Ethiopian calendar is P2 (§12).
|
||||||
|
export const fmtDate = (iso?: string | null) =>
|
||||||
|
iso ? new Date(iso).toLocaleDateString('en-GB', { day: 'numeric', month: 'short', year: 'numeric' }) : '—';
|
||||||
|
export const fmtDateTime = (iso?: string | null) =>
|
||||||
|
iso ? new Date(iso).toLocaleString('en-GB', { day: 'numeric', month: 'short', year: 'numeric', hour: '2-digit', minute: '2-digit' }) : '—';
|
||||||
1
packages/features/tsconfig.json
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{ "extends": "../../tsconfig.base.json", "include": ["src", "messages"] }
|
||||||
261
packages/i18n/messages/am.json
Normal file
|
|
@ -0,0 +1,261 @@
|
||||||
|
{
|
||||||
|
"common": {
|
||||||
|
"loading": "በመጫን ላይ…",
|
||||||
|
"retry": "እንደገና ይሞክሩ",
|
||||||
|
"cancel": "ይቅር",
|
||||||
|
"save": "አስቀምጥ",
|
||||||
|
"saved": "ተቀምጧል",
|
||||||
|
"close": "ዝጋ",
|
||||||
|
"back": "ተመለስ",
|
||||||
|
"feedback": "አስተያየት ይስጡ",
|
||||||
|
"demoBanner": "ማሳያ — ክፍያ፣ ኤስኤምኤስ እና ኢሜይል የማስመሰያ ናቸው።",
|
||||||
|
"language": "ቋንቋ",
|
||||||
|
"saveFailed": "ማስቀመጥ አልተቻለም። ግንኙነትዎን አረጋግጠው እንደገና ይሞክሩ።",
|
||||||
|
"readOnly": "መመልከት ይችላሉ፣ ነገር ግን ይህ መለያ በማሳያው ላይ ለውጥ ማስቀመጥ አይችልም።"
|
||||||
|
},
|
||||||
|
"nav": {
|
||||||
|
"home": "መነሻ",
|
||||||
|
"courses": "ኮርሶች",
|
||||||
|
"myCourses": "የእኔ ኮርሶች",
|
||||||
|
"help": "እገዛ",
|
||||||
|
"profile": "መገለጫ",
|
||||||
|
"notifications": "ማሳወቂያዎች",
|
||||||
|
"signIn": "ግባ",
|
||||||
|
"signOut": "ውጣ",
|
||||||
|
"admin": "የአስተዳዳሪ ገጽ"
|
||||||
|
},
|
||||||
|
"landing": {
|
||||||
|
"title": "ሙያዊ ሜካፕን በራስዎ ቋንቋ ይማሩ",
|
||||||
|
"lead": "በሥራ ላይ ካሉ ባለሙያዎች የቪዲዮ ኮርሶች። አንድ ጊዜ ይክፈሉ፣ ኮርሱ ለዘላለም የእርስዎ ነው፣ በስልክዎ ይመልከቱ።",
|
||||||
|
"browse": "ኮርሶችን ይመልከቱ",
|
||||||
|
"start": "መለያ ይፍጠሩ",
|
||||||
|
"featured": "ተመራጭ ኮርሶች",
|
||||||
|
"howTitle": "እንዴት ይሠራል",
|
||||||
|
"how1": "ነጻ የሙከራ ትምህርቶችን ይመልከቱ",
|
||||||
|
"how2": "በቴሌብር ወይም በሲቢኢ ብር ይክፈሉ",
|
||||||
|
"how3": "ኮርሱ ወዲያውኑ ይከፈታል፣ ለዘላለም",
|
||||||
|
"payTitle": "በለመዱት መንገድ ይክፈሉ",
|
||||||
|
"fact1": "አማርኛ፣ አፋን ኦሮሞ፣ ትግርኛና እንግሊዝኛ",
|
||||||
|
"fact2": "አንድ ጊዜ ይክፈሉ፣ ለዘላለም ይጠቀሙ",
|
||||||
|
"fact3": "ነጻ የሙከራ ትምህርቶች",
|
||||||
|
"from": "ከ{price} ጀምሮ",
|
||||||
|
"footer": "ለሜካፕ ባለሙያዎች የቪዲዮ ኮርሶች፣ በስልክዎ።"
|
||||||
|
},
|
||||||
|
"auth": {
|
||||||
|
"phoneTitle": "በስልክዎ ይግቡ",
|
||||||
|
"phoneLabel": "ስልክ ቁጥር",
|
||||||
|
"sendCode": "ኮድ ላክ",
|
||||||
|
"useEmail": "በኢሜይል ይግቡ",
|
||||||
|
"usePhone": "በስልክ ይግቡ",
|
||||||
|
"emailTitle": "በኢሜይል ይግቡ",
|
||||||
|
"emailLabel": "ኢሜይል",
|
||||||
|
"passwordLabel": "የይለፍ ቃል",
|
||||||
|
"passwordHint": "ቢያንስ 8 ፊደላት።",
|
||||||
|
"passwordShort": "ቢያንስ 8 ፊደላት ይጠቀሙ።",
|
||||||
|
"phoneInvalid": "ከ+251 በኋላ 9 አሃዝ ያለው ስልክ ቁጥር ያስገቡ።",
|
||||||
|
"emailInvalid": "እንደ name@example.com ያለ ኢሜይል ያስገቡ።",
|
||||||
|
"codeTitle": "ኮዱን ያስገቡ",
|
||||||
|
"codeSent": "ባለ 6 አሃዝ ኮድ ወደ {target} ልከናል።",
|
||||||
|
"demoCode": "የማሳያ ኮድ፦ {code}",
|
||||||
|
"verify": "አረጋግጥ",
|
||||||
|
"resend": "አዲስ ኮድ ላክ",
|
||||||
|
"resendIn": "በ{s} ሰከንድ ውስጥ አዲስ ኮድ መላክ ይችላሉ",
|
||||||
|
"wrongCode": "ኮዱ ትክክል አይደለም። {n} ሙከራ ቀርቷል።",
|
||||||
|
"locked": "ብዙ የተሳሳቱ ሙከራዎች። አዲስ ኮድ ይላኩ።",
|
||||||
|
"noIdentity": "የተማሪ መለያ ለመፍጠር ወደ Claude ገብተው ይህን ማሳያ ይክፈቱ።"
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"title": "ስለ እርስዎ ይንገሩን",
|
||||||
|
"name": "ሙሉ ስም",
|
||||||
|
"country": "አገር",
|
||||||
|
"city": "ከተማ",
|
||||||
|
"cityPick": "ከተማዎን ይምረጡ",
|
||||||
|
"cityType": "ከተማዎን ይጻፉ",
|
||||||
|
"language": "የመማሪያ ቋንቋ",
|
||||||
|
"save": "መማር ጀምር",
|
||||||
|
"nameRequired": "ስምዎን ያስገቡ።",
|
||||||
|
"CITY_REQUIRED": "ከተማዎን ያስገቡ።",
|
||||||
|
"CITY_NOT_IN_LIST": "ከዝርዝሩ ከተማ ይምረጡ።",
|
||||||
|
"COUNTRY_REQUIRED": "አገርዎን ይምረጡ።"
|
||||||
|
},
|
||||||
|
"home": {
|
||||||
|
"hello": "ሰላም፣ {name}",
|
||||||
|
"continue": "መመልከት ይቀጥሉ",
|
||||||
|
"featured": "ተመራጭ",
|
||||||
|
"categories": "ምድቦች",
|
||||||
|
"new": "አዳዲስ ኮርሶች",
|
||||||
|
"emptyMine": "እስካሁን ኮርስ አልገዙም። በነጻ የሙከራ ትምህርት ይጀምሩ።"
|
||||||
|
},
|
||||||
|
"catalog": {
|
||||||
|
"title": "ሁሉም ኮርሶች",
|
||||||
|
"search": "ኮርስ፣ አሠልጣኝ ወይም ርዕስ ይፈልጉ",
|
||||||
|
"all": "ሁሉም",
|
||||||
|
"count": "{n} ኮርሶች",
|
||||||
|
"empty": "ከ«{q}» ጋር የሚዛመድ ኮርስ የለም። አጠር ያለ ቃል ይሞክሩ።",
|
||||||
|
"emptyCategory": "በዚህ ምድብ እስካሁን ኮርስ የለም።"
|
||||||
|
},
|
||||||
|
"course": {
|
||||||
|
"by": "ከ{name} ጋር",
|
||||||
|
"lessons": "{n} ትምህርቶች",
|
||||||
|
"taughtIn": "የማስተማሪያ ቋንቋ፦ {lang}",
|
||||||
|
"updated": "የተሻሻለው {date}",
|
||||||
|
"buy": "በ{price} ይግዙ",
|
||||||
|
"continue": "ትምህርት {n}ን ይቀጥሉ",
|
||||||
|
"owned": "ይህ ኮርስ የእርስዎ ነው",
|
||||||
|
"preview": "ነጻ ሙከራ",
|
||||||
|
"comingSoon": "በቅርቡ",
|
||||||
|
"prereq": "መጀመሪያ «{title}»ን ይጨርሱ። ይህ ኮርስ በእሱ ላይ ይገነባል።",
|
||||||
|
"prereqLink": "ወደ {title} ይሂዱ",
|
||||||
|
"outcomes": "ምን መሥራት ይችላሉ",
|
||||||
|
"audience": "ለማን ነው",
|
||||||
|
"content": "የኮርሱ ይዘት",
|
||||||
|
"ready": "ሲዘጋጁ ይጀምሩ",
|
||||||
|
"readyBody": "ትምህርት 1 ወደ {min} ደቂቃ ይወስዳል።",
|
||||||
|
"watchPreview": "ነጻ ሙከራ ይመልከቱ",
|
||||||
|
"notFound": "ይህ ኮርስ አይገኝም።",
|
||||||
|
"sequential": "ትምህርቶች በቅደም ተከተል ይከፈታሉ።",
|
||||||
|
"completed": "ኮርሱን ጨርሰዋል",
|
||||||
|
"watchAgain": "እንደገና ይመልከቱ"
|
||||||
|
},
|
||||||
|
"checkout": {
|
||||||
|
"title": "የመክፈያ መንገድ ይምረጡ",
|
||||||
|
"total": "ጠቅላላ",
|
||||||
|
"lifetime": "አንድ ጊዜ ክፍያ። ለዘላለም መዳረሻ።",
|
||||||
|
"pay": "ወደ {method} ይቀጥሉ",
|
||||||
|
"simulated": "የማሳያ ክፍያ። ገንዘብ አይንቀሳቀስም።",
|
||||||
|
"providerTitle": "{method} (ማሳያ)",
|
||||||
|
"providerBody": "በእውነተኛው መተግበሪያ ይህ የArifPay ደኅንነቱ የተጠበቀ ገጽ ነው። ውጤቱን ለማስመሰል ይምረጡ።",
|
||||||
|
"approve": "{price} ይክፈሉ",
|
||||||
|
"decline": "ክፍያውን አትቀበል",
|
||||||
|
"leave": "ሳይከፍሉ ይውጡ",
|
||||||
|
"orderTitle": "ትዕዛዝ {id}",
|
||||||
|
"pending": "{method} ክፍያዎን እስኪያረጋግጥ በመጠበቅ ላይ…",
|
||||||
|
"stillWaiting": "ከባንክዎ ማረጋገጫ እየጠበቅን ነው። ሲጠናቀቅ በኤስኤምኤስ እናሳውቅዎታለን።",
|
||||||
|
"paid": "አሁን ይህ ኮርስ የእርስዎ ነው",
|
||||||
|
"start": "ትምህርት 1ን ይጀምሩ",
|
||||||
|
"failed": "ክፍያው አልተሳካም",
|
||||||
|
"failedReason": "ምክንያት፦ {reason}",
|
||||||
|
"tryAgain": "እንደገና ይሞክሩ",
|
||||||
|
"expired": "ይህ ትዕዛዝ ከ30 ደቂቃ በኋላ ጊዜው አልፏል። አዲስ ይጀምሩ።",
|
||||||
|
"cancelled": "ይህን ትዕዛዝ ሰርዘዋል።",
|
||||||
|
"alreadyOwned": "ይህ ኮርስ አስቀድሞ የእርስዎ ነው።"
|
||||||
|
},
|
||||||
|
"player": {
|
||||||
|
"back": "ወደ ኮርሱ ይመለሱ",
|
||||||
|
"notes": "የትምህርቱ ማስታወሻ",
|
||||||
|
"next": "ቀጣይ ትምህርት",
|
||||||
|
"completed": "ትምህርቱ ተጠናቋል",
|
||||||
|
"dataSaver": "ዳታ ቆጣቢ",
|
||||||
|
"quality": "ጥራት",
|
||||||
|
"speed": "ፍጥነት",
|
||||||
|
"COURSE_NOT_OWNED": "ይህን ትምህርት ለማየት ኮርሱን ይግዙ።",
|
||||||
|
"LESSON_LOCKED": "ይህን ለመክፈት የቀደመውን ትምህርት ይጨርሱ።",
|
||||||
|
"PREREQUISITE_REQUIRED": "መጀመሪያ የሚያስፈልገውን ኮርስ ይጨርሱ።",
|
||||||
|
"COMING_SOON": "የዚህ ትምህርት ቪዲዮ እየተዘጋጀ ነው።",
|
||||||
|
"ACCOUNT_DEACTIVATED": "መለያዎ ታግዷል። እገዛ ያግኙ።",
|
||||||
|
"demoVideo": "የናሙና ማጫወቻ — ለዚህ ትምህርት እስካሁን ቪዲዮ አልተጫነም",
|
||||||
|
"play": "አጫውት",
|
||||||
|
"pause": "ለአፍታ አቁም",
|
||||||
|
"back10": "10 ሰከንድ ወደ ኋላ",
|
||||||
|
"fwd10": "10 ሰከንድ ወደ ፊት",
|
||||||
|
"fullscreen": "ሙሉ ማያ",
|
||||||
|
"contents": "ይዘት",
|
||||||
|
"progress": "ከ{total} ትምህርቶች {done} ተጠናቀዋል"
|
||||||
|
},
|
||||||
|
"my": {
|
||||||
|
"title": "የእኔ ኮርሶች",
|
||||||
|
"empty": "የሚገዟቸው ኮርሶች እዚህ ይታያሉ።",
|
||||||
|
"resume": "ቀጥል",
|
||||||
|
"progressTitle": "የእኔ እድገት",
|
||||||
|
"viewProgress": "እድገት ይመልከቱ",
|
||||||
|
"lessonsDone": "ከ{total} ትምህርቶች {done}"
|
||||||
|
},
|
||||||
|
"notif": {
|
||||||
|
"title": "ማሳወቂያዎች",
|
||||||
|
"markAll": "ሁሉንም እንደተነበበ ምልክት አድርግ",
|
||||||
|
"empty": "ሁሉንም አይተዋል። ስለ አዳዲስ ትምህርቶችና ክፍያዎች እዚህ እናሳውቅዎታለን።",
|
||||||
|
"open": "ክፈት"
|
||||||
|
},
|
||||||
|
"help": {
|
||||||
|
"title": "እገዛ",
|
||||||
|
"faq": "በብዛት የሚጠየቁ ጥያቄዎች",
|
||||||
|
"q1": "እንዴት እከፍላለሁ?",
|
||||||
|
"a1": "ኮርስ ይምረጡ፣ ግዛ የሚለውን ይጫኑ፣ ከዚያ በቴሌብር ወይም በሲቢኢ ብር ይክፈሉ። ክፍያው እንደተረጋገጠ ኮርሱ ይከፈታል።",
|
||||||
|
"q2": "ኮርሱ ለዘላለም የእኔ ነው?",
|
||||||
|
"a2": "አዎ። አንድ ጊዜ ከፍለው ለዘላለም ይጠቀሙበታል።",
|
||||||
|
"q3": "ቪዲዮው በዳታዬ አይጫወትም።",
|
||||||
|
"a3": "በማጫወቻው ላይ ዳታ ቆጣቢን ያብሩ። አነስተኛ ዳታ የሚጠቀም ጥራት ይመርጣል።",
|
||||||
|
"contact": "ያግኙን",
|
||||||
|
"telegram": "በቴሌግራም ይጻፉልን",
|
||||||
|
"call": "ለእገዛ ይደውሉ",
|
||||||
|
"copy": "ቅዳ",
|
||||||
|
"copied": "ተቀድቷል",
|
||||||
|
"report": "ችግር ሪፖርት ያድርጉ",
|
||||||
|
"type": "ስለ ምንድን ነው?",
|
||||||
|
"subject": "ርዕስ",
|
||||||
|
"description": "ምን ተፈጠረ?",
|
||||||
|
"screenshot": "ቅጽበታዊ ገጽ እይታ (አማራጭ፣ እስከ 5 ሜባ)",
|
||||||
|
"screenshotTooBig": "ምስሉ ከ5 ሜባ በላይ ነው። ትንሽ ምስል ይምረጡ።",
|
||||||
|
"submit": "ሪፖርት ላክ",
|
||||||
|
"sent": "ሪፖርቱ ተልኳል። ሁኔታው ሲቀየር እናሳውቅዎታለን።",
|
||||||
|
"mine": "የእኔ ሪፖርቶች",
|
||||||
|
"noReports": "እስካሁን ሪፖርት የለም።",
|
||||||
|
"required": "ርዕሱንና የተፈጠረውን ይሙሉ።"
|
||||||
|
},
|
||||||
|
"profile": {
|
||||||
|
"title": "መገለጫ",
|
||||||
|
"details": "የእርስዎ መረጃ",
|
||||||
|
"phone": "ስልክ",
|
||||||
|
"email": "ኢሜይል",
|
||||||
|
"prefs": "የማሳወቂያ ቅንብሮች",
|
||||||
|
"prefsNote": "የክፍያ ደረሰኞች ሁልጊዜ ይላካሉ።",
|
||||||
|
"sessions": "ንቁ ክፍለ ጊዜዎች",
|
||||||
|
"thisDevice": "ይህ አሳሽ",
|
||||||
|
"signOutSession": "ውጣ",
|
||||||
|
"purchases": "የግዢ ታሪክ",
|
||||||
|
"noPurchases": "እስካሁን ግዢ የለም።",
|
||||||
|
"delete": "መለያ ሰርዝ",
|
||||||
|
"deleteBody": "መለያዎ አሁን ይዘጋል፣ የግል መረጃዎ ከ30 ቀን በኋላ ይሰረዛል። የገዟቸው ኮርሶች መመለስ አይችሉም።",
|
||||||
|
"deleteConfirm": "አዎ፣ መለያዬን ሰርዝ",
|
||||||
|
"deleted": "ይህ መለያ ተሰርዟል።"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"PENDING": "በመጠባበቅ ላይ",
|
||||||
|
"PAID": "ተከፍሏል",
|
||||||
|
"FAILED": "አልተሳካም",
|
||||||
|
"EXPIRED": "ጊዜው አልፏል",
|
||||||
|
"CANCELLED": "ተሰርዟል",
|
||||||
|
"REFUNDED": "ተመላሽ ተደርጓል",
|
||||||
|
"OPEN": "ክፍት",
|
||||||
|
"IN_PROGRESS": "በሂደት ላይ",
|
||||||
|
"RESOLVED": "ተፈትቷል",
|
||||||
|
"CLOSED": "ተዘግቷል"
|
||||||
|
},
|
||||||
|
"issueType": {
|
||||||
|
"BUG": "የሆነ ነገር አይሠራም",
|
||||||
|
"PAYMENT": "ክፍያ",
|
||||||
|
"VIDEO": "ቪዲዮ አይጫወትም",
|
||||||
|
"ACCOUNT": "መለያዬ",
|
||||||
|
"CONTENT": "የኮርስ ይዘት",
|
||||||
|
"OTHER": "ሌላ"
|
||||||
|
},
|
||||||
|
"notifType": {
|
||||||
|
"PAYMENT": "የክፍያ ደረሰኞች",
|
||||||
|
"NEW_LESSON": "በኮርሶቼ ውስጥ አዳዲስ ትምህርቶች",
|
||||||
|
"ISSUE": "ስለ ሪፖርቶቼ መረጃ",
|
||||||
|
"ANNOUNCEMENT": "ዜናና ቅናሾች"
|
||||||
|
},
|
||||||
|
"channel": {
|
||||||
|
"IN_APP": "በመተግበሪያ",
|
||||||
|
"EMAIL": "ኢሜይል",
|
||||||
|
"SMS": "ኤስኤምኤስ"
|
||||||
|
},
|
||||||
|
"system": {
|
||||||
|
"paidTitle": "ኮርሱ ተገዝቷል",
|
||||||
|
"paidBody": "«{title}» አሁን የእርስዎ ነው። ደረሰኝ፦ {price}።",
|
||||||
|
"issueTitle": "ሪፖርትዎ ተሻሽሏል",
|
||||||
|
"issueBody": "«{subject}» አሁን {status} ነው።",
|
||||||
|
"grantTitle": "ኮርስ ወደ መለያዎ ተጨምሯል",
|
||||||
|
"grantBody": "አሁን «{title}»ን ማግኘት ይችላሉ።"
|
||||||
|
}
|
||||||
|
}
|
||||||
261
packages/i18n/messages/en.json
Normal file
|
|
@ -0,0 +1,261 @@
|
||||||
|
{
|
||||||
|
"common": {
|
||||||
|
"loading": "Loading…",
|
||||||
|
"retry": "Try again",
|
||||||
|
"cancel": "Cancel",
|
||||||
|
"save": "Save",
|
||||||
|
"saved": "Saved",
|
||||||
|
"close": "Close",
|
||||||
|
"back": "Back",
|
||||||
|
"feedback": "Leave feedback",
|
||||||
|
"demoBanner": "Demo — payments, SMS and email are simulated.",
|
||||||
|
"language": "Language",
|
||||||
|
"saveFailed": "Couldn't save. Check your connection and try again.",
|
||||||
|
"readOnly": "You can look around, but this account can't save changes in the demo."
|
||||||
|
},
|
||||||
|
"nav": {
|
||||||
|
"home": "Home",
|
||||||
|
"courses": "Courses",
|
||||||
|
"myCourses": "My courses",
|
||||||
|
"help": "Help",
|
||||||
|
"profile": "Profile",
|
||||||
|
"notifications": "Notifications",
|
||||||
|
"signIn": "Sign in",
|
||||||
|
"signOut": "Sign out",
|
||||||
|
"admin": "Admin panel"
|
||||||
|
},
|
||||||
|
"landing": {
|
||||||
|
"title": "Learn professional makeup, in your language",
|
||||||
|
"lead": "Video courses from working artists. Pay once, keep the course for life, and watch on your phone.",
|
||||||
|
"browse": "Browse courses",
|
||||||
|
"start": "Create your account",
|
||||||
|
"featured": "Featured courses",
|
||||||
|
"howTitle": "How it works",
|
||||||
|
"how1": "Watch the free preview lessons",
|
||||||
|
"how2": "Pay with Telebirr or CBE Birr",
|
||||||
|
"how3": "The course unlocks right away, for life",
|
||||||
|
"payTitle": "Pay the way you already do",
|
||||||
|
"fact1": "Amharic, Afaan Oromoo, Tigrinya and English",
|
||||||
|
"fact2": "Pay once, keep it for life",
|
||||||
|
"fact3": "Free preview lessons",
|
||||||
|
"from": "From {price}",
|
||||||
|
"footer": "Video courses for makeup artists, on your phone."
|
||||||
|
},
|
||||||
|
"auth": {
|
||||||
|
"phoneTitle": "Sign in with your phone",
|
||||||
|
"phoneLabel": "Phone number",
|
||||||
|
"sendCode": "Send code",
|
||||||
|
"useEmail": "Use email instead",
|
||||||
|
"usePhone": "Use phone instead",
|
||||||
|
"emailTitle": "Sign in with email",
|
||||||
|
"emailLabel": "Email",
|
||||||
|
"passwordLabel": "Password",
|
||||||
|
"passwordHint": "At least 8 characters.",
|
||||||
|
"passwordShort": "Use at least 8 characters.",
|
||||||
|
"phoneInvalid": "Enter a phone number with 9 digits after +251.",
|
||||||
|
"emailInvalid": "Enter an email address like name@example.com.",
|
||||||
|
"codeTitle": "Enter the code",
|
||||||
|
"codeSent": "We sent a 6-digit code to {target}.",
|
||||||
|
"demoCode": "Demo code: {code}",
|
||||||
|
"verify": "Verify",
|
||||||
|
"resend": "Send a new code",
|
||||||
|
"resendIn": "Send a new code in {s} s",
|
||||||
|
"wrongCode": "That code is wrong. {n, plural, one {# try} other {# tries}} left.",
|
||||||
|
"locked": "Too many wrong tries. Send a new code.",
|
||||||
|
"noIdentity": "Open this demo while signed in to Claude to create a student account."
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"title": "Tell us about you",
|
||||||
|
"name": "Full name",
|
||||||
|
"country": "Country",
|
||||||
|
"city": "City",
|
||||||
|
"cityPick": "Choose your city",
|
||||||
|
"cityType": "Type your city",
|
||||||
|
"language": "Learning language",
|
||||||
|
"save": "Start learning",
|
||||||
|
"nameRequired": "Enter your name.",
|
||||||
|
"CITY_REQUIRED": "Enter your city.",
|
||||||
|
"CITY_NOT_IN_LIST": "Choose a city from the list.",
|
||||||
|
"COUNTRY_REQUIRED": "Choose your country."
|
||||||
|
},
|
||||||
|
"home": {
|
||||||
|
"hello": "Selam, {name}",
|
||||||
|
"continue": "Continue watching",
|
||||||
|
"featured": "Featured",
|
||||||
|
"categories": "Categories",
|
||||||
|
"new": "New courses",
|
||||||
|
"emptyMine": "You don't own any courses yet. Start with a free preview lesson."
|
||||||
|
},
|
||||||
|
"catalog": {
|
||||||
|
"title": "All courses",
|
||||||
|
"search": "Search courses, teachers or topics",
|
||||||
|
"all": "All",
|
||||||
|
"count": "{n, plural, one {# course} other {# courses}}",
|
||||||
|
"empty": "No courses match “{q}”. Try a shorter word.",
|
||||||
|
"emptyCategory": "No courses in this category yet."
|
||||||
|
},
|
||||||
|
"course": {
|
||||||
|
"by": "With {name}",
|
||||||
|
"lessons": "{n, plural, one {# lesson} other {# lessons}}",
|
||||||
|
"taughtIn": "Taught in {lang}",
|
||||||
|
"updated": "Updated {date}",
|
||||||
|
"buy": "Buy for {price}",
|
||||||
|
"continue": "Continue lesson {n}",
|
||||||
|
"owned": "You own this course",
|
||||||
|
"preview": "Free preview",
|
||||||
|
"comingSoon": "Coming soon",
|
||||||
|
"prereq": "Finish “{title}” first. This course builds on it.",
|
||||||
|
"prereqLink": "Go to {title}",
|
||||||
|
"outcomes": "What you'll be able to do",
|
||||||
|
"audience": "Who it's for",
|
||||||
|
"content": "Course content",
|
||||||
|
"ready": "Ready when you are",
|
||||||
|
"readyBody": "Lesson 1 takes about {min} minutes.",
|
||||||
|
"watchPreview": "Watch free preview",
|
||||||
|
"notFound": "This course isn't available.",
|
||||||
|
"sequential": "Lessons unlock in order.",
|
||||||
|
"completed": "Course completed",
|
||||||
|
"watchAgain": "Watch again"
|
||||||
|
},
|
||||||
|
"checkout": {
|
||||||
|
"title": "Choose how to pay",
|
||||||
|
"total": "Total",
|
||||||
|
"lifetime": "One payment. Lifetime access.",
|
||||||
|
"pay": "Continue to {method}",
|
||||||
|
"simulated": "Demo checkout. No money moves.",
|
||||||
|
"providerTitle": "{method} (demo)",
|
||||||
|
"providerBody": "In the real app this is ArifPay's secure page. Pick an outcome to simulate it.",
|
||||||
|
"approve": "Pay {price}",
|
||||||
|
"decline": "Decline payment",
|
||||||
|
"leave": "Leave without paying",
|
||||||
|
"orderTitle": "Order {id}",
|
||||||
|
"pending": "Waiting for {method} to confirm your payment…",
|
||||||
|
"stillWaiting": "We're still waiting for confirmation from your bank. You'll get an SMS when it's done.",
|
||||||
|
"paid": "You now own this course",
|
||||||
|
"start": "Start lesson 1",
|
||||||
|
"failed": "Payment didn't go through",
|
||||||
|
"failedReason": "Reason: {reason}",
|
||||||
|
"tryAgain": "Try again",
|
||||||
|
"expired": "This order expired after 30 minutes. Start a new one.",
|
||||||
|
"cancelled": "You cancelled this order.",
|
||||||
|
"alreadyOwned": "You already own this course."
|
||||||
|
},
|
||||||
|
"player": {
|
||||||
|
"back": "Back to course",
|
||||||
|
"notes": "Lesson notes",
|
||||||
|
"next": "Next lesson",
|
||||||
|
"completed": "Lesson completed",
|
||||||
|
"dataSaver": "Data saver",
|
||||||
|
"quality": "Quality",
|
||||||
|
"speed": "Speed",
|
||||||
|
"COURSE_NOT_OWNED": "Buy this course to watch this lesson.",
|
||||||
|
"LESSON_LOCKED": "Finish the previous lesson to unlock this one.",
|
||||||
|
"PREREQUISITE_REQUIRED": "Finish the required course first.",
|
||||||
|
"COMING_SOON": "This lesson's video is still being prepared.",
|
||||||
|
"ACCOUNT_DEACTIVATED": "Your account is deactivated. Contact support.",
|
||||||
|
"demoVideo": "Sample playback — no video uploaded for this lesson yet",
|
||||||
|
"play": "Play",
|
||||||
|
"pause": "Pause",
|
||||||
|
"back10": "Back 10 seconds",
|
||||||
|
"fwd10": "Forward 10 seconds",
|
||||||
|
"fullscreen": "Full screen",
|
||||||
|
"contents": "Contents",
|
||||||
|
"progress": "{done} of {total} lessons completed"
|
||||||
|
},
|
||||||
|
"my": {
|
||||||
|
"title": "My courses",
|
||||||
|
"empty": "Courses you buy show up here.",
|
||||||
|
"resume": "Resume",
|
||||||
|
"progressTitle": "My progress",
|
||||||
|
"viewProgress": "View progress",
|
||||||
|
"lessonsDone": "{done} of {total} lessons"
|
||||||
|
},
|
||||||
|
"notif": {
|
||||||
|
"title": "Notifications",
|
||||||
|
"markAll": "Mark all as read",
|
||||||
|
"empty": "You're all caught up. We'll tell you about new lessons and payments here.",
|
||||||
|
"open": "Open"
|
||||||
|
},
|
||||||
|
"help": {
|
||||||
|
"title": "Help",
|
||||||
|
"faq": "Common questions",
|
||||||
|
"q1": "How do I pay?",
|
||||||
|
"a1": "Choose a course, tap Buy, then pay with Telebirr or CBE Birr. The course unlocks as soon as the payment is confirmed.",
|
||||||
|
"q2": "Do I keep the course?",
|
||||||
|
"a2": "Yes. You pay once and keep access for life.",
|
||||||
|
"q3": "The video won't play on my data plan.",
|
||||||
|
"a3": "Turn on Data saver in the player. It switches to a lower quality that uses less data.",
|
||||||
|
"contact": "Contact us",
|
||||||
|
"telegram": "Message us on Telegram",
|
||||||
|
"call": "Call support",
|
||||||
|
"copy": "Copy",
|
||||||
|
"copied": "Copied",
|
||||||
|
"report": "Report a problem",
|
||||||
|
"type": "What is it about?",
|
||||||
|
"subject": "Subject",
|
||||||
|
"description": "What happened?",
|
||||||
|
"screenshot": "Screenshot (optional, up to 5 MB)",
|
||||||
|
"screenshotTooBig": "That image is over 5 MB. Choose a smaller one.",
|
||||||
|
"submit": "Send report",
|
||||||
|
"sent": "Report sent. We'll notify you when its status changes.",
|
||||||
|
"mine": "My reports",
|
||||||
|
"noReports": "No reports yet.",
|
||||||
|
"required": "Fill in the subject and what happened."
|
||||||
|
},
|
||||||
|
"profile": {
|
||||||
|
"title": "Profile",
|
||||||
|
"details": "Your details",
|
||||||
|
"phone": "Phone",
|
||||||
|
"email": "Email",
|
||||||
|
"prefs": "Notification settings",
|
||||||
|
"prefsNote": "Payment receipts are always sent.",
|
||||||
|
"sessions": "Active sessions",
|
||||||
|
"thisDevice": "This browser",
|
||||||
|
"signOutSession": "Sign out",
|
||||||
|
"purchases": "Purchase history",
|
||||||
|
"noPurchases": "No purchases yet.",
|
||||||
|
"delete": "Delete account",
|
||||||
|
"deleteBody": "Your account is closed now and your personal data is removed after 30 days. Courses you bought can't be restored.",
|
||||||
|
"deleteConfirm": "Yes, delete my account",
|
||||||
|
"deleted": "This account was deleted."
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"PENDING": "Pending",
|
||||||
|
"PAID": "Paid",
|
||||||
|
"FAILED": "Failed",
|
||||||
|
"EXPIRED": "Expired",
|
||||||
|
"CANCELLED": "Cancelled",
|
||||||
|
"REFUNDED": "Refunded",
|
||||||
|
"OPEN": "Open",
|
||||||
|
"IN_PROGRESS": "In progress",
|
||||||
|
"RESOLVED": "Resolved",
|
||||||
|
"CLOSED": "Closed"
|
||||||
|
},
|
||||||
|
"issueType": {
|
||||||
|
"BUG": "Something is broken",
|
||||||
|
"PAYMENT": "Payment",
|
||||||
|
"VIDEO": "Video won't play",
|
||||||
|
"ACCOUNT": "My account",
|
||||||
|
"CONTENT": "Course content",
|
||||||
|
"OTHER": "Something else"
|
||||||
|
},
|
||||||
|
"notifType": {
|
||||||
|
"PAYMENT": "Payment receipts",
|
||||||
|
"NEW_LESSON": "New lessons in my courses",
|
||||||
|
"ISSUE": "Updates on my reports",
|
||||||
|
"ANNOUNCEMENT": "News and offers"
|
||||||
|
},
|
||||||
|
"channel": {
|
||||||
|
"IN_APP": "In app",
|
||||||
|
"EMAIL": "Email",
|
||||||
|
"SMS": "SMS"
|
||||||
|
},
|
||||||
|
"system": {
|
||||||
|
"paidTitle": "Course bought",
|
||||||
|
"paidBody": "You now own “{title}”. Receipt: {price}.",
|
||||||
|
"issueTitle": "Your report was updated",
|
||||||
|
"issueBody": "“{subject}” is now {status}.",
|
||||||
|
"grantTitle": "Course added to your account",
|
||||||
|
"grantBody": "You now have access to “{title}”."
|
||||||
|
}
|
||||||
|
}
|
||||||
261
packages/i18n/messages/om.json
Normal file
|
|
@ -0,0 +1,261 @@
|
||||||
|
{
|
||||||
|
"common": {
|
||||||
|
"loading": "Fe'aa jira…",
|
||||||
|
"retry": "Irra deebi'ii yaali",
|
||||||
|
"cancel": "Haqi",
|
||||||
|
"save": "Olkaa'i",
|
||||||
|
"saved": "Olkaa'ameera",
|
||||||
|
"close": "Cufi",
|
||||||
|
"back": "Duubatti",
|
||||||
|
"feedback": "Yaada kenni",
|
||||||
|
"demoBanner": "Agarsiisa — kaffaltiin, SMS fi imeeliin fakkeessa.",
|
||||||
|
"language": "Afaan",
|
||||||
|
"saveFailed": "Olkaa'uun hin danda'amne. Walqunnamtii kee mirkaneessiitii irra deebi'ii yaali.",
|
||||||
|
"readOnly": "Ilaaluu dandeessa, garuu herregni kun agarsiisa keessatti jijjiirama olkaa'uu hin danda'u."
|
||||||
|
},
|
||||||
|
"nav": {
|
||||||
|
"home": "Mana",
|
||||||
|
"courses": "Koorsiiwwan",
|
||||||
|
"myCourses": "Koorsiiwwan koo",
|
||||||
|
"help": "Gargaarsa",
|
||||||
|
"profile": "Piroofaayilii",
|
||||||
|
"notifications": "Beeksisota",
|
||||||
|
"signIn": "Seeni",
|
||||||
|
"signOut": "Ba'i",
|
||||||
|
"admin": "Fuula bulchiinsaa"
|
||||||
|
},
|
||||||
|
"landing": {
|
||||||
|
"title": "Meekaappii ogummaa afaan keetiin baradhu",
|
||||||
|
"lead": "Koorsiiwwan viidiyoo ogeeyyii hojii irra jiran irraa. Al tokko kaffali, koorsiin bara baraan kan kee ta'a, bilbila keetiin ilaali.",
|
||||||
|
"browse": "Koorsiiwwan ilaali",
|
||||||
|
"start": "Herrega uumi",
|
||||||
|
"featured": "Koorsiiwwan filatamoo",
|
||||||
|
"howTitle": "Akkamitti hojjeta",
|
||||||
|
"how1": "Barnoota yaalii bilisaa ilaali",
|
||||||
|
"how2": "Telebirr ykn CBE Birr'n kaffali",
|
||||||
|
"how3": "Koorsiin battalumatti, bara baraan siif bana",
|
||||||
|
"payTitle": "Karaa duraan beekteen kaffali",
|
||||||
|
"fact1": "Amaariffa, Afaan Oromoo, Tigrinyaa fi Ingiliffa",
|
||||||
|
"fact2": "Al tokko kaffali, bara baraan qabadhu",
|
||||||
|
"fact3": "Barnoota yaalii bilisaa",
|
||||||
|
"from": "{price} irraa",
|
||||||
|
"footer": "Koorsiiwwan viidiyoo ogeeyyii meekaappiif, bilbila keessan irratti."
|
||||||
|
},
|
||||||
|
"auth": {
|
||||||
|
"phoneTitle": "Bilbila keetiin seeni",
|
||||||
|
"phoneLabel": "Lakkoofsa bilbilaa",
|
||||||
|
"sendCode": "Koodii ergi",
|
||||||
|
"useEmail": "Imeeliin seeni",
|
||||||
|
"usePhone": "Bilbilaan seeni",
|
||||||
|
"emailTitle": "Imeeliin seeni",
|
||||||
|
"emailLabel": "Imeelii",
|
||||||
|
"passwordLabel": "Jecha icciitii",
|
||||||
|
"passwordHint": "Yoo xiqqaate qubee 8.",
|
||||||
|
"passwordShort": "Yoo xiqqaate qubee 8 fayyadami.",
|
||||||
|
"phoneInvalid": "+251 booda lakkoofsa 9 galchi.",
|
||||||
|
"emailInvalid": "Imeelii akka name@example.com galchi.",
|
||||||
|
"codeTitle": "Koodii galchi",
|
||||||
|
"codeSent": "Koodii lakkoofsa 6 {target}tti ergineerra.",
|
||||||
|
"demoCode": "Koodii agarsiisaa: {code}",
|
||||||
|
"verify": "Mirkaneessi",
|
||||||
|
"resend": "Koodii haaraa ergi",
|
||||||
|
"resendIn": "Sekondii {s} booda koodii haaraa erguu dandeessa",
|
||||||
|
"wrongCode": "Koodiin sun dogoggora. Yaaliin {n} hafeera.",
|
||||||
|
"locked": "Yaaliin dogoggoraa baay'ateera. Koodii haaraa ergi.",
|
||||||
|
"noIdentity": "Herrega barataa uumuuf Claude'tti seenii agarsiisa kana bani."
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"title": "Waa'ee kee nutti himi",
|
||||||
|
"name": "Maqaa guutuu",
|
||||||
|
"country": "Biyya",
|
||||||
|
"city": "Magaalaa",
|
||||||
|
"cityPick": "Magaalaa kee filadhu",
|
||||||
|
"cityType": "Magaalaa kee barreessi",
|
||||||
|
"language": "Afaan barumsaa",
|
||||||
|
"save": "Barachuu jalqabi",
|
||||||
|
"nameRequired": "Maqaa kee galchi.",
|
||||||
|
"CITY_REQUIRED": "Magaalaa kee galchi.",
|
||||||
|
"CITY_NOT_IN_LIST": "Tarree keessaa magaalaa filadhu.",
|
||||||
|
"COUNTRY_REQUIRED": "Biyya kee filadhu."
|
||||||
|
},
|
||||||
|
"home": {
|
||||||
|
"hello": "Akkam, {name}",
|
||||||
|
"continue": "Ilaaluu itti fufi",
|
||||||
|
"featured": "Filatamoo",
|
||||||
|
"categories": "Ramaddii",
|
||||||
|
"new": "Koorsiiwwan haaraa",
|
||||||
|
"emptyMine": "Ammatti koorsii hin qabdu. Barnoota yaalii bilisaatiin jalqabi."
|
||||||
|
},
|
||||||
|
"catalog": {
|
||||||
|
"title": "Koorsiiwwan hunda",
|
||||||
|
"search": "Koorsii, leenjisaa ykn mata-duree barbaadi",
|
||||||
|
"all": "Hunda",
|
||||||
|
"count": "Koorsii {n}",
|
||||||
|
"empty": "Koorsiin “{q}” wajjin walsimu hin jiru. Jecha gabaabaa yaali.",
|
||||||
|
"emptyCategory": "Ramaddii kana keessa ammatti koorsiin hin jiru."
|
||||||
|
},
|
||||||
|
"course": {
|
||||||
|
"by": "{name} wajjin",
|
||||||
|
"lessons": "Barnoota {n}",
|
||||||
|
"taughtIn": "Afaan barsiisaa: {lang}",
|
||||||
|
"updated": "Kan haaromfame {date}",
|
||||||
|
"buy": "{price}n bitadhu",
|
||||||
|
"continue": "Barnoota {n} itti fufi",
|
||||||
|
"owned": "Koorsiin kun kan keeti",
|
||||||
|
"preview": "Yaalii bilisaa",
|
||||||
|
"comingSoon": "Dhiheenyatti",
|
||||||
|
"prereq": "Jalqaba “{title}” xumuri. Koorsiin kun isa irratti ijaarama.",
|
||||||
|
"prereqLink": "Gara {title} deemi",
|
||||||
|
"outcomes": "Maal hojjechuu dandeessa",
|
||||||
|
"audience": "Eenyuuf",
|
||||||
|
"content": "Qabiyyee koorsii",
|
||||||
|
"ready": "Yeroo qophoofte jalqabi",
|
||||||
|
"readyBody": "Barnoonni 1 daqiiqaa {min} fudhata.",
|
||||||
|
"watchPreview": "Yaalii bilisaa ilaali",
|
||||||
|
"notFound": "Koorsiin kun hin argamu.",
|
||||||
|
"sequential": "Barnoonni tartiibaan bana.",
|
||||||
|
"completed": "Koorsii xumurteetta",
|
||||||
|
"watchAgain": "Irra deebi'ii ilaali"
|
||||||
|
},
|
||||||
|
"checkout": {
|
||||||
|
"title": "Akkaataa kaffaltii filadhu",
|
||||||
|
"total": "Waliigala",
|
||||||
|
"lifetime": "Kaffaltii tokko. Bara baraan.",
|
||||||
|
"pay": "Gara {method} itti fufi",
|
||||||
|
"simulated": "Kaffaltii agarsiisaa. Maallaqni hin socho'u.",
|
||||||
|
"providerTitle": "{method} (agarsiisa)",
|
||||||
|
"providerBody": "Appii dhugaa keessatti kun fuula nageenya qabu ArifPay ti. Bu'aa fakkeessuuf filadhu.",
|
||||||
|
"approve": "{price} kaffali",
|
||||||
|
"decline": "Kaffaltii didi",
|
||||||
|
"leave": "Osoo hin kaffalin ba'i",
|
||||||
|
"orderTitle": "Ajaja {id}",
|
||||||
|
"pending": "{method}n kaffaltii kee akka mirkaneessu eegaa jira…",
|
||||||
|
"stillWaiting": "Ammallee baankii kee irraa mirkaneessa eegaa jirra. Yeroo xumurame SMS siif erga.",
|
||||||
|
"paid": "Amma koorsiin kun kan keeti",
|
||||||
|
"start": "Barnoota 1 jalqabi",
|
||||||
|
"failed": "Kaffaltiin hin milkoofne",
|
||||||
|
"failedReason": "Sababa: {reason}",
|
||||||
|
"tryAgain": "Irra deebi'ii yaali",
|
||||||
|
"expired": "Ajajni kun daqiiqaa 30 booda yeroon isaa darbeera. Haaraa jalqabi.",
|
||||||
|
"cancelled": "Ajaja kana haqxeetta.",
|
||||||
|
"alreadyOwned": "Koorsiin kun duraanuu kan keeti."
|
||||||
|
},
|
||||||
|
"player": {
|
||||||
|
"back": "Gara koorsiitti deebi'i",
|
||||||
|
"notes": "Yaadannoo barnootaa",
|
||||||
|
"next": "Barnoota itti aanu",
|
||||||
|
"completed": "Barnoonni xumurameera",
|
||||||
|
"dataSaver": "Daataa qusachuu",
|
||||||
|
"quality": "Qulqullina",
|
||||||
|
"speed": "Saffisa",
|
||||||
|
"COURSE_NOT_OWNED": "Barnoota kana ilaaluuf koorsii bitadhu.",
|
||||||
|
"LESSON_LOCKED": "Kana banuuf barnoota duraa xumuri.",
|
||||||
|
"PREREQUISITE_REQUIRED": "Jalqaba koorsii barbaachisu xumuri.",
|
||||||
|
"COMING_SOON": "Viidiyoon barnoota kanaa qophaa'aa jira.",
|
||||||
|
"ACCOUNT_DEACTIVATED": "Herregni kee dhaabateera. Gargaarsa qunnami.",
|
||||||
|
"demoVideo": "Taphachiisa fakkeenyaa — barnoota kanaaf viidiyoon ammatti hin feene",
|
||||||
|
"play": "Taphachiisi",
|
||||||
|
"pause": "Dhaabi",
|
||||||
|
"back10": "Sekondii 10 duubatti",
|
||||||
|
"fwd10": "Sekondii 10 fuulduratti",
|
||||||
|
"fullscreen": "Guutuu iskiriinii",
|
||||||
|
"contents": "Qabiyyee",
|
||||||
|
"progress": "Barnoota {total} keessaa {done} xumurameera"
|
||||||
|
},
|
||||||
|
"my": {
|
||||||
|
"title": "Koorsiiwwan koo",
|
||||||
|
"empty": "Koorsiiwwan bitattu asitti mul'atu.",
|
||||||
|
"resume": "Itti fufi",
|
||||||
|
"progressTitle": "Guddina koo",
|
||||||
|
"viewProgress": "Guddina ilaali",
|
||||||
|
"lessonsDone": "Barnoota {total} keessaa {done}"
|
||||||
|
},
|
||||||
|
"notif": {
|
||||||
|
"title": "Beeksisota",
|
||||||
|
"markAll": "Hunda akka dubbifametti mallattoo godhi",
|
||||||
|
"empty": "Hunda ilaalteetta. Waa'ee barnoota haaraa fi kaffaltii asitti si beeksifna.",
|
||||||
|
"open": "Bani"
|
||||||
|
},
|
||||||
|
"help": {
|
||||||
|
"title": "Gargaarsa",
|
||||||
|
"faq": "Gaaffilee baay'inaan gaafataman",
|
||||||
|
"q1": "Akkamittan kaffala?",
|
||||||
|
"a1": "Koorsii filadhu, Bitadhu tuqi, sana booda Telebirr ykn CBE Birr'n kaffali. Kaffaltiin akkuma mirkanaa'een koorsiin bana.",
|
||||||
|
"q2": "Koorsiin bara baraan kan koo?",
|
||||||
|
"a2": "Eeyyee. Al tokko kaffaltee bara baraan itti fayyadamta.",
|
||||||
|
"q3": "Viidiyoon daataa kootiin hin taphatu.",
|
||||||
|
"a3": "Taphachiisaa irratti Daataa qusachuu banii. Qulqullina daataa xiqqaa fayyadamu filata.",
|
||||||
|
"contact": "Nu qunnamaa",
|
||||||
|
"telegram": "Telegram irratti nuuf barreessi",
|
||||||
|
"call": "Gargaarsaaf bilbili",
|
||||||
|
"copy": "Garagalchi",
|
||||||
|
"copied": "Garagalchameera",
|
||||||
|
"report": "Rakkoo gabaasi",
|
||||||
|
"type": "Waa'ee maalii?",
|
||||||
|
"subject": "Mata-duree",
|
||||||
|
"description": "Maaltu uumame?",
|
||||||
|
"screenshot": "Suuraa iskiriinii (filannoo, hanga MB 5)",
|
||||||
|
"screenshotTooBig": "Suuraan sun MB 5 ol. Kan xiqqaa filadhu.",
|
||||||
|
"submit": "Gabaasa ergi",
|
||||||
|
"sent": "Gabaasni ergameera. Haalli isaa yeroo jijjiiramu si beeksifna.",
|
||||||
|
"mine": "Gabaasota koo",
|
||||||
|
"noReports": "Ammatti gabaasni hin jiru.",
|
||||||
|
"required": "Mata-duree fi waan uumame guuti."
|
||||||
|
},
|
||||||
|
"profile": {
|
||||||
|
"title": "Piroofaayilii",
|
||||||
|
"details": "Odeeffannoo kee",
|
||||||
|
"phone": "Bilbila",
|
||||||
|
"email": "Imeelii",
|
||||||
|
"prefs": "Qindaa'ina beeksisaa",
|
||||||
|
"prefsNote": "Nagaheen kaffaltii yeroo hunda ni ergama.",
|
||||||
|
"sessions": "Seenii hojii irra jiran",
|
||||||
|
"thisDevice": "Brawuzarii kana",
|
||||||
|
"signOutSession": "Ba'i",
|
||||||
|
"purchases": "Seenaa bittaa",
|
||||||
|
"noPurchases": "Ammatti bittaan hin jiru.",
|
||||||
|
"delete": "Herrega haqi",
|
||||||
|
"deleteBody": "Herregni kee amma ni cufama, odeeffannoon dhuunfaa kee guyyaa 30 booda ni haqama. Koorsiiwwan bitatte deebi'uu hin danda'an.",
|
||||||
|
"deleteConfirm": "Eeyyee, herrega koo haqi",
|
||||||
|
"deleted": "Herregni kun haqameera."
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"PENDING": "Eegaa jira",
|
||||||
|
"PAID": "Kaffalameera",
|
||||||
|
"FAILED": "Hin milkoofne",
|
||||||
|
"EXPIRED": "Yeroon darbeera",
|
||||||
|
"CANCELLED": "Haqameera",
|
||||||
|
"REFUNDED": "Deebi'eera",
|
||||||
|
"OPEN": "Banaa",
|
||||||
|
"IN_PROGRESS": "Adeemsa irra",
|
||||||
|
"RESOLVED": "Furameera",
|
||||||
|
"CLOSED": "Cufameera"
|
||||||
|
},
|
||||||
|
"issueType": {
|
||||||
|
"BUG": "Wanti tokko hin hojjetu",
|
||||||
|
"PAYMENT": "Kaffaltii",
|
||||||
|
"VIDEO": "Viidiyoon hin taphatu",
|
||||||
|
"ACCOUNT": "Herrega koo",
|
||||||
|
"CONTENT": "Qabiyyee koorsii",
|
||||||
|
"OTHER": "Kan biraa"
|
||||||
|
},
|
||||||
|
"notifType": {
|
||||||
|
"PAYMENT": "Nagahee kaffaltii",
|
||||||
|
"NEW_LESSON": "Barnoota haaraa koorsiiwwan koo keessatti",
|
||||||
|
"ISSUE": "Odeeffannoo gabaasota koo",
|
||||||
|
"ANNOUNCEMENT": "Oduu fi carraawwan"
|
||||||
|
},
|
||||||
|
"channel": {
|
||||||
|
"IN_APP": "Appii keessatti",
|
||||||
|
"EMAIL": "Imeelii",
|
||||||
|
"SMS": "SMS"
|
||||||
|
},
|
||||||
|
"system": {
|
||||||
|
"paidTitle": "Koorsiin bitameera",
|
||||||
|
"paidBody": "“{title}” amma kan keeti. Nagahee: {price}.",
|
||||||
|
"issueTitle": "Gabaasni kee haaromfameera",
|
||||||
|
"issueBody": "“{subject}” amma {status}.",
|
||||||
|
"grantTitle": "Koorsiin herrega keetti dabalameera",
|
||||||
|
"grantBody": "Amma “{title}” argachuu dandeessa."
|
||||||
|
}
|
||||||
|
}
|
||||||
261
packages/i18n/messages/ti.json
Normal file
|
|
@ -0,0 +1,261 @@
|
||||||
|
{
|
||||||
|
"common": {
|
||||||
|
"loading": "ይጽዕን ኣሎ…",
|
||||||
|
"retry": "እንደገና ፈትን",
|
||||||
|
"cancel": "ሰርዝ",
|
||||||
|
"save": "ዓቅብ",
|
||||||
|
"saved": "ተዓቂቡ",
|
||||||
|
"close": "ዕጸው",
|
||||||
|
"back": "ተመለስ",
|
||||||
|
"feedback": "ርእይቶ ሃብ",
|
||||||
|
"demoBanner": "መርኣያ — ክፍሊት፣ ኤስኤምኤስን ኢመይልን ናይ ምምሳል እዮም።",
|
||||||
|
"language": "ቋንቋ",
|
||||||
|
"saveFailed": "ክዕቀብ ኣይከኣለን። ርክብካ ኣረጋግጽካ እንደገና ፈትን።",
|
||||||
|
"readOnly": "ክትርኢ ትኽእል ኢኻ፣ እዚ ሕሳብ ግን ኣብ መርኣያ ለውጢ ክዕቅብ ኣይክእልን።"
|
||||||
|
},
|
||||||
|
"nav": {
|
||||||
|
"home": "መበገሲ",
|
||||||
|
"courses": "ኮርሳት",
|
||||||
|
"myCourses": "ናተይ ኮርሳት",
|
||||||
|
"help": "ሓገዝ",
|
||||||
|
"profile": "ፕሮፋይል",
|
||||||
|
"notifications": "መፍለጢታት",
|
||||||
|
"signIn": "እቶ",
|
||||||
|
"signOut": "ውጻእ",
|
||||||
|
"admin": "ገጽ ምምሕዳር"
|
||||||
|
},
|
||||||
|
"landing": {
|
||||||
|
"title": "ሞያዊ ሜካፕ ብቋንቋኻ ተማሃር",
|
||||||
|
"lead": "ካብ ኣብ ስራሕ ዘለዉ ክኢላታት ናይ ቪድዮ ኮርሳት። ሓንሳብ ክፈል፣ ኮርሱ ንዘለኣለም ናትካ እዩ፣ ብተሌፎንካ ርአ።",
|
||||||
|
"browse": "ኮርሳት ርአ",
|
||||||
|
"start": "ሕሳብ ፍጠር",
|
||||||
|
"featured": "ፍሉያት ኮርሳት",
|
||||||
|
"howTitle": "ከመይ ይሰርሕ",
|
||||||
|
"how1": "ናጻ ናይ ፈተነ ትምህርትታት ርአ",
|
||||||
|
"how2": "ብቴሌብር ወይ ሲቢኢ ብር ክፈል",
|
||||||
|
"how3": "ኮርሱ ብቕጽበት ይኽፈት፣ ንዘለኣለም",
|
||||||
|
"payTitle": "ብዝለመድካዮ መንገዲ ክፈል",
|
||||||
|
"fact1": "ኣምሓርኛ፣ ኦሮምኛ፣ ትግርኛን እንግሊዝኛን",
|
||||||
|
"fact2": "ሓንሳብ ክፈል፣ ንዘለኣለም ሓዞ",
|
||||||
|
"fact3": "ናጻ ናይ ፈተነ ትምህርትታት",
|
||||||
|
"from": "ካብ {price}",
|
||||||
|
"footer": "ንክኢላታት ሜካፕ ናይ ቪድዮ ኮርሳት፣ ኣብ ተሌፎንካ።"
|
||||||
|
},
|
||||||
|
"auth": {
|
||||||
|
"phoneTitle": "ብተሌፎንካ እቶ",
|
||||||
|
"phoneLabel": "ቁጽሪ ተሌፎን",
|
||||||
|
"sendCode": "ኮድ ስደድ",
|
||||||
|
"useEmail": "ብኢመይል እቶ",
|
||||||
|
"usePhone": "ብተሌፎን እቶ",
|
||||||
|
"emailTitle": "ብኢመይል እቶ",
|
||||||
|
"emailLabel": "ኢመይል",
|
||||||
|
"passwordLabel": "መሕለፊ ቃል",
|
||||||
|
"passwordHint": "እንተወሓደ 8 ፊደላት።",
|
||||||
|
"passwordShort": "እንተወሓደ 8 ፊደላት ተጠቐም።",
|
||||||
|
"phoneInvalid": "ድሕሪ +251 9 ኣሃዝ ዘለዎ ቁጽሪ ኣእቱ።",
|
||||||
|
"emailInvalid": "ከም name@example.com ዝበለ ኢመይል ኣእቱ።",
|
||||||
|
"codeTitle": "ኮድ ኣእቱ",
|
||||||
|
"codeSent": "ባዕለ 6 ኣሃዝ ኮድ ናብ {target} ሰዲድና።",
|
||||||
|
"demoCode": "ናይ መርኣያ ኮድ፦ {code}",
|
||||||
|
"verify": "ኣረጋግጽ",
|
||||||
|
"resend": "ሓድሽ ኮድ ስደድ",
|
||||||
|
"resendIn": "ድሕሪ {s} ካልኢት ሓድሽ ኮድ ክትሰድድ ትኽእል",
|
||||||
|
"wrongCode": "እቲ ኮድ ጌጋ እዩ። {n} ፈተነ ተሪፉ።",
|
||||||
|
"locked": "ብዙሕ ጌጋ ፈተነታት። ሓድሽ ኮድ ስደድ።",
|
||||||
|
"noIdentity": "ናይ ተማሃራይ ሕሳብ ንምፍጣር ናብ Claude ኣቲኻ እዚ መርኣያ ክፈቶ።"
|
||||||
|
},
|
||||||
|
"setup": {
|
||||||
|
"title": "ብዛዕባኻ ንገረና",
|
||||||
|
"name": "ምሉእ ስም",
|
||||||
|
"country": "ሃገር",
|
||||||
|
"city": "ከተማ",
|
||||||
|
"cityPick": "ከተማኻ ምረጽ",
|
||||||
|
"cityType": "ከተማኻ ጽሓፍ",
|
||||||
|
"language": "ቋንቋ ትምህርቲ",
|
||||||
|
"save": "ምምሃር ጀምር",
|
||||||
|
"nameRequired": "ስምካ ኣእቱ።",
|
||||||
|
"CITY_REQUIRED": "ከተማኻ ኣእቱ።",
|
||||||
|
"CITY_NOT_IN_LIST": "ካብቲ ዝርዝር ከተማ ምረጽ።",
|
||||||
|
"COUNTRY_REQUIRED": "ሃገርካ ምረጽ።"
|
||||||
|
},
|
||||||
|
"home": {
|
||||||
|
"hello": "ሰላም፣ {name}",
|
||||||
|
"continue": "ምርኣይ ቀጽል",
|
||||||
|
"featured": "ፍሉያት",
|
||||||
|
"categories": "ምድባት",
|
||||||
|
"new": "ሓደስቲ ኮርሳት",
|
||||||
|
"emptyMine": "ክሳብ ሕጂ ኮርስ ኣይገዛእካን። ብናጻ ናይ ፈተነ ትምህርቲ ጀምር።"
|
||||||
|
},
|
||||||
|
"catalog": {
|
||||||
|
"title": "ኩሎም ኮርሳት",
|
||||||
|
"search": "ኮርስ፣ መምህር ወይ ኣርእስቲ ድለ",
|
||||||
|
"all": "ኩሉ",
|
||||||
|
"count": "{n} ኮርሳት",
|
||||||
|
"empty": "ምስ «{q}» ዝሰማማዕ ኮርስ የለን። ሓጺር ቃል ፈትን።",
|
||||||
|
"emptyCategory": "ኣብዚ ምድብ ክሳብ ሕጂ ኮርስ የለን።"
|
||||||
|
},
|
||||||
|
"course": {
|
||||||
|
"by": "ምስ {name}",
|
||||||
|
"lessons": "{n} ትምህርትታት",
|
||||||
|
"taughtIn": "ቋንቋ ምምሃር፦ {lang}",
|
||||||
|
"updated": "ዝተመሓየሸሉ {date}",
|
||||||
|
"buy": "ብ{price} ግዛእ",
|
||||||
|
"continue": "ትምህርቲ {n} ቀጽል",
|
||||||
|
"owned": "እዚ ኮርስ ናትካ እዩ",
|
||||||
|
"preview": "ናጻ ፈተነ",
|
||||||
|
"comingSoon": "ኣብ ቀረባ",
|
||||||
|
"prereq": "ቅድም «{title}» ወድእ። እዚ ኮርስ ኣብኡ ይህነጽ።",
|
||||||
|
"prereqLink": "ናብ {title} ኪድ",
|
||||||
|
"outcomes": "እንታይ ክትሰርሕ ትኽእል",
|
||||||
|
"audience": "ንመን እዩ",
|
||||||
|
"content": "ትሕዝቶ ኮርስ",
|
||||||
|
"ready": "ምስ ተዳለኻ ጀምር",
|
||||||
|
"readyBody": "ትምህርቲ 1 ኣስታት {min} ደቒቕ ይወስድ።",
|
||||||
|
"watchPreview": "ናጻ ፈተነ ርአ",
|
||||||
|
"notFound": "እዚ ኮርስ ኣይርከብን።",
|
||||||
|
"sequential": "ትምህርትታት ብቕደም ተኸተል ይኽፈቱ።",
|
||||||
|
"completed": "ኮርስ ወዲእካ",
|
||||||
|
"watchAgain": "እንደገና ርአ"
|
||||||
|
},
|
||||||
|
"checkout": {
|
||||||
|
"title": "መንገዲ ክፍሊት ምረጽ",
|
||||||
|
"total": "ጠቕላላ",
|
||||||
|
"lifetime": "ሓደ ክፍሊት። ንዘለኣለም።",
|
||||||
|
"pay": "ናብ {method} ቀጽል",
|
||||||
|
"simulated": "ናይ መርኣያ ክፍሊት። ገንዘብ ኣይንቀሳቐስን።",
|
||||||
|
"providerTitle": "{method} (መርኣያ)",
|
||||||
|
"providerBody": "ኣብቲ ሓቀኛ መተግበሪ እዚ ውሑስ ገጽ ArifPay እዩ። ውጽኢት ንምምሳል ምረጽ።",
|
||||||
|
"approve": "{price} ክፈል",
|
||||||
|
"decline": "ክፍሊት ኣይትቐበል",
|
||||||
|
"leave": "ከይከፈልካ ውጻእ",
|
||||||
|
"orderTitle": "ትእዛዝ {id}",
|
||||||
|
"pending": "{method} ክፍሊትካ ክሳብ ዘረጋግጽ ንጽበ ኣለና…",
|
||||||
|
"stillWaiting": "ካብ ባንክኻ ምርግጋጽ ንጽበ ኣለና። ምስ ተወደአ ብኤስኤምኤስ ክንሕብረካ ኢና።",
|
||||||
|
"paid": "ሕጂ እዚ ኮርስ ናትካ እዩ",
|
||||||
|
"start": "ትምህርቲ 1 ጀምር",
|
||||||
|
"failed": "ክፍሊት ኣይተዓወተን",
|
||||||
|
"failedReason": "ምኽንያት፦ {reason}",
|
||||||
|
"tryAgain": "እንደገና ፈትን",
|
||||||
|
"expired": "እዚ ትእዛዝ ድሕሪ 30 ደቒቕ ግዜኡ ሓሊፉ። ሓድሽ ጀምር።",
|
||||||
|
"cancelled": "ነዚ ትእዛዝ ሰሪዝካዮ።",
|
||||||
|
"alreadyOwned": "እዚ ኮርስ ድሮ ናትካ እዩ።"
|
||||||
|
},
|
||||||
|
"player": {
|
||||||
|
"back": "ናብ ኮርስ ተመለስ",
|
||||||
|
"notes": "መዘኻኸሪ ትምህርቲ",
|
||||||
|
"next": "ዝቕጽል ትምህርቲ",
|
||||||
|
"completed": "ትምህርቲ ተወዲኡ",
|
||||||
|
"dataSaver": "ዳታ ቆጣቢ",
|
||||||
|
"quality": "ጽሬት",
|
||||||
|
"speed": "ቅልጣፈ",
|
||||||
|
"COURSE_NOT_OWNED": "ነዚ ትምህርቲ ንምርኣይ ኮርሱ ግዛእ።",
|
||||||
|
"LESSON_LOCKED": "ነዚ ንምኽፋት እቲ ዝቐደመ ትምህርቲ ወድእ።",
|
||||||
|
"PREREQUISITE_REQUIRED": "ቅድም እቲ ዘድሊ ኮርስ ወድእ።",
|
||||||
|
"COMING_SOON": "ቪድዮ ናይዚ ትምህርቲ ይዳሎ ኣሎ።",
|
||||||
|
"ACCOUNT_DEACTIVATED": "ሕሳብካ ተዓጽዩ። ሓገዝ ርኸብ።",
|
||||||
|
"demoVideo": "ናይ ኣብነት ምጽዋት — ንዚ ትምህርቲ ክሳብ ሕጂ ቪድዮ ኣይተጻዕነን",
|
||||||
|
"play": "ተጻወት",
|
||||||
|
"pause": "ደው ኣብል",
|
||||||
|
"back10": "10 ካልኢት ንድሕሪት",
|
||||||
|
"fwd10": "10 ካልኢት ንቕድሚት",
|
||||||
|
"fullscreen": "ምሉእ ስክሪን",
|
||||||
|
"contents": "ትሕዝቶ",
|
||||||
|
"progress": "ካብ {total} ትምህርትታት {done} ተወዲኦም"
|
||||||
|
},
|
||||||
|
"my": {
|
||||||
|
"title": "ናተይ ኮርሳት",
|
||||||
|
"empty": "ዝገዛእካዮም ኮርሳት ኣብዚ ይርኣዩ።",
|
||||||
|
"resume": "ቀጽል",
|
||||||
|
"progressTitle": "ምዕባለይ",
|
||||||
|
"viewProgress": "ምዕባለ ርአ",
|
||||||
|
"lessonsDone": "ካብ {total} ትምህርትታት {done}"
|
||||||
|
},
|
||||||
|
"notif": {
|
||||||
|
"title": "መፍለጢታት",
|
||||||
|
"markAll": "ኩሉ ከም ዝተነበበ ምልክት ግበር",
|
||||||
|
"empty": "ኩሉ ርኢኻዮ። ብዛዕባ ሓደስቲ ትምህርትታትን ክፍሊትን ኣብዚ ክንሕብረካ ኢና።",
|
||||||
|
"open": "ክፈት"
|
||||||
|
},
|
||||||
|
"help": {
|
||||||
|
"title": "ሓገዝ",
|
||||||
|
"faq": "ብተደጋጋሚ ዝሕተቱ ሕቶታት",
|
||||||
|
"q1": "ብኸመይ እኸፍል?",
|
||||||
|
"a1": "ኮርስ ምረጽ፣ ግዛእ ጠውቕ፣ ድሕሪኡ ብቴሌብር ወይ ሲቢኢ ብር ክፈል። ክፍሊት ምስ ተረጋገጸ ኮርሱ ይኽፈት።",
|
||||||
|
"q2": "ኮርሱ ንዘለኣለም ናተይ ድዩ?",
|
||||||
|
"a2": "እወ። ሓንሳብ ከፊልካ ንዘለኣለም ትጥቀመሉ።",
|
||||||
|
"q3": "ቪድዮ ብዳታይ ኣይጻወትን።",
|
||||||
|
"a3": "ኣብ ተጻዋቲ ዳታ ቆጣቢ ኣብርህ። ውሑድ ዳታ ዝጥቀም ጽሬት ይመርጽ።",
|
||||||
|
"contact": "ርኸቡና",
|
||||||
|
"telegram": "ብቴሌግራም ጽሓፉልና",
|
||||||
|
"call": "ንሓገዝ ደውል",
|
||||||
|
"copy": "ቅዳሕ",
|
||||||
|
"copied": "ተቐዲሑ",
|
||||||
|
"report": "ጸገም ሕበር",
|
||||||
|
"type": "ብዛዕባ እንታይ እዩ?",
|
||||||
|
"subject": "ኣርእስቲ",
|
||||||
|
"description": "እንታይ ኣጋጠመ?",
|
||||||
|
"screenshot": "ስእሊ ስክሪን (ኣማራጺ፣ ክሳብ 5 ሜባ)",
|
||||||
|
"screenshotTooBig": "እቲ ስእሊ ካብ 5 ሜባ ይበዝሕ። ንእሽቶ ምረጽ።",
|
||||||
|
"submit": "ጸብጻብ ስደድ",
|
||||||
|
"sent": "ጸብጻብ ተላኢኹ። ኩነታቱ ምስ ተቐየረ ክንሕብረካ ኢና።",
|
||||||
|
"mine": "ናተይ ጸብጻባት",
|
||||||
|
"noReports": "ክሳብ ሕጂ ጸብጻብ የለን።",
|
||||||
|
"required": "ኣርእስትን ዘጋጠመን ምላእ።"
|
||||||
|
},
|
||||||
|
"profile": {
|
||||||
|
"title": "ፕሮፋይል",
|
||||||
|
"details": "ሓበሬታኻ",
|
||||||
|
"phone": "ተሌፎን",
|
||||||
|
"email": "ኢመይል",
|
||||||
|
"prefs": "ቅጥዕታት መፍለጢ",
|
||||||
|
"prefsNote": "ቅብሊት ክፍሊት ኩሉ ግዜ ይለኣኽ።",
|
||||||
|
"sessions": "ንጡፋት ክፍለ ግዜታት",
|
||||||
|
"thisDevice": "እዚ ብራውዘር",
|
||||||
|
"signOutSession": "ውጻእ",
|
||||||
|
"purchases": "ታሪኽ ዕድጊ",
|
||||||
|
"noPurchases": "ክሳብ ሕጂ ዕድጊ የለን።",
|
||||||
|
"delete": "ሕሳብ ደምስስ",
|
||||||
|
"deleteBody": "ሕሳብካ ሕጂ ይዕጾ፣ ውልቃዊ ሓበሬታኻ ድሕሪ 30 መዓልቲ ይድምሰስ። ዝገዛእካዮም ኮርሳት ክምለሱ ኣይክእሉን።",
|
||||||
|
"deleteConfirm": "እወ፣ ሕሳበይ ደምስስ",
|
||||||
|
"deleted": "እዚ ሕሳብ ተደምሲሱ።"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"PENDING": "ይጽበ ኣሎ",
|
||||||
|
"PAID": "ተኸፊሉ",
|
||||||
|
"FAILED": "ኣይተዓወተን",
|
||||||
|
"EXPIRED": "ግዜኡ ሓሊፉ",
|
||||||
|
"CANCELLED": "ተሰሪዙ",
|
||||||
|
"REFUNDED": "ተመሊሱ",
|
||||||
|
"OPEN": "ክፉት",
|
||||||
|
"IN_PROGRESS": "ኣብ መስርሕ",
|
||||||
|
"RESOLVED": "ተፈቲሑ",
|
||||||
|
"CLOSED": "ተዓጽዩ"
|
||||||
|
},
|
||||||
|
"issueType": {
|
||||||
|
"BUG": "ገለ ነገር ኣይሰርሕን",
|
||||||
|
"PAYMENT": "ክፍሊት",
|
||||||
|
"VIDEO": "ቪድዮ ኣይጻወትን",
|
||||||
|
"ACCOUNT": "ሕሳበይ",
|
||||||
|
"CONTENT": "ትሕዝቶ ኮርስ",
|
||||||
|
"OTHER": "ካልእ"
|
||||||
|
},
|
||||||
|
"notifType": {
|
||||||
|
"PAYMENT": "ቅብሊት ክፍሊት",
|
||||||
|
"NEW_LESSON": "ኣብ ኮርሳተይ ሓደስቲ ትምህርትታት",
|
||||||
|
"ISSUE": "ሓበሬታ ብዛዕባ ጸብጻባተይ",
|
||||||
|
"ANNOUNCEMENT": "ዜናን ቅናሻትን"
|
||||||
|
},
|
||||||
|
"channel": {
|
||||||
|
"IN_APP": "ኣብ መተግበሪ",
|
||||||
|
"EMAIL": "ኢመይል",
|
||||||
|
"SMS": "ኤስኤምኤስ"
|
||||||
|
},
|
||||||
|
"system": {
|
||||||
|
"paidTitle": "ኮርስ ተገዚኡ",
|
||||||
|
"paidBody": "«{title}» ሕጂ ናትካ እዩ። ቅብሊት፦ {price}።",
|
||||||
|
"issueTitle": "ጸብጻብካ ተመሓይሹ",
|
||||||
|
"issueBody": "«{subject}» ሕጂ {status} እዩ።",
|
||||||
|
"grantTitle": "ኮርስ ናብ ሕሳብካ ተወሲኹ",
|
||||||
|
"grantBody": "ሕጂ «{title}» ክትረክብ ትኽእል።"
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/i18n/package.json
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{ "name": "@lms/i18n", "version": "0.0.0", "private": true, "main": "src/index.ts", "types": "src/index.ts" }
|
||||||
10
packages/i18n/src/index.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
import en from '../messages/en.json';
|
||||||
|
import am from '../messages/am.json';
|
||||||
|
import om from '../messages/om.json';
|
||||||
|
import ti from '../messages/ti.json';
|
||||||
|
|
||||||
|
export const messages = { en, am, om, ti } as const;
|
||||||
|
export type Messages = typeof en;
|
||||||
|
/** Catalogs that are machine drafts and still need a translator (§12). */
|
||||||
|
export const DRAFT_LOCALES = ['om', 'ti'] as const;
|
||||||
|
export const LOCALE_NAMES = { am: 'አማርኛ', en: 'English', om: 'Afaan Oromoo', ti: 'ትግርኛ' } as const;
|
||||||
1
packages/i18n/tsconfig.json
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{ "extends": "../../tsconfig.base.json", "include": ["src", "messages"] }
|
||||||
1437
pnpm-lock.yaml
Normal file
3
pnpm-workspace.yaml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
packages:
|
||||||
|
- apps/*
|
||||||
|
- packages/*
|
||||||
33
tools/artifact-check.mjs
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
// CI check: loads the inlined demo in jsdom with ALL network blocked and fails if the page
|
||||||
|
// tries to fetch or load any script (e.g. a lazy chunk or an RSC .txt payload), or throws.
|
||||||
|
// Usage: node tools/artifact-check.mjs dist/demo.html
|
||||||
|
import { JSDOM, VirtualConsole } from 'jsdom'; import fs from 'fs';
|
||||||
|
const file = process.argv[2] || 'dist/demo.html';
|
||||||
|
const errors = [], network = [];
|
||||||
|
const vc = new VirtualConsole();
|
||||||
|
vc.on('jsdomError', (e) => errors.push(String(e.message)));
|
||||||
|
const dom = new JSDOM(fs.readFileSync(file, 'utf8'), {
|
||||||
|
runScripts: 'dangerously', url: 'https://artifact.local/', virtualConsole: vc, pretendToBeVisual: true,
|
||||||
|
beforeParse(w) {
|
||||||
|
Object.assign(w, { TextEncoder, TextDecoder, MessageChannel, ReadableStream, structuredClone });
|
||||||
|
w.fetch = (u) => { network.push(`fetch ${u}`); return Promise.reject(new Error('blocked')); };
|
||||||
|
const create = w.document.createElement.bind(w.document);
|
||||||
|
w.document.createElement = (tag, ...rest) => {
|
||||||
|
const el = create(tag, ...rest);
|
||||||
|
if (tag === 'script') {
|
||||||
|
const d = Object.getOwnPropertyDescriptor(w.HTMLScriptElement.prototype, 'src');
|
||||||
|
Object.defineProperty(el, 'src', { set(v) { network.push(`script ${v}`); d.set.call(el, v); }, get() { return d.get.call(el); } });
|
||||||
|
}
|
||||||
|
return el;
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const w = dom.window;
|
||||||
|
await new Promise((r) => setTimeout(r, 2000));
|
||||||
|
for (const route of ['#/am', '#/am/courses', '#/admin']) { w.location.hash = route; await new Promise((r) => setTimeout(r, 300)); }
|
||||||
|
// React can re-insert hoisted <link>/<script> tags at hydration; jsdom doesn't fetch them, so scan the DOM too.
|
||||||
|
for (const el of w.document.querySelectorAll('link[href],script[src]')) network.push(`${el.tagName.toLowerCase()} ${el.getAttribute('href') ?? el.getAttribute('src')}`);
|
||||||
|
const allowed = (u) => /^link https:\/\/fonts\.(googleapis|gstatic)\.com/.test(u) || /cdnjs\.cloudflare\.com|cdn\.jsdelivr\.net\/npm|fonts\.googleapis\.com|fonts\.gstatic\.com/.test(u);
|
||||||
|
const bad = network.filter((n) => !allowed(n));
|
||||||
|
console.log({ networkAttempts: bad, errors });
|
||||||
|
process.exit(bad.length || errors.length ? 1 : 0);
|
||||||
30
tools/artifact-inline.mjs
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
// Turns a Next.js static export (output: 'export') into ONE self-contained HTML file
|
||||||
|
// that can be published as a Claude artifact. Usage: node tools/artifact-inline.mjs apps/demo/out dist/demo.html
|
||||||
|
import fs from 'fs'; import path from 'path';
|
||||||
|
const [outDir = 'apps/demo/out', dest = 'dist/demo.html'] = process.argv.slice(2);
|
||||||
|
let html = fs.readFileSync(path.join(outDir, 'index.html'), 'utf8');
|
||||||
|
const read = (p) => fs.readFileSync(path.join(outDir, p.replace(/^\//, '')), 'utf8');
|
||||||
|
|
||||||
|
html = html.replace(/<link[^>]+rel="preload"[^>]*>/g, ''); // preloads would hit the network
|
||||||
|
html = html.replace(/<link[^>]+rel="stylesheet"[^>]*href="(\/_next[^"]+)"[^>]*>/g, (_, h) => `<style>${read(h)}</style>`);
|
||||||
|
html = html.replace(/<script([^>]*?)src="(\/_next[^"]+)"([^>]*)><\/script>/g, (_, a, src, b) => {
|
||||||
|
const attrs = (a + b).replace(/\s(async|defer|noModule|nomodule)(="")?/g, '');
|
||||||
|
return `<script${attrs}>${read(src).replace(/<\/script/gi, '<\\/script')}</script>`;
|
||||||
|
});
|
||||||
|
|
||||||
|
// The artifact host only scans the first 8 KB for <title>, and wants viewport-fit=cover for safe-area insets.
|
||||||
|
const title = html.match(/<title>[^<]*<\/title>/)?.[0];
|
||||||
|
if (title) html = html.replace(title, '').replace(/<head>/, `<head>${title}`);
|
||||||
|
html = html.replace(/(<meta name="viewport" content="[^"]*?)"/, (m, a) => (a.includes('viewport-fit') ? m : `${a}, viewport-fit=cover"`));
|
||||||
|
|
||||||
|
// The publisher rejects raw U+FFFD as a sign of lost text; in our bundles it only appears inside JS string literals
|
||||||
|
// (URI-decoding fallbacks in dependencies), where the \uFFFD escape means the same thing.
|
||||||
|
html = html.replace(/<script([^>]*)>([\s\S]*?)<\/script>/g, (m, a, body) => (body.includes('\uFFFD') ? `<script${a}>${body.replace(/\uFFFD/g, '\\uFFFD')}</script>` : m));
|
||||||
|
if (html.includes('\uFFFD')) { console.error('U+FFFD outside scripts — find the lost character'); process.exit(1); }
|
||||||
|
|
||||||
|
const leftovers = (html.match(/(src|href)="\/_next\/[^"]+"/g) || []);
|
||||||
|
if (leftovers.length) { console.error('Un-inlined Next assets:', leftovers); process.exit(1); }
|
||||||
|
const mb = Buffer.byteLength(html) / 1024 / 1024;
|
||||||
|
if (mb > 15) { console.error(`Too large for an artifact: ${mb.toFixed(1)} MB (limit 16 MB)`); process.exit(1); }
|
||||||
|
fs.mkdirSync(path.dirname(dest), { recursive: true }); fs.writeFileSync(dest, html);
|
||||||
|
console.log(`Wrote ${dest} (${mb.toFixed(2)} MB)`);
|
||||||
13
tools/i18n-check.mjs
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Fails when a locale catalog is missing keys that en.json has (§12). Usage: node tools/i18n-check.mjs
|
||||||
|
import fs from 'fs';
|
||||||
|
const dir = 'packages/i18n/messages';
|
||||||
|
const flat = (o, p = '') => Object.entries(o).flatMap(([k, v]) => (typeof v === 'object' ? flat(v, p + k + '.') : [p + k]));
|
||||||
|
const en = new Set(flat(JSON.parse(fs.readFileSync(`${dir}/en.json`, 'utf8'))));
|
||||||
|
let bad = 0;
|
||||||
|
for (const loc of ['am', 'om', 'ti']) {
|
||||||
|
const keys = new Set(flat(JSON.parse(fs.readFileSync(`${dir}/${loc}.json`, 'utf8'))));
|
||||||
|
const missing = [...en].filter((k) => !keys.has(k));
|
||||||
|
if (missing.length) { bad++; console.error(`${loc}: missing ${missing.length} keys`, missing.slice(0, 20)); }
|
||||||
|
}
|
||||||
|
console.log(bad ? 'i18n: FAIL' : `i18n: OK (${en.size} keys × 4 locales)`);
|
||||||
|
process.exit(bad ? 1 : 0);
|
||||||
29
tools/preview/runtime-mock.js
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// In-memory stand-in for the artifact runtime (window.claude), for local screenshots only.
|
||||||
|
(() => {
|
||||||
|
const SEED = window.__SEED__ || {}; const store = new Map(Object.entries(SEED).filter(([, v]) => v)); const subs = new Set();
|
||||||
|
const merge = (a, b) => { const o = { ...(a || {}) }; for (const [k, v] of Object.entries(b)) o[k] = v && typeof v === 'object' && !Array.isArray(v) && o[k] && typeof o[k] === 'object' ? merge(o[k], v) : v; return o; };
|
||||||
|
const snapDoc = (p) => ({ id: p.split('/').pop(), exists: store.has(p), data: () => store.get(p), metadata: {} });
|
||||||
|
const notify = () => setTimeout(() => subs.forEach((f) => f()), 0);
|
||||||
|
const query = (col, ord, lim) => ({
|
||||||
|
where: () => query(col, ord, lim), orderBy: (f, d = 'asc') => query(col, [f, d], lim), limit: (n) => query(col, ord, n),
|
||||||
|
get: async () => snapQ(), onSnapshot(next) { const f = () => next(snapQ()); subs.add(f); setTimeout(f, 30); return () => subs.delete(f); },
|
||||||
|
doc: (id = Math.random().toString(36).slice(2)) => docRef(col + '/' + id), path: col,
|
||||||
|
});
|
||||||
|
function snapQ() { return null; }
|
||||||
|
const docRef = (p) => ({ id: p.split('/').pop(), path: p, get: async () => snapDoc(p),
|
||||||
|
set: async (d) => { store.set(p, JSON.parse(JSON.stringify(d))); notify(); }, update: async (d) => { store.set(p, merge(store.get(p), JSON.parse(JSON.stringify(d)))); notify(); },
|
||||||
|
delete: async () => { store.delete(p); notify(); }, onSnapshot(next) { const f = () => next(snapDoc(p)); subs.add(f); setTimeout(f, 30); return () => subs.delete(f); },
|
||||||
|
collection: (c) => collection(p + '/' + c) });
|
||||||
|
function collection(col, ord, lim) {
|
||||||
|
const q = query(col, ord, lim);
|
||||||
|
const run = () => { let docs = [...store.keys()].filter((k) => k.startsWith(col + '/') && k.split('/').length === col.split('/').length + 1).map(snapDoc);
|
||||||
|
if (ord) docs.sort((a, b) => String(a.data()[ord[0]] ?? '').localeCompare(String(b.data()[ord[0]] ?? '')) * (ord[1] === 'desc' ? -1 : 1));
|
||||||
|
if (lim) docs = docs.slice(0, lim); return { docs, size: docs.length, empty: !docs.length, docChanges: () => [], metadata: {} }; };
|
||||||
|
return { ...q, orderBy: (f, d = 'asc') => collection(col, [f, d], lim), limit: (n) => collection(col, ord, n), get: async () => run(),
|
||||||
|
onSnapshot(next) { const f = () => next(run()); subs.add(f); setTimeout(f, 30); return () => subs.delete(f); }, add: async (d) => { const r = docRef(col + '/' + Math.random().toString(36).slice(2)); await r.set(d); return r; } };
|
||||||
|
}
|
||||||
|
const ME = window.__ME__ || { id: 'u_reviewer', name: 'Kirubel', isOwner: true, canEdit: true };
|
||||||
|
const user = { me: async () => ({ ...ME, avatarUrl: '', color: '#888', email: null }), id: async () => ME.id, isOwner: async () => ME.isOwner, canEdit: async () => ME.canEdit, can: async () => null, profiles: async (ids) => Object.fromEntries([].concat(ids).map((i) => [i, { id: i, name: i === ME.id ? ME.name : 'Admin', avatarUrl: '', color: '#888', email: null, isMe: i === ME.id, guest: false }])) };
|
||||||
|
const ns = { db: { doc: docRef, collection }, user, comments: { openComposer: async () => ({ opened: true }) }, downloads: { save: async () => ({ saved: true }) }, assets: null };
|
||||||
|
window.claude = { use: async (n) => ns[n] ?? null };
|
||||||
|
})();
|
||||||
56
tools/preview/smoke.mjs
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
// Click-everything smoke test (SPEC §13.5, L3) against the inlined demo with an in-memory runtime.
|
||||||
|
// Usage: node packages/db/seed/demo-seed.mjs /tmp/seed && node tools/preview/smoke.mjs "$PWD/dist/demo.html" /tmp/seed
|
||||||
|
// Needs puppeteer-core and a local Chrome (not wired into CI yet; W1-14 replaces this with Playwright).
|
||||||
|
import puppeteer from 'puppeteer-core'; import fs from 'fs'; import path from 'path';
|
||||||
|
const [file, seedDir] = process.argv.slice(2);
|
||||||
|
const seed = {}; for (const col of fs.readdirSync(seedDir)) for (const f of fs.readdirSync(path.join(seedDir, col))) seed[`${col}/${f.replace('.json', '')}`] = JSON.parse(fs.readFileSync(path.join(seedDir, col, f), 'utf8'));
|
||||||
|
seed['students/u_reviewer'] = { ...seed['students/sample-2'], id: 'u_reviewer', name: 'Kirubel Kibru', isSample: false };
|
||||||
|
const mock = fs.readFileSync(new URL('./runtime-mock.js', import.meta.url), 'utf8');
|
||||||
|
const routes = [
|
||||||
|
['', 1], ['#/am/signin', 1], ['#/am'], ['#/am/courses'], ['#/en/course/makeup-foundations'], ['#/am/course/bridal-makeup'], ['#/am/learn/makeup-foundations/les-f3'],
|
||||||
|
['#/am/learn/bridal-makeup/les-b4'], ['#/am/checkout/bridal-makeup'], ['#/am/my'], ['#/am/progress'], ['#/am/notifications'], ['#/am/help'], ['#/am/profile'],
|
||||||
|
['#/admin'], ['#/admin/analytics'], ['#/admin/courses'], ['#/admin/courses/crs-foundations/details'], ['#/admin/courses/crs-foundations/curriculum'], ['#/admin/courses/crs-business/details'],
|
||||||
|
['#/admin/categories'], ['#/admin/students'], ['#/admin/students/sample-1'], ['#/admin/orders'], ['#/admin/notifications'], ['#/admin/issues'], ['#/admin/settings'], ['#/admin/admins'], ['#/admin/audit'],
|
||||||
|
];
|
||||||
|
const b = await puppeteer.launch({ executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', headless: true });
|
||||||
|
const problems = []; let clicks = 0;
|
||||||
|
async function open(p, hash, signedOut) {
|
||||||
|
await p.goto('about:blank');
|
||||||
|
await p.goto('file://' + file + hash, { waitUntil: 'domcontentloaded' }); await new Promise((r) => setTimeout(r, 500));
|
||||||
|
}
|
||||||
|
async function worker(list) {
|
||||||
|
const p = await b.newPage(); await p.setViewport({ width: 1280, height: 900 });
|
||||||
|
let errs = []; p.on('pageerror', (e) => errs.push(e.message));
|
||||||
|
await p.evaluateOnNewDocument((s) => { window.__SEED__ = s; }, seed);
|
||||||
|
await p.evaluateOnNewDocument(mock);
|
||||||
|
for (const [hash, signedOut] of list) {
|
||||||
|
await p.evaluateOnNewDocument((so) => { try { so ? localStorage.setItem('lms.signedOut', '1') : localStorage.removeItem('lms.signedOut'); } catch {} }, !!signedOut);
|
||||||
|
await open(p, hash, signedOut);
|
||||||
|
if (errs.length) { problems.push(`${hash} LOAD ERROR ${errs}`); errs = []; }
|
||||||
|
const main = await p.evaluate(() => (document.querySelector('main')?.innerText ?? '').trim().length);
|
||||||
|
if (main < 20) problems.push(`${hash} blank main region`);
|
||||||
|
const n = await p.evaluate(() => [...document.querySelectorAll('button, a[href^="#"]')].filter((e) => e.offsetParent && !e.disabled).length);
|
||||||
|
for (let i = 0; i < Math.min(n, 60); i++) {
|
||||||
|
await open(p, hash, signedOut); errs = [];
|
||||||
|
const res = await p.evaluate(async (i) => {
|
||||||
|
const els = [...document.querySelectorAll('button, a[href^="#"]')].filter((e) => e.offsetParent && !e.disabled);
|
||||||
|
const el = els[i]; if (!el) return null;
|
||||||
|
const label = (el.getAttribute('aria-label') || el.innerText || '').trim().slice(0, 40);
|
||||||
|
if (/feedback|አስተያየት/i.test(label) || el.closest('.s-tabs')) return { label, skip: true };
|
||||||
|
const before = document.body.innerHTML.length + location.hash + document.body.innerText;
|
||||||
|
el.click(); await new Promise((r) => setTimeout(r, 350));
|
||||||
|
const after = document.body.innerHTML.length + location.hash + document.body.innerText;
|
||||||
|
return { label, changed: before !== after };
|
||||||
|
}, i);
|
||||||
|
clicks++;
|
||||||
|
if (!res || res.skip) continue;
|
||||||
|
if (errs.length) problems.push(`${hash} [${res.label}] ERROR ${errs[0]}`);
|
||||||
|
else if (!res.changed) problems.push(`${hash} [${res.label}] no visible change`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await p.close();
|
||||||
|
}
|
||||||
|
const chunks = [[], [], [], []]; routes.forEach((r, i) => chunks[i % 4].push(r));
|
||||||
|
await Promise.all(chunks.map(worker));
|
||||||
|
await b.close();
|
||||||
|
console.log(`clicked ${clicks} controls on ${routes.length} routes`); console.log(problems.length ? problems.join('\n') : 'no problems');
|
||||||
8
tsconfig.base.json
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2022", "lib": ["dom", "dom.iterable", "es2023"], "module": "esnext",
|
||||||
|
"moduleResolution": "bundler", "jsx": "preserve", "strict": true, "skipLibCheck": true,
|
||||||
|
"noEmit": true, "esModuleInterop": true, "resolveJsonModule": true, "isolatedModules": true,
|
||||||
|
"allowImportingTsExtensions": true
|
||||||
|
}
|
||||||
|
}
|
||||||