added price filter, changed mobile filter ui
This commit is contained in:
@@ -2,31 +2,16 @@ import React from "react";
|
||||
import { Home, ShoppingBag, ShoppingCart, Heart, User } from "lucide-react";
|
||||
import { Link, useLocation } from "react-router-dom";
|
||||
import styles from "./FooterBar.module.scss";
|
||||
import { useGetCartQuery } from "../../app/api/cartApi";
|
||||
import { useCart } from "../../app/api/useCart";
|
||||
import { useGetFavoritesQuery } from "../../app/api/favoritesApi";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
const FooterBar = () => {
|
||||
const location = useLocation();
|
||||
const { t } = useTranslation();
|
||||
const { data: cartData } = useGetCartQuery();
|
||||
const { cartCount } = useCart();
|
||||
const { data: favoriteData } = useGetFavoritesQuery();
|
||||
|
||||
// FIX: Object içindeki tüm channel'ların item'larını birleştir
|
||||
const getCartCount = () => {
|
||||
if (!cartData?.data || typeof cartData.data !== 'object') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Object.values ile tüm channel array'lerini al
|
||||
const allCartItems = Object.values(cartData.data).flat();
|
||||
|
||||
return allCartItems.reduce((total, item) => {
|
||||
return total + (parseInt(item.product_quantity, 10) || 0);
|
||||
}, 0);
|
||||
};
|
||||
|
||||
const cartCount = getCartCount();
|
||||
const favoriteCount = favoriteData?.length || 0;
|
||||
|
||||
const navItems = [
|
||||
@@ -88,4 +73,4 @@ const FooterBar = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export default FooterBar;
|
||||
export default FooterBar;
|
||||
|
||||
Reference in New Issue
Block a user