import { useState } from "react"; import { useRouter } from "next/router"; import { useSaveIntegrationAccessToken } from "@app/hooks/api"; import { Button, Card, CardTitle, FormControl, Input } from "../../../components/v2"; export default function CloudflareWorkersIntegrationPage() { const router = useRouter(); const { mutateAsync } = useSaveIntegrationAccessToken(); const [accessKey, setAccessKey] = useState(""); const [accessKeyErrorText, setAccessKeyErrorText] = useState(""); const [accountId, setAccountId] = useState(""); const [accountIdErrorText, setAccountIdErrorText] = useState(""); const [isLoading, setIsLoading] = useState(false); const handleButtonClick = async () => { try { setAccessKeyErrorText(""); setAccountIdErrorText(""); if (accessKey.length === 0 || accountId.length === 0) { if (accessKey.length === 0) setAccessKeyErrorText("API token cannot be blank!"); if (accountId.length === 0) setAccountIdErrorText("Account ID cannot be blank!"); return; } setIsLoading(true); const integrationAuth = await mutateAsync({ workspaceId: localStorage.getItem("projectData.id"), integration: "cloudflare-workers", accessId: accountId, accessToken: accessKey }); setAccessKey(""); setAccountId(""); setIsLoading(false); router.push( `/integrations/cloudflare-workers/create?integrationAuthId=${integrationAuth.id}` ); } catch (err) { console.error(err); } }; return (