-
-

-
-
{product.name}
-
{product.description}
-
-
-
Category:
-
{product.category}
-
-
-
Condition:
-
{product.condition}
-
+ {showAddForm && (
+
+
+
setShowAddForm(false)}
+ isEditing={false}
+ />
+
-
-
-
- {product.price}
-
-
-
-
-
-
-
+ )}
+
+ {/* 3 карточки в ряд на всех экранах кроме мобильных */}
+
+ {products.map(product => (
+
+ ))}
-
- ))}
-
-
- );
+
+ {products.length === 0 && !showAddForm && (
+
+
Товаров пока нет
+
Добавьте первый товар в каталог
+
+
+ )}
+
+ );
}
\ No newline at end of file
diff --git a/src/Pages/LikesPage.jsx b/src/Pages/LikesPage.jsx
index 0dbef1b..dc8c4d4 100644
--- a/src/Pages/LikesPage.jsx
+++ b/src/Pages/LikesPage.jsx
@@ -1,18 +1,115 @@
+import { useContext } from 'react';
import { Link } from 'react-router-dom';
+import { useLikesContext } from '../context/LikesContext.jsx';
+import { useBasketContext } from '../context/BasketContext.jsx';
export default function LikesPage() {
- return (
-
-
-
Здесь будут лежать товары, которые тебе понравились
-
А пока здесь так пусто...
-

-
-
- Вернуться в каталог
-
-
-
-
- );
+ const { likesItems, removeFromLikes, loading, error } = useLikesContext();
+ const { addToBasket } = useBasketContext();
+
+ const handleMoveToBasket = async (product) => {
+ try {
+ await addToBasket(product);
+ await removeFromLikes(product.id);
+ alert('Товар перенесен в корзину!');
+ } catch (err) {
+ alert('Ошибка при переносе товара в корзину');
+ }
+ };
+
+ const handleRemoveFromLikes = async (productId) => {
+ try {
+ await removeFromLikes(productId);
+ alert('Товар удален из избранного!');
+ } catch (err) {
+ alert('Ошибка при удалении из избранного');
+ }
+ };
+
+ if (loading) {
+ return (
+
+
+
+ );
+ }
+
+ if (error) {
+ return (
+
+
+ {error}
+
+
+ );
+ }
+
+ if (likesItems.length === 0) {
+ return (
+
+
+
Здесь будут лежать товары, которые тебе понравились
+
А пока здесь так пусто...
+

+
+
+ Вернуться в каталог
+
+
+
+
+ );
+ }
+
+ return (
+
+ Избранное
+
+ {likesItems.map(item => (
+
+
+

+
+
{item.name}
+
{item.description}
+
+
+
Category:
+
{item.category || '-'}
+
+
+
Condition:
+
{item.condition || '-'}
+
+
+
+
+
+
${item.price}
+
+
+
+
+
+
+
+
+ ))}
+
+
+ );
}
\ No newline at end of file
diff --git a/src/components/Navbar.jsx b/src/components/Navbar.jsx
index dfcd9b6..b133089 100644
--- a/src/components/Navbar.jsx
+++ b/src/components/Navbar.jsx
@@ -1,6 +1,15 @@
+// src/components/Navbar.jsx
import { Link } from 'react-router-dom';
+import { useBasketContext } from '../context/BasketContext.jsx';
+import { useLikesContext } from '../context/LikesContext.jsx';
export default function Navbar() {
+ const { basketItems, getBasketCount } = useBasketContext();
+ const { getLikesCount } = useLikesContext();
+
+ const basketItemsCount = getBasketCount();
+ const likesItemsCount = getLikesCount();
+
return (