import React, { useState } from "react"; import { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import { Button } from "@/components/ui/button"; import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { ControllerTableItems } from "@/constants"; import Link from "next/link"; import { Decrypt, convertDate } from "@/lib/utils"; import useData from "@/store/useData"; import { Label } from "./ui/label"; import { Input } from "./ui/input"; import { useRouter } from "next/navigation"; import { toast } from "sonner"; interface Complaint { id: string; trackingNumber: string; title: string; category: { id: string; title: string; description: string; }; status: number; registeredAt: string; lastChanged: string; lastActor: number; cipherKeyInspector: string; } export default function TableController({ data, checkKey, }: { data: Complaint[]; checkKey: (item:any) => any; }) { console.log(data); const saveData = useData((state) => state.saveData); const [selectedFile, setSelectedFile] = useState(null); const router = useRouter(); const handleFileChange = (event: any) => { const file = event.target.files[0]; const reader = new FileReader(); reader.onload = (e) => { const contents = e?.target?.result; // Process the contents of the file here setSelectedFile(contents); console.log(contents); }; reader.readAsText(file); }; // const checkKey = (item: any) => { // const dcKey = Decrypt(item.cipherKeyInspector, selectedFile); // if (dcKey != false && dcKey != null) { // saveData({ // trackingNumber: item.trackingNumber, // password: Decrypt(item.cipherKeyInspector, selectedFile), // }); // router.push(`/UserPanel/ControllerDashboard/Complaints/${item.id}`); // } else { // } // }; return (
{/* */} {/* A list of your recent invoices. */} ردیف تاریخ موضوع دستگاه مربوطه {data?.map((item: Complaint, index: number) => { return ( checkKey(item) // saveData({ // trackingNumber: item.trackingNumber, // password: Decrypt(item.cipherKeyInspector), // }) } className=" hover:bg-gray-200 cursor-pointer" key={item.id} > {/* */} {index + 1} {convertDate(item.registeredAt)} {item?.category ? item.category.title : "-"} - {/* */} ); })}
{/* */} بارگذاری کلید خصوصی لطفا کلید خصوصی خود را آپلود نمایید.
{/* */}
); }