import { Dialog, DialogClose, DialogContent } from "@components/Dialog"; import { Tooltip } from "@components/Tooltip"; import { Button } from "@components/ui/Button"; // TODO: replace headlessui with radix-ui import { Menu, Transition } from "@headlessui/react"; import { ChevronDownIcon, DotsHorizontalIcon, ExternalLinkIcon, LinkIcon, PlusIcon, UsersIcon, } from "@heroicons/react/solid"; import classNames from "@lib/classNames"; import { getSession } from "next-auth/client"; import Head from "next/head"; import Link from "next/link"; import { useRouter } from "next/router"; import React, { Fragment, useRef } from "react"; import dayjs from "dayjs"; import Shell from "@components/Shell"; import prisma from "@lib/prisma"; import { EventType, SchedulingType } from "@prisma/client"; import showToast from "@lib/notification"; import Avatar from "@components/ui/Avatar"; import UserCalendarIllustration from "@components/ui/svg/UserCalendarIllustration"; import * as DropdownMenu from "@radix-ui/react-dropdown-menu"; import EventTypeDescription from "@components/eventtype/EventTypeDescription"; import * as RadioArea from "@components/ui/form/radio-area"; import { ONBOARDING_INTRODUCED_AT } from "@lib/getting-started"; import { inferSSRProps } from "@lib/types/inferSSRProps"; import { Alert } from "@components/ui/Alert"; import { useToggleQuery } from "@lib/hooks/useToggleQuery"; import { useMutation } from "react-query"; import createEventType from "@lib/mutations/event-types/create-event-type"; import { HttpError } from "@lib/core/http/error"; import { asStringOrNull } from "@lib/asStringOrNull"; import AvatarGroup from "@components/ui/AvatarGroup"; const EventTypesPage = (props: inferSSRProps) => { const CreateFirstEventTypeView = () => (

Create your first event type

Event types enable you to share links that show available times on your calendar and allow people to make bookings with you.

); const EventTypeListHeading = ({ profile, membershipCount }) => (
{profile.name} {membershipCount && ( {membershipCount} )} {typeof window !== "undefined" && ( {`${window.location.host}/${profile.slug}`} )}
); const EventTypeList = ({ readOnly, types, profile, }: { profile; readOnly: boolean; types: EventType[]; }) => (
); return (
Event Types | Calendso ) }> {props.user.plan === "FREE" && typeof window !== "undefined" && ( You need to upgrade your plan to have more than one active event type.} message={ <> To upgrade go to{" "} {`${window.location.origin}/upgrade`} } className="my-4" /> )} {props.eventTypes && props.eventTypes.map((input) => ( <> {/* hide list heading when there is only one (current user) */} {(props.eventTypes.length !== 1 || input.teamId) && ( )} ))} {props.eventTypes.length === 0 && }
); }; const CreateNewEventDialog = ({ profiles, canAddEvents }) => { const router = useRouter(); const teamId: number | null = Number(router.query.teamId) || null; const modalOpen = useToggleQuery("new"); const createMutation = useMutation(createEventType, { onSuccess: async ({ eventType }) => { await router.push("/event-types/" + eventType.id); showToast(`${eventType.title} event type created successfully`, "success"); }, onError: (err: HttpError) => { const message = `${err.statusCode}: ${err.message}`; showToast(message, "error"); }, }); const slugRef = useRef(null); return ( { router.push(isOpen ? modalOpen.hrefOn : modalOpen.hrefOff); }}> {!profiles.filter((profile) => profile.teamId).length && ( )} {profiles.filter((profile) => profile.teamId).length > 0 && ( Create an event type under
your name or a team.
{profiles.map((profile) => ( router.push({ pathname: router.pathname, query: { ...router.query, new: "1", eventPage: profile.slug, ...(profile.teamId ? { teamId: profile.teamId, } : {}), }, }) }> {profile.name} ))}
)}

Create a new event type for people to book times with.

{ e.preventDefault(); const target = e.target as unknown as Record< "title" | "slug" | "description" | "length" | "schedulingType", { value: string } >; const payload = { title: target.title.value, slug: target.slug.value, description: target.description.value, length: parseInt(target.length.value), }; if (router.query.teamId) { payload.teamId = parseInt(asStringOrNull(router.query.teamId), 10); payload.schedulingType = target.schedulingType.value; } createMutation.mutate(payload); }}>
{ if (!slugRef.current) { return; } slugRef.current.value = e.target.value.replace(/\s+/g, "-").toLowerCase(); }} type="text" name="title" id="title" required className="shadow-sm focus:ring-neutral-900 focus:border-neutral-900 block w-full sm:text-sm border-gray-300 rounded-sm" placeholder="Quick Chat" />
{location.hostname}/{router.query.eventPage || profiles[0].slug}/