Spaces:
Sleeping
Sleeping
File size: 13,799 Bytes
760b33c | 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 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | import React, { useState } from 'react';
import { Button } from './ui/button';
import { Input } from './ui/input';
import { Label } from './ui/label';
import { Card } from './ui/card';
import { Separator } from './ui/separator';
import { Textarea } from './ui/textarea';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './ui/select';
import {
LogIn,
LogOut,
Download,
ClipboardList,
FileText,
Sparkles,
ChevronUp,
ChevronDown,
PanelRightClose,
MessageSquare
} from 'lucide-react';
import type { User } from '../App';
import { toast } from 'sonner@2.0.3';
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogTrigger,
DialogFooter,
} from './ui/dialog';
interface RightPanelProps {
user: User | null;
onLogin: (user: User) => void;
onLogout: () => void;
isLoggedIn: boolean;
onClose?: () => void;
exportResult: string;
setExportResult: (result: string) => void;
resultType: 'export' | 'quiz' | 'summary' | null;
setResultType: (type: 'export' | 'quiz' | 'summary' | null) => void;
}
export function RightPanel({ user, onLogin, onLogout, isLoggedIn, onClose, exportResult, setExportResult, resultType, setResultType }: RightPanelProps) {
const [showLoginForm, setShowLoginForm] = useState(false);
const [name, setName] = useState('');
const [email, setEmail] = useState('');
const [isExpanded, setIsExpanded] = useState(true);
const [feedbackDialogOpen, setFeedbackDialogOpen] = useState(false);
const [feedbackText, setFeedbackText] = useState('');
const [feedbackCategory, setFeedbackCategory] = useState<'general' | 'bug' | 'feature'>('general');
const handleLogin = () => {
if (!name.trim() || !email.trim()) {
toast.error('Please fill in all fields');
return;
}
onLogin({ name: name.trim(), email: email.trim() });
setShowLoginForm(false);
setName('');
setEmail('');
toast.success(`Welcome, ${name}!`);
};
const handleLogout = () => {
onLogout();
setShowLoginForm(false);
toast.success('Logged out successfully');
};
const handleExport = () => {
const result = `# Conversation Export
Date: ${new Date().toLocaleDateString()}
Student: ${user?.name}
## Summary
This conversation covered key concepts in Module 10 – Responsible AI, including ethical considerations, fairness, transparency, and accountability in AI systems.
## Key Takeaways
1. Understanding the principles of Responsible AI
2. Real-world applications and implications
3. Best practices for ethical AI development
Exported successfully! ✓`;
setExportResult(result);
setResultType('export');
toast.success('Conversation exported!');
};
const handleQuiz = () => {
const quiz = `# Micro-Quiz: Responsible AI
**Question 1:** Which of the following is a key principle of Responsible AI?
a) Profit maximization
b) Transparency
c) Rapid deployment
d) Cost reduction
**Question 2:** What is algorithmic fairness?
(Short answer expected)
**Question 3:** True or False: AI systems should always prioritize accuracy over fairness.
Generate quiz based on your conversation!`;
setExportResult(quiz);
setResultType('quiz');
toast.success('Quiz generated!');
};
const handleSummary = () => {
const summary = `# Learning Summary
## Today's Session
**Duration:** 25 minutes
**Topics Covered:** 3
**Messages Exchanged:** 12
## Key Concepts Discussed
• Principles of Responsible AI
• Ethical considerations in AI development
• Fairness and transparency in algorithms
## Recommended Next Steps
1. Review Module 10, Section 2.3
2. Complete practice quiz on algorithmic fairness
3. Read additional resources on AI ethics
## Progress Update
You've covered 65% of Module 10 content. Keep up the great work! 🎉`;
setExportResult(summary);
setResultType('summary');
toast.success('Summary generated!');
};
const handleFeedbackSubmit = () => {
if (!feedbackText.trim()) {
toast.error('Please provide feedback text');
return;
}
// Here you can add logic to send feedback to your server or handle it as needed
console.log('Feedback submitted:', feedbackText, feedbackCategory);
setFeedbackDialogOpen(false);
setFeedbackText('');
toast.success('Feedback submitted!');
};
return (
<div className="flex-1 overflow-auto p-4 space-y-4">
{isExpanded && (
<>
{/* Login Section */}
<Card className="p-4">
{!isLoggedIn ? (
<div className="space-y-4">
<div className="flex flex-col items-center py-4">
<img
src="https://images.unsplash.com/photo-1588912914049-d2664f76a947?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3w3Nzg4Nzd8MHwxfHNlYXJjaHwxfHxzdHVkZW50JTIwc3R1ZHlpbmclMjBpbGx1c3RyYXRpb258ZW58MXx8fHwxNzY2MDY2NjcyfDA&ixlib=rb-4.1.0&q=80&w=1080&utm_source=figma&utm_medium=referral"
alt="Student studying"
className="w-20 h-20 rounded-full object-cover mb-4"
/>
<h3 className="mb-2">Welcome to Clare!</h3>
<p className="text-sm text-muted-foreground text-center mb-4">
Log in to start your personalized learning journey
</p>
</div>
{!showLoginForm ? (
<Button onClick={() => setShowLoginForm(true)} className="w-full gap-2">
<LogIn className="h-4 w-4" />
Student Login
</Button>
) : (
<div className="space-y-3">
<div className="space-y-2">
<Label htmlFor="name">Name</Label>
<Input
id="name"
value={name}
onChange={(e) => setName(e.target.value)}
placeholder="Enter your name"
/>
</div>
<div className="space-y-2">
<Label htmlFor="email">Email / Student ID</Label>
<Input
id="email"
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
placeholder="Enter your email or ID"
/>
</div>
<div className="flex gap-2">
<Button onClick={handleLogin} className="flex-1">
Enter
</Button>
<Button
variant="outline"
onClick={() => setShowLoginForm(false)}
>
Cancel
</Button>
</div>
</div>
)}
</div>
) : (
<div className="space-y-4">
<div className="flex items-center gap-3">
<div className="w-12 h-12 rounded-full bg-gradient-to-br from-purple-500 to-blue-500 flex items-center justify-center text-white">
{user.name.charAt(0).toUpperCase()}
</div>
<div className="flex-1 min-w-0">
<h4 className="truncate">{user.name}</h4>
<p className="text-sm text-muted-foreground truncate">{user.email}</p>
</div>
</div>
<Button
variant="destructive"
onClick={handleLogout}
className="w-full gap-2"
>
<LogOut className="h-4 w-4" />
Log Out
</Button>
</div>
)}
</Card>
<Separator />
{/* Actions section removed - functionality available via floating buttons */}
{/* <div className="space-y-3">
<h3>Actions</h3>
<Dialog>
<DialogTrigger asChild>
<Button
variant="outline"
className="w-full justify-start gap-2"
disabled={!isLoggedIn}
onClick={handleExport}
>
<Download className="h-4 w-4" />
Export Conversation
</Button>
</DialogTrigger>
</Dialog>
<Dialog>
<DialogTrigger asChild>
<Button
variant="outline"
className="w-full justify-start gap-2"
disabled={!isLoggedIn}
onClick={handleQuiz}
>
<ClipboardList className="h-4 w-4" />
Let's Try (Micro-Quiz)
</Button>
</DialogTrigger>
</Dialog>
<Dialog>
<DialogTrigger asChild>
<Button
variant="outline"
className="w-full justify-start gap-2"
disabled={!isLoggedIn}
onClick={handleSummary}
>
<Sparkles className="h-4 w-4" />
Summarization
</Button>
</DialogTrigger>
</Dialog>
{!isLoggedIn && (
<p className="text-xs text-muted-foreground text-center pt-2">
Log in to unlock all features
</p>
)}
</div> */}
<Separator />
{/* Results Section */}
<div className="space-y-3">
<h3>
{resultType === 'export' && 'Exported Conversation'}
{resultType === 'quiz' && 'Micro-Quiz'}
{resultType === 'summary' && 'Summarization'}
{!resultType && 'Results'}
</h3>
<Card className="p-4 min-h-[200px] bg-muted/30">
{exportResult ? (
<div className="space-y-3">
<div className="flex items-center justify-between">
<FileText className="h-4 w-4 text-muted-foreground" />
<Button
variant="ghost"
size="sm"
onClick={() => {
navigator.clipboard.writeText(exportResult);
toast.success('Copied to clipboard!');
}}
>
Copy
</Button>
</div>
<div className="text-sm whitespace-pre-wrap text-foreground">
{exportResult}
</div>
</div>
) : (
<div className="flex items-center justify-center h-full text-sm text-muted-foreground text-left">
Results (export / summary / quiz) will appear here after using the actions above
</div>
)}
</Card>
</div>
<Separator />
{/* Feedback Section */}
<div className="space-y-3">
<h3>Feedback</h3>
<Button
variant="outline"
className="w-full justify-start gap-2"
onClick={() => setFeedbackDialogOpen(true)}
>
<MessageSquare className="h-4 w-4" />
Provide Feedback
</Button>
</div>
{/* Feedback Dialog */}
<Dialog open={feedbackDialogOpen} onOpenChange={setFeedbackDialogOpen}>
<DialogContent className="sm:max-w-[425px]">
<DialogHeader>
<DialogTitle>Provide Feedback</DialogTitle>
<DialogDescription>
Help us improve Clare by sharing your thoughts and suggestions.
</DialogDescription>
</DialogHeader>
<div className="space-y-3">
<div className="space-y-2">
<Label htmlFor="feedbackCategory">Category</Label>
<Select value={feedbackCategory} onValueChange={(value) => setFeedbackCategory(value as 'general' | 'bug' | 'feature')}>
<SelectTrigger>
<SelectValue placeholder="Select a category" />
</SelectTrigger>
<SelectContent>
<SelectItem value="general">General Feedback</SelectItem>
<SelectItem value="bug">Bug Report</SelectItem>
<SelectItem value="feature">Feature Request</SelectItem>
</SelectContent>
</Select>
</div>
<div className="space-y-2">
<Label htmlFor="feedbackText">Feedback</Label>
<Textarea
id="feedbackText"
value={feedbackText}
onChange={(e) => setFeedbackText(e.target.value)}
placeholder="Enter your feedback here..."
className="min-h-[100px]"
/>
</div>
</div>
<DialogFooter>
<Button
variant="outline"
onClick={() => setFeedbackDialogOpen(false)}
>
Cancel
</Button>
<Button
variant="primary"
onClick={handleFeedbackSubmit}
>
Submit
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</>
)}
</div>
);
} |