diff --git a/apps/web/pages/event-types/index.tsx b/apps/web/pages/event-types/index.tsx index bcc9950770..9938b766c6 100644 --- a/apps/web/pages/event-types/index.tsx +++ b/apps/web/pages/event-types/index.tsx @@ -2,7 +2,8 @@ import { useAutoAnimate } from "@formkit/auto-animate/react"; import { GetServerSidePropsContext } from "next"; import Link from "next/link"; import { useRouter } from "next/router"; -import React, { Fragment, useEffect, useState } from "react"; +import { FC, useEffect, useState, memo } from "react"; +import { z } from "zod"; import { CreateEventTypeButton, @@ -11,6 +12,8 @@ import { import Shell from "@calcom/features/shell/Shell"; import { APP_NAME, CAL_URL, WEBAPP_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import useMediaQuery from "@calcom/lib/hooks/useMediaQuery"; +import { useTypedQuery } from "@calcom/lib/hooks/useTypedQuery"; import { RouterOutputs, trpc, TRPCClientError } from "@calcom/trpc/react"; import { Badge, @@ -31,6 +34,7 @@ import { Avatar, AvatarGroup, Tooltip, + HorizontalTabs, } from "@calcom/ui"; import { FiArrowDown, @@ -74,6 +78,40 @@ interface EventTypeListProps { types: EventType[]; } +interface MobileTeamsTabProps { + eventTypeGroups: EventTypeGroups; +} + +const querySchema = z.object({ + teamId: z.nullable(z.coerce.number()).optional().default(null), +}); + +const MobileTeamsTab: FC = (props) => { + const { eventTypeGroups } = props; + + const tabs = eventTypeGroups.map((item) => ({ + name: item.profile.name ?? "", + href: item.teamId ? `/event-types?teamId=${item.teamId}` : "/event-types", + avatar: item.profile.image ?? `${WEBAPP_URL}/${item.profile.slug}/avatar.png`, + })); + const { data } = useTypedQuery(querySchema); + const events = eventTypeGroups.filter((item) => item.teamId === data.teamId); + + return ( +
+ + {events.length && ( + + )} +
+ ); +}; + const Item = ({ type, group, readOnly }: { type: EventType; group: EventTypeGroup; readOnly: boolean }) => { const { t } = useLocale(); @@ -105,7 +143,7 @@ const Item = ({ type, group, readOnly }: { type: EventType; group: EventTypeGrou ); }; -const MemoizedItem = React.memo(Item); +const MemoizedItem = memo(Item); export const EventTypeList = ({ group, groupIndex, readOnly, types }: EventTypeListProps): JSX.Element => { const { t } = useLocale(); @@ -589,6 +627,8 @@ const WithQuery = withQuery(trpc.viewer.eventTypes.getByViewer); const EventTypesPage = () => { const { t } = useLocale(); + const isMobile = useMediaQuery("(max-width: 768px)"); + return (
}> @@ -596,26 +636,40 @@ const EventTypesPage = () => { customLoader={} success={({ data }) => ( <> - {data.eventTypeGroups.map((group, index) => ( - - {/* hide list heading when there is only one (current user) */} - {(data.eventTypeGroups.length !== 1 || group.teamId) && ( - + {data.eventTypeGroups.length > 1 ? ( + <> + {isMobile ? ( + + ) : ( + data.eventTypeGroups.map((group, index) => ( +
+ + + +
+ )) )} - -
- ))} + + ) : data.eventTypeGroups.length === 1 ? ( + + ) : ( + + )} - {data.eventTypeGroups.length === 0 && } )} diff --git a/packages/features/shell/Shell.tsx b/packages/features/shell/Shell.tsx index 8d8244a392..c72446e477 100644 --- a/packages/features/shell/Shell.tsx +++ b/packages/features/shell/Shell.tsx @@ -846,7 +846,7 @@ function MainContainer({
{/* show top navigation for md and smaller (tablet and phones) */} {TopNavContainerProp} -
+
{!props.withoutMain ? {props.children} : props.children} diff --git a/packages/trpc/server/routers/viewer/eventTypes.tsx b/packages/trpc/server/routers/viewer/eventTypes.tsx index bb552ed3f5..94a86a7df0 100644 --- a/packages/trpc/server/routers/viewer/eventTypes.tsx +++ b/packages/trpc/server/routers/viewer/eventTypes.tsx @@ -299,6 +299,7 @@ export const eventTypesRouter = router({ profile: { slug: typeof user["username"]; name: typeof user["name"]; + image?: string; }; metadata: { membershipCount: number; diff --git a/packages/ui/components/navigation/tabs/HorizontalTabItem.tsx b/packages/ui/components/navigation/tabs/HorizontalTabItem.tsx index 5433583ec1..f71f9b589f 100644 --- a/packages/ui/components/navigation/tabs/HorizontalTabItem.tsx +++ b/packages/ui/components/navigation/tabs/HorizontalTabItem.tsx @@ -6,6 +6,7 @@ import classNames from "@calcom/lib/classNames"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { SVGComponent } from "@calcom/types/SVGComponent"; +import { Avatar } from "../../avatar"; import { SkeletonText } from "../../skeleton"; export type HorizontalTabItemProps = { @@ -15,12 +16,14 @@ export type HorizontalTabItemProps = { href: string; linkProps?: Omit, "href">; icon?: SVGComponent; + avatar?: string; }; -const HorizontalTabItem = function ({ name, href, linkProps, ...props }: HorizontalTabItemProps) { +const HorizontalTabItem = function ({ name, href, linkProps, avatar, ...props }: HorizontalTabItemProps) { const { t, isLocaleReady } = useLocale(); const { asPath } = useRouter(); - const isCurrent = asPath.startsWith(href); + + const isCurrent = asPath === href; return ( )} - {isLocaleReady ? t(name) : } + {isLocaleReady ? ( +
+ {avatar && } {t(name)} +
+ ) : ( + + )} ); };