import React from 'react'; import { confirm, Modal, Form, Icon, Checkbox, Input } from 'UI'; import { Button } from 'antd'; import cn from 'classnames'; import { toast } from 'react-toastify'; import { useStore } from 'App/mstore'; import { observer } from 'mobx-react-lite'; import stl from './SaveSearchModal.module.css'; import { useTranslation } from 'react-i18next'; interface Props { show: boolean; closeHandler: () => void; rename?: boolean; } function SaveSearchModal({ show, closeHandler, rename = false }: Props) { const { t } = useTranslation(); const { searchStore, userStore } = useStore(); const userId = userStore.account.id; const { savedSearch } = searchStore; const loading = searchStore.isSaving; const onNameChange = ({ target: { value } }: any) => { searchStore.editSavedSearch({ name: value }); }; const onSave = () => { searchStore .save(savedSearch.exists() ? savedSearch.searchId : null, rename) .then(() => { toast.success( `${savedSearch.exists() ? t('Updated') : t('Saved')} ${t('Successfully')}`, ); closeHandler(); }) .catch((e) => { console.error(e); toast.error(t('Something went wrong, please try again')); }); }; const onDelete = async () => { if ( await confirm({ header: t('Confirm'), confirmButton: t('Yes, delete'), confirmation: t( 'Are you sure you want to permanently delete this Saved search?', ), }) ) { searchStore.removeSavedSearch(savedSearch.searchId!).then(() => { closeHandler(); }); } }; const onChangeOption = ({ target: { checked, name } }: any) => searchStore.editSavedSearch({ [name]: checked }); return (
{t('Save Search')}
searchStore.editSavedSearch({ isPublic: !savedSearch.isPublic })} > {t('Team Visible')}
{/* {savedSearch.exists() &&
Changes in filters will be updated.
} */}
{savedSearch.exists() && ( )}
); } export default observer(SaveSearchModal);