import { zodResolver } from "@hookform/resolvers/zod"; import { useRouter } from "next/router"; import { useEffect, useState } from "react"; import { Controller, useForm } from "react-hook-form"; import { Toaster } from "react-hot-toast"; import z from "zod"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { Button, Form, showToast, TextField, Icon } from "@calcom/ui"; const formSchema = z.object({ api_key: z.string(), }); export default function CloseComSetup() { const { t } = useLocale(); const router = useRouter(); const [testPassed, setTestPassed] = useState(undefined); const [testLoading, setTestLoading] = useState(false); const form = useForm<{ api_key: string; }>({ resolver: zodResolver(formSchema), }); useEffect(() => { const timer = setTimeout(() => { if (testPassed === false) { setTestPassed(undefined); } }, 3000); return () => clearTimeout(timer); }, [testPassed]); return (
{/* eslint-disable @next/next/no-img-element */} Apple Calendar

{t("provide_api_key")}

{t("generate_api_key_description")}{" "} Close.com . {t("it_stored_encrypted")}
{ const res = await fetch("/api/integrations/closecom/add", { method: "POST", body: JSON.stringify(values), headers: { "Content-Type": "application/json", }, }); const json = await res.json(); if (res.ok) { router.push(json.url); } else { showToast(json.message, "error"); } }}>
( { onChange(e.target.value); form.setValue("api_key", e.target.value); await form.trigger("api_key"); }} /> )} />
); }