@@ -15,7 +15,6 @@ import { useSession } from 'next-auth/react' import { useNextStep } from 'nextstepjs' import { useAppSelector } from '#/app/store/store' -import { useUserSettingsContext } from '#/entities/user-account' import { BUSINESS_ERROR_REPORT, ERROR_REPORT, getModalById } from '#/features/modals' import '../styles/styles.module.css' @@ -121,7 +120,6 @@ const Drawer = styled(MuiDrawer, { shouldForwardProp: (prop) => prop !== 'open' export const SideMenu = ({}) => { const { status } = useSession() const { pathname, asPath } = useRouter() - const { getOptionValue, settings, updateSettings } = useUserSettingsContext() const account_type = useAppSelector((state) => state.user.account_type) const { isNextStepVisible } = useNextStep() @@ -129,11 +127,11 @@ export const SideMenu = ({}) => { const business_error_report = getModalById(BUSINESS_ERROR_REPORT) const match = useMediaQuery('(min-height:800px)') - const open = useMemo(() => getOptionValue('sidemenu', { sidemenu_state: 'opened' }).sidemenu_state, [settings]) + const [isOpen, setIsOpen] = React.useState(false) useEffect(() => { - if (isNextStepVisible) updateSettings('sidemenu', { sidemenu_state: 'closed' }) - }, [isNextStepVisible, updateSettings]) + if (isNextStepVisible) setIsOpen(false) + }, [isNextStepVisible]) const filteredMenuListTop = useMemo(() => { return menuListTop.filter((item) => { @@ -146,18 +144,18 @@ export const SideMenu = ({}) => { }, [account_type]) const handleCloseDrawer = () => { - if (!isNextStepVisible) updateSettings('sidemenu', { sidemenu_state: 'closed' }) + if (isNextStepVisible) return + setIsOpen(false) } const handleToggleOpen = () => { - if (!isNextStepVisible) { - updateSettings('sidemenu', { sidemenu_state: open === 'opened' ? 'closed' : 'opened' }) - } + if (isNextStepVisible) return + setIsOpen((v) => !v) } return ( <> - {open === 'opened' && ( + {isOpen && ( { }} variant='permanent' anchor='left' - open={open === 'opened'} + open={isOpen} > { marginLeft: -1, marginRight: 5, transition: 'transform 0.4s ease', - transform: open === 'closed' ? 'rotate(180deg)' : 'rotate(0deg)', + transform: isOpen ? 'rotate(0deg)' : 'rotate(180deg)', }} src={'/arrow-left.svg'} width={20} @@ -218,7 +216,7 @@ export const SideMenu = ({}) => { return ( { return ( { }} > { }} > { /> { /> - - {open === 'opened' && ( + + {isOpen && (