fix: create global settings on team creation (#1601)

The global team settings weren't created when creating a new team.

## Changes Made

The global team settings are now created when a new team is created.
This commit is contained in:
Catalin Pit
2025-01-28 07:16:18 +02:00
committed by David Nguyen
parent b0f8c83134
commit 0f50110853

View File

@ -95,7 +95,7 @@ export const createTeam = async ({
}); });
} }
await tx.team.create({ const team = await tx.team.create({
data: { data: {
name: teamName, name: teamName,
url: teamUrl, url: teamUrl,
@ -104,13 +104,23 @@ export const createTeam = async ({
members: { members: {
create: [ create: [
{ {
userId, userId: user.id,
role: TeamMemberRole.ADMIN, role: TeamMemberRole.ADMIN,
}, },
], ],
}, },
}, },
}); });
await tx.teamGlobalSettings.upsert({
where: {
teamId: team.id,
},
update: {},
create: {
teamId: team.id,
},
});
}); });
return { return {
@ -225,6 +235,16 @@ export const createTeamFromPendingTeam = async ({
}, },
}); });
await tx.teamGlobalSettings.upsert({
where: {
teamId: team.id,
},
update: {},
create: {
teamId: team.id,
},
});
await tx.subscription.upsert( await tx.subscription.upsert(
mapStripeSubscriptionToPrismaUpsertAction(subscription, undefined, team.id), mapStripeSubscriptionToPrismaUpsertAction(subscription, undefined, team.id),
); );