import { InferGetServerSidePropsType } from "next"; import Link from "next/link"; import { HeadSeo } from "@components/seo/head-seo"; import useTheme from "@lib/hooks/useTheme"; import { ArrowRightIcon } from "@heroicons/react/solid"; import prisma from "@lib/prisma"; import Avatar from "@components/ui/Avatar"; import Text from "@components/ui/Text"; import React from "react"; import { defaultAvatarSrc } from "@lib/profile"; import EventTypeDescription from "@components/eventtype/EventTypeDescription"; import Team from "@components/team/screens/Team"; import { useToggleQuery } from "@lib/hooks/useToggleQuery"; import AvatarGroup from "@components/ui/AvatarGroup"; import Button from "@components/ui/Button"; function TeamPage({ team }: InferGetServerSidePropsType) { const { isReady } = useTheme(); const showMembers = useToggleQuery("members"); const eventTypes = ( ); return ( isReady && (
{team.name}
{(showMembers.isOn || !team.eventTypes.length) && } {!showMembers.isOn && team.eventTypes.length && (
{eventTypes}
)}
) ); } export const getServerSideProps = async (context) => { const slug = Array.isArray(context.query?.slug) ? context.query.slug.pop() : context.query.slug; const teamSelectInput = { id: true, name: true, slug: true, logo: true, members: { select: { user: { select: { username: true, avatar: true, name: true, id: true, bio: true, }, }, }, }, eventTypes: { where: { hidden: false, }, select: { id: true, title: true, description: true, length: true, slug: true, schedulingType: true, users: { select: { id: true, name: true, avatar: true, email: true, }, }, }, }, }; const team = await prisma.team.findUnique({ where: { slug, }, select: teamSelectInput, }); if (!team) { return { notFound: true, }; } team.eventTypes = team.eventTypes.map((type) => ({ ...type, users: type.users.map((user) => ({ ...user, avatar: user.avatar || defaultAvatarSrc({ email: user.email }), })), })); return { props: { team, }, }; }; export default TeamPage;