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, FileText, MessageSquare } from 'lucide-react'; import type { User } from '../App'; import { toast } from 'sonner'; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogFooter, } from './ui/dialog'; interface RightPanelProps { user: User | null; onLogin: (name: string, emailOrId: string) => Promise; 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 [emailOrId, setEmailOrId] = useState(''); const [isLoggingIn, setIsLoggingIn] = useState(false); const [feedbackDialogOpen, setFeedbackDialogOpen] = useState(false); const [feedbackText, setFeedbackText] = useState(''); const [feedbackCategory, setFeedbackCategory] = useState<'general' | 'bug' | 'feature'>('general'); const handleLoginClick = async () => { if (!name.trim() || !emailOrId.trim()) { toast.error('Please fill in all fields'); return; } try { setIsLoggingIn(true); await onLogin(name.trim(), emailOrId.trim()); setShowLoginForm(false); setName(''); setEmailOrId(''); } finally { setIsLoggingIn(false); } }; const handleLogoutClick = () => { onLogout(); setShowLoginForm(false); }; const handleFeedbackSubmit = () => { if (!feedbackText.trim()) { toast.error('Please provide feedback text'); return; } // 这里是“产品总体反馈”,不是 message-level feedback console.log('Feedback submitted:', feedbackText, feedbackCategory); setFeedbackDialogOpen(false); setFeedbackText(''); toast.success('Feedback submitted!'); }; return (
{!isLoggedIn ? (

Welcome to Clare!

Log in to start your learning session

{!showLoginForm ? ( ) : (
setName(e.target.value)} placeholder="Enter your name" />
setEmailOrId(e.target.value)} placeholder="Enter your email or ID" />
)}
) : (
{user?.name?.charAt(0).toUpperCase()}

{user?.name}

{user?.email}

user_id: {user?.user_id}

)}

{resultType === 'export' && 'Exported Conversation'} {resultType === 'quiz' && 'Micro-Quiz'} {resultType === 'summary' && 'Summarization'} {!resultType && 'Results'}

{exportResult ? (
{exportResult}
) : (
Results (export / summary / quiz) will appear here after actions run
)}

Feedback

Provide Feedback Help us improve Clare by sharing your thoughts and suggestions.