-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommit_page.tsx
More file actions
225 lines (208 loc) · 6.71 KB
/
commit_page.tsx
File metadata and controls
225 lines (208 loc) · 6.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
"use client";
import { useState, useEffect } from "react";
import { useRouter } from "next/navigation";
import { Brain, Plus, ArrowRight, BookOpen, Clock } from "lucide-react";
import { Card } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
import { Badge } from "@/components/ui/badge";
import { SessionStore, type SessionSummary } from "@/lib/session-store";
function formatDate(iso: string) {
const d = new Date(iso);
return d.toLocaleDateString(undefined, {
month: "short",
day: "numeric",
year: "numeric",
});
}
function SessionCard({
session,
onResume,
}: {
session: SessionSummary;
onResume: (id: string) => void;
}) {
return (
<Card
className="flex flex-col p-5 cursor-pointer transition-colors hover:border-[var(--color-primary)]/30"
onClick={() => onResume(session.sessionId)}
>
<div className="flex items-center justify-between mb-3">
<Badge
variant={session.learningPathCreated ? "default" : "outline"}
className="text-xs"
>
{session.learningPathCreated ? "Path Created" : "In Progress"}
</Badge>
<span
className="text-xs"
style={{ color: "var(--color-muted-foreground)" }}
>
{formatDate(session.updatedAt)}
</span>
</div>
<h3
className="text-sm font-semibold mb-2 line-clamp-2"
style={{ color: "var(--color-foreground)" }}
>
{session.objective || "New conversation"}
</h3>
{session.skills.length > 0 && (
<div className="flex flex-wrap gap-1.5 mb-3">
{session.skills.slice(0, 4).map((skill, idx) => (
<span
key={idx}
className="text-xs px-2 py-0.5 rounded-full"
style={{
backgroundColor: "rgba(139, 92, 246, 0.1)",
color: "var(--color-primary)",
}}
>
{skill}
</span>
))}
{session.skills.length > 4 && (
<span
className="text-xs px-2 py-0.5"
style={{ color: "var(--color-muted-foreground)" }}
>
+{session.skills.length - 4} more
</span>
)}
</div>
)}
{session.skillLevel && (
<p
className="text-xs mb-3"
style={{ color: "var(--color-muted-foreground)" }}
>
Level: {session.skillLevel}
</p>
)}
<div className="mt-auto pt-3 border-t" style={{ borderColor: "var(--color-border)" }}>
<Button variant="ghost" size="sm" className="w-full gap-1 text-xs">
Resume <ArrowRight className="h-3 w-3" />
</Button>
</div>
</Card>
);
}
export default function Page() {
const router = useRouter();
const [sessions, setSessions] = useState<SessionSummary[]>([]);
const [isLoaded, setIsLoaded] = useState(false);
useEffect(() => {
setSessions(SessionStore.getAllSessions());
setIsLoaded(true);
}, []);
const handleResume = (sessionId: string) => {
router.push(`/chat?session=${sessionId}`);
};
const handleNewSession = () => {
const newId = SessionStore.generateSessionId();
router.push(`/chat?session=${newId}`);
};
const sessionsWithPaths = sessions.filter((s) => s.learningPathCreated);
const sessionsInProgress = sessions.filter(
(s) => !s.learningPathCreated && s.objective,
);
return (
<main className="min-h-screen p-6 md:p-12">
<div className="max-w-5xl mx-auto">
{/* Header */}
<div className="mb-12 text-center">
<div
className="mb-4 inline-flex items-center justify-center w-16 h-16 rounded-2xl"
style={{ backgroundColor: "rgba(139, 92, 246, 0.1)" }}
>
<Brain
className="h-8 w-8"
style={{ color: "var(--color-primary)" }}
/>
</div>
<h1
className="text-4xl font-bold tracking-tight mb-2"
style={{
fontFamily: "var(--font-display)",
color: "var(--color-foreground)",
}}
>
MentorAI
</h1>
<p
className="text-lg max-w-2xl mx-auto"
style={{ color: "var(--color-muted-foreground)" }}
>
Your AI-powered guide to personalized learning paths
</p>
</div>
{/* New Session CTA */}
<div className="mb-10 flex justify-center">
<Button onClick={handleNewSession} size="lg" className="gap-2">
<Plus className="h-5 w-5" />
Start New Learning Path
</Button>
</div>
{/* Completed learning paths */}
{sessionsWithPaths.length > 0 && (
<section className="mb-10">
<h2
className="text-xl font-semibold mb-4 flex items-center gap-2"
style={{ color: "var(--color-foreground)" }}
>
<BookOpen
className="h-5 w-5"
style={{ color: "var(--color-primary)" }}
/>
Your Learning Paths
</h2>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
{sessionsWithPaths.map((session) => (
<SessionCard
key={session.sessionId}
session={session}
onResume={handleResume}
/>
))}
</div>
</section>
)}
{/* In-progress sessions */}
{sessionsInProgress.length > 0 && (
<section className="mb-10">
<h2
className="text-xl font-semibold mb-4 flex items-center gap-2"
style={{ color: "var(--color-foreground)" }}
>
<Clock
className="h-5 w-5"
style={{ color: "var(--color-primary)" }}
/>
In Progress
</h2>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
{sessionsInProgress.map((session) => (
<SessionCard
key={session.sessionId}
session={session}
onResume={handleResume}
/>
))}
</div>
</section>
)}
{/* Empty state */}
{isLoaded && sessions.length === 0 && (
<div
className="text-center py-20"
style={{ color: "var(--color-muted-foreground)" }}
>
<p className="text-lg mb-2">No learning paths yet</p>
<p className="text-sm">
Click "Start New Learning Path" to begin your journey
</p>
</div>
)}
</div>
</main>
);
}