Files
tm_panel/src/components/ui/table.tsx
T
AmirReza Jamali 2fa774b6bd feat(companies): implement companies page with data table
This commit introduces a new "Companies" page to the dashboard, providing a comprehensive view of company data in a sortable and paginated table.

Key changes include:
- A new page at `/companies` to display the data table.
- A new API route `/api/companies` that serves mock company data.
- A `CompaniesTable` component built with `react-table` featuring sorting, pagination, and search functionality.
- Reusable `TablePagination` and `TableActions` components to support the table.
- The `moment` library has been added as a dependency to format dates within the table.
- A new `CrossIcon` has been added for UI controls.
- The `InputGroup` component is enhanced with an `autoComplete` prop.
- A link to the new "Companies" page has been added to the sidebar navigation.
2025-09-16 16:01:59 +03:30

95 lines
2.1 KiB
TypeScript

import { cn } from "@/lib/utils";
import * as React from "react";
export function Table({
className,
...props
}: React.HTMLAttributes<HTMLTableElement>) {
return (
<div className="relative w-full overflow-auto">
<table
className={cn("w-full caption-bottom text-sm", className)}
{...props}
/>
</div>
);
}
export function TableHeader({
className,
...props
}: React.HTMLAttributes<HTMLTableSectionElement>) {
return <thead className={cn("[&_tr]:border-b", className)} {...props} />;
}
export function TableBody({
className,
...props
}: React.HTMLAttributes<HTMLTableSectionElement>) {
return (
<tbody className={cn("[&_tr:last-child]:border-0", className)} {...props} />
);
}
export function TableFooter({
className,
...props
}: React.HTMLAttributes<HTMLTableSectionElement>) {
return (
<tfoot
className={cn(
"border-t bg-neutral-100/50 font-medium dark:bg-neutral-800/50 [&>tr]:last:border-b-0",
className,
)}
{...props}
/>
);
}
export const TableRow = React.forwardRef<
HTMLTableRowElement,
React.HTMLAttributes<HTMLTableRowElement>
>(({ className, ...props }, ref) => {
return (
<tr
ref={ref}
className={cn(
"border-b transition-colors hover:bg-neutral-100/50 data-[state=selected]:bg-neutral-100 dark:border-dark-3 dark:hover:bg-dark-2 dark:data-[state=selected]:bg-neutral-800",
className,
)}
{...props}
/>
);
});
TableRow.displayName = "TableRow";
export function TableHead({
className,
...props
}: React.ThHTMLAttributes<HTMLTableCellElement>) {
return (
<th
className={cn(
"h-12 px-4 text-left align-middle font-medium text-neutral-500 dark:text-neutral-400 [&:has([role=checkbox])]:pr-0",
className,
)}
{...props}
/>
);
}
export function TableCell({
className,
...props
}: React.TdHTMLAttributes<HTMLTableCellElement>) {
return (
<td
className={cn(
"p-4 align-middle [&:has([role=checkbox])]:pr-0",
className,
)}
{...props}
/>
);
}