Polish Novya UI with brand colors, first-load skeletons, and session transition overlay.
Keep chat pinned to the latest message while AI thinks or streams, and align buttons/inputs with the logo teal/blue focus treatment. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,11 +6,12 @@ import { PROGRAM_SESSION_COUNT } from '@/data/program/sessions';
|
||||
import { getProgramProgress } from '@/services/programService';
|
||||
import { Progress } from '@/components/ui/progress';
|
||||
import { Navigate, useNavigate } from 'react-router-dom';
|
||||
import { Check, ChevronLeft, Loader2, Lock } from 'lucide-react';
|
||||
import { Check, ChevronLeft, Lock } from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { StaggeredList, StaggerItem, AnimationWrapper } from '@/components/motion';
|
||||
import { motion } from 'framer-motion';
|
||||
import { fastTransition } from '@/lib/motion';
|
||||
import { CourseStatusSkeleton } from '@/components/skeletons';
|
||||
|
||||
type StepState = 'open' | 'locked' | 'done';
|
||||
|
||||
@@ -19,17 +20,14 @@ type StepState = 'open' | 'locked' | 'done';
|
||||
* Journey status only — no settings, scores, or assessment results.
|
||||
*/
|
||||
export default function AccountPage() {
|
||||
const { effectiveUserId, isGuest, guestSessionHydrated } = useAuth();
|
||||
const { effectiveUserId, isGuest, guestSessionHydrated, user } = useAuth();
|
||||
const { progress, loading, permissions } = useLearningJourney(effectiveUserId ?? undefined);
|
||||
const { currentSession, isProgramComplete, programProgress } = useCurrentSession(effectiveUserId);
|
||||
const navigate = useNavigate();
|
||||
const usernameLabel = isGuest ? 'مهمان' : user?.email?.trim() || null;
|
||||
|
||||
if (!guestSessionHydrated || loading) {
|
||||
return (
|
||||
<div className="flex min-h-[50vh] items-center justify-center">
|
||||
<Loader2 className="h-8 w-8 animate-spin text-neon-cyan" />
|
||||
</div>
|
||||
);
|
||||
return <CourseStatusSkeleton />;
|
||||
}
|
||||
|
||||
if (!effectiveUserId) {
|
||||
@@ -48,6 +46,10 @@ export default function AccountPage() {
|
||||
: Math.round((completedSessions / PROGRAM_SESSION_COUNT) * 100);
|
||||
|
||||
const preDone = Boolean(progress?.pre_test_completed_at);
|
||||
const reachedFinalSession =
|
||||
Boolean(progress?.training_completed_at) ||
|
||||
completedSessions >= PROGRAM_SESSION_COUNT - 1 ||
|
||||
programDone;
|
||||
const trainingDone = Boolean(progress?.training_completed_at) || programDone;
|
||||
const postDone = Boolean(progress?.post_test_completed_at);
|
||||
|
||||
@@ -63,16 +65,23 @@ export default function AccountPage() {
|
||||
: 'open';
|
||||
const postState: StepState = postDone
|
||||
? 'done'
|
||||
: permissions.canTakePostTest || (trainingDone && preDone && !postDone)
|
||||
: permissions.canTakePostTest || (reachedFinalSession && preDone && !postDone)
|
||||
? 'open'
|
||||
: 'locked';
|
||||
|
||||
return (
|
||||
<div className="h-full min-h-0 flex-1 overflow-y-auto px-4 py-6">
|
||||
<div className="h-full min-h-0 flex-1 overflow-y-auto bg-slate-50 px-4 py-6 transition-colors duration-300 dark:bg-slate-900">
|
||||
<div className="mx-auto w-full max-w-md space-y-4">
|
||||
<AnimationWrapper immediate className="space-y-1 pb-2">
|
||||
<h1 className="text-2xl font-bold tracking-tight text-foreground">وضعیت دوره</h1>
|
||||
{isGuest && <p className="text-sm text-body">جلسه مهمان</p>}
|
||||
{usernameLabel && (
|
||||
<p className="text-sm text-body">
|
||||
نام کاربری:{' '}
|
||||
<span className="font-medium text-foreground" dir="ltr">
|
||||
{usernameLabel}
|
||||
</span>
|
||||
</p>
|
||||
)}
|
||||
</AnimationWrapper>
|
||||
|
||||
<StaggeredList itemCount={3} className="space-y-3" role="region" aria-label="وضعیت دوره">
|
||||
@@ -114,7 +123,7 @@ export default function AccountPage() {
|
||||
</p>
|
||||
<div className="flex items-center gap-3">
|
||||
<Progress value={progressPercent} className="h-2.5 flex-1" />
|
||||
<span className="min-w-[2.5rem] text-left text-sm tabular-nums text-body">
|
||||
<span className="min-w-[2.75rem] text-left text-sm font-semibold tabular-nums text-foreground">
|
||||
{progressPercent}٪
|
||||
</span>
|
||||
</div>
|
||||
@@ -131,14 +140,14 @@ export default function AccountPage() {
|
||||
lockedHint={
|
||||
postDone
|
||||
? 'انجام شده — قابل تکرار نیست'
|
||||
: 'پس از پایان دوره آموزشی فعال میشود'
|
||||
: 'پس از رسیدن به جلسه پایانی فعال میشود'
|
||||
}
|
||||
>
|
||||
{postState === 'done' && <StatusDone label="انجام شده" />}
|
||||
{postState === 'open' && (
|
||||
<p className="flex items-center gap-2 text-sm font-medium text-foreground">
|
||||
<span
|
||||
className="inline-block h-2 w-2 shrink-0 rounded-full bg-neon-teal shadow-[0_0_8px_rgba(52,184,150,0.7)]"
|
||||
className="inline-block h-2 w-2 shrink-0 rounded-full bg-teal-500 dark:bg-teal-400"
|
||||
aria-hidden
|
||||
/>
|
||||
آماده انجام
|
||||
@@ -147,7 +156,7 @@ export default function AccountPage() {
|
||||
{postState === 'locked' && (
|
||||
<p className="flex items-start gap-2 text-sm text-body">
|
||||
<Lock className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" aria-hidden />
|
||||
<span>پس از پایان دوره فعال میشود</span>
|
||||
<span>پس از رسیدن به جلسه پایانی فعال میشود</span>
|
||||
</p>
|
||||
)}
|
||||
</StatusRow>
|
||||
@@ -180,12 +189,12 @@ function StatusRow({
|
||||
{children}
|
||||
</div>
|
||||
{isInteractive ? (
|
||||
<ChevronLeft className="mt-0.5 h-5 w-5 shrink-0 text-neon-cyan" aria-hidden />
|
||||
<ChevronLeft className="mt-0.5 h-5 w-5 shrink-0 text-sky-600 dark:text-sky-400" aria-hidden />
|
||||
) : (
|
||||
<Lock
|
||||
className={cn(
|
||||
'mt-0.5 h-4 w-4 shrink-0',
|
||||
state === 'done' ? 'text-neon-emerald/70' : 'text-muted-foreground'
|
||||
state === 'done' ? 'text-emerald-600/80 dark:text-emerald-400/70' : 'text-muted-foreground'
|
||||
)}
|
||||
aria-hidden
|
||||
/>
|
||||
@@ -201,7 +210,14 @@ function StatusRow({
|
||||
whileHover={{ scale: 1.02 }}
|
||||
whileTap={{ scale: 0.98 }}
|
||||
transition={fastTransition}
|
||||
className="glass-panel w-full px-4 py-4 text-right transition-colors duration-200 hover:border-neon-cyan/55 hover:shadow-[0_0_18px_rgba(72,180,200,0.22)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neon-cyan/50"
|
||||
className={cn(
|
||||
'status-card w-full rounded-2xl px-4 py-4 text-right transition-all duration-200',
|
||||
'border border-slate-200/90 bg-gradient-to-b from-white to-slate-50/80',
|
||||
'hover:border-sky-300/80 hover:from-white hover:to-sky-50/40',
|
||||
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-400/40',
|
||||
'dark:border-slate-700/50 dark:from-slate-800/90 dark:to-slate-900/80',
|
||||
'dark:hover:border-slate-600 dark:hover:from-slate-800 dark:hover:to-slate-800/90'
|
||||
)}
|
||||
aria-label={`${title} — باز کردن`}
|
||||
>
|
||||
{content}
|
||||
@@ -211,7 +227,11 @@ function StatusRow({
|
||||
|
||||
return (
|
||||
<div
|
||||
className="glass-panel w-full px-4 py-4 opacity-90"
|
||||
className={cn(
|
||||
'status-card w-full rounded-2xl px-4 py-4 opacity-90',
|
||||
'border border-slate-200/80 bg-gradient-to-b from-white to-slate-50/70',
|
||||
'dark:border-slate-700/50 dark:from-slate-800/70 dark:to-slate-900/60'
|
||||
)}
|
||||
aria-disabled="true"
|
||||
title={lockedHint}
|
||||
>
|
||||
@@ -223,7 +243,7 @@ function StatusRow({
|
||||
function StatusDone({ label }: { label: string }) {
|
||||
return (
|
||||
<p className="flex items-center gap-2 text-sm font-medium text-foreground">
|
||||
<Check className="h-4 w-4 shrink-0 text-neon-emerald" aria-hidden />
|
||||
<Check className="h-4 w-4 shrink-0 text-emerald-600 dark:text-emerald-400" aria-hidden />
|
||||
{label}
|
||||
</p>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user