"use client";
import {
IconCheck,
IconX,
IconClockHour4,
IconGitMerge,
IconAlertTriangle,
IconGitPullRequestDraft,
} from "@tabler/icons-react";
import type { Icon } from "@tabler/icons-react";
import type { GitHubPR, GitHubPRStatus } from "@/lib/types/github";
import { cn } from "@/lib/utils";
type StatusChipProps = {
Icon: Icon;
label: string;
tone: "success" | "failure" | "pending" | "neutral";
title?: string;
};
function StatusChip({ Icon, label, tone, title }: StatusChipProps) {
const toneClass = {
success: "text-emerald-600 dark:text-emerald-400",
failure: "text-red-600 dark:text-red-400",
pending: "text-amber-600 dark:text-amber-400",
neutral: "text-muted-foreground",
}[tone];
return (
{label}
);
}
function ChecksChip({ status }: { status: GitHubPRStatus }) {
const { checks_state: state, checks_total: total, checks_passing: passing } = status;
if (!state) return null;
const label = total > 0 ? `${passing}/${total}` : "";
if (state === "success")
return ;
if (state === "failure")
return ;
return ;
}
function ReviewChip({
state,
pending,
}: {
state: GitHubPRStatus["review_state"];
pending: number;
}) {
if (state === "approved") return ;
if (state === "changes_requested")
return ;
if (pending > 0)
return (
);
return null;
}
function MergeableChip({
state,
prState,
}: {
state: GitHubPRStatus["mergeable_state"];
prState: GitHubPR["state"];
}) {
if (prState === "merged") return ;
if (state === "draft")
return ;
if (state === "dirty")
return ;
if (state === "blocked")
return ;
if (state === "behind")
return ;
return null;
}
export function PRStatusBadges({
pr,
status,
}: {
pr: GitHubPR;
status: GitHubPRStatus | null | undefined;
}) {
if (!status) return null;
return (
<>
>
);
}