import Link from "next/link"; import Image from "next/image"; import { notFound, redirect } from "next/navigation"; import { getServerSession } from "next-auth"; import { authOptions } from "@/lib/auth"; import { isAdminEmail } from "@/lib/admin"; import { userRepo } from "@/server/repositories/user.repo"; import { formatRupiah } from "@/lib/utils"; import { SuspendUserButton } from "@/features/admin/components/suspend-user-button"; import { ManualVerifyButton } from "@/features/admin/components/manual-verify-button"; interface PageProps { params: Promise<{ id: string }>; } export default async function AdminUserDetailPage({ params }: PageProps) { const session = await getServerSession(authOptions); if (!session?.user) redirect("/login?callbackUrl=/admin/users"); if (!isAdminEmail(session.user.email)) { return (

Halaman ini hanya untuk admin SeTrip.

); } const { id } = await params; const user = await userRepo.findByIdForAdmin(id); if (!user) notFound(); const isSelf = user.id === session.user.id; const totalSpent = user.bookings .filter((b) => b.status === "PAID" || b.status === "PARTIALLY_REFUNDED") .reduce((sum, b) => sum + b.amount, 0); return (
← Kembali ke list users
{user.image ? ( ) : (
{user.name.charAt(0).toUpperCase()}
)}

{user.name}

{user.suspended && ( Suspended )} {user.organizerVerification?.status === "APPROVED" && ( ✓ Verified Organizer )}

{user.email}

User ID:{" "} {user.id}

Bergabung{" "} {user.createdAt.toLocaleDateString("id-ID", { day: "numeric", month: "long", year: "numeric", })} {user.acceptedAt && ( <> {" "} · Setuju T&C{" "} {user.acceptedAt.toLocaleDateString("id-ID", { day: "numeric", month: "short", year: "numeric", })} )}

{user.suspended && (

⛔ Akun ditangguhkan

{user.suspendedReason ?? "Tidak ada alasan tercatat."}

{user.suspendedBy && (

Disuspend oleh {user.suspendedBy.email} {user.suspendedAt && ( <> {" "} pada{" "} {user.suspendedAt.toLocaleString("id-ID", { day: "2-digit", month: "short", year: "numeric", hour: "2-digit", minute: "2-digit", })} )}

)}
)}

Aksi Admin

{isSelf ? (

Tidak bisa suspend / modifikasi akun sendiri.

) : (
{!user.organizerVerification && ( )}
)}
{user.profile && (

Profil Sosial

{user.profile.bio && (
Bio
{user.profile.bio}
)} {user.profile.city && (
Kota
{user.profile.city}
)} {user.profile.vibe && (
Vibe
{user.profile.vibe}
)} {user.profile.interests.length > 0 && (
Minat
{user.profile.interests.map((tag) => ( #{tag} ))}
)} {user.profile.instagram && (
Instagram
@{user.profile.instagram}
)}
)} {user.organizerVerification && (

Verifikasi Organizer

Status:{" "} {user.organizerVerification.status} {" · "} Buka di /admin/verifications →

{user.organizerVerification.rejectionReason && (

Reason: {user.organizerVerification.rejectionReason}

)}
)}

Trip yang dibuat ({user.trips.length})

{user.trips.length === 0 ? (

User ini belum pernah membuat trip.

) : ( )}

Booking sebagai peserta ({user.bookings.length})

{user.bookings.length === 0 ? (

Belum ada booking.

) : ( )}
); } function StatCard({ label, value, accent = "primary", }: { label: string; value: string; accent?: "primary" | "emerald"; }) { const cls = accent === "emerald" ? "text-emerald-700" : "text-primary-700"; return (

{label}

{value}

); }