Scheduling infrastructure for absolutely everyone.
fix: update profile picture to be clickable on cal.com/[user]/[type] (#5596)
Shane Maglangit2a6dc340dfbb
diff --git a/apps/web/components/booking/UserAvatars.tsx b/apps/web/components/booking/UserAvatars.tsxindex a20351343d6..3e336910be1 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<AvatarGroupProps, "size" | "truncateAfter">) => {@@ -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.tsxindex 73bd09c2040..06c8a1def55 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) {<ul className={classNames(props.className)}>{props.items.slice(0, props.truncateAfter).map((item, idx) => {if (item.image != null) {+ const avatar = (+ <AvatarSSR+ className={props.border}+ imageSrc={item.image}+ title={item.title}+ alt={item.alt || ""}+ size={props.size}+ />+ );+return (<li key={idx} className="-mr-2 inline-block">- <AvatarSSR- className={props.border}- imageSrc={item.image}- title={item.title}- alt={item.alt || ""}- size={props.size}- />+ {item.href ? (+ <Link href={item.href}>+ <a>{avatar}</a>+ </Link>+ ) : (+ avatar+ )}</li>);}diff --git a/apps/web/components/ui/AvatarSSR.tsx b/apps/web/components/ui/AvatarSSR.tsxindex c982f9138bb..4543cf23fa9 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 ? <img alt={alt} className={className} src={imgSrc} /> : null;return title ? (<Tooltip.Tooltip delayDuration={300}>- <Tooltip.TooltipTrigger className="cursor-default">{avatar}</Tooltip.TooltipTrigger>+ <Tooltip.TooltipTrigger asChild>{avatar}</Tooltip.TooltipTrigger><Tooltip.Content className="rounded-sm bg-black p-2 text-sm text-white"><Tooltip.Arrow />{title}