"use client"; import React from "react"; import AddDocumentIcon from "@/components/Icons/AddDocument"; import Popup from "@/components/Popup"; import { useState } from "react"; import Pterodactyl from "@/components/Pterodactyl"; import { useSearchParams } from "next/navigation"; const Index = () => { const [showPopup, setShowPopup] = useState(false); const [fileName, setFileName] = useState(""); const urlParams = useSearchParams(); const serverId = urlParams.get("serverid") || ""; const pathParam = urlParams.get("path") || "/"; const apiKey = `${process.env.NEXT_PUBLIC_API_KEY}`; const pterodactyl = new Pterodactyl(); function togglePopup() { setShowPopup(!showPopup); } function handleOk() { console.log({ fileName }); if (fileName) { pterodactyl.setApiKey(apiKey); pterodactyl.setServerId(serverId); pterodactyl.helpers.setWorkingDirectory(pathParam); pterodactyl.files.createFile(fileName); } setShowPopup(false); } return ( <> setFileName(e.target.value)} /> { setFileName(""); togglePopup(); }} className="btn btn-sm" > Add Document > ); }; export default Index;