feat(yonetim): üyeleri görme ve elle kredi tanımlama paneli (S-017)
All checks were successful
Deploy / deploy (push) Successful in 11m10s
All checks were successful
Deploy / deploy (push) Successful in 11m10s
/yonetim yalnız ADMIN_EMAILS'teki hesaba açılır (varsayılan yok; tanımsızsa kimseye açılmaz). Üye listesi, arama, özet şeridi ve kredi ekle/düş çekmecesi. Hareket credit_ledger'a admin_grant nedeniyle, ref_id'de yönetici kimliğiyle yazılır; bakiye sıfırın altına inmez, çift gönderim UNIQUE(reason, ref_id) ile durur. Sayfa Rybbit'ten çıkarıldı (arama e-postası analitiğe gitmesin). Öğrenciye görünmediği için sürüm artmadı. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
133
src/features/yonetim/components/yonetim-icerik.tsx
Normal file
133
src/features/yonetim/components/yonetim-icerik.tsx
Normal file
@@ -0,0 +1,133 @@
|
||||
import { notFound } from "next/navigation";
|
||||
import { Search } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { OzetHucre, OzetSerit } from "@/components/ozet-kart";
|
||||
import { SATIR_AD_DUZ, SATIR_CIP, SATIR_META } from "@/components/liste-satiri";
|
||||
import { yoneticiyiAl } from "@/lib/yonetici";
|
||||
import { UYE_SAYFA_BOYU, uyeOzeti, uyeleriListele } from "../yonetim-queries";
|
||||
import { EpostaMetni } from "./eposta-metni";
|
||||
import { KrediCekmecesi } from "./kredi-cekmecesi";
|
||||
import { UyeSayfalama } from "./uye-sayfalama";
|
||||
|
||||
const sayi = new Intl.NumberFormat("tr-TR");
|
||||
const tarih = new Intl.DateTimeFormat("tr-TR", {
|
||||
day: "numeric",
|
||||
month: "short",
|
||||
year: "numeric",
|
||||
timeZone: "Europe/Istanbul",
|
||||
});
|
||||
|
||||
export async function YonetimIcerik({
|
||||
ara,
|
||||
sayfa,
|
||||
}: {
|
||||
ara?: string;
|
||||
sayfa: number;
|
||||
}) {
|
||||
// Yönetici değilse sayfanın varlığı da belli olmasın
|
||||
const yonetici = await yoneticiyiAl();
|
||||
if (!yonetici) notFound();
|
||||
|
||||
const [ozet, liste] = await Promise.all([
|
||||
uyeOzeti(),
|
||||
uyeleriListele({ ara, sayfa }),
|
||||
]);
|
||||
const toplamSayfa = Math.max(1, Math.ceil(liste.toplam / UYE_SAYFA_BOYU));
|
||||
|
||||
return (
|
||||
<div className="mx-auto w-full max-w-6xl px-4 py-12 sm:py-16">
|
||||
<h1 className="text-center font-heading text-3xl font-bold leading-tight text-slate-900 sm:text-5xl lg:text-left">
|
||||
Üyeler
|
||||
</h1>
|
||||
<p className="mx-auto mt-4 max-w-xl text-center text-base leading-relaxed text-slate-600 sm:text-lg lg:mx-0 lg:text-left">
|
||||
Kayıtlı hesaplar ve kredi bakiyeleri. Eklediğin ya da düştüğün her
|
||||
kredi deftere yazılır.
|
||||
</p>
|
||||
|
||||
<OzetSerit className="mt-10">
|
||||
<OzetHucre etiket="Toplam üye" deger={sayi.format(ozet.toplam)} alt="Tüm zamanlar" />
|
||||
<OzetHucre etiket="Paketli" deger={sayi.format(ozet.paketli)} alt="Tercih Dönemi Paketi alan" />
|
||||
<OzetHucre etiket="Son 7 gün" deger={sayi.format(ozet.yeni)} alt="Yeni kayıt" />
|
||||
</OzetSerit>
|
||||
|
||||
<form action="/yonetim" className="mt-12 flex flex-col gap-3 sm:flex-row">
|
||||
<label htmlFor="uye-ara" className="sr-only">
|
||||
E-posta ya da ad ara
|
||||
</label>
|
||||
<div className="relative sm:flex-1">
|
||||
<Search
|
||||
className="pointer-events-none absolute left-5 top-1/2 size-4 -translate-y-1/2 text-slate-400"
|
||||
aria-hidden
|
||||
/>
|
||||
<Input
|
||||
id="uye-ara"
|
||||
name="ara"
|
||||
type="search"
|
||||
defaultValue={ara}
|
||||
placeholder="E-posta ya da ad"
|
||||
autoComplete="off"
|
||||
className="pl-12"
|
||||
/>
|
||||
</div>
|
||||
<Button type="submit" size="lg" variant="ikincil">
|
||||
Ara
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
<h2 className="mt-12 font-heading text-2xl font-bold text-slate-900 sm:text-3xl">
|
||||
{ara ? `"${ara}" için ${sayi.format(liste.toplam)} üye` : `${sayi.format(liste.toplam)} üye`}
|
||||
</h2>
|
||||
|
||||
{liste.satirlar.length === 0 ? (
|
||||
<p className="mt-6 text-base text-slate-600">
|
||||
{ara ? "Bu aramayla eşleşen üye yok." : "Henüz kayıtlı üye yok."}
|
||||
</p>
|
||||
) : (
|
||||
<ul className="mt-6 divide-y divide-slate-200 border-y border-slate-200">
|
||||
{liste.satirlar.map((u) => (
|
||||
<li key={u.id} className="flex items-center gap-4 py-4">
|
||||
<div className="min-w-0 flex-1">
|
||||
<span className={`${SATIR_AD_DUZ} [overflow-wrap:anywhere]`}>
|
||||
<EpostaMetni eposta={u.email} />
|
||||
</span>
|
||||
<div className={`mt-1 ${SATIR_META}`}>
|
||||
{u.ad ? <span className="[overflow-wrap:anywhere]">{u.ad}</span> : null}
|
||||
<span>{tarih.format(u.kayit)}</span>
|
||||
{u.hasPaket ? <span className={SATIR_CIP}>Paketli</span> : null}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex shrink-0 flex-col items-end">
|
||||
<span className="font-heading text-2xl font-bold leading-none text-slate-900">
|
||||
{sayi.format(u.bakiye)}
|
||||
</span>
|
||||
<span className="mt-1 text-xs font-semibold text-slate-400">kredi</span>
|
||||
</div>
|
||||
<KrediCekmecesi userId={u.id} email={u.email} bakiye={u.bakiye} />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
|
||||
{toplamSayfa > 1 ? (
|
||||
<UyeSayfalama sayfa={sayfa} toplamSayfa={toplamSayfa} ara={ara} />
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function YonetimIcerikSkeleton() {
|
||||
return (
|
||||
<div className="mx-auto w-full max-w-6xl px-4 py-12 sm:py-16" aria-busy>
|
||||
<Skeleton className="mx-auto h-12 w-48 lg:mx-0" />
|
||||
<Skeleton className="mt-10 h-28 w-full" />
|
||||
<Skeleton className="mt-12 h-12 w-full rounded-full" />
|
||||
<div className="mt-12 space-y-4">
|
||||
{Array.from({ length: 6 }, (_, i) => (
|
||||
<Skeleton key={i} className="h-16 w-full" />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user