import { useRouter } from "next/router"; import { useState } from "react"; import { useForm } from "react-hook-form"; import { Toaster } from "react-hot-toast"; import { APP_NAME } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { Alert, Button, Form, TextField } from "@calcom/ui"; export default function AppleCalendarSetup() { const { t } = useLocale(); const router = useRouter(); const form = useForm({ defaultValues: { username: "", password: "", }, }); const [errorMessage, setErrorMessage] = useState(""); return (
{/* eslint-disable @next/next/no-img-element */} Apple Calendar

{t("connect_apple_server")}

{t("apple_server_generate_password", { appName: APP_NAME })}{" "} https://appleid.apple.com/account/manage . {t("credentials_stored_encrypted")}
{ setErrorMessage(""); const res = await fetch("/api/integrations/applecalendar/add", { method: "POST", body: JSON.stringify(values), headers: { "Content-Type": "application/json", }, }); const json = await res.json(); if (!res.ok) { setErrorMessage(json?.message || t("something_went_wrong")); } else { router.push(json.url); } }}>
{errorMessage && }
); }