import { redirect } from "next/navigation"; import Image from "next/image"; import Link from "next/link"; import { getServerSession } from "next-auth"; import { authOptions } from "@/lib/auth"; import { profileService } from "@/server/services/profile.service"; import { TripCard } from "@/features/trip/components/trip-card"; import { ProfileTripRow } from "@/features/profile/components/profile-trip-row"; export default async function ProfilePage() { const session = await getServerSession(authOptions); if (!session?.user) { redirect("/login?callbackUrl=/profile"); } const data = await profileService.getProfileDashboard(session.user.id); const { user, organizedTrips, activeJoined, cancelledJoined, reviewable } = data; const memberSince = new Intl.DateTimeFormat("id-ID", { month: "long", year: "numeric", }).format(user.createdAt); return (
{user.image ? ( ) : (
{user.name.charAt(0).toUpperCase()}
)}

{user.name}

{user.email}

Anggota sejak {memberSince}

Di sini kamu bisa lihat trip yang kamu buat sebagai{" "} organizer, trip yang kamu{" "} ikuti{" "} sebagai peserta, dan{" "} ulasan untuk trip yang sudah selesai (lewat halaman trip).

+ Buat trip
{/* Trip selesai — akses ulasan (trip ini tidak muncul di Open Trip) */} {reviewable.length > 0 && (

Trip selesai & ulasan

Trip yang sudah lewat tidak tampil di daftar Open Trip. Buka trip di bawah ini lalu scroll ke bagian ulasan di halaman detail untuk memberi atau mengubah rating.

)}

Trip yang kamu buat ({organizedTrips.length})

{organizedTrips.length === 0 ? (

Belum ada trip.{" "} Buat trip pertama

) : (
{organizedTrips.map((trip) => ( ))}
)}

Trip yang kamu ikuti ({activeJoined.length})

{activeJoined.length === 0 ? (

Belum join trip.{" "} Cari open trip

) : (
    {activeJoined.map((p) => { const t = p.trip; return (
  • {p.status === "CONFIRMED" ? "Terkonfirmasi" : p.status === "PENDING" ? "Menunggu organizer" : p.status} } />
  • ); })}
)} {cancelledJoined.length > 0 && (

Riwayat batal ({cancelledJoined.length})

    {cancelledJoined.map((p) => { const t = p.trip; return (
  • Dibatalkan } />
  • ); })}
)}
); }