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(