chore: remove unused queries on user event types (#11159)
* remove unused queries on user event types * Fix typespull/11149/head
parent
3539693729
commit
829f90b82f
|
@ -391,7 +391,9 @@ export const EventTypeList = ({ group, groupIndex, readOnly, types }: EventTypeL
|
|||
className="relative right-3 top-1"
|
||||
size="sm"
|
||||
truncateAfter={4}
|
||||
items={type.users.map(
|
||||
items={
|
||||
type?.users
|
||||
? type.users.map(
|
||||
(organizer: { name: string | null; username: string | null }) => ({
|
||||
alt: organizer.name || "",
|
||||
image: `${orgBranding?.fullDomain ?? WEBAPP_URL}/${
|
||||
|
@ -399,15 +401,17 @@ export const EventTypeList = ({ group, groupIndex, readOnly, types }: EventTypeL
|
|||
}/avatar.png`,
|
||||
title: organizer.name || "",
|
||||
})
|
||||
)}
|
||||
)
|
||||
: []
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{isManagedEventType && type.children && (
|
||||
{isManagedEventType && type?.children && type.children?.length > 0 && (
|
||||
<AvatarGroup
|
||||
className="relative right-3 top-1"
|
||||
size="sm"
|
||||
truncateAfter={4}
|
||||
items={type.children
|
||||
items={type?.children
|
||||
.flatMap((ch) => ch.users)
|
||||
.map((user: Pick<User, "name" | "username">) => ({
|
||||
alt: user.name || "",
|
||||
|
|
|
@ -61,7 +61,9 @@ export default function WorkflowDetailsPage(props: Props) {
|
|||
...options,
|
||||
...group.eventTypes.map((eventType) => ({
|
||||
value: String(eventType.id),
|
||||
label: `${eventType.title} ${eventType.children.length ? `(+${eventType.children.length})` : ``}`,
|
||||
label: `${eventType.title} ${
|
||||
eventType.children && eventType.children.length ? `(+${eventType.children.length})` : ``
|
||||
}`,
|
||||
})),
|
||||
];
|
||||
}, [] as Option[]) || [],
|
||||
|
|
|
@ -52,14 +52,6 @@ const userEventTypeSelect = Prisma.validator<Prisma.EventTypeSelect>()({
|
|||
users: {
|
||||
select: userSelect,
|
||||
},
|
||||
// Temporarily putting this back for testing
|
||||
children: {
|
||||
include: {
|
||||
users: {
|
||||
select: userSelect,
|
||||
},
|
||||
},
|
||||
},
|
||||
parentId: true,
|
||||
hosts: {
|
||||
select: {
|
||||
|
@ -74,13 +66,13 @@ const userEventTypeSelect = Prisma.validator<Prisma.EventTypeSelect>()({
|
|||
|
||||
const teamEventTypeSelect = Prisma.validator<Prisma.EventTypeSelect>()({
|
||||
...userEventTypeSelect,
|
||||
// children: {
|
||||
// include: {
|
||||
// users: {
|
||||
// select: userSelect,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
children: {
|
||||
include: {
|
||||
users: {
|
||||
select: userSelect,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const compareMembership = (mship1: MembershipRole, mship2: MembershipRole) => {
|
||||
|
@ -167,11 +159,15 @@ export const getByViewerHandler = async ({ ctx, input }: GetByViewerOptions) =>
|
|||
throw new TRPCError({ code: "INTERNAL_SERVER_ERROR" });
|
||||
}
|
||||
|
||||
const mapEventType = (eventType: (typeof user.eventTypes)[number]) => ({
|
||||
type UserEventTypes = (typeof user.eventTypes)[number];
|
||||
type TeamEventTypeChildren = (typeof user.teams)[number]["team"]["eventTypes"][number];
|
||||
|
||||
const mapEventType = (eventType: UserEventTypes & Partial<TeamEventTypeChildren>) => ({
|
||||
...eventType,
|
||||
safeDescription: markdownToSafeHTML(eventType.description),
|
||||
users: !!eventType.hosts?.length ? eventType.hosts.map((host) => host.user) : eventType.users,
|
||||
safeDescription: eventType?.description ? markdownToSafeHTML(eventType.description) : undefined,
|
||||
users: !!eventType?.hosts?.length ? eventType?.hosts.map((host) => host.user) : eventType.users,
|
||||
metadata: eventType.metadata ? EventTypeMetaDataSchema.parse(eventType.metadata) : undefined,
|
||||
children: eventType.children,
|
||||
});
|
||||
|
||||
const userEventTypes = user.eventTypes.map(mapEventType);
|
||||
|
|
Loading…
Reference in New Issue