diff --git a/src/components/ui/datatable.tsx b/src/components/ui/datatable.tsx index dabc801..0eb8624 100644 --- a/src/components/ui/datatable.tsx +++ b/src/components/ui/datatable.tsx @@ -1,504 +1,521 @@ -"use client" +'use client' -import * as React from "react" +import * as React from 'react' import { - ColumnDef, - ColumnFiltersState, - SortingState, - VisibilityState, - flexRender, - getCoreRowModel, - getFilteredRowModel, - getPaginationRowModel, - getSortedRowModel, - useReactTable, -} from "@tanstack/react-table" + ColumnDef, + ColumnFiltersState, + SortingState, + VisibilityState, + flexRender, + getCoreRowModel, + getFilteredRowModel, + getPaginationRowModel, + getSortedRowModel, + useReactTable +} from '@tanstack/react-table' -import { Button } from "@/components/ui/button" +import { Button } from '@/components/ui/button' import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table" -import clsx from "clsx" -import { EyeToggleIcon } from "../icons/EyeToggleIcon" -import { ArrowLeft2, ArrowRight2 } from "iconsax-react" + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow +} from '@/components/ui/table' +import clsx from 'clsx' +import { EyeToggleIcon } from '../icons/EyeToggleIcon' +import { ArrowLeft2, ArrowRight2 } from 'iconsax-react' +import { ef } from '@/lib/helpers/utfNumbers' const data: Payment[] = [ - { - id: "m5gr84i9", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "3u1reuv4", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "derv1ws0", - type: 'تایپ', - status: false, - date: 14040401, - }, - { - id: "5kma53ae", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "bhqecj4p", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "m5gr84i9", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "3u1reuv4", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "derv1ws0", - type: 'تایپ', - status: false, - date: 14040401, - }, - { - id: "5kma53ae", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "bhqecj4p", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "m5gr84i9", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "3u1reuv4", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "derv1ws0", - type: 'تایپ', - status: false, - date: 14040401, - }, - { - id: "5kma53ae", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "bhqecj4p", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "m5gr84i9", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "3u1reuv4", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "derv1ws0", - type: 'تایپ', - status: false, - date: 14040401, - }, - { - id: "5kma53ae", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "bhqecj4p", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "m5gr84i9", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "3u1reuv4", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "derv1ws0", - type: 'تایپ', - status: false, - date: 14040401, - }, - { - id: "5kma53ae", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "bhqecj4p", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "m5gr84i9", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "3u1reuv4", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "derv1ws0", - type: 'تایپ', - status: false, - date: 14040401, - }, - { - id: "5kma53ae", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "bhqecj4p", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "m5gr84i9", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "3u1reuv4", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "derv1ws0", - type: 'تایپ', - status: false, - date: 14040401, - }, - { - id: "5kma53ae", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "bhqecj4p", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "m5gr84i9", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "3u1reuv4", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "derv1ws0", - type: 'تایپ', - status: false, - date: 14040401, - }, - { - id: "5kma53ae", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "bhqecj4p", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "m5gr84i9", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "3u1reuv4", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "derv1ws0", - type: 'تایپ', - status: false, - date: 14040401, - }, - { - id: "5kma53ae", - type: 'تایپ', - status: true, - date: 14040401, - }, - { - id: "bhqecj4p", - type: 'تایپ', - status: true, - date: 14040401, - }, + { + id: 'm5gr84i9', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: '3u1reuv4', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'derv1ws0', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: false, + date: 14040401 + }, + { + id: '5kma53ae', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'bhqecj4p', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'm5gr84i9', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: '3u1reuv4', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'derv1ws0', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: false, + date: 14040401 + }, + { + id: '5kma53ae', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'bhqecj4p', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'm5gr84i9', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: '3u1reuv4', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'derv1ws0', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: false, + date: 14040401 + }, + { + id: '5kma53ae', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'bhqecj4p', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'm5gr84i9', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: '3u1reuv4', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'derv1ws0', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: false, + date: 14040401 + }, + { + id: '5kma53ae', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'bhqecj4p', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'm5gr84i9', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: '3u1reuv4', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'derv1ws0', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: false, + date: 14040401 + }, + { + id: '5kma53ae', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'bhqecj4p', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'm5gr84i9', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: '3u1reuv4', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'derv1ws0', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: false, + date: 14040401 + }, + { + id: '5kma53ae', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'bhqecj4p', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'm5gr84i9', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: '3u1reuv4', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'derv1ws0', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: false, + date: 14040401 + }, + { + id: '5kma53ae', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'bhqecj4p', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'm5gr84i9', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: '3u1reuv4', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'derv1ws0', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: false, + date: 14040401 + }, + { + id: '5kma53ae', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'bhqecj4p', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'm5gr84i9', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: '3u1reuv4', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'derv1ws0', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: false, + date: 14040401 + }, + { + id: '5kma53ae', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + }, + { + id: 'bhqecj4p', + type: 'لورم ایپسوم متن ساختگی با تولید سادگی', + status: true, + date: 14040401 + } ] export type Payment = { - id: string - type: string - // status: "pending" | "processing" | "success" | "failed" - status: boolean - date: number + id: string + type: string + // status: "pending" | "processing" | "success" | "failed" + status: boolean + date: number } export const columns: ColumnDef[] = [ - { - accessorKey: "id", - header: () =>
شماره
, - cell: ({ row }) => ( -
{row.getValue("id")}
- ), - }, - { - accessorKey: "type", - header: () => "نوع تراکنش", - cell: ({ row }) =>
{row.getValue("type")}
, - }, - { - accessorKey: "date", - header: () =>
تاریخ
, - cell: ({ row }) => { - const date = parseFloat(row.getValue("date")) + { + accessorKey: 'id', + header: () =>
شماره
, + cell: ({ row }) => ( +
{row.getValue('id')}
+ ) + }, + { + accessorKey: 'type', + header: () =>
نوع تراکنش
, + cell: ({ row }) =>
{row.getValue('type')}
+ }, + { + accessorKey: 'date', + header: () =>
تاریخ
, + cell: ({ row }) => { + const date = parseFloat(row.getValue('date')) - // Format the amount as a dollar amount - // const formatted = new Intl.NumberFormat("en-US", { - // style: "currency", - // currency: "USD", - // }).format(amount) - // TODO: convert to jalali + // Format the amount as a dollar amount + // const formatted = new Intl.NumberFormat("en-US", { + // style: "currency", + // currency: "USD", + // }).format(amount) + // TODO: convert to jalali - return
{date}
- }, - }, - { - accessorKey: "status", - header: () =>
وضعیت
, - cell: ({ row }) => { - const status = Boolean(row.getValue("status")) + return
{date}
+ } + }, + { + accessorKey: 'status', + header: () =>
وضعیت
, + cell: ({ row }) => { + const status = Boolean(row.getValue('status')) - const str = status ? 'پاسخ داده شده' : 'پاسخ داده نشده'; + const str = status ? 'پاسخ داده شده' : 'پاسخ داده نشده' - return ( -
- - {str} -
- ) - }, - }, - { - id: "actions", - enableHiding: false, - cell: ({ row }) => { - const status = Boolean(row.getValue("status")) + return ( +
+ + {str} +
+ ) + } + }, + { + id: 'actions', + enableHiding: false, + cell: ({ row }) => { + const status = Boolean(row.getValue('status')) - return ( - <> - - - ) - }, - }, + return ( + <> + + + ) + } + } ] -export function DataTableDemo() { - const [sorting, setSorting] = React.useState([]) - const [columnFilters, setColumnFilters] = React.useState( - [] - ) - const [columnVisibility, setColumnVisibility] = - React.useState({}) - const [rowSelection, setRowSelection] = React.useState({}) +export function DataTableDemo () { + const [sorting, setSorting] = React.useState([]) + const [columnFilters, setColumnFilters] = React.useState( + [] + ) + const [columnVisibility, setColumnVisibility] = + React.useState({}) + const [rowSelection, setRowSelection] = React.useState({}) - const table = useReactTable({ - data, - columns, - onSortingChange: setSorting, - onColumnFiltersChange: setColumnFilters, - getCoreRowModel: getCoreRowModel(), - getPaginationRowModel: getPaginationRowModel(), - getSortedRowModel: getSortedRowModel(), - getFilteredRowModel: getFilteredRowModel(), - onColumnVisibilityChange: setColumnVisibility, - onRowSelectionChange: setRowSelection, - state: { - sorting, - columnFilters, - columnVisibility, - rowSelection, - }, - }) + const table = useReactTable({ + data, + columns, + onSortingChange: setSorting, + onColumnFiltersChange: setColumnFilters, + getCoreRowModel: getCoreRowModel(), + getPaginationRowModel: getPaginationRowModel(), + getSortedRowModel: getSortedRowModel(), + getFilteredRowModel: getFilteredRowModel(), + onColumnVisibilityChange: setColumnVisibility, + onRowSelectionChange: setRowSelection, + state: { + sorting, + columnFilters, + columnVisibility, + rowSelection + } + }) - return ( -
-
- - - {table.getHeaderGroups().map((headerGroup) => ( - - {headerGroup.headers.map((header) => { - return ( - - {header.isPlaceholder - ? null - : flexRender( - header.column.columnDef.header, - header.getContext() - )} - - ) - })} - - ))} - - - {table.getRowModel().rows?.length ? ( - table.getRowModel().rows.map((row) => ( - - {row.getVisibleCells().map((cell) => ( - - {flexRender( - cell.column.columnDef.cell, - cell.getContext() - )} - - ))} - - )) - ) : ( - - - No results. - - - )} - -
-
-
-
- نمایش: {table.getRowModel().rows.length} از {table.getFilteredRowModel().rows.length} -
-
- + + + + + +
+
+
+ ) }