import Link from "next/link"; import { redirect } from "next/navigation"; import { getServerSession } from "next-auth"; import { CalendarDays, MapPin } from "lucide-react"; import { authOptions } from "@/lib/auth"; import { isAdminEmail } from "@/lib/admin"; import { tripRepo } from "@/server/repositories/trip.repo"; import { formatRupiah } from "@/lib/utils"; import { formatTripCalendarDateRangeLong } from "@/lib/trip-dates"; import { categoryMeta } from "@/lib/activity-category"; type Tab = "ALL" | "OPEN" | "FULL" | "CLOSED" | "COMPLETED"; const TABS: { key: Tab; label: string }[] = [ { key: "ALL", label: "Semua" }, { key: "OPEN", label: "Open" }, { key: "FULL", label: "Penuh" }, { key: "CLOSED", label: "Dibatalkan" }, { key: "COMPLETED", label: "Selesai" }, ]; interface PageProps { searchParams: Promise<{ tab?: string; q?: string }>; } export default async function AdminTripsPage({ searchParams }: PageProps) { const session = await getServerSession(authOptions); if (!session?.user) redirect("/login?callbackUrl=/admin/trips"); if (!isAdminEmail(session.user.email)) { return (

Halaman ini hanya untuk admin SeTrip.

); } const params = await searchParams; const tab: Tab = TABS.some((t) => t.key === params.tab) ? (params.tab as Tab) : "ALL"; const q = (params.q ?? "").trim(); const trips = await tripRepo.searchForAdmin({ status: tab === "ALL" ? undefined : tab, q: q || undefined, }); return (

Trip Operations

Cari trip, lihat detail, dan intervensi (cancel + auto-refund) saat organizer unreachable.

{q && ( Reset )}
{TABS.map((t) => ( {t.label} ))}
{trips.length === 0 ? (

{q ? `Tidak ada trip yang cocok dengan "${q}".` : "Tidak ada trip pada status ini."}

) : ( )}
); } function StatusBadge({ status }: { status: string }) { const cls = status === "OPEN" ? "bg-emerald-100 text-emerald-800" : status === "FULL" ? "bg-amber-100 text-amber-800" : status === "CLOSED" ? "bg-red-100 text-red-800" : "bg-neutral-200 text-neutral-700"; return ( {status} ); }