Frontend - i18n: install tailwindcss-rtl, Cairo font, RTL-aware direction in index.css. - Language toggle: localize aria-label / menu label, persist choice, update document dir synchronously. - Sidebar: add `side` prop so the drawer pins to the right in RTL; wire up AdminLmsLayout, RoleLayout (student/teacher) and AppSidebar to pass side = i18n.dir() === 'rtl' ? 'right' : 'left'. - AdminLmsLayout: convert every nav item from hard-coded title to titleKey, translate group labels (incl. the collapsible Training), breadcrumbs, user menu (Profile / Settings / Logout), help button and toggle aria labels; replace physical mr-/right- utilities with logical me-/end-. - AI components (AiTipBanner, AiInsightsPanel, AiAlertBanner, AiSearchBar, AiAssistantDrawer): apply dir="auto" at the container level, localize titles, loading / error / empty states. - Dashboards (admin / student / teacher): wrap numeric values in <bdi>, localize dates via ar-EG, fix flex direction for KPI and assignment cards. - UI primitives (breadcrumb, calendar, carousel, dropdown-menu, menubar, context-menu, pagination, sidebar): flip chevrons in RTL via a scoped CSS rule, swap pl-/pr-/ml-/mr- for ps-/pe-/ms-/me-. - Add logical-direction helpers and bidirectional isolation classes. Locales - Expand en.ts and ar.ts with full `nav`, `sidebarGroup`, `breadcrumb`, `userMenu`, `chrome`, `ai`, and dashboard key sets; keep key parity. API client - `api-client.ts` reads the active language from localStorage/i18n and sends `Accept-Language` on every request so the backend can localize AI output. Backend (encoach_ai) - openai_service: add _LANGUAGE_NAMES, normalize_language, language-aware system prompt injection for every OpenAI call. - coach_service + controllers (coach_controller, ai_controller): thread the requested language from headers / user locale down to OpenAIService. - ai_feedback: fix latent registry error by pointing course_id at op.course instead of the non-existent encoach.course. Other - .gitignore: ignore runtime odoo logs and local caches. Made-with: Cursor
87 lines
4.1 KiB
TypeScript
87 lines
4.1 KiB
TypeScript
import { useNavigate } from "react-router-dom";
|
|
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Progress } from "@/components/ui/progress";
|
|
import { BookOpen, ArrowRight } from "lucide-react";
|
|
import { useSubjects, useProficiencySummary } from "@/hooks/queries";
|
|
|
|
export default function SubjectSelection() {
|
|
const navigate = useNavigate();
|
|
const { data: subjects = [], isLoading: ls } = useSubjects();
|
|
const { data: summaries = [], isLoading: lp } = useProficiencySummary();
|
|
|
|
if (ls || lp) return <div className="flex items-center justify-center min-h-[400px]"><div className="animate-spin rounded-full h-8 w-8 border-b-2 border-primary" /></div>;
|
|
|
|
const getSummary = (subjectId: number) => summaries.find(s => s.subject_id === subjectId);
|
|
|
|
return (
|
|
<div className="space-y-6">
|
|
<div>
|
|
<h1 className="text-2xl font-bold">My Subjects</h1>
|
|
<p className="text-muted-foreground">Select a subject to view your progress or start a diagnostic assessment.</p>
|
|
</div>
|
|
|
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
|
{subjects.map((subject) => {
|
|
const summary = getSummary(subject.id);
|
|
const mastery = summary?.overall_mastery ?? 0;
|
|
const hasTaken = !!summary;
|
|
|
|
return (
|
|
<Card key={subject.id} className="hover:shadow-md transition-shadow">
|
|
<CardHeader>
|
|
<div className="flex items-center gap-3">
|
|
<div className="h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center">
|
|
<BookOpen className="h-5 w-5 text-primary" />
|
|
</div>
|
|
<div>
|
|
<CardTitle className="text-lg">{subject.name}</CardTitle>
|
|
<CardDescription>{subject.code}</CardDescription>
|
|
</div>
|
|
</div>
|
|
</CardHeader>
|
|
<CardContent className="space-y-4">
|
|
{hasTaken ? (
|
|
<>
|
|
<div className="space-y-2">
|
|
<div className="flex justify-between text-sm">
|
|
<span className="text-muted-foreground">Overall Mastery</span>
|
|
<span className="font-medium">{Math.round(mastery)}%</span>
|
|
</div>
|
|
<Progress value={mastery} className="h-2" />
|
|
</div>
|
|
<div className="flex items-center justify-between text-sm text-muted-foreground">
|
|
<span>{summary?.topics_mastered ?? 0} / {summary?.topics_total ?? 0} topics mastered</span>
|
|
</div>
|
|
<div className="flex gap-2">
|
|
<Button variant="outline" size="sm" className="flex-1" onClick={() => navigate(`/student/proficiency/${subject.id}`)}>
|
|
View Profile
|
|
</Button>
|
|
<Button size="sm" className="flex-1" onClick={() => navigate(`/student/plan/${subject.id}`)}>
|
|
Learning Plan <ArrowRight className="ms-1 h-3 w-3 rtl:rotate-180" />
|
|
</Button>
|
|
</div>
|
|
</>
|
|
) : (
|
|
<>
|
|
<p className="text-sm text-muted-foreground">Take a diagnostic assessment to discover your proficiency level and get a personalized learning plan.</p>
|
|
<Button className="w-full" onClick={() => navigate(`/student/diagnostic/${subject.id}`)}>
|
|
Start Diagnostic <ArrowRight className="ms-1 h-4 w-4 rtl:rotate-180" />
|
|
</Button>
|
|
</>
|
|
)}
|
|
</CardContent>
|
|
</Card>
|
|
);
|
|
})}
|
|
{subjects.length === 0 && (
|
|
<div className="col-span-full text-center py-12 text-muted-foreground">
|
|
<BookOpen className="h-12 w-12 mx-auto mb-3 opacity-40" />
|
|
<p>No subjects available yet.</p>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|