refund roadmap pr-1 and pr-2
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import type { Metadata } from "next";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Admin · Refund Manual",
|
||||
description:
|
||||
"Halaman admin untuk meninjau laporan refund dari peserta dan organizer.",
|
||||
alternates: { canonical: "/admin/refunds" },
|
||||
robots: { index: false, follow: false },
|
||||
};
|
||||
|
||||
export default function AdminRefundsLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return children;
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { getServerSession } from "next-auth";
|
||||
import { authOptions } from "@/lib/auth";
|
||||
import { isAdminEmail } from "@/lib/admin";
|
||||
import { refundRepo } from "@/server/repositories/refund.repo";
|
||||
import { CreateRefundForm } from "@/features/refund/components/create-refund-form";
|
||||
import {
|
||||
RefundReviewCard,
|
||||
type RefundCardData,
|
||||
} from "@/features/refund/components/refund-review-card";
|
||||
|
||||
type Tab = "PENDING" | "APPROVED" | "REJECTED" | "SUCCEEDED" | "FAILED";
|
||||
|
||||
const TABS: { key: Tab; label: string }[] = [
|
||||
{ key: "PENDING", label: "Pending" },
|
||||
{ key: "APPROVED", label: "Disetujui" },
|
||||
{ key: "SUCCEEDED", label: "Selesai" },
|
||||
{ key: "REJECTED", label: "Ditolak" },
|
||||
{ key: "FAILED", label: "Gagal" },
|
||||
];
|
||||
|
||||
interface PageProps {
|
||||
searchParams: Promise<{ tab?: string }>;
|
||||
}
|
||||
|
||||
export default async function AdminRefundsPage({ searchParams }: PageProps) {
|
||||
const session = await getServerSession(authOptions);
|
||||
if (!session?.user) redirect("/login?callbackUrl=/admin/refunds");
|
||||
if (!isAdminEmail(session.user.email)) {
|
||||
return (
|
||||
<div className="mx-auto max-w-2xl px-4 py-12 text-center">
|
||||
<p className="text-sm text-neutral-600">
|
||||
Halaman ini hanya untuk admin SeTrip.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const params = await searchParams;
|
||||
const tab: Tab = TABS.some((t) => t.key === params.tab)
|
||||
? (params.tab as Tab)
|
||||
: "PENDING";
|
||||
|
||||
const rows = await refundRepo.listByStatus(tab);
|
||||
const items: RefundCardData[] = rows.map((r) => ({
|
||||
id: r.id,
|
||||
amount: r.amount,
|
||||
currency: r.currency,
|
||||
reason: r.reason,
|
||||
reportedBy: r.reportedBy,
|
||||
reportNote: r.reportNote,
|
||||
initiatedBy: r.initiatedBy,
|
||||
status: r.status,
|
||||
adminNote: r.adminNote,
|
||||
createdAt: r.createdAt,
|
||||
reviewedAt: r.reviewedAt,
|
||||
succeededAt: r.succeededAt,
|
||||
failedAt: r.failedAt,
|
||||
reviewedBy: r.reviewedBy,
|
||||
booking: {
|
||||
id: r.booking.id,
|
||||
amount: r.booking.amount,
|
||||
status: r.booking.status,
|
||||
trip: {
|
||||
id: r.booking.trip.id,
|
||||
title: r.booking.trip.title,
|
||||
date: r.booking.trip.date,
|
||||
},
|
||||
user: r.booking.user,
|
||||
payments: r.booking.payments.map((p) => ({
|
||||
id: p.id,
|
||||
provider: p.provider,
|
||||
method: p.method,
|
||||
amount: p.amount,
|
||||
status: p.status,
|
||||
paidAt: p.paidAt,
|
||||
})),
|
||||
},
|
||||
}));
|
||||
|
||||
return (
|
||||
<div className="mx-auto max-w-4xl px-4 py-8 sm:py-12">
|
||||
<header className="mb-6">
|
||||
<h1 className="text-2xl font-bold text-neutral-900 sm:text-3xl">
|
||||
Review Refund Manual
|
||||
</h1>
|
||||
<p className="mt-1 text-sm text-neutral-500">
|
||||
Tinjau laporan refund dari peserta dan organizer. Setiap refund harus
|
||||
melalui approval admin sebelum dieksekusi.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<CreateRefundForm />
|
||||
|
||||
<div className="mb-6 flex flex-wrap gap-2">
|
||||
{TABS.map((t) => (
|
||||
<a
|
||||
key={t.key}
|
||||
href={`/admin/refunds?tab=${t.key}`}
|
||||
className={`rounded-full px-4 py-1.5 text-sm font-semibold transition-colors ${
|
||||
tab === t.key
|
||||
? "bg-primary-600 text-white"
|
||||
: "bg-neutral-100 text-neutral-600 hover:bg-neutral-200"
|
||||
}`}
|
||||
>
|
||||
{t.label}
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{items.length === 0 ? (
|
||||
<div className="rounded-2xl border border-dashed border-neutral-300 bg-white p-10 text-center">
|
||||
<p className="text-sm text-neutral-500">
|
||||
Tidak ada refund pada status ini.
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-4">
|
||||
{items.map((r) => (
|
||||
<RefundReviewCard key={r.id} refund={r} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user