import { useState } from "react"; import { useForm } from "react-hook-form"; import { Alert } from "@calcom/ui/Alert"; import Button from "@calcom/ui/Button"; import { Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader, DialogProps, } from "@calcom/ui/Dialog"; import { Form, TextField } from "@calcom/ui/form/fields"; export const ADD_INTEGRATION_FORM_TITLE = "addAppleIntegration"; function AddIntegrationModal(props: DialogProps) { const form = useForm({ defaultValues: { username: "", password: "", }, }); const [errorMessage, setErrorMessage] = useState(""); return ( Generate an app specific password to use with Cal.com at{" "} https://appleid.apple.com/account/manage . Your credentials will be stored and 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 || "Something went wrong"); } else { props.onOpenChange?.(false); } }}>
{errorMessage && } { props.onOpenChange?.(false); }} asChild>
); } export default AddIntegrationModal;