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
129 lines
6.0 KiB
TypeScript
129 lines
6.0 KiB
TypeScript
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Badge } from "@/components/ui/badge";
|
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
|
import { BookOpen, Users, ClipboardList, TrendingUp, ArrowRight } from "lucide-react";
|
|
import { Link } from "react-router-dom";
|
|
import { useTranslation } from "react-i18next";
|
|
import { useCourses, useAssignments } from "@/hooks/queries";
|
|
import AiInsightsPanel from "@/components/ai/AiInsightsPanel";
|
|
import AiTipBanner from "@/components/ai/AiTipBanner";
|
|
|
|
export default function TeacherDashboard() {
|
|
const { t } = useTranslation();
|
|
const { data: coursesData, isLoading: lc } = useCourses();
|
|
const { data: assignmentsData, isLoading: la } = useAssignments();
|
|
const courses = coursesData?.items ?? [];
|
|
const assignments = assignmentsData?.items ?? [];
|
|
const submissions: unknown[] = [];
|
|
const activityFeed: { id: string; action: string; user: string; target: string; time: string }[] = [];
|
|
if (lc || la) 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 teacherCourses = courses;
|
|
const pendingGrading = (submissions as { id: string; studentName: string; submittedAt: string; status: string }[]).filter(s => s.status === "pending");
|
|
|
|
const stats = [
|
|
{ label: t("teacherDash.activeCourses"), value: String(teacherCourses.filter(c => c.status === "active").length), icon: BookOpen, color: "text-primary" },
|
|
{ label: t("teacherDash.totalStudents"), value: "55", icon: Users, color: "text-info" },
|
|
{ label: t("teacherDash.pendingGrading"), value: String(pendingGrading.length), icon: ClipboardList, color: "text-warning" },
|
|
{ label: t("teacherDash.avgPassRate"), value: "82%", icon: TrendingUp, color: "text-success" },
|
|
];
|
|
|
|
return (
|
|
<div className="space-y-6">
|
|
<div>
|
|
<h1 className="text-2xl font-bold">{t("teacherDash.title")}</h1>
|
|
<p className="text-muted-foreground">{t("teacherDash.subtitle")}</p>
|
|
</div>
|
|
|
|
<AiTipBanner context="teacher-dashboard" variant="recommendation" />
|
|
|
|
<AiInsightsPanel />
|
|
|
|
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
|
{stats.map(s => (
|
|
<Card key={s.label}>
|
|
<CardContent className="pt-6">
|
|
<div className="flex items-center justify-between gap-3">
|
|
<div className="min-w-0"><p className="text-sm text-muted-foreground">{s.label}</p><p className="text-2xl font-bold"><bdi>{s.value}</bdi></p></div>
|
|
<s.icon className={`h-8 w-8 ${s.color} opacity-80 shrink-0`} />
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
))}
|
|
</div>
|
|
|
|
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
|
<Card>
|
|
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
|
<CardTitle className="text-lg">{t("teacherDash.myCourses")}</CardTitle>
|
|
<Button variant="ghost" size="sm" asChild>
|
|
<Link to="/teacher/courses">
|
|
{t("common.viewAll")} <ArrowRight className="ms-1 h-3 w-3 rtl:rotate-180" />
|
|
</Link>
|
|
</Button>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<Table>
|
|
<TableHeader>
|
|
<TableRow>
|
|
<TableHead>{t("teacherDash.colCourse")}</TableHead>
|
|
<TableHead>{t("teacherDash.colStudents")}</TableHead>
|
|
<TableHead>{t("teacherDash.colStatus")}</TableHead>
|
|
</TableRow>
|
|
</TableHeader>
|
|
<TableBody>
|
|
{teacherCourses.map(c => (
|
|
<TableRow key={c.id}>
|
|
<TableCell className="font-medium" dir="auto">{c.title}</TableCell>
|
|
<TableCell><bdi>{c.enrolled}/{c.max_capacity}</bdi></TableCell>
|
|
<TableCell><Badge variant={c.status === "active" ? "default" : "secondary"} className="capitalize">{c.status}</Badge></TableCell>
|
|
</TableRow>
|
|
))}
|
|
</TableBody>
|
|
</Table>
|
|
</CardContent>
|
|
</Card>
|
|
|
|
<div className="space-y-6">
|
|
<Card>
|
|
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
|
<CardTitle className="text-lg">{t("teacherDash.pendingGrading")}</CardTitle>
|
|
<Button variant="ghost" size="sm" asChild>
|
|
<Link to="/teacher/assignments">
|
|
{t("common.viewAll")} <ArrowRight className="ms-1 h-3 w-3 rtl:rotate-180" />
|
|
</Link>
|
|
</Button>
|
|
</CardHeader>
|
|
<CardContent className="space-y-3">
|
|
{pendingGrading.slice(0, 4).map(s => (
|
|
<div key={s.id} className="flex items-center justify-between p-2 rounded border">
|
|
<div>
|
|
<p className="text-sm font-medium">{s.studentName}</p>
|
|
<p className="text-xs text-muted-foreground">
|
|
{t("teacherDash.submitted", { when: s.submittedAt })}
|
|
</p>
|
|
</div>
|
|
<Badge variant="secondary">{t("teacherDash.pending")}</Badge>
|
|
</div>
|
|
))}
|
|
</CardContent>
|
|
</Card>
|
|
|
|
<Card>
|
|
<CardHeader><CardTitle className="text-lg">{t("teacherDash.recentActivity")}</CardTitle></CardHeader>
|
|
<CardContent className="space-y-2">
|
|
{activityFeed.slice(0, 4).map(a => (
|
|
<div key={a.id} className="text-sm">
|
|
<span className="font-medium">{a.user}</span> <span className="text-muted-foreground">{a.action}</span> <span>{a.target}</span>
|
|
<span className="text-xs text-muted-foreground ms-2">· {a.time}</span>
|
|
</div>
|
|
))}
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|