"use client"; import React, { useState } from "react"; import { useQuery } from "@tanstack/react-query"; import { GenerateKeyPair, GetKeys } from "@/utils/adminApi"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/alert-dialog"; import { Button } from "@/components/ui/button"; import { ThreeDots } from "react-loader-spinner"; import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; // const FormSchema = z.object({ // title: z.string().min(2, { // message: "trackingNumber must be at least 2 characters.", // }), // password: z.string().min(4, { // message: "Password must be at least 4 characters.", // }), // }); export default function AdminKeysManagement() { // List Keys const { data: data1, error: Error1, isLoading: isListLoading, refetch: refetch1, } = useQuery({ queryKey: ["KeysList"], queryFn: () => GetKeys(), // refetchOnWindowFocus: false, }); console.log(data1); // GenerateKeyPair const { data: data2, error: Error2, isLoading: isNewKeyLoading, refetch: refetch2, } = useQuery({ queryKey: ["GenerateKey"], queryFn: () => GenerateKeyPair(), enabled: false, // Disable automatic fetching }); const handleClick = () => { refetch2(); console.log(data2); // Manually trigger the query when the button is clicked }; // } return (
{/* 1 */} اطلاعات کلید جدید {isNewKeyLoading ? (
) : (

کلید عمومی :

{data2?.publicKey}

کلید خصوصی :

{data2?.privateKey}

)}
بستن {/* Continue */}
{/* 1 */} افزودن کلید جدید {isNewKeyLoading ? (
) : ( <> //
// //
// ( // // // کد پیگیری // // // // // // // )} // /> // ( // // // رمز عبور // // // // // // // )} // /> //
//
// //
//
// )}
بستن {/* Continue */}
لیست کلیدها
{/* 2 */}
{data1?.map((item: any) => { return (

عنوان کلید : {item.title}

آی دی بازرس : {item.inspectorId}

); })}
); }