diff --git a/src/features/kullanici/components/giris-linki.tsx b/src/features/kullanici/components/giris-linki.tsx new file mode 100644 index 0000000..c9b9358 --- /dev/null +++ b/src/features/kullanici/components/giris-linki.tsx @@ -0,0 +1,40 @@ +"use client"; + +import Link from "next/link"; +import { usePathname } from "next/navigation"; +import { Button } from "@/components/ui/button"; + +/** + * Navbar'ın "Giriş yap" butonu: giriş bitince kullanıcıyı **bulunduğu + * sayfaya** geri döndürür (`/giris?callback=`). Callback verilmezse + * `giris-karti.tsx` "/"'a düşürüyordu — rehber okuyan ziyaretçi girişten + * sonra ana sayfada uyanıyordu. + * + * Callback neden sabit bir hedef (ör. `/listem`) değil: buton her sayfada + * duruyor, sabit hedef bağlam kaybı olurdu; `/listem?uret=1` yazılsaydı + * girişten dönüşte üretim kendiliğinden başlar ve kullanıcının ayrı onayı + * olmadan 3 kredi yakardı. + * + * Callback yalnız pathname taşır: sorgu dizesini okuyan kanca tüm navbar'ı + * Suspense zorunluluğuna sokardı. `usePathname` bu ağaçta zaten var + * (`header-gate`), `UserNav` da site-header'da Suspense içinde render + * ediliyor — cacheComponents açıkken dinamik parametreli rotalarda gereken + * sınır hazır (next/dist/docs/.../use-pathname.md). + */ +export function GirisLinki() { + const pathname = usePathname(); + // /giris kendine callback veremez (döngü); pathname yoksa sade hedef. + const href = + pathname && !pathname.startsWith("/giris") + ? `/giris?callback=${encodeURIComponent(pathname)}` + : "/giris"; + + return ( + + ); +} diff --git a/src/features/kullanici/components/user-nav.tsx b/src/features/kullanici/components/user-nav.tsx index f762460..b58f107 100644 --- a/src/features/kullanici/components/user-nav.tsx +++ b/src/features/kullanici/components/user-nav.tsx @@ -1,10 +1,10 @@ import Link from "next/link"; import { ClipboardList, Coins } from "lucide-react"; import { getCurrentUser } from "@/lib/session"; -import { Button } from "@/components/ui/button"; import { ListemButonu } from "@/features/liste/components/listem-butonu"; import { ListeSenkron } from "@/features/liste/components/liste-senkron"; import { RybbitIdentify } from "@/components/rybbit-identify"; +import { GirisLinki } from "./giris-linki"; import { SignOutButton } from "./sign-out-button"; /** @@ -32,12 +32,7 @@ export async function UserNav() { - + ); }