import type { IssueResponse } from "@sprint/shared"; import Avatar from "@/components/avatar"; import StatusTag from "@/components/status-tag"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { cn } from "@/lib/utils"; export function IssuesTable({ issuesData, columns = {}, issueSelectAction, statuses, className, }: { issuesData: IssueResponse[]; columns?: { id?: boolean; title?: boolean; description?: boolean; status?: boolean; assignee?: boolean }; issueSelectAction?: (issue: IssueResponse) => void; statuses: Record; className: string; }) { return ( {(columns.id == null || columns.id === true) && ( ID )} {(columns.title == null || columns.title === true) && Title} {(columns.description == null || columns.description === true) && ( Description )} {/* below is kept blank to fill the space, used as the "Assignee" column */} {(columns.assignee == null || columns.assignee === true) && ( )} {issuesData.map((issueData) => ( { issueSelectAction?.(issueData); }} > {(columns.id == null || columns.id === true) && ( {issueData.Issue.number.toString().padStart(3, "0")} )} {(columns.title == null || columns.title === true) && (
{(columns.status == null || columns.status === true) && ( )} {issueData.Issue.title}
)} {(columns.description == null || columns.description === true) && ( {issueData.Issue.description} )} {(columns.assignee == null || columns.assignee === true) && ( {issueData.Assignees && issueData.Assignees.length > 0 && (
{issueData.Assignees.slice(0, 3).map((assignee) => ( ))} {issueData.Assignees.length > 3 && ( +{issueData.Assignees.length - 3} )}
)}
)}
))}
); }