import { zodResolver } from "@hookform/resolvers/zod"; import { useRouter } from "next/router"; import { useState, useEffect } from "react"; import { Check, X } from "react-feather"; import { useForm, Controller } from "react-hook-form"; import { Toaster } from "react-hot-toast"; import z from "zod"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; import Button from "@calcom/ui/v2/Button"; import { Form, TextField } from "@calcom/ui/v2/form/fields"; 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/closecomothercalendar/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"); }} /> )} />
); }