* fix: Test flakiness due to unfilled name/email * Better toast-success checks * Revert "test: Create E2E tests for bookings with custom/required Phone + other questions (#11502)" This reverts commit614741d207. * Revert "test: Create E2E tests for bookings with custom/required Multiple Emails + other questions (teste2e-multipleEmailQuestion) (#11565)" This reverts commitd1d50b0d91. * Revert "test: Create E2E tests for bookings with custom/required Long Text + other questions (teste2e-longTextQuestion) (#11559)" This reverts commit96810b5ba1. * Revert "test: Check the webhook event tab and your funtionalities (#12433)" This reverts commit9db9204088. * Re-instate regularBookings * Fixtures used by other tests * Removed dead code from regularBookings.ts --------- Co-authored-by: Udit Takkar <[email protected]>
59 lines
1.9 KiB
TypeScript
59 lines
1.9 KiB
TypeScript
import { classNames } from "@calcom/lib";
|
|
import { getOrgAvatarUrl, getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
|
|
import type { User } from "@calcom/prisma/client";
|
|
import type { UserProfile } from "@calcom/types/UserProfile";
|
|
import { Avatar } from "@calcom/ui";
|
|
|
|
type Organization = {
|
|
id: number;
|
|
slug: string | null;
|
|
requestedSlug: string | null;
|
|
logoUrl?: string;
|
|
};
|
|
|
|
type UserAvatarProps = Omit<React.ComponentProps<typeof Avatar>, "alt" | "imageSrc"> & {
|
|
user: Pick<User, "name" | "username" | "avatarUrl"> & {
|
|
profile: Omit<UserProfile, "upId">;
|
|
};
|
|
noOrganizationIndicator?: boolean;
|
|
/**
|
|
* Useful when allowing the user to upload their own avatar and showing the avatar before it's uploaded
|
|
*/
|
|
previewSrc?: string | null;
|
|
alt?: string | null;
|
|
};
|
|
|
|
function OrganizationIndicator({
|
|
size,
|
|
organization,
|
|
user,
|
|
}: Pick<UserAvatarProps, "size" | "user"> & { organization: Organization }) {
|
|
const organizationUrl = organization.logoUrl ?? getOrgAvatarUrl(organization);
|
|
return (
|
|
<div className={classNames("absolute bottom-0 right-0 z-10", size === "lg" ? "h-6 w-6" : "h-10 w-10")}>
|
|
<img
|
|
data-testid="organization-logo"
|
|
src={organizationUrl}
|
|
alt={user.username || ""}
|
|
className="flex h-full items-center justify-center rounded-full"
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
/**
|
|
* It is aware of the user's organization to correctly show the avatar from the correct URL
|
|
*/
|
|
export function UserAvatar(props: UserAvatarProps) {
|
|
const { user, previewSrc = getUserAvatarUrl(user), noOrganizationIndicator, ...rest } = props;
|
|
const organization = user.profile?.organization ?? null;
|
|
const indicator =
|
|
organization && !noOrganizationIndicator ? (
|
|
<OrganizationIndicator size={props.size} organization={organization} user={props.user} />
|
|
) : (
|
|
props.indicator
|
|
);
|
|
|
|
return <Avatar {...rest} alt={user.name || "Nameless User"} imageSrc={previewSrc} indicator={indicator} />;
|
|
}
|