diff --git a/packages/frontend/src/components/issues-table.tsx b/packages/frontend/src/components/issues-table.tsx index f3dce14..2fbb84f 100644 --- a/packages/frontend/src/components/issues-table.tsx +++ b/packages/frontend/src/components/issues-table.tsx @@ -1,25 +1,45 @@ import type { IssueRecord } from "@issue/shared"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; -export function IssuesTable({ issues }: { issues: IssueRecord[] }) { +export function IssuesTable({ + issues, + columns = {}, +}: { + issues: IssueRecord[]; + columns?: { id?: boolean; title?: boolean; description?: boolean; assignee?: boolean }; +}) { return ( - ID - Title - Description + {(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) && } {issues.map((issue) => ( - - {issue.id} - {issue.title} - {issue.description} - ? + + {(columns.id == null || columns.id === true) && ( + + {String(issue.id).padStart(3, "0")} + + )} + {(columns.title == null || columns.title === true) && ( + {issue.title} + )} + {(columns.description == null || columns.description === true) && ( + {issue.description} + )} + {(columns.assignee == null || columns.assignee === true) && ( + ? + )} ))} diff --git a/packages/frontend/src/components/ui/table.tsx b/packages/frontend/src/components/ui/table.tsx index 5513a5c..af83329 100644 --- a/packages/frontend/src/components/ui/table.tsx +++ b/packages/frontend/src/components/ui/table.tsx @@ -1,114 +1,82 @@ -import * as React from "react" +import * as React from "react"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; function Table({ className, ...props }: React.ComponentProps<"table">) { - return ( -
-
- - ) + return ( +
+
+ + ); } function TableHeader({ className, ...props }: React.ComponentProps<"thead">) { - return ( - - ) + return ; } function TableBody({ className, ...props }: React.ComponentProps<"tbody">) { - return ( - - ) + return ( + + ); } function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) { - return ( - tr]:last:border-b-0", - className - )} - {...props} - /> - ) + return ( + tr]:last:border-b-0", className)} + {...props} + /> + ); } function TableRow({ className, ...props }: React.ComponentProps<"tr">) { - return ( - - ) + return ( + + ); } function TableHead({ className, ...props }: React.ComponentProps<"th">) { - return ( -
[role=checkbox]]:translate-y-[2px]", - className - )} - {...props} - /> - ) + return ( + [role=checkbox]]:translate-y-[2px]", + className, + )} + {...props} + /> + ); } function TableCell({ className, ...props }: React.ComponentProps<"td">) { - return ( - [role=checkbox]]:translate-y-[2px]", - className - )} - {...props} - /> - ) + return ( + [role=checkbox]]:translate-y-[2px]", + className, + )} + {...props} + /> + ); } -function TableCaption({ - className, - ...props -}: React.ComponentProps<"caption">) { - return ( -
- ) +function TableCaption({ className, ...props }: React.ComponentProps<"caption">) { + return ( + + ); } -export { - Table, - TableHeader, - TableBody, - TableFooter, - TableHead, - TableRow, - TableCell, - TableCaption, -} +export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption };