fixed some ui, refactored code

This commit is contained in:
Jelaletdin12
2025-12-13 00:05:43 +05:00
parent 5085c0cffd
commit 633a3c9d47
30 changed files with 1274 additions and 923 deletions

View File

@@ -1,5 +1,5 @@
"use client";
import { useRouter } from "next/navigation";
import { useMemo } from "react";
import type React from "react";
import Link from "next/link";
@@ -47,7 +47,7 @@ export default function ActionButtons({
}: ActionButtonsProps) {
const t = useTranslations();
const { mutate: logout, isPending: isLoggingOut } = useLogout();
const router = useRouter();
const { data: cartData, isLoading: cartLoading } = useCart();
const { data: favoritesData, isLoading: favoritesLoading } = useFavorites();
const { data: ordersData, isLoading: ordersLoading } = useOrders();
@@ -101,8 +101,7 @@ export default function ActionButtons({
href: "/cart",
badgeCount: cartCount,
isLoading: cartLoading,
}
},
],
[
ordersCount,
@@ -133,9 +132,7 @@ export default function ActionButtons({
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem
onClick={() => (window.location.href = `/${locale}/me`)}
>
<DropdownMenuItem onClick={() => router.push(`/${locale}/me`)}>
<User className="mr-2 h-4 w-4" />
{t("profile")}
</DropdownMenuItem>

View File

@@ -2,6 +2,7 @@
import { useRouter, usePathname } from "next/navigation";
import Image from "next/image";
import { useLocale } from "next-intl";
import { useQueryClient } from "@tanstack/react-query";
import {
Select,
SelectContent,
@@ -26,13 +27,18 @@ const LANGUAGES: Language[] = [
export default function LanguageSelector() {
const locale = useLocale();
const router = useRouter();
const pathname = usePathname(); // Şu anki path'i al
const pathname = usePathname();
const queryClient = useQueryClient();
const handleLanguageChange = async (newLocale: string) => {
if (typeof window !== "undefined") {
(window as any).i18n = { language: newLocale };
}
queryClient.invalidateQueries();
const handleLanguageChange = (newLocale: string) => {
// Mevcut path'i yeni locale ile değiştir
// Örnek: /tm/cart -> /ru/cart
const currentPath = pathname.replace(`/${locale}`, "");
router.push(`/${newLocale}${currentPath}`);
router.replace(`/${newLocale}${currentPath}`);
};
return (