export async function GET(request: Request) {

  try {
    // const body = await request.json()
    // console.log({ body })

    // const { clientId, expertId, date, time , clientEmail } = body

    // if (!clientId || !expertId || !date || !time) {
    //   return new Response(JSON.stringify({ error: 'Missing fields' }), {
    //     status: 400,
    //     headers: { 'Content-Type': 'application/json' },
    //   })
    // }

    // Create the appointment
    // const appointment = await prisma.appointment.create({
    //   data: {
    //     clientId,
    //     expertId,
    //     client: { connect: { id: clientId } },
    //     expert: { connect: { id: expertId } },
    //     appointementKeyInClientTimeZone: body.appointementKeyInClientTimeZone,
    //     appointementKeyInExpertTimeZone: body.appointementKeyInExpertTimeZone,
    //     clientEmail,
    //     date,
    //     clientName : body.clientName,
    //     expertName : body.expertName,
    //     isAcceptedByExpert : body.isAcceptedByExpert,
    //     price : body.price,
    //     paymentStatus: 'paid',
    //     timezone : body.timezone,
    //     appointmentKey: body.appointmentKey,
    //     dayName: body.dayName,
    //     status : body.status,
    //     videoRoomId: body.videoRoomId,
    //     bookedAppointments: body.bookedAppointments,
    //     time,
    //   },
    // })

    // await prisma.appointment.update({
    //   where : {
    //     id : appointment.id
    //   }
    //   data : {
    //     status : 'paid'
    //   }
    // })

    const redirectUrl = `/` // or whatever route you use

    return new Response(null, {
      status: 303,
      headers: {
        Location: redirectUrl,
      },
    })

  } catch (error) {
    console.error(error)
    return new Response(
      JSON.stringify({
        error: 'An error occurred while creating appointment',
      }),
      {
        status: 400,
        headers: {
          'Content-Type': 'application/json',
        },
      }
    )
  }
}
