From 8135c2895230b3023adf8f1838d77eee974c5314 Mon Sep 17 00:00:00 2001 From: Bohdan Date: Wed, 24 Jul 2024 12:09:03 +0300 Subject: [PATCH] remove unnessesary code --- .../app-button-menu/AppButtonMenu.tsx | 21 +++---------------- .../app-select-button/AppSelectButton.tsx | 8 +++---- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/src/components/app-button-menu/AppButtonMenu.tsx b/src/components/app-button-menu/AppButtonMenu.tsx index f0f197709..33dcea531 100644 --- a/src/components/app-button-menu/AppButtonMenu.tsx +++ b/src/components/app-button-menu/AppButtonMenu.tsx @@ -35,7 +35,6 @@ interface AppButtonMenuProps extends Omit { valueField?: keyof T showNoneProperty?: boolean customSx?: { root?: SxProps } - disabled?: boolean } const AppButtonMenu = >({ @@ -52,24 +51,13 @@ const AppButtonMenu = >({ const { t } = useTranslation() const [inputValue, setInputValue] = useState('') const [selectedNames, setSelectedNames] = useState([]) - const [, setIsNoneSelectedNames] = useState(false) const { anchorEl, openMenu, renderMenu } = useMenu() const onMenuItemClick = (item: string, id: string) => { - if (item === 'No category') { - if (selectedNames.includes(item)) { - setIsNoneSelectedNames(false) - setSelectedItems([]) - } else { - setIsNoneSelectedNames(true) - setSelectedItems([id]) - } + if (selectedNames.includes(item)) { + setSelectedItems(selectedItems.filter((selected) => selected !== id)) } else { - if (selectedNames.includes(item)) { - setSelectedItems(selectedItems.filter((selected) => selected !== id)) - } else { - setSelectedItems([...selectedItems, id]) - } + setSelectedItems([...selectedItems, id]) } } @@ -99,12 +87,9 @@ const AppButtonMenu = >({ const menuItems = filteredItems.map((item) => { const field = String(valueField ? (item as T)[valueField] : item) const id = item._id - const isDisabled = - selectedNames.includes('No category') && field !== 'No category' return ( onMenuItemClick(field, id)} > diff --git a/src/components/app-select-button/AppSelectButton.tsx b/src/components/app-select-button/AppSelectButton.tsx index 34821a0f8..299ec8c3a 100644 --- a/src/components/app-select-button/AppSelectButton.tsx +++ b/src/components/app-select-button/AppSelectButton.tsx @@ -6,19 +6,17 @@ import { styles } from '~/components/app-select-button/AppSelectButton.styles' interface AppSelectButtonProps { onMenuItemClick: () => void checked: boolean - disabled?: boolean children: ReactNode } const AppSelectButton: FC = ({ checked, children, - onMenuItemClick, - disabled = false + onMenuItemClick }) => { return ( - - + + {children} )