parent
9177fe86dc
commit
6880f88dbe
|
@ -4,6 +4,8 @@ import { useState } from "react";
|
|||
|
||||
import InviteLinkSettingsModal from "@calcom/ee/teams/components/InviteLinkSettingsModal";
|
||||
import MemberInvitationModal from "@calcom/ee/teams/components/MemberInvitationModal";
|
||||
import { useOrgBrandingValues } from "@calcom/features/ee/organizations/hooks";
|
||||
import { subdomainSuffix } from "@calcom/features/ee/organizations/lib/orgDomains";
|
||||
import classNames from "@calcom/lib/classNames";
|
||||
import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
|
@ -105,6 +107,7 @@ export default function TeamListItem(props: Props) {
|
|||
|
||||
const acceptInvite = () => acceptOrLeave(true);
|
||||
const declineInvite = () => acceptOrLeave(false);
|
||||
const orgBranding = useOrgBrandingValues();
|
||||
|
||||
const isOwner = props.team.role === MembershipRole.OWNER;
|
||||
const isInvitee = !props.team.accepted;
|
||||
|
@ -124,7 +127,11 @@ export default function TeamListItem(props: Props) {
|
|||
<div className="ms-3 inline-block truncate">
|
||||
<span className="text-default text-sm font-bold">{team.name}</span>
|
||||
<span className="text-muted block text-xs">
|
||||
{team.slug ? `${process.env.NEXT_PUBLIC_WEBSITE_URL}/team/${team.slug}` : "Unpublished team"}
|
||||
{team.slug
|
||||
? orgBranding
|
||||
? `${orgBranding.slug}.${subdomainSuffix()}/${team.slug}`
|
||||
: `${process.env.NEXT_PUBLIC_WEBSITE_URL}/team/${team.slug}`
|
||||
: "Unpublished team"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -49,15 +49,24 @@ export const createTeamsHandler = async ({ ctx, input }: CreateTeamsOptions) =>
|
|||
|
||||
const duplicatedSlugs = existingSlugs.filter((slug) => teamNames.includes(slug));
|
||||
|
||||
await prisma.team.createMany({
|
||||
data: teamNames.flatMap((name) => {
|
||||
await prisma.$transaction(
|
||||
teamNames.flatMap((name) => {
|
||||
if (!duplicatedSlugs.includes(name)) {
|
||||
return { name, parentId: orgId, slug: slugify(name) };
|
||||
return prisma.team.create({
|
||||
data: {
|
||||
name,
|
||||
parentId: orgId,
|
||||
slug: slugify(name),
|
||||
members: {
|
||||
create: { userId: ctx.user.id, role: MembershipRole.OWNER, accepted: true },
|
||||
},
|
||||
},
|
||||
});
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}),
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
return { duplicatedSlugs };
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { prisma } from "@calcom/prisma";
|
||||
import { teamMetadataSchema } from "@calcom/prisma/zod-utils";
|
||||
|
||||
import type { TrpcSessionUser } from "../../../trpc";
|
||||
|
||||
|
@ -23,7 +24,12 @@ export const listHandler = async ({ ctx }: ListOptions) => {
|
|||
orderBy: { role: "desc" },
|
||||
});
|
||||
|
||||
return memberships.map(({ team, ...membership }) => ({
|
||||
return memberships
|
||||
.filter((mmship) => {
|
||||
const metadata = teamMetadataSchema.parse(mmship.team.metadata);
|
||||
return !metadata?.isOrganization;
|
||||
})
|
||||
.map(({ team, ...membership }) => ({
|
||||
role: membership.role,
|
||||
accepted: membership.accepted,
|
||||
...team,
|
||||
|
|
Loading…
Reference in New Issue