changed order

This commit is contained in:
Jelaletdin12
2025-12-23 22:55:19 +05:00
parent db68bf9c3d
commit 9d95438ab2
13 changed files with 541 additions and 339 deletions

View File

@@ -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> */}
</>
) : (
<>