добавил ветку main-page
This commit is contained in:
1 parent
1fe3ba2ba5
commit
8dc704c466
41 files changed
+1988
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import React, { useEffect } from "react";
|
||||
import { useParams } from "react-router-dom";
|
||||
import type { RootState } from "../../app/store";
|
||||
import { getCategoryProducts } from "../../features/catalog/catalogSlice";
|
||||
import CatalogSidebar from "../../features/catalog/catalogeSidebar"
|
||||
import ProductGrid from "../../features/catalog/ProductGrid";
|
||||
import styles from "../../features/catalog/catalog.module.css";
|
||||
import { useAppDispatch, useAppSelector } from "../../app/hooks";
|
||||
|
||||
const CatalogPage: React.FC = () => {
|
||||
const { category } = useParams<{ category: string }>();
|
||||
const dispatch = useAppDispatch()
|
||||
const { loading, filtered, error } = useAppSelector((s: RootState) => s.catalog);
|
||||
|
||||
useEffect(() => {
|
||||
if (category) dispatch(getCategoryProducts(category));
|
||||
}, [category]);
|
||||
|
||||
return (
|
||||
<div className={styles.catalogWrapper}>
|
||||
<CatalogSidebar />
|
||||
<div className={styles.productsSection}>
|
||||
{loading && <p>Загрузка...</p>}
|
||||
{error && <p>Ошибка: {error}</p>}
|
||||
<ProductGrid products={filtered} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default CatalogPage;
|
||||
Reference in new issue
Block a user