create review and profile

This commit is contained in:
arifal
2026-04-20 00:25:05 +07:00
parent 7159e9108f
commit ba5f64ae0e
37 changed files with 3324 additions and 109 deletions
+44
View File
@@ -6,6 +6,11 @@ import { tripService } from "@/server/services/trip.service";
import { formatRupiah, formatDateRange } from "@/lib/utils";
import { JoinTripButton } from "@/features/trip/components/join-trip-button";
import { ImageGallery } from "@/features/trip/components/image-gallery";
import { TripReviewSection } from "@/features/review/components/trip-review-section";
import {
isPastTripLastDayForReview,
isTripDepartureDayPast,
} from "@/lib/trip-dates";
export default async function TripDetailPage({
params,
@@ -38,6 +43,26 @@ export default async function TripDetailPage({
)
: null;
const isDeparturePast = isTripDepartureDayPast(trip.date);
const canReview =
!!session?.user &&
!isOrganizer &&
currentParticipation?.status === "CONFIRMED" &&
isPastTripLastDayForReview(trip.date, trip.endDate);
const myReview = session?.user
? trip.reviews.find((r) => r.userId === session.user.id) ?? null
: null;
const averageRating =
trip.reviews.length > 0
? Math.round(
(trip.reviews.reduce((s, r) => s + r.rating, 0) /
trip.reviews.length) *
10
) / 10
: null;
return (
<div className="mx-auto max-w-3xl px-4 py-4 sm:py-8">
{/* Breadcrumb */}
@@ -180,6 +205,25 @@ export default async function TripDetailPage({
isJoined={!!currentParticipation}
isFull={spotsLeft <= 0}
tripStatus={trip.status}
isDeparturePast={isDeparturePast}
/>
<TripReviewSection
tripId={trip.id}
reviews={trip.reviews.map((r) => ({
id: r.id,
rating: r.rating,
comment: r.comment,
createdAt: r.createdAt,
user: r.user,
}))}
averageRating={averageRating}
canReview={canReview}
myReview={
myReview
? { rating: myReview.rating, comment: myReview.comment }
: null
}
/>
{/* Participants List */}