"use client"; import { motion, AnimatePresence } from "framer-motion"; import { GitPullRequest, GitMerge, XCircle, MessageSquare, Search, Tag, Calendar, User, ArrowUpDown, Plus, Sparkles, GitBranch, CheckCircle2 } from "lucide-react"; import { useState } from "react"; interface PullRequest { id: string; number: number; title: string; state: "open" | "closed" | "merged"; createdAt: string; commentCount: number; sourceBranch: string; targetBranch: string; author: { username: string; avatarUrl?: string; }; labels?: Array<{ name: string; color: string; }>; isDraft?: boolean; } interface Props { pullRequests: PullRequest[]; openCount: number; closedCount: number; repoOwner: string; repoName: string; } function timeAgo(date: string): string { const now = new Date(); const past = new Date(date); const diffMs = now.getTime() - past.getTime(); const diffMins = Math.floor(diffMs / 60000); if (diffMins < 1) return 'just now'; if (diffMins < 60) return `${diffMins} minutes ago`; const diffHours = Math.floor(diffMins / 60); if (diffHours < 24) return `${diffHours} hours ago`; const diffDays = Math.floor(diffHours / 24); if (diffDays < 30) return `${diffDays} days ago`; const diffMonths = Math.floor(diffDays / 30); return `${diffMonths} months ago`; } function getPRIcon(state: string, isDraft?: boolean) { if (isDraft) { return { icon: GitPullRequest, color: "text-gray-400", bg: "bg-gray-500/10" }; } switch (state) { case "open": return { icon: GitPullRequest, color: "text-green-400", bg: "bg-green-500/10" }; case "merged": return { icon: GitMerge, color: "text-purple-400", bg: "bg-purple-500/10" }; case "closed": return { icon: XCircle, color: "text-red-400", bg: "bg-red-500/10" }; default: return { icon: GitPullRequest, color: "text-gray-400", bg: "bg-gray-500/10" }; } } export default function PullRequestsList({ pullRequests, openCount, closedCount, repoOwner, repoName }: Props) { const [filter, setFilter] = useState<"open" | "closed" | "all">("open"); const [searchQuery, setSearchQuery] = useState(""); const filteredPRs = pullRequests.filter(pr => { const matchesFilter = filter === "all" || (filter === "open" && pr.state === "open") || (filter === "closed" && (pr.state === "closed" || pr.state === "merged")); const matchesSearch = pr.title.toLowerCase().includes(searchQuery.toLowerCase()); return matchesFilter && matchesSearch; }); return (
{pr.sourceBranch}
→
{pr.targetBranch}
>
)}
{searchQuery ? "Try adjusting your search or filter to find what you're looking for." : "Pull requests help you collaborate on code with others. When you're ready, you can merge your code into the main branch."}
{!searchQuery && (