More avatar fixes across org
parent
9250b91bb0
commit
0b5853078e
|
@ -72,6 +72,7 @@ import useMeQuery from "@lib/hooks/useMeQuery";
|
||||||
|
|
||||||
import PageWrapper from "@components/PageWrapper";
|
import PageWrapper from "@components/PageWrapper";
|
||||||
import SkeletonLoader from "@components/eventtype/SkeletonLoader";
|
import SkeletonLoader from "@components/eventtype/SkeletonLoader";
|
||||||
|
import { UserAvatarGroup } from "@components/ui/avatar/UserAvatarGroup";
|
||||||
|
|
||||||
type EventTypeGroups = RouterOutputs["viewer"]["eventTypes"]["getByViewer"]["eventTypeGroups"];
|
type EventTypeGroups = RouterOutputs["viewer"]["eventTypes"]["getByViewer"]["eventTypeGroups"];
|
||||||
type EventTypeGroupProfile = EventTypeGroups[number]["profile"];
|
type EventTypeGroupProfile = EventTypeGroups[number]["profile"];
|
||||||
|
@ -398,23 +399,11 @@ export const EventTypeList = ({ group, groupIndex, readOnly, types }: EventTypeL
|
||||||
<div className="mt-4 hidden sm:mt-0 sm:flex">
|
<div className="mt-4 hidden sm:mt-0 sm:flex">
|
||||||
<div className="flex justify-between space-x-2 rtl:space-x-reverse">
|
<div className="flex justify-between space-x-2 rtl:space-x-reverse">
|
||||||
{type.team && !isManagedEventType && (
|
{type.team && !isManagedEventType && (
|
||||||
<AvatarGroup
|
<UserAvatarGroup
|
||||||
className="relative right-3 top-1"
|
className="relative right-3 top-1"
|
||||||
size="sm"
|
size="sm"
|
||||||
truncateAfter={4}
|
truncateAfter={4}
|
||||||
items={
|
users={type?.users ?? []}
|
||||||
type?.users
|
|
||||||
? type.users.map(
|
|
||||||
(organizer: { name: string | null; username: string | null }) => ({
|
|
||||||
alt: organizer.name || "",
|
|
||||||
image: `${orgBranding?.fullDomain ?? WEBAPP_URL}/${
|
|
||||||
organizer.username
|
|
||||||
}/avatar.png`,
|
|
||||||
title: organizer.name || "",
|
|
||||||
})
|
|
||||||
)
|
|
||||||
: []
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{isManagedEventType && type?.children && type.children?.length > 0 && (
|
{isManagedEventType && type?.children && type.children?.length > 0 && (
|
||||||
|
|
|
@ -4,10 +4,9 @@ import { getLocationGroupedOptions } from "@calcom/app-store/server";
|
||||||
import type { StripeData } from "@calcom/app-store/stripepayment/lib/server";
|
import type { StripeData } from "@calcom/app-store/stripepayment/lib/server";
|
||||||
import { getEventTypeAppData } from "@calcom/app-store/utils";
|
import { getEventTypeAppData } from "@calcom/app-store/utils";
|
||||||
import type { LocationObject } from "@calcom/core/location";
|
import type { LocationObject } from "@calcom/core/location";
|
||||||
import { getOrgFullOrigin } from "@calcom/ee/organizations/lib/orgDomains";
|
|
||||||
import { getBookingFieldsWithSystemFields } from "@calcom/features/bookings/lib/getBookingFields";
|
import { getBookingFieldsWithSystemFields } from "@calcom/features/bookings/lib/getBookingFields";
|
||||||
import { parseBookingLimit, parseDurationLimit, parseRecurringEvent } from "@calcom/lib";
|
import { parseBookingLimit, parseDurationLimit, parseRecurringEvent } from "@calcom/lib";
|
||||||
import { CAL_URL } from "@calcom/lib/constants";
|
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
|
||||||
import { getTranslation } from "@calcom/lib/server/i18n";
|
import { getTranslation } from "@calcom/lib/server/i18n";
|
||||||
import type { PrismaClient } from "@calcom/prisma";
|
import type { PrismaClient } from "@calcom/prisma";
|
||||||
import type { Credential } from "@calcom/prisma/client";
|
import type { Credential } from "@calcom/prisma/client";
|
||||||
|
@ -36,6 +35,7 @@ export default async function getEventTypeById({
|
||||||
username: true,
|
username: true,
|
||||||
id: true,
|
id: true,
|
||||||
email: true,
|
email: true,
|
||||||
|
organizationId: true,
|
||||||
locale: true,
|
locale: true,
|
||||||
defaultScheduleId: true,
|
defaultScheduleId: true,
|
||||||
});
|
});
|
||||||
|
@ -298,9 +298,7 @@ export default async function getEventTypeById({
|
||||||
const eventTypeUsers: ((typeof eventType.users)[number] & { avatar: string })[] = eventType.users.map(
|
const eventTypeUsers: ((typeof eventType.users)[number] & { avatar: string })[] = eventType.users.map(
|
||||||
(user) => ({
|
(user) => ({
|
||||||
...user,
|
...user,
|
||||||
avatar: `${eventType.team?.parent?.slug ? getOrgFullOrigin(eventType.team?.parent?.slug) : CAL_URL}/${
|
avatar: getUserAvatarUrl(user),
|
||||||
user.username
|
|
||||||
}/avatar.png`,
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -346,11 +344,7 @@ export default async function getEventTypeById({
|
||||||
.map((member) => {
|
.map((member) => {
|
||||||
const user: typeof member.user & { avatar: string } = {
|
const user: typeof member.user & { avatar: string } = {
|
||||||
...member.user,
|
...member.user,
|
||||||
avatar: `${
|
avatar: getUserAvatarUrl(member.user),
|
||||||
eventTypeObject.team?.parent?.slug
|
|
||||||
? getOrgFullOrigin(eventTypeObject.team?.parent?.slug)
|
|
||||||
: CAL_URL
|
|
||||||
}/${member.user.username}/avatar.png`,
|
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
...user,
|
...user,
|
||||||
|
|
|
@ -30,6 +30,7 @@ const userSelect = Prisma.validator<Prisma.UserSelect>()({
|
||||||
id: true,
|
id: true,
|
||||||
username: true,
|
username: true,
|
||||||
name: true,
|
name: true,
|
||||||
|
organizationId: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const userEventTypeSelect = Prisma.validator<Prisma.EventTypeSelect>()({
|
const userEventTypeSelect = Prisma.validator<Prisma.EventTypeSelect>()({
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { isOrganisationAdmin } from "@calcom/lib/server/queries/organisations";
|
|
||||||
import { prisma } from "@calcom/prisma";
|
import { prisma } from "@calcom/prisma";
|
||||||
import { teamMetadataSchema } from "@calcom/prisma/zod-utils";
|
import { teamMetadataSchema } from "@calcom/prisma/zod-utils";
|
||||||
|
|
||||||
|
@ -11,42 +10,12 @@ type ListOptions = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const listHandler = async ({ ctx }: ListOptions) => {
|
export const listHandler = async ({ ctx }: ListOptions) => {
|
||||||
if (ctx.user?.organization?.id) {
|
|
||||||
const membershipsWithoutParent = await prisma.membership.findMany({
|
|
||||||
where: {
|
|
||||||
userId: ctx.user.id,
|
|
||||||
team: {
|
|
||||||
parent: {
|
|
||||||
is: {
|
|
||||||
id: ctx.user?.organization?.id,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
include: {
|
|
||||||
team: {
|
|
||||||
include: {
|
|
||||||
inviteTokens: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
orderBy: { role: "desc" },
|
|
||||||
});
|
|
||||||
|
|
||||||
const isOrgAdmin = !!(await isOrganisationAdmin(ctx.user.id, ctx.user.organization.id)); // Org id exists here as we're inside a conditional TS complaining for some reason
|
|
||||||
|
|
||||||
return membershipsWithoutParent.map(({ team: { inviteTokens, ..._team }, ...membership }) => ({
|
|
||||||
role: membership.role,
|
|
||||||
accepted: membership.accepted,
|
|
||||||
isOrgAdmin,
|
|
||||||
..._team,
|
|
||||||
/** To prevent breaking we only return non-email attached token here, if we have one */
|
|
||||||
inviteToken: inviteTokens.find((token) => token.identifier === `invite-link-for-teamId-${_team.id}`),
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
const memberships = await prisma.membership.findMany({
|
const memberships = await prisma.membership.findMany({
|
||||||
where: {
|
where: {
|
||||||
|
// Show all the teams this user belongs to regardless of the team being part of the user's org or not
|
||||||
|
// We don't want to restrict in the listing here. If we need to restrict a situation where a user is part of the org along with being part of a non-org team, we should do that instead of filtering out from here
|
||||||
|
// This became necessary when we started migrating user to Org, without migrating some teams of the user to the org
|
||||||
|
// Also, we would allow a user to be part of multiple orgs, then also it would be necessary.
|
||||||
userId: ctx.user.id,
|
userId: ctx.user.id,
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
|
|
Loading…
Reference in New Issue