import Head from 'next/head'; import Link from 'next/link'; import { useRouter } from 'next/router'; import prisma from '../../lib/prisma'; const dayjs = require('dayjs'); export default function Book(props) { const router = useRouter(); const { date, user } = router.query; const bookingHandler = event => { event.preventDefault(); const res = fetch( '/api/book/' + user, { body: JSON.stringify({ start: dayjs(date).format(), end: dayjs(date).add(props.eventType.length, 'minute').format(), name: event.target.name.value, email: event.target.email.value, notes: event.target.notes.value }), headers: { 'Content-Type': 'application/json' }, method: 'POST' } ); router.push("/success?date=" + date + "&type=" + props.eventType.id + "&user=" + props.user.username); } return (
Confirm your {props.eventType.title} with {props.user.name || props.user.username} | Calendso
{props.user.avatar && Avatar}

{props.user.name}

{props.eventType.title}

{props.eventType.length} minutes

{dayjs(date).format("hh:mma, dddd DD MMMM YYYY")}

{props.eventType.description}

Cancel
) } export async function getServerSideProps(context) { const user = await prisma.user.findFirst({ where: { username: context.query.user, }, select: { username: true, name: true, bio: true, avatar: true, eventTypes: true } }); const eventType = await prisma.eventType.findUnique({ where: { id: parseInt(context.query.type), }, select: { id: true, title: true, description: true, length: true } }); return { props: { user, eventType }, } }