import { observer } from 'mobx-react-lite'; import React from 'react'; import { useStore } from 'App/mstore'; import { confirm, Form, Input, Message } from 'UI'; import { Button } from 'antd'; import { useTranslation } from 'react-i18next'; interface Props { onClose: () => void; } function TeamsAddForm({ onClose }: Props) { const { t } = useTranslation(); const { integrationsStore } = useStore(); const { instance } = integrationsStore.msteams; const saving = integrationsStore.msteams.loading; const { errors } = integrationsStore.msteams; const { edit } = integrationsStore.msteams; const onSave = integrationsStore.msteams.saveIntegration; const { init } = integrationsStore.msteams; const onRemove = integrationsStore.msteams.removeInt; const { update } = integrationsStore.msteams; React.useEffect(() => () => init({}), []); const save = () => { if (instance?.exists()) { update().then(() => { void onClose(); }); } else { void onSave().then(() => { void onClose(); }); } }; const remove = async (id: string) => { if ( await confirm({ header: t('Confirm'), confirmButton: t('Yes, delete'), confirmation: t( 'Are you sure you want to permanently delete this channel?', ), }) ) { void onRemove(id).then(onClose); } }; const write = ({ target: { name, value }, }: { target: { name: string; value: string }; }) => edit({ [name]: value }); return (
{errors && (
{errors.map((error: any) => ( {error} ))}
)}
); } export default observer(TeamsAddForm);