import { useState } from 'react'; import { format } from 'date-fns'; import { motion, AnimatePresence } from 'framer-motion'; import { Clock, CheckCircle, AlertCircle, Hourglass, Trash2, ChevronDown, ChevronUp } from 'lucide-react'; import { useFeedbackStore, type FeedbackSubmission, type FeedbackStatus } from './feedbackStore'; import { Button, Badge } from '../ui'; const statusConfig: Record = { pending: { label: 'Pending', color: 'text-gray-500', icon: }, submitted: { label: 'Submitted', color: 'text-blue-500', icon: }, acknowledged: { label: 'Acknowledged', color: 'text-purple-500', icon: }, in_progress: { label: 'In Progress', color: 'text-yellow-500', icon: }, resolved: { label: 'Resolved', color: 'text-green-500', icon: }, }; const typeLabels: Record = { bug: 'Bug Report', feature: 'Feature Request', general: 'General Feedback', }; const priorityLabels: Record = { low: 'Low', medium: 'Medium', high: 'High', }; interface FeedbackHistoryProps { onViewDetails?: (feedback: FeedbackSubmission) => void; } export function FeedbackHistory({ onViewDetails: _onViewDetails }: FeedbackHistoryProps) { const { feedbackItems, deleteFeedback, updateFeedbackStatus } = useFeedbackStore(); const [expandedId, setExpandedId] = useState(null); const formatDate = (timestamp: number) => { return format(new Date(timestamp), 'yyyy-MM-dd HH:mm'); }; const handleDelete = (id: string) => { if (confirm('Are you sure you want to delete this feedback?')) { deleteFeedback(id); } }; const handleStatusChange = (id: string, newStatus: FeedbackStatus) => { updateFeedbackStatus(id, newStatus); }; if (feedbackItems.length === 0) { return (

No feedback submissions yet.

Click the feedback button to submit your first feedback.

); } return (
{feedbackItems.map((feedback) => { const isExpanded = expandedId === feedback.id; const statusInfo = statusConfig[feedback.status]; return ( {/* Header */}
setExpandedId(isExpanded ? null : feedback.id)} >
{feedback.type === 'bug' && } {feedback.type === 'feature' && } {feedback.type === 'general' && }

{feedback.title}

{typeLabels[feedback.type]} - {formatDate(feedback.createdAt)}

{priorityLabels[feedback.priority]}
{/* Expandable Content */} {isExpanded && (
{/* Description */}
Description

{feedback.description}

{/* Attachments */} {feedback.attachments.length > 0 && (
Attachments ({feedback.attachments.length})
{feedback.attachments.map((att, idx) => ( {att.name} ))}
)} {/* Metadata */}
System Info

App Version: {feedback.metadata.appVersion}

OS: {feedback.metadata.os}

Submitted: {formatDate(feedback.createdAt)}

{/* Status and Actions */}
{statusInfo.icon} {statusInfo.label}
)}
); })}
); }