import { Form, Formik } from "formik"; import * as Yup from "yup"; import { PopupSpec } from "@/components/admin/connectors/Popup"; import { SlackBotTokens } from "@/lib/types"; import { TextArrayField, TextFormField, } from "@/components/admin/connectors/Field"; import { createSlackBotConfig, setSlackBotTokens, updateSlackBotConfig, } from "./lib"; interface SlackBotTokensFormProps { onClose: () => void; setPopup: (popupSpec: PopupSpec | null) => void; existingTokens?: SlackBotTokens; } export const SlackBotTokensForm = ({ onClose, setPopup, existingTokens, }: SlackBotTokensFormProps) => { return (
event.stopPropagation()} > { formikHelpers.setSubmitting(true); const response = await setSlackBotTokens(values); formikHelpers.setSubmitting(false); if (response.ok) { setPopup({ message: "Successfully set Slack tokens!", type: "success", }); onClose(); } else { const errorMsg = await response.text(); setPopup({ message: `Error setting Slack tokens - ${errorMsg}`, type: "error", }); } }} > {({ isSubmitting }) => (

Set Slack Bot Tokens

)}
); };