All checks were successful
Deploy / deploy (push) Successful in 14m22s
- Integrated Rybbit analytics script in layout.tsx for improved tracking. - Updated pricing section in page.tsx to include detailed package features and pricing information. - Refined button interactions and added icons for better user engagement. - Adjusted return URL handling in odeme/sonuc/page.tsx to preserve order information. - Enhanced satin-al-form.tsx to include visual indicators for payment redirection.
133 lines
4.9 KiB
TypeScript
133 lines
4.9 KiB
TypeScript
import Link from "next/link";
|
||
import type { Metadata } from "next";
|
||
import { eq } from "drizzle-orm";
|
||
import { ArrowRight, CheckCircle2, XCircle } from "lucide-react";
|
||
import { verifySession } from "@/lib/session";
|
||
import { appDb, schema } from "@/lib/appdb";
|
||
import { odemeyiSonuclandir } from "@/lib/odeme";
|
||
import { Button } from "@/components/ui/button";
|
||
import { PagePixelDivider } from "@/components/pixel-decor";
|
||
import { SiteFooter } from "@/components/site-footer";
|
||
import { RaporYokCta } from "./rapor-yok-cta";
|
||
|
||
export const metadata: Metadata = {
|
||
title: "Ödeme Sonucu",
|
||
robots: { index: false, follow: false },
|
||
};
|
||
|
||
export default async function OdemeSonucPage({
|
||
searchParams,
|
||
}: {
|
||
searchParams: Promise<{ siparis?: string }>;
|
||
}) {
|
||
const { siparis } = await searchParams;
|
||
// Oturum düşmüşse geri dönüşte ?siparis= kaybolmasın (başarı/unblur deneyimi)
|
||
const geriDonus = siparis
|
||
? `/odeme/sonuc?siparis=${encodeURIComponent(siparis)}`
|
||
: "/paket";
|
||
const session = await verifySession(geriDonus);
|
||
|
||
const order = siparis
|
||
? await appDb.query.orders.findFirst({
|
||
where: eq(schema.orders.id, siparis),
|
||
})
|
||
: null;
|
||
|
||
// Yalnızca kendi siparişi görüntülenebilir
|
||
const sahibiMi = order?.userId === session.user.id;
|
||
|
||
// Self-healing: callback kaybolduysa burada tekrar doğrula
|
||
const durum =
|
||
order && sahibiMi
|
||
? order.status === "paid"
|
||
? "paid"
|
||
: await odemeyiSonuclandir(order.id)
|
||
: "not_found";
|
||
|
||
const basarili = durum === "paid";
|
||
|
||
// Rapor zaten üretildiyse ödül bir tık uzakta: kullanıcıyı doğrudan
|
||
// rapor sayfasına döndür ki blur çözülme animasyonuyla tam listeyi görsün.
|
||
const rapor = basarili
|
||
? await appDb.query.reports.findFirst({
|
||
where: eq(schema.reports.userId, session.user.id),
|
||
columns: { id: true },
|
||
})
|
||
: null;
|
||
const listeHref = rapor ? "/listem?acildi=1" : null;
|
||
|
||
return (
|
||
<div className="flex min-h-screen flex-col bg-slate-50 text-slate-900">
|
||
<main className="mx-auto flex w-full max-w-md flex-1 flex-col justify-center px-4 py-16 text-center">
|
||
{basarili ? (
|
||
<div className="rounded-2xl border border-emerald-200 bg-white p-8 shadow-sm">
|
||
<CheckCircle2
|
||
className="mx-auto size-12 text-emerald-500"
|
||
aria-hidden
|
||
/>
|
||
<h1 className="mt-4 font-heading text-2xl font-bold">
|
||
Ödeme alındı 🎉
|
||
</h1>
|
||
<p className="mt-2 text-sm text-slate-600">
|
||
<span className="font-semibold">
|
||
{order!.credits} kredi
|
||
</span>{" "}
|
||
hesabına tanımlandı
|
||
{order!.product === "paket"
|
||
? " ve Tercih Dönemi Paketi'n aktif — kişisel listen, risk raporun ve PDF çıktın hazır olduğunda burada."
|
||
: "."}
|
||
</p>
|
||
<PagePixelDivider seed={79} className="mx-auto mt-5" />
|
||
<div className="mt-6 flex flex-col gap-2">
|
||
{listeHref ? (
|
||
<>
|
||
<Button
|
||
asChild
|
||
className="h-11 cursor-pointer bg-orange-500 text-white transition-colors duration-200 hover:bg-orange-600"
|
||
>
|
||
<Link href={listeHref}>
|
||
Listeni aç — kilidi kaldırdık
|
||
<ArrowRight className="size-4" aria-hidden />
|
||
</Link>
|
||
</Button>
|
||
<p className="text-center text-xs text-slate-500">
|
||
24 tercihin tamamı, gerekçeler, riskler ve PDF artık açık.
|
||
</p>
|
||
</>
|
||
) : (
|
||
<RaporYokCta />
|
||
)}
|
||
</div>
|
||
</div>
|
||
) : (
|
||
<div className="rounded-2xl border border-red-200 bg-white p-8 shadow-sm">
|
||
<XCircle className="mx-auto size-12 text-red-500" aria-hidden />
|
||
<h1 className="mt-4 font-heading text-2xl font-bold">
|
||
Ödeme tamamlanamadı
|
||
</h1>
|
||
<p className="mt-2 text-sm text-slate-600">
|
||
{durum === "pending" ? (
|
||
"Ödemen hâlâ işleniyor. Birkaç saniye sonra bu sayfayı yenile — kartından çekim yapıldıysa krediler mutlaka tanımlanır."
|
||
) : (
|
||
<>
|
||
Çekim yapılmadı ya da işlem iptal edildi. Kartından para
|
||
çekildiğini düşünüyorsan{" "}
|
||
<Link href="/iletisim" className="underline">
|
||
bizimle iletişime geç
|
||
</Link>
|
||
.
|
||
</>
|
||
)}
|
||
</p>
|
||
<PagePixelDivider seed={83} className="mx-auto mt-5" />
|
||
<Button asChild variant="outline" className="mt-6 h-11 cursor-pointer">
|
||
<Link href="/paket">Tekrar dene</Link>
|
||
</Button>
|
||
</div>
|
||
)}
|
||
</main>
|
||
<SiteFooter />
|
||
</div>
|
||
);
|
||
}
|