From 2a6dc340dfbb7aac4e1d37a60187006c1da77a20 Mon Sep 17 00:00:00 2001 From: Shane Maglangit Date: Fri, 25 Nov 2022 20:12:16 +0800 Subject: [PATCH] fix: update profile picture to be clickable on cal.com/[user]/[type] (#5596) * fix: update profile picture to be clickable on /[user]/[type] * fix: disable clickable profile on private booking pages Co-authored-by: Peer Richelsen --- apps/web/components/booking/UserAvatars.tsx | 17 +++++++++++--- apps/web/components/ui/AvatarGroup.tsx | 26 +++++++++++++++------ apps/web/components/ui/AvatarSSR.tsx | 3 ++- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/apps/web/components/booking/UserAvatars.tsx b/apps/web/components/booking/UserAvatars.tsx index a20351343d..3e336910be 100644 --- a/apps/web/components/booking/UserAvatars.tsx +++ b/apps/web/components/booking/UserAvatars.tsx @@ -7,7 +7,7 @@ export const UserAvatars = ({ users, ...props }: { - profile: { image: string | null; name?: string | null }; + profile: { image: string | null; name?: string | null; username?: string | null }; showMembers: boolean; users: { username: string | null; name?: string | null }[]; } & Pick) => { @@ -17,15 +17,26 @@ export const UserAvatars = ({ border="border-2 dark:border-darkgray-100 border-white" items={ [ - { image: profile.image, alt: profile.name, title: profile.name }, + { + image: profile.image, + alt: profile.name, + title: profile.name, + href: profile.username ? `${CAL_URL}/${profile.username}` : undefined, + }, ...(showMembers ? users.map((user) => ({ title: user.name, image: `${CAL_URL}/${user.username}/avatar.png`, alt: user.name || undefined, + href: user.username ? `${CAL_URL}/${user.username}` : undefined, })) : []), - ].filter((item) => !!item.image) as { image: string; alt?: string; title?: string }[] + ].filter((item) => !!item.image) as { + image: string; + alt?: string; + title?: string; + href?: string; + }[] } size={props.size} truncateAfter={props.truncateAfter} diff --git a/apps/web/components/ui/AvatarGroup.tsx b/apps/web/components/ui/AvatarGroup.tsx index 73bd09c204..06c8a1def5 100644 --- a/apps/web/components/ui/AvatarGroup.tsx +++ b/apps/web/components/ui/AvatarGroup.tsx @@ -1,3 +1,4 @@ +import Link from "next/link"; import React from "react"; import classNames from "@lib/classNames"; @@ -12,6 +13,7 @@ export type AvatarGroupProps = { image: string; title?: string; alt?: string; + href?: string; }[]; className?: string; }; @@ -21,15 +23,25 @@ export const AvatarGroup = function AvatarGroup(props: AvatarGroupProps) {
    {props.items.slice(0, props.truncateAfter).map((item, idx) => { if (item.image != null) { + const avatar = ( + + ); + return (
  • - + {item.href ? ( + + {avatar} + + ) : ( + avatar + )}
  • ); } diff --git a/apps/web/components/ui/AvatarSSR.tsx b/apps/web/components/ui/AvatarSSR.tsx index c982f9138b..4543cf23fa 100644 --- a/apps/web/components/ui/AvatarSSR.tsx +++ b/apps/web/components/ui/AvatarSSR.tsx @@ -15,6 +15,7 @@ export type AvatarProps = ( className?: string; size?: number; title?: string; + href?: string; alt: string; }; @@ -49,7 +50,7 @@ export function AvatarSSR(props: AvatarProps) { const avatar = imgSrc ? {alt} : null; return title ? ( - {avatar} + {avatar} {title}