Spaces:
Sleeping
Sleeping
Update web/src/components/RightPanel.tsx
Browse files5 unmodified lines6789101112131415161718192021222324256 unmodified lines32333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401 unmodified line1421431441451461471481492 unmodified lines1521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973985 unmodified linesimport { 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,6 unmodified linesinterface 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 ExportDate: ${new Date().toLocaleDateString()}Student: ${user?.name}## SummaryThis conversation covered key concepts in Module 10 – Responsible AI, including ethical considerations, fairness, transparency, and accountability in AI systems.## Key Takeaways1. Understanding the principles of Responsible AI2. Real-world applications and implications3. Best practices for ethical AI developmentExported 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 maximizationb) Transparencyc) Rapid deploymentd) 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 Steps1. Review Module 10, Section 2.32. Complete practice quiz on algorithmic fairness3. Read additional resources on AI ethics## Progress UpdateYou've covered 65% of Module 10 content. Keep up the great work! 🎉`;setExportResult(summary);setResultType('summary');toast.success('Summary generated!');};const handleFeedbackSubmit = () => {1 unmodified linetoast.error('Please provide feedback text');return;}// Here you can add logic to send feedback to your server or handle it as neededconsole.log('Feedback submitted:', feedbackText, feedbackCategory);setFeedbackDialogOpen(false);setFeedbackText('');2 unmodified linesreturn (<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"><imgsrc="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><Inputid="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><Inputid="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><Buttonvariant="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><Buttonvariant="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><Buttonvariant="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><Buttonvariant="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><Buttonvariant="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" /><Buttonvariant="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><Buttonvariant="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><Textareaid="feedbackText"value={feedbackText}onChange={(e) => setFeedbackText(e.target.value)}placeholder="Enter your feedback here..."className="min-h-[100px]"/></div></div><DialogFooter><Buttonvariant="outline"onClick={() => setFeedbackDialogOpen(false)}>Cancel</Button><Buttonvariant="primary"onClick={handleFeedbackSubmit}>Submit</Button></DialogFooter></DialogContent></Dialog></>)}</div>);}5 unmodified lines678910111213146 unmodified lines212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768691 unmodified line717273747576772 unmodified lines80818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502515 unmodified linesimport { Separator } from './ui/separator';import { Textarea } from './ui/textarea';import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './ui/select';import { LogIn, LogOut, FileText, MessageSquare } from 'lucide-react';import type { User } from '../App';import { toast } from 'sonner';import {Dialog,DialogContent,6 unmodified linesinterface RightPanelProps {user: User | null;onLogin: (payload: { name: string; email: string }) => Promise<void> | 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,exportResult,setExportResult,resultType,setResultType,}: RightPanelProps) {const [showLoginForm, setShowLoginForm] = useState(false);const [name, setName] = useState('');const [email, setEmail] = useState('');const [feedbackDialogOpen, setFeedbackDialogOpen] = useState(false);const [feedbackText, setFeedbackText] = useState('');const [feedbackCategory, setFeedbackCategory] = useState<'general' | 'bug' | 'feature'>('general');const handleLoginClick = async () => {if (!name.trim() || !email.trim()) {toast.error('Please fill in all fields');return;}await onLogin({ name: name.trim(), email: email.trim() });setShowLoginForm(false);setName('');setEmail('');};const handleLogout = () => {onLogout();setShowLoginForm(false);};const handleFeedbackSubmit = () => {1 unmodified linetoast.error('Please provide feedback text');return;}// MVP: keep console log; next step we can POST to /api/feedbackconsole.log('Feedback submitted:', feedbackText, feedbackCategory);setFeedbackDialogOpen(false);setFeedbackText('');2 unmodified linesreturn (<div className="flex-1 overflow-auto p-4 space-y-4">{/* Login Section */}<Card className="p-4">{!isLoggedIn ? (<div className="space-y-4"><div className="flex flex-col items-center py-4"><imgsrc="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><Inputid="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><Inputid="email"value={email}onChange={(e) => setEmail(e.target.value)}placeholder="Enter your email or ID"/></div><div className="flex gap-2"><Button onClick={handleLoginClick} 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() ?? 'U'}</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 />{/* 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" /><Buttonvariant="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</div>)}</Card></div><Separator />{/* Feedback Section */}<div className="space-y-3"><h3>Feedback</h3><Dialog open={feedbackDialogOpen} onOpenChange={setFeedbackDialogOpen}><DialogTrigger asChild><Button variant="outline" className="w-full justify-start gap-2"><MessageSquare className="h-4 w-4" />Provide Feedback</Button></DialogTrigger><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><Selectvalue={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><Textareaid="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 onClick={handleFeedbackSubmit}>Submit</Button></DialogFooter></DialogContent></Dialog></div></div>);}
web/src/components/RightPanel.tsx+171-318