SarahXia0405 commited on
Commit
3cdbc9d
·
verified ·
1 Parent(s): d76cdcf

Update web/src/components/RightPanel.tsx

Browse files
Files changed (1) hide show
  1. web/src/components/RightPanel.tsx +34 -19
web/src/components/RightPanel.tsx CHANGED
@@ -20,7 +20,7 @@ import {
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;
@@ -44,20 +44,27 @@ export function RightPanel({
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 = () => {
@@ -70,6 +77,7 @@ export function RightPanel({
70
  toast.error('Please provide feedback text');
71
  return;
72
  }
 
73
  console.log('Feedback submitted:', feedbackText, feedbackCategory);
74
  setFeedbackDialogOpen(false);
75
  setFeedbackText('');
@@ -97,23 +105,27 @@ export function RightPanel({
97
  <div className="space-y-3">
98
  <div className="space-y-2">
99
  <Label htmlFor="name">Name</Label>
100
- <Input id="name" value={name} onChange={(e) => setName(e.target.value)} placeholder="Enter your name" />
 
 
 
 
 
101
  </div>
102
  <div className="space-y-2">
103
- <Label htmlFor="email">Email / Student ID</Label>
104
  <Input
105
- id="email"
106
- type="email"
107
- value={email}
108
- onChange={(e) => setEmail(e.target.value)}
109
  placeholder="Enter your email or ID"
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)}>
117
  Cancel
118
  </Button>
119
  </div>
@@ -181,7 +193,11 @@ export function RightPanel({
181
 
182
  <div className="space-y-3">
183
  <h3>Feedback</h3>
184
- <Button variant="outline" className="w-full justify-start gap-2" onClick={() => setFeedbackDialogOpen(true)}>
 
 
 
 
185
  <MessageSquare className="h-4 w-4" />
186
  Provide Feedback
187
  </Button>
@@ -232,4 +248,3 @@ export function RightPanel({
232
  </div>
233
  );
234
  }
235
-
 
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;
 
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
  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('');
 
105
  <div className="space-y-3">
106
  <div className="space-y-2">
107
  <Label htmlFor="name">Name</Label>
108
+ <Input
109
+ id="name"
110
+ value={name}
111
+ onChange={(e) => setName(e.target.value)}
112
+ placeholder="Enter your name"
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>
 
193
 
194
  <div className="space-y-3">
195
  <h3>Feedback</h3>
196
+ <Button
197
+ variant="outline"
198
+ className="w-full justify-start gap-2"
199
+ onClick={() => setFeedbackDialogOpen(true)}
200
+ >
201
  <MessageSquare className="h-4 w-4" />
202
  Provide Feedback
203
  </Button>
 
248
  </div>
249
  );
250
  }