From 7dc47ee1a9d882ff11b7385afa43c332bec06252 Mon Sep 17 00:00:00 2001 From: bilalgursen Date: Tue, 22 Sep 2026 01:21:32 +0300 Subject: [PATCH] =?UTF-8?q?fix(funnel):=20navbar=20giri=C5=9F=20butonu=20k?= =?UTF-8?q?ullan=C4=B1c=C4=B1y=C4=B1=20bulundu=C4=9Fu=20sayfaya=20d=C3=B6n?= =?UTF-8?q?d=C3=BCr=C3=BCr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Navbar'daki "Giriş yap" callback vermiyordu; giris-karti.tsx callback'siz isteği "/"'a düşürdüğü için rehber ya da katalog okuyan ziyaretçi girişten sonra ana sayfada uyanıyordu. Yeni GirisLinki bileşeni usePathname ile bulunulan yolu callback yapıyor. Callback bilerek sabit bir hedef (ör. /listem) değil: buton her sayfada duruyor, sabit hedef bağlam kaybı olur; /listem?uret=1 yazılsaydı girişten dönüşte üretim kendiliğinden başlar, kullanıcının ayrı onayı olmadan 3 kredi yanardı. Sorgu dizesi taşınmıyor — sorgu okuyan kanca tüm navbar'ı Suspense zorunluluğuna sokardı. Co-Authored-By: Claude Opus 5 --- .../kullanici/components/giris-linki.tsx | 40 +++++++++++++++++++ .../kullanici/components/user-nav.tsx | 9 +---- 2 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 src/features/kullanici/components/giris-linki.tsx 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() { - + ); }