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