import React from 'react'; import { Button, Modal, Form, Icon, Checkbox, Input } from 'UI'; import { confirm } from 'UI'; import stl from './SaveSearchModal.module.css'; import cn from 'classnames'; import { toast } from 'react-toastify'; import { useStore } from 'App/mstore'; import { observer } from 'mobx-react-lite'; interface Props { show: boolean; closeHandler: () => void; rename?: boolean; } function SaveSearchModal({ show, closeHandler, rename = false }: Props) { const { searchStore, userStore } = useStore(); const userId = userStore.account.id; const savedSearch = searchStore.savedSearch; 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() ? 'Updated' : 'Saved'} Successfully`); closeHandler(); }) .catch((e) => { toast.error('Something went wrong, please try again'); }); }; const onDelete = async () => { if ( await confirm({ header: 'Confirm', confirmButton: 'Yes, delete', confirmation: `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 (
{'Save Search'}
searchStore.editSavedSearch({ isPublic: !savedSearch.isPublic })} > Team Visible
{/* {savedSearch.exists() &&
Changes in filters will be updated.
} */}
{savedSearch.exists() && ( )}
); } export default observer(SaveSearchModal);