"use server"; import { getServerSession } from "next-auth"; import { authOptions } from "@/lib/auth"; import { tripService } from "@/server/services/trip.service"; import { revalidatePath } from "next/cache"; export async function markParticipantPaidAction(tripId: string) { const session = await getServerSession(authOptions); if (!session?.user) { return { error: "Kamu harus login terlebih dahulu" }; } try { await tripService.markParticipantPayment(tripId, session.user.id); revalidatePath(`/trips/${tripId}`); revalidatePath("/trips"); revalidatePath("/"); revalidatePath("/profile"); return { success: true }; } catch (err) { return { error: (err as Error).message }; } } export async function confirmParticipantPaymentAction( tripId: string, participantId: string ) { const session = await getServerSession(authOptions); if (!session?.user) { return { error: "Kamu harus login terlebih dahulu" }; } try { await tripService.confirmParticipantPayment( tripId, participantId, session.user.id ); revalidatePath(`/trips/${tripId}`); revalidatePath("/trips"); revalidatePath("/"); revalidatePath("/profile"); return { success: true }; } catch (err) { return { error: (err as Error).message }; } }