import Head from 'next/head'; import Link from 'next/link'; import prisma from '../lib/prisma'; import { useRouter } from 'next/router'; import { CheckIcon } from '@heroicons/react/outline'; import { ClockIcon, CalendarIcon } from '@heroicons/react/solid'; const dayjs = require('dayjs'); const ics = require('ics'); export default function Success(props) { const router = useRouter(); const { date } = router.query; function eventLink(): string { const start = Array.prototype.concat(...date.split('T').map( (parts) => parts.split('-').length > 1 ? parts.split('-').map( (n) => parseInt(n, 10) ) : parts.split(':').map( (n) => parseInt(n, 10) ) )); const event = ics.createEvent({ start, startInputType: 'utc', title: props.eventType.title + ' with ' + props.user.name, description: props.eventType.description, duration: { minutes: props.eventType.length } }); if (event.error) { throw event.error; } return encodeURIComponent(event.value); } return(
Booking Confirmed | {props.eventType.title} with {props.user.name || props.user.username} | Calendso
) } 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 }, } }