import Head from 'next/head'; import Link from 'next/link'; import prisma from '../../lib/prisma'; import Shell from '../../components/Shell'; import Router from 'next/router'; import { useRef } from 'react'; import { useState } from 'react'; import { useSession, getSession } from 'next-auth/client'; export default function Availability(props) { const [ session, loading ] = useSession(); const [showAddModal, setShowAddModal] = useState(false); const titleRef = useRef(); const descriptionRef = useRef(); const lengthRef = useRef(); if (loading) { return
Loading...
; } else { if (!session) { window.location.href = "/auth/login"; } } function toggleAddModal() { setShowAddModal(!showAddModal); } async function createEventTypeHandler(event) { event.preventDefault(); const enteredTitle = titleRef.current.value; const enteredDescription = descriptionRef.current.value; const enteredLength = lengthRef.current.value; // TODO: Add validation const response = await fetch('/api/availability/eventtype', { method: 'POST', body: JSON.stringify({title: enteredTitle, description: enteredDescription, length: enteredLength}), headers: { 'Content-Type': 'application/json' } }); console.log(response); Router.reload(); } return(Name | Description | Length | Edit |
---|---|---|---|
{eventType.title} | {eventType.description} | {eventType.length} minutes | Edit |
Create a new event type for people to book times with.