fix(funnel): navbar giriş butonu kullanıcıyı bulunduğu sayfaya döndürür
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 <noreply@anthropic.com>
This commit is contained in:
40
src/features/kullanici/components/giris-linki.tsx
Normal file
40
src/features/kullanici/components/giris-linki.tsx
Normal file
@@ -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=<yol>`). 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 (
|
||||
<Button
|
||||
asChild
|
||||
className="h-9 cursor-pointer rounded-full bg-slate-900 px-3.5 text-sm font-medium text-white transition-colors duration-200 hover:bg-slate-700 sm:h-12 sm:px-7 sm:text-base"
|
||||
>
|
||||
<Link href={href}>Giriş yap</Link>
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
@@ -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() {
|
||||
<RybbitIdentify kullaniciId={null} />
|
||||
<ListeSenkron userId={null} />
|
||||
<ListemButonu />
|
||||
<Button
|
||||
asChild
|
||||
className="h-9 cursor-pointer rounded-full bg-slate-900 px-3.5 text-sm font-medium text-white transition-colors duration-200 hover:bg-slate-700 sm:h-12 sm:px-7 sm:text-base"
|
||||
>
|
||||
<Link href="/giris">Giriş yap</Link>
|
||||
</Button>
|
||||
<GirisLinki />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user