'use client'; import { useState, FormEvent } from 'react'; import { mixpanelClient } from '@/utils/mixpanel'; import { usePathname } from 'next/navigation'; import { ThumbsUp, ThumbsDown } from 'lucide-react'; import { cn } from '@/utils/cn'; export function Feedback() { const MAX_CHARS = 500; const pathname = usePathname(); const [voted, setVoted] = useState(null); const [showReasonInput, setShowReasonInput] = useState(false); const [reason, setReason] = useState(''); const handleVote = (useful: boolean) => { if (!useful) { setShowReasonInput(true); return; } setVoted(true); mixpanelClient.track('helpfulness_vote', { path: pathname, useful: true, }); }; const handleSubmitNegativeFeedback = (e: FormEvent) => { e.preventDefault(); if (!reason.trim()) return; setVoted(false); setShowReasonInput(false); mixpanelClient.track('helpfulness_vote', { path: pathname, useful: false, reason: reason.trim(), }); }; if (voted !== null) { return (

Thanks for your feedback!

); } if (showReasonInput) { return (