diff --git a/app/components/data-table.tsx b/app/components/data-table.tsx index 2cda5c5..0e2d76d 100644 --- a/app/components/data-table.tsx +++ b/app/components/data-table.tsx @@ -1,10 +1,10 @@ +import { useState } from "react"; +import { BaseRecord } from "@refinedev/core"; +import { useTable } from "@refinedev/react-table"; import { ColumnDef, flexRender, - getCoreRowModel, - useReactTable, - getPaginationRowModel, -} from "@tanstack/react-table" +} from "@tanstack/react-table"; import { Table, @@ -16,20 +16,23 @@ import { } from "./ui/table" import { DataTablePagination } from "./table-pagination" -interface DataTableProps { +interface DataTableProps { columns: ColumnDef[] - data: TData[] } -export function DataTable({ - columns, - data, +export function DataTable({ + columns }: DataTableProps) { - const table = useReactTable({ - data, + const [hoveredRowId, setHoveredRowId] = useState(""); + + const table = useTable({ columns, - getCoreRowModel: getCoreRowModel(), - getPaginationRowModel: getPaginationRowModel(), + meta: { + hoveredRowId, + }, + refineCoreProps: { + resource: "files" + } }) return ( @@ -40,7 +43,7 @@ export function DataTable({ {headerGroup.headers.map((header) => { return ( - + {header.isPlaceholder ? null : flexRender( @@ -59,6 +62,10 @@ export function DataTable({ { + console.log(hoveredRowId, row.id); + setHoveredRowId(row.id) + }} > {row.getVisibleCells().map((cell) => ( diff --git a/app/components/ui/dropdown-menu.tsx b/app/components/ui/dropdown-menu.tsx index cbe1985..f300984 100644 --- a/app/components/ui/dropdown-menu.tsx +++ b/app/components/ui/dropdown-menu.tsx @@ -67,7 +67,7 @@ const DropdownMenuContent = React.forwardRef< ref={ref} sideOffset={sideOffset} className={cn( - "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md", + "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-primary p-1 text-white shadow-md", "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className )} @@ -80,14 +80,17 @@ DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName const DropdownMenuItem = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef & { - inset?: boolean + inset?: boolean, + variant?: string } ->(({ className, inset, ...props }, ref) => ( +>(({ className, inset, variant, ...props }, ref) => ( (({ className, ...props }, ref) => ( )) diff --git a/app/routes/file-manager/columns.tsx b/app/routes/file-manager/columns.tsx index 0441170..cc4fbc5 100644 --- a/app/routes/file-manager/columns.tsx +++ b/app/routes/file-manager/columns.tsx @@ -1,6 +1,8 @@ -import type { ColumnDef } from "@tanstack/react-table"; +import { DrawingPinIcon, TrashIcon } from "@radix-ui/react-icons"; +import type { ColumnDef, RowData } from "@tanstack/react-table"; import { FileIcon, MoreIcon } from "~/components/icons"; import { Checkbox } from "~/components/ui/checkbox"; +import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "~/components/ui/dropdown-menu"; // This type is used to define the shape of our data. // You can use a Zod schema here if you want. @@ -11,9 +13,16 @@ export type File = { createdOn: string; }; +declare module '@tanstack/table-core' { + interface TableMeta { + hoveredRowId: string, + } +} + export const columns: ColumnDef[] = [ { id: "select", + size: 20, header: ({ table }) => ( [] = [ }, { accessorKey: "createdOn", + size: 200, header: "Created On", - cell: ({ row }) => ( + cell: ({ row, table }) => (
{row.getValue("createdOn")} - {row.getIsSelected() && } + {(row.getIsSelected() || table.options.meta?.hoveredRowId === row.id) && ( + + + + + + + + + Ping CID + + + + + Delete + + + + + )}
) } diff --git a/app/routes/file-manager/index.tsx b/app/routes/file-manager/index.tsx index ad0e35e..96a5777 100644 --- a/app/routes/file-manager/index.tsx +++ b/app/routes/file-manager/index.tsx @@ -7,11 +7,6 @@ import { Button } from "~/components/ui/button"; import { AddIcon } from "~/components/icons"; export default function FileManager() { - const isLogged = true; - if (!isLogged) { - window.location.href = "/login"; - } - return (

File Manager

@@ -60,20 +55,6 @@ export default function FileManager() {
); diff --git a/package.json b/package.json index 9b070cd..0cc9af6 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "@refinedev/core": "https://gitpkg.now.sh/LumeWeb/refine/packages/core?remix", "@refinedev/devtools-internal": "https://gitpkg.now.sh/LumeWeb/refine/packages/devtools-internal?remix", "@refinedev/devtools-shared": "https://gitpkg.now.sh/LumeWeb/refine/packages/devtools-shared?remix", + "@refinedev/react-table": "https://gitpkg.now.sh/LumeWeb/refine/packages/react-table?remix", "@refinedev/remix-router": "https://gitpkg.now.sh/LumeWeb/refine/packages/remix?remix", "@remix-run/node": "^2.8.0", "@remix-run/react": "^2.8.0",