"use client"
import { z } from "zod"
import { Button } from "@/components/ui/button"
import { Drawer, DrawerClose, DrawerContent, DrawerFooter, DrawerHeader, DrawerTrigger } from "@/components/ui/drawer"
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { useSortable } from "@dnd-kit/sortable"
import { IconGripVertical } from "@tabler/icons-react"
import { useIsMobile } from "@/hooks/use-mobile"
import { Separator } from "@/components/ui/separator"
import { ColumnDef, flexRender, Row } from "@tanstack/react-table"
import { TableCell, TableRow } from "@/components/ui/table"
import { CSS } from "@dnd-kit/utilities"
import { schema, schemaType } from "./schema"
import { dateToLocaleString } from "@/lib/utils"
import { Pencil, Trash } from "lucide-react"
function DragHandle({ id }: { id: number }) {
const { attributes, listeners } = useSortable({ id })
return (
)
}
export function DraggableRow({ row }: { row: Row> }) {
const { transform, transition, setNodeRef, isDragging } = useSortable({ id: row.original._id })
return (
{row.getVisibleCells().map((cell) => (
{flexRender(cell.column.columnDef.cell, cell.getContext())}
))}
)
}
function getColumns(router: any, deleteHandler: (id: string) => void): ColumnDef[] {
return [
{
accessorKey: "buildType.token",
header: "Token",
cell: ({ getValue }) => getValue(),
},
{
accessorKey: "collectionToken",
header: "Collection Token",
cell: ({ getValue }) => getValue(),
},
{
accessorKey: "info.govAddressCode",
header: "Gov Address Code",
cell: ({ getValue }) => getValue(),
},
{
accessorKey: "info.buildName",
header: "Build Name",
cell: ({ getValue }) => getValue(),
},
{
accessorKey: "info.buildNo",
header: "Build No",
cell: ({ getValue }) => getValue(),
},
{
accessorKey: "info.maxFloor",
header: "Max Floor",
cell: ({ getValue }) => getValue(),
},
{
accessorKey: "info.undergroundFloor",
header: "Underground Floor",
cell: ({ getValue }) => getValue(),
},
{
accessorKey: "info.buildDate",
header: "Build Date",
cell: ({ getValue }) => getValue(),
},
{
accessorKey: "info.decisionPeriodDate",
header: "Decision Period Date",
cell: ({ getValue }) => getValue(),
},
{
accessorKey: "info.taxNo",
header: "Tax No",
cell: ({ getValue }) => getValue(),
},
{
accessorKey: "info.liftCount",
header: "Lift Count",
cell: ({ getValue }) => getValue(),
},
{
accessorKey: "info.heatingSystem",
header: "Heating System",
cell: ({ getValue }) => getValue(),
},
{
accessorKey: "info.coolingSystem",
header: "Cooling System",
cell: ({ getValue }) => getValue(),
},
{
accessorKey: "info.hotWaterSystem",
header: "Hot Water System",
cell: ({ getValue }) => getValue(),
},
{
accessorKey: "info.blockServiceManCount",
header: "Block Service Man Count",
cell: ({ getValue }) => getValue(),
},
{
accessorKey: "info.securityServiceManCount",
header: "Security Service Man Count",
cell: ({ getValue }) => getValue(),
},
{
accessorKey: "info.garageCount",
header: "Garage Count",
cell: ({ getValue }) => getValue(),
},
{
accessorKey: "info.managementRoomId",
header: "Management Room ID",
cell: ({ getValue }) => getValue(),
},
{
id: "actions",
header: "Actions",
cell: ({ row }) => {
return (
);
},
}
]
}
export { getColumns };