diff --git a/src/app/providers/SroreProvider/config/StateSchema.ts b/src/app/providers/SroreProvider/config/StateSchema.ts index 2adc174a..4d6796e5 100644 --- a/src/app/providers/SroreProvider/config/StateSchema.ts +++ b/src/app/providers/SroreProvider/config/StateSchema.ts @@ -1,8 +1,10 @@ +import { CategorySchema } from '@/entities/Category/types/types' import { LoginSchema } from '@/features/login/model/types/types' import { ApiInstance } from '@/shared/api/api' export interface StateSchema { login: LoginSchema + category: CategorySchema } export interface ThunkExtraArg { diff --git a/src/app/providers/SroreProvider/config/store.ts b/src/app/providers/SroreProvider/config/store.ts index eb73b868..afa56ba1 100644 --- a/src/app/providers/SroreProvider/config/store.ts +++ b/src/app/providers/SroreProvider/config/store.ts @@ -2,9 +2,13 @@ import { configureStore, ReducersMapObject } from '@reduxjs/toolkit' import { loginReducer } from '@/features/login/model/slice/loginSlice' import { StateSchema, ThunkExtraArg } from './StateSchema' import { $api } from '@/shared/api/api' +import categorySlice from '@/entities/Category/slice/categorySlice' + +export type RootState = StateSchema const rootReducer: ReducersMapObject = { - login: loginReducer + login: loginReducer, + category: categorySlice } export function createReduxStore(initialState: StateSchema) { diff --git a/src/app/router/AppRouter/ui/AppRouter.tsx b/src/app/router/AppRouter/ui/AppRouter.tsx index 0566066e..416bf6a7 100644 --- a/src/app/router/AppRouter/ui/AppRouter.tsx +++ b/src/app/router/AppRouter/ui/AppRouter.tsx @@ -28,6 +28,11 @@ export const AppRouter = createBrowserRouter([ path: Routes.PRODUCTS_ID, element: }, + // Добавил как временную заглушку пока не будет страницы категории + { + path: Routes.CATEGORIES + '/:slug', + element: + }, { path: Routes.LOGIN, element: diff --git a/src/components/ContextMenuElement/ContextMenuElement.tsx b/src/components/ContextMenuElement/ContextMenuElement.tsx index 5067621b..fd2df7f3 100644 --- a/src/components/ContextMenuElement/ContextMenuElement.tsx +++ b/src/components/ContextMenuElement/ContextMenuElement.tsx @@ -1,7 +1,6 @@ -import { FC, ReactNode, useEffect, useRef, useState } from 'react' -import styles from './contextMenuElement.module.scss' - +import { type FC, ReactNode, useEffect, useRef, useState } from 'react' import { LEFT_POSITION, RIGHT_POSITION } from '@/shared/constants/constants' +import styles from './contextMenuElement.module.scss' type TContextMenuElement = { readonly children: ReactNode @@ -14,8 +13,12 @@ type TContextMenuElement = { * @param {string} className - нужно для изменения некоторых css-параметров * @param {string} type - нужно для определения, к какому краю прилегает текст */ - -const ContextMenuElement: FC = ({ children, content, className, type = LEFT_POSITION }) => { +const ContextMenuElement: FC = ({ + children, + content, + className, + type = LEFT_POSITION +}) => { const ref = useRef(null) const [top, setTop] = useState(0) @@ -43,11 +46,17 @@ const ContextMenuElement: FC = ({ children, content, classN } const contextMenu = ( -
+
{content}
) + // @TODO: Добавить обработчик клика по элементу из ContextMenuElement + // От таких кликов меню должно скрываться + // https://github.com/Studio-Yandex-Practicum/maxboom_frontend/issues/188 + return (
() + const categories = useSelector(selectCategories) + const displayedCategories = useSelector(selectDisplayedCategories) + const aboutUsNode = useMemo( () => (
    @@ -91,51 +100,32 @@ function Header() { const catalogNode = useMemo( () => (
      - {catalogListData.map((item, index) => ( -
    • - - {item.name} - -
    • + {categories.map(category => ( + ))}
    ), - [] + [categories] ) + useEffect(() => { + dispatch(fetchCategories()) + }, [dispatch]) + return (