SarahXia0405 commited on
Commit
56b7341
·
verified ·
1 Parent(s): 76c4923

Update web/src/components/RightPanel.tsx

Browse files
Files changed (1) hide show
  1. web/src/components/RightPanel.tsx +26 -30
web/src/components/RightPanel.tsx CHANGED
@@ -1,4 +1,3 @@
1
- // web/src/components/RightPanel.tsx
2
  import React, { useState } from 'react';
3
  import { Button } from './ui/button';
4
  import { Input } from './ui/input';
@@ -10,11 +9,18 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '.
10
  import { LogIn, LogOut, FileText, MessageSquare } from 'lucide-react';
11
  import type { User } from '../App';
12
  import { toast } from 'sonner';
13
- import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogFooter } from './ui/dialog';
 
 
 
 
 
 
 
14
 
15
  interface RightPanelProps {
16
  user: User | null;
17
- onLogin: (user: User) => void;
18
  onLogout: () => void;
19
  isLoggedIn: boolean;
20
  onClose?: () => void;
@@ -23,10 +29,6 @@ interface RightPanelProps {
23
  setExportResult: (result: string) => void;
24
  resultType: 'export' | 'quiz' | 'summary' | null;
25
  setResultType: (type: 'export' | 'quiz' | 'summary' | null) => void;
26
-
27
- onExport: () => void;
28
- onQuiz: () => void;
29
- onSummary: () => void;
30
  }
31
 
32
  export function RightPanel({
@@ -34,31 +36,35 @@ export function RightPanel({
34
  onLogin,
35
  onLogout,
36
  isLoggedIn,
 
37
  exportResult,
 
38
  resultType,
39
- onExport,
40
- onQuiz,
41
- onSummary,
42
  }: RightPanelProps) {
43
  const [showLoginForm, setShowLoginForm] = useState(false);
44
  const [name, setName] = useState('');
45
  const [email, setEmail] = useState('');
46
-
47
  const [feedbackDialogOpen, setFeedbackDialogOpen] = useState(false);
48
  const [feedbackText, setFeedbackText] = useState('');
49
  const [feedbackCategory, setFeedbackCategory] = useState<'general' | 'bug' | 'feature'>('general');
50
 
51
- const handleLogin = () => {
52
  if (!name.trim() || !email.trim()) {
53
  toast.error('Please fill in all fields');
54
  return;
55
  }
56
- onLogin({ name: name.trim(), email: email.trim() });
57
  setShowLoginForm(false);
58
  setName('');
59
  setEmail('');
60
  };
61
 
 
 
 
 
 
62
  const handleFeedbackSubmit = () => {
63
  if (!feedbackText.trim()) {
64
  toast.error('Please provide feedback text');
@@ -78,7 +84,7 @@ export function RightPanel({
78
  <div className="flex flex-col items-center py-4">
79
  <h3 className="mb-2">Welcome to Clare!</h3>
80
  <p className="text-sm text-muted-foreground text-center mb-4">
81
- Log in to start your personalized learning journey
82
  </p>
83
  </div>
84
 
@@ -104,7 +110,7 @@ export function RightPanel({
104
  />
105
  </div>
106
  <div className="flex gap-2">
107
- <Button onClick={handleLogin} className="flex-1">
108
  Enter
109
  </Button>
110
  <Button variant="outline" onClick={() => setShowLoginForm(false)}>
@@ -123,22 +129,11 @@ export function RightPanel({
123
  <div className="flex-1 min-w-0">
124
  <h4 className="truncate">{user?.name}</h4>
125
  <p className="text-sm text-muted-foreground truncate">{user?.email}</p>
 
126
  </div>
127
  </div>
128
 
129
- <div className="grid grid-cols-3 gap-2">
130
- <Button variant="outline" onClick={onExport} className="text-xs" disabled={!isLoggedIn}>
131
- Export
132
- </Button>
133
- <Button variant="outline" onClick={onSummary} className="text-xs" disabled={!isLoggedIn}>
134
- Summary
135
- </Button>
136
- <Button variant="outline" onClick={onQuiz} className="text-xs" disabled={!isLoggedIn}>
137
- Quiz
138
- </Button>
139
- </div>
140
-
141
- <Button variant="destructive" onClick={onLogout} className="w-full gap-2">
142
  <LogOut className="h-4 w-4" />
143
  Log Out
144
  </Button>
@@ -155,6 +150,7 @@ export function RightPanel({
155
  {resultType === 'summary' && 'Summarization'}
156
  {!resultType && 'Results'}
157
  </h3>
 
158
  <Card className="p-4 min-h-[200px] bg-muted/30">
159
  {exportResult ? (
160
  <div className="space-y-3">
@@ -175,7 +171,7 @@ export function RightPanel({
175
  </div>
176
  ) : (
177
  <div className="flex items-center justify-center h-full text-sm text-muted-foreground text-left">
178
- Results (export / summary / quiz) will appear here after using the buttons above
179
  </div>
180
  )}
181
  </Card>
@@ -201,7 +197,7 @@ export function RightPanel({
201
  <div className="space-y-3">
202
  <div className="space-y-2">
203
  <Label htmlFor="feedbackCategory">Category</Label>
204
- <Select value={feedbackCategory} onValueChange={(value) => setFeedbackCategory(value as any)}>
205
  <SelectTrigger>
206
  <SelectValue placeholder="Select a category" />
207
  </SelectTrigger>
 
 
1
  import React, { useState } from 'react';
2
  import { Button } from './ui/button';
3
  import { Input } from './ui/input';
 
9
  import { LogIn, LogOut, FileText, MessageSquare } from 'lucide-react';
10
  import type { User } from '../App';
11
  import { toast } from 'sonner';
12
+ import {
13
+ Dialog,
14
+ DialogContent,
15
+ DialogDescription,
16
+ DialogHeader,
17
+ DialogTitle,
18
+ DialogFooter,
19
+ } from './ui/dialog';
20
 
21
  interface RightPanelProps {
22
  user: User | null;
23
+ onLogin: (name: string, email: string) => void; // CHANGED
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
 
34
  export function RightPanel({
 
36
  onLogin,
37
  onLogout,
38
  isLoggedIn,
39
+ onClose,
40
  exportResult,
41
+ setExportResult,
42
  resultType,
43
+ setResultType,
 
 
44
  }: RightPanelProps) {
45
  const [showLoginForm, setShowLoginForm] = useState(false);
46
  const [name, setName] = useState('');
47
  const [email, setEmail] = useState('');
 
48
  const [feedbackDialogOpen, setFeedbackDialogOpen] = useState(false);
49
  const [feedbackText, setFeedbackText] = useState('');
50
  const [feedbackCategory, setFeedbackCategory] = useState<'general' | 'bug' | 'feature'>('general');
51
 
52
+ const handleLoginClick = () => {
53
  if (!name.trim() || !email.trim()) {
54
  toast.error('Please fill in all fields');
55
  return;
56
  }
57
+ onLogin(name.trim(), email.trim());
58
  setShowLoginForm(false);
59
  setName('');
60
  setEmail('');
61
  };
62
 
63
+ const handleLogoutClick = () => {
64
+ onLogout();
65
+ setShowLoginForm(false);
66
+ };
67
+
68
  const handleFeedbackSubmit = () => {
69
  if (!feedbackText.trim()) {
70
  toast.error('Please provide feedback text');
 
84
  <div className="flex flex-col items-center py-4">
85
  <h3 className="mb-2">Welcome to Clare!</h3>
86
  <p className="text-sm text-muted-foreground text-center mb-4">
87
+ Log in to start your learning session
88
  </p>
89
  </div>
90
 
 
110
  />
111
  </div>
112
  <div className="flex gap-2">
113
+ <Button onClick={handleLoginClick} className="flex-1">
114
  Enter
115
  </Button>
116
  <Button variant="outline" onClick={() => setShowLoginForm(false)}>
 
129
  <div className="flex-1 min-w-0">
130
  <h4 className="truncate">{user?.name}</h4>
131
  <p className="text-sm text-muted-foreground truncate">{user?.email}</p>
132
+ <p className="text-xs text-muted-foreground truncate">user_id: {user?.user_id}</p>
133
  </div>
134
  </div>
135
 
136
+ <Button variant="destructive" onClick={handleLogoutClick} className="w-full gap-2">
 
 
 
 
 
 
 
 
 
 
 
 
137
  <LogOut className="h-4 w-4" />
138
  Log Out
139
  </Button>
 
150
  {resultType === 'summary' && 'Summarization'}
151
  {!resultType && 'Results'}
152
  </h3>
153
+
154
  <Card className="p-4 min-h-[200px] bg-muted/30">
155
  {exportResult ? (
156
  <div className="space-y-3">
 
171
  </div>
172
  ) : (
173
  <div className="flex items-center justify-center h-full text-sm text-muted-foreground text-left">
174
+ Results (export / summary / quiz) will appear here after actions run
175
  </div>
176
  )}
177
  </Card>
 
197
  <div className="space-y-3">
198
  <div className="space-y-2">
199
  <Label htmlFor="feedbackCategory">Category</Label>
200
+ <Select value={feedbackCategory} onValueChange={(v) => setFeedbackCategory(v as any)}>
201
  <SelectTrigger>
202
  <SelectValue placeholder="Select a category" />
203
  </SelectTrigger>