changed order
This commit is contained in:
@@ -22,6 +22,7 @@ import { useGetOrdersQuery } from "../../app/api/orderApi";
|
||||
import { useGetFavoritesQuery } from "../../app/api/favoritesApi";
|
||||
import { useAuth } from "../../context/authContext";
|
||||
import ProfileModal from "../../components/MyProfileModal/index";
|
||||
|
||||
const NavbarDown = () => {
|
||||
const [isSearchVisible, setSearchVisible] = useState(false);
|
||||
const { t, i18n } = useTranslation();
|
||||
@@ -34,10 +35,22 @@ const NavbarDown = () => {
|
||||
refetchOnMountOrArgChange: false,
|
||||
});
|
||||
const { isAuthenticated, logout } = useAuth();
|
||||
const cartItemCount =
|
||||
cartData?.data?.reduce((total, item) => {
|
||||
|
||||
// FIX: Object içindeki tüm channel'ların item'larını birleştir
|
||||
const getCartItemCount = () => {
|
||||
if (!cartData?.data || typeof cartData.data !== 'object') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Object.values ile tüm channel array'lerini al ve flat ile birleştir
|
||||
const allCartItems = Object.values(cartData.data).flat();
|
||||
|
||||
return allCartItems.reduce((total, item) => {
|
||||
return total + (parseInt(item.product_quantity, 10) || 0);
|
||||
}, 0) || 0;
|
||||
}, 0);
|
||||
};
|
||||
|
||||
const cartItemCount = getCartItemCount();
|
||||
|
||||
const { data: ordersData } = useGetOrdersQuery();
|
||||
const ordersItemCount = ordersData?.length || 0;
|
||||
@@ -45,6 +58,7 @@ const NavbarDown = () => {
|
||||
const { data: favoritesData } = useGetFavoritesQuery();
|
||||
const favoritesItemCount = favoritesData?.length || 0;
|
||||
const [profileModalVisible, setProfileModalVisible] = useState(false);
|
||||
|
||||
const handleSearch = () => {
|
||||
if (searchQuery.trim()) {
|
||||
refetch();
|
||||
@@ -60,7 +74,7 @@ const NavbarDown = () => {
|
||||
const toggleSearch = () => {
|
||||
setSearchVisible(!isSearchVisible);
|
||||
};
|
||||
|
||||
|
||||
const changeLanguage = (langCode) => {
|
||||
i18n.changeLanguage(langCode);
|
||||
localStorage.setItem("preferredLanguage", langCode);
|
||||
@@ -69,11 +83,10 @@ const NavbarDown = () => {
|
||||
|
||||
const handleLogout = async () => {
|
||||
await logout();
|
||||
|
||||
};
|
||||
|
||||
|
||||
useEffect(() => {}, [isAuthenticated]);
|
||||
|
||||
|
||||
const items = [
|
||||
{
|
||||
key: "tk",
|
||||
@@ -115,6 +128,7 @@ const NavbarDown = () => {
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
const profileItems = [
|
||||
{
|
||||
key: "profile",
|
||||
@@ -125,15 +139,6 @@ const NavbarDown = () => {
|
||||
</div>
|
||||
),
|
||||
},
|
||||
// {
|
||||
// key: "address",
|
||||
// label: (
|
||||
// <Link to="/addresses">
|
||||
// <HomeOutlined style={{ marginRight: "10px" }} />
|
||||
// {t("profile.my_address")}
|
||||
// </Link>
|
||||
// ),
|
||||
// },
|
||||
{
|
||||
key: "logout",
|
||||
label: (
|
||||
@@ -155,7 +160,6 @@ const NavbarDown = () => {
|
||||
</li>
|
||||
<div className={styles.stick}></div>
|
||||
<li>
|
||||
{" "}
|
||||
<Link to={"/brands"}>
|
||||
<button className={styles.navButton}>
|
||||
<BrandIcon />
|
||||
@@ -199,9 +203,6 @@ const NavbarDown = () => {
|
||||
<LoginModal />
|
||||
</li>
|
||||
<div className={styles.stick}></div>
|
||||
{/* <li>
|
||||
<SignUpModal />
|
||||
</li> */}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user