diff --git a/packages/features/ee/teams/components/TeamListItem.tsx b/packages/features/ee/teams/components/TeamListItem.tsx
index 95404e1e6b..d0fc01c41e 100644
--- a/packages/features/ee/teams/components/TeamListItem.tsx
+++ b/packages/features/ee/teams/components/TeamListItem.tsx
@@ -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) {
{team.name}
- {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"}
diff --git a/packages/trpc/server/routers/viewer/organizations/createTeams.handler.ts b/packages/trpc/server/routers/viewer/organizations/createTeams.handler.ts
index 0b99e339bc..ab1cb1b80a 100644
--- a/packages/trpc/server/routers/viewer/organizations/createTeams.handler.ts
+++ b/packages/trpc/server/routers/viewer/organizations/createTeams.handler.ts
@@ -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 };
};
diff --git a/packages/trpc/server/routers/viewer/teams/list.handler.ts b/packages/trpc/server/routers/viewer/teams/list.handler.ts
index 3dd7551fed..0db29bbb32 100644
--- a/packages/trpc/server/routers/viewer/teams/list.handler.ts
+++ b/packages/trpc/server/routers/viewer/teams/list.handler.ts
@@ -1,4 +1,5 @@
import { prisma } from "@calcom/prisma";
+import { teamMetadataSchema } from "@calcom/prisma/zod-utils";
import type { TrpcSessionUser } from "../../../trpc";
@@ -23,9 +24,14 @@ export const listHandler = async ({ ctx }: ListOptions) => {
orderBy: { role: "desc" },
});
- return memberships.map(({ team, ...membership }) => ({
- role: membership.role,
- accepted: membership.accepted,
- ...team,
- }));
+ return memberships
+ .filter((mmship) => {
+ const metadata = teamMetadataSchema.parse(mmship.team.metadata);
+ return !metadata?.isOrganization;
+ })
+ .map(({ team, ...membership }) => ({
+ role: membership.role,
+ accepted: membership.accepted,
+ ...team,
+ }));
};