diff --git a/frontend/src/components/bounty/BountyDiscussion.tsx b/frontend/src/components/bounty/BountyDiscussion.tsx new file mode 100644 index 000000000..51ee1b853 --- /dev/null +++ b/frontend/src/components/bounty/BountyDiscussion.tsx @@ -0,0 +1,106 @@ +import React, { useState } from 'react'; +import { motion, AnimatePresence } from 'framer-motion'; +import { MessageSquare, Send, ChevronDown, ChevronUp } from 'lucide-react'; + +interface Comment { + id: string; + author: string; + avatar: string; + content: string; + timestamp: string; + replies?: Comment[]; +} + +interface BountyDiscussionProps { + bountyId: string; + comments?: Comment[]; +} + +function timeAgo(dateStr: string): string { + const diff = Date.now() - new Date(dateStr).getTime(); + const mins = Math.floor(diff / 60000); + if (mins < 60) return mins + 'm ago'; + const hrs = Math.floor(mins / 60); + if (hrs < 24) return hrs + 'h ago'; + return Math.floor(hrs / 24) + 'd ago'; +} + +function CommentThread({ comment, depth = 0 }: { comment: Comment; depth?: number }) { + const [showReplies, setShowReplies] = useState(depth < 1); + const [replyText, setReplyText] = useState(''); + const [showReplyInput, setShowReplyInput] = useState(false); + + return ( +
0 ? 'ml-8 border-l border-border/30 pl-4' : ''}> +
+ +
+
+ {comment.author} + {timeAgo(comment.timestamp)} +
+

{comment.content}

+
+ + {comment.replies && comment.replies.length > 0 && ( + + )} +
+ {showReplyInput && ( +
+ setReplyText(e.target.value)} + placeholder="Write a reply..." + className="flex-1 bg-forge-800 border border-border rounded px-3 py-1.5 text-sm text-text-primary" /> + +
+ )} +
+
+ + {showReplies && comment.replies?.map(r => ( + + + + ))} + +
+ ); +} + +export function BountyDiscussion({ bountyId, comments = [] }: BountyDiscussionProps) { + const [newComment, setNewComment] = useState(''); + + return ( +
+
+ +

Discussion ({comments.length})

+
+ +
+ {comments.map(c => )} +
+ +
+
+ setNewComment(e.target.value)} + placeholder="Add to the discussion..." + className="flex-1 bg-forge-800 border border-border rounded-lg px-4 py-2 text-sm text-text-primary focus:outline-none focus:border-emerald/50" /> + +
+
+
+ ); +} \ No newline at end of file