SarahXia0405 commited on
Commit
50f2833
·
verified ·
1 Parent(s): dd5cc20

Update web/src/components/RightPanel.tsx

Browse files
Files changed (1) hide show
  1. web/src/components/RightPanel.tsx +76 -25
web/src/components/RightPanel.tsx CHANGED
@@ -6,7 +6,7 @@ import { Card } from './ui/card';
6
  import { Separator } from './ui/separator';
7
  import { Textarea } from './ui/textarea';
8
  import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './ui/select';
9
- import { LogIn, LogOut, FileText, MessageSquare } from 'lucide-react';
10
  import type { User } from '../App';
11
  import { toast } from 'sonner';
12
  import {
@@ -20,7 +20,7 @@ import {
20
 
21
  interface RightPanelProps {
22
  user: User | null;
23
- onLogin: (name: string, emailOrId: string) => Promise<void>;
24
  onLogout: () => void;
25
  isLoggedIn: boolean;
26
  onClose?: () => void;
@@ -29,6 +29,11 @@ interface RightPanelProps {
29
  setExportResult: (result: string) => void;
30
  resultType: 'export' | 'quiz' | 'summary' | null;
31
  setResultType: (type: 'export' | 'quiz' | 'summary' | null) => void;
 
 
 
 
 
32
  }
33
 
34
  export function RightPanel({
@@ -41,30 +46,27 @@ export function RightPanel({
41
  setExportResult,
42
  resultType,
43
  setResultType,
 
 
 
44
  }: RightPanelProps) {
45
  const [showLoginForm, setShowLoginForm] = useState(false);
46
  const [name, setName] = useState('');
47
- const [emailOrId, setEmailOrId] = useState('');
48
- const [isLoggingIn, setIsLoggingIn] = useState(false);
49
 
50
  const [feedbackDialogOpen, setFeedbackDialogOpen] = useState(false);
51
  const [feedbackText, setFeedbackText] = useState('');
52
  const [feedbackCategory, setFeedbackCategory] = useState<'general' | 'bug' | 'feature'>('general');
53
 
54
- const handleLoginClick = async () => {
55
- if (!name.trim() || !emailOrId.trim()) {
56
  toast.error('Please fill in all fields');
57
  return;
58
  }
59
- try {
60
- setIsLoggingIn(true);
61
- await onLogin(name.trim(), emailOrId.trim());
62
- setShowLoginForm(false);
63
- setName('');
64
- setEmailOrId('');
65
- } finally {
66
- setIsLoggingIn(false);
67
- }
68
  };
69
 
70
  const handleLogoutClick = () => {
@@ -77,7 +79,6 @@ export function RightPanel({
77
  toast.error('Please provide feedback text');
78
  return;
79
  }
80
- // 这里是“产品总体反馈”,不是 message-level feedback
81
  console.log('Feedback submitted:', feedbackText, feedbackCategory);
82
  setFeedbackDialogOpen(false);
83
  setFeedbackText('');
@@ -86,6 +87,7 @@ export function RightPanel({
86
 
87
  return (
88
  <div className="flex-1 overflow-auto p-4 space-y-4">
 
89
  <Card className="p-4">
90
  {!isLoggedIn ? (
91
  <div className="space-y-4">
@@ -113,19 +115,19 @@ export function RightPanel({
113
  />
114
  </div>
115
  <div className="space-y-2">
116
- <Label htmlFor="emailOrId">Email / Student ID</Label>
117
  <Input
118
- id="emailOrId"
119
- value={emailOrId}
120
- onChange={(e) => setEmailOrId(e.target.value)}
121
  placeholder="Enter your email or ID"
122
  />
123
  </div>
124
  <div className="flex gap-2">
125
- <Button onClick={handleLoginClick} className="flex-1" disabled={isLoggingIn}>
126
- {isLoggingIn ? 'Logging in...' : 'Enter'}
127
  </Button>
128
- <Button variant="outline" onClick={() => setShowLoginForm(false)} disabled={isLoggingIn}>
129
  Cancel
130
  </Button>
131
  </div>
@@ -153,8 +155,55 @@ export function RightPanel({
153
  )}
154
  </Card>
155
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  <Separator />
157
 
 
158
  <div className="space-y-3">
159
  <h3>
160
  {resultType === 'export' && 'Exported Conversation'}
@@ -191,6 +240,7 @@ export function RightPanel({
191
 
192
  <Separator />
193
 
 
194
  <div className="space-y-3">
195
  <h3>Feedback</h3>
196
  <Button
@@ -207,7 +257,9 @@ export function RightPanel({
207
  <DialogContent className="sm:max-w-[425px]">
208
  <DialogHeader>
209
  <DialogTitle>Provide Feedback</DialogTitle>
210
- <DialogDescription>Help us improve Clare by sharing your thoughts and suggestions.</DialogDescription>
 
 
211
  </DialogHeader>
212
 
213
  <div className="space-y-3">
@@ -248,4 +300,3 @@ export function RightPanel({
248
  </div>
249
  );
250
  }
251
-
 
6
  import { Separator } from './ui/separator';
7
  import { Textarea } from './ui/textarea';
8
  import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './ui/select';
9
+ import { LogIn, LogOut, FileText, MessageSquare, Download, ClipboardList, Sparkles } from 'lucide-react';
10
  import type { User } from '../App';
11
  import { toast } from 'sonner';
12
  import {
 
20
 
21
  interface RightPanelProps {
22
  user: User | null;
23
+ onLogin: (name: string, email: string) => void;
24
  onLogout: () => void;
25
  isLoggedIn: boolean;
26
  onClose?: () => void;
 
29
  setExportResult: (result: string) => void;
30
  resultType: 'export' | 'quiz' | 'summary' | null;
31
  setResultType: (type: 'export' | 'quiz' | 'summary' | null) => void;
32
+
33
+ // ✅ 新增:右侧面板里的三个 action 按钮
34
+ onExport: () => void;
35
+ onQuiz: () => void;
36
+ onSummary: () => void;
37
  }
38
 
39
  export function RightPanel({
 
46
  setExportResult,
47
  resultType,
48
  setResultType,
49
+ onExport,
50
+ onQuiz,
51
+ onSummary,
52
  }: RightPanelProps) {
53
  const [showLoginForm, setShowLoginForm] = useState(false);
54
  const [name, setName] = useState('');
55
+ const [email, setEmail] = useState('');
 
56
 
57
  const [feedbackDialogOpen, setFeedbackDialogOpen] = useState(false);
58
  const [feedbackText, setFeedbackText] = useState('');
59
  const [feedbackCategory, setFeedbackCategory] = useState<'general' | 'bug' | 'feature'>('general');
60
 
61
+ const handleLoginClick = () => {
62
+ if (!name.trim() || !email.trim()) {
63
  toast.error('Please fill in all fields');
64
  return;
65
  }
66
+ onLogin(name.trim(), email.trim());
67
+ setShowLoginForm(false);
68
+ setName('');
69
+ setEmail('');
 
 
 
 
 
70
  };
71
 
72
  const handleLogoutClick = () => {
 
79
  toast.error('Please provide feedback text');
80
  return;
81
  }
 
82
  console.log('Feedback submitted:', feedbackText, feedbackCategory);
83
  setFeedbackDialogOpen(false);
84
  setFeedbackText('');
 
87
 
88
  return (
89
  <div className="flex-1 overflow-auto p-4 space-y-4">
90
+ {/* ===== Login Card ===== */}
91
  <Card className="p-4">
92
  {!isLoggedIn ? (
93
  <div className="space-y-4">
 
115
  />
116
  </div>
117
  <div className="space-y-2">
118
+ <Label htmlFor="email">Email / Student ID</Label>
119
  <Input
120
+ id="email"
121
+ value={email}
122
+ onChange={(e) => setEmail(e.target.value)}
123
  placeholder="Enter your email or ID"
124
  />
125
  </div>
126
  <div className="flex gap-2">
127
+ <Button onClick={handleLoginClick} className="flex-1">
128
+ Enter
129
  </Button>
130
+ <Button variant="outline" onClick={() => setShowLoginForm(false)}>
131
  Cancel
132
  </Button>
133
  </div>
 
155
  )}
156
  </Card>
157
 
158
+ {/* ✅ 这里加三按钮:在 login 下面、Results 上面 */}
159
+ <Card className="p-4 space-y-2">
160
+ <h3 className="text-sm font-medium">Actions</h3>
161
+
162
+ <div className="grid grid-cols-3 gap-2">
163
+ <Button
164
+ variant="outline"
165
+ className="gap-2"
166
+ onClick={onExport}
167
+ disabled={!isLoggedIn}
168
+ title="Export Conversation"
169
+ >
170
+ <Download className="h-4 w-4" />
171
+ <span className="hidden xl:inline">Export</span>
172
+ </Button>
173
+
174
+ <Button
175
+ variant="outline"
176
+ className="gap-2"
177
+ onClick={onQuiz}
178
+ disabled={!isLoggedIn}
179
+ title="Micro-Quiz"
180
+ >
181
+ <ClipboardList className="h-4 w-4" />
182
+ <span className="hidden xl:inline">Quiz</span>
183
+ </Button>
184
+
185
+ <Button
186
+ variant="outline"
187
+ className="gap-2"
188
+ onClick={onSummary}
189
+ disabled={!isLoggedIn}
190
+ title="Summarization"
191
+ >
192
+ <Sparkles className="h-4 w-4" />
193
+ <span className="hidden xl:inline">Summary</span>
194
+ </Button>
195
+ </div>
196
+
197
+ {!isLoggedIn && (
198
+ <p className="text-xs text-muted-foreground mt-1">
199
+ Log in to enable export / quiz / summary.
200
+ </p>
201
+ )}
202
+ </Card>
203
+
204
  <Separator />
205
 
206
+ {/* ===== Results ===== */}
207
  <div className="space-y-3">
208
  <h3>
209
  {resultType === 'export' && 'Exported Conversation'}
 
240
 
241
  <Separator />
242
 
243
+ {/* ===== Feedback ===== */}
244
  <div className="space-y-3">
245
  <h3>Feedback</h3>
246
  <Button
 
257
  <DialogContent className="sm:max-w-[425px]">
258
  <DialogHeader>
259
  <DialogTitle>Provide Feedback</DialogTitle>
260
+ <DialogDescription>
261
+ Help us improve Clare by sharing your thoughts and suggestions.
262
+ </DialogDescription>
263
  </DialogHeader>
264
 
265
  <div className="space-y-3">
 
300
  </div>
301
  );
302
  }