@@ -1,7 +1,9 @@ import * as React from 'react' import { Box, Typography } from '@mui/material' +import { useRouter } from 'next/router' import { NextPageWithLayout } from '#/pages/_app' +import { useAppSelector } from '#/app/store/store' import { getDeviceType } from '#/shared/lib/helpers/get-type-device' import { PromoCardsList } from './promo-cards-list' import type { PromoCardType } from './promo-card' @@ -10,6 +12,15 @@ export interface HomePageProps {} const Home: NextPageWithLayout = () => { const deviceType = getDeviceType() + const router = useRouter() + const account_type = useAppSelector((state) => state.user.account_type) + + // Редирект на dashboard, если account_type не соответствует regular или business_host + React.useEffect(() => { + if (account_type && account_type !== 'regular' && account_type !== 'business_host') { + router.replace('/dashboard') + } + }, [account_type, router]) const promoCards: PromoCardType[] = [ { @@ -15,6 +15,7 @@ import { useSession } from 'next-auth/react' import { useUserSettingsContext } from '#/entities/user-account' import { BUSINESS_ERROR_REPORT, ERROR_REPORT, getModalById } from '#/features/modals' +import { useAppSelector } from '#/app/store/store' import '../styles/styles.module.css' import styles from '../styles/styles.module.css' @@ -113,6 +114,7 @@ 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 error_report = getModalById(ERROR_REPORT) const business_error_report = getModalById(BUSINESS_ERROR_REPORT) @@ -120,6 +122,15 @@ export const SideMenu = ({}) => { const open = useMemo(() => getOptionValue('sidemenu', { sidemenu_state: 'opened' }).sidemenu_state, [settings]) + const filteredMenuListTop = useMemo(() => { + return menuListTop.filter((item) => { + if (item.title === 'Главная') { + return account_type === 'regular' || account_type === 'business_host' + } + return true + }) + }, [account_type]) + return ( { {status === 'authenticated' && ( <> - {menuListTop.map((el) => { + {filteredMenuListTop.map((el) => { return (