"use client";
import Link from "next/link";
import { IconCircle, IconCircleCheck, IconExternalLink } from "@tabler/icons-react";
import { Badge } from "@kandev/ui/badge";
import { Spinner } from "@kandev/ui/spinner";
import { cn, formatRelativeTime } from "@/lib/utils";
import type { Issue } from "@/lib/types/gitlab";
type IssueListProps = {
items: Issue[];
loading: boolean;
error: string | null;
};
function IssueLabels({ labels }: { labels: string[] }) {
if (!labels?.length) return null;
return (
<>
{labels.slice(0, 4).map((l) => (
{l}
))}
{labels.length > 4 && (
+{labels.length - 4}
)}
>
);
}
function IssueRow({ issue }: { issue: Issue }) {
const isOpen = issue.state !== "closed";
const StateIcon = isOpen ? IconCircle : IconCircleCheck;
const stateClass = isOpen
? "text-emerald-600 dark:text-emerald-400"
: "text-purple-600 dark:text-purple-400";
return (
{issue.title}
{issue.project_path}#{issue.iid}
·
by {issue.author_username} · opened {formatRelativeTime(issue.created_at)}
);
}
function IssueListBody({ loading, error, items }: IssueListProps) {
if (loading) {
return (
);
}
if (error) {
return {error}
;
}
if (items.length === 0) {
return (
No issues match this filter.
);
}
return (
{items.map((issue) => (
))}
);
}
export function IssueList(props: IssueListProps) {
return (
);
}