This commit is contained in:
Carl-Gerhard Lindesvärd
2026-01-20 12:34:56 +01:00
parent 6e997e62f1
commit 56f1c5e894
16 changed files with 601 additions and 4 deletions

View File

@@ -22,6 +22,13 @@ async function createOrGetOrganization(
const TRIAL_DURATION_IN_DAYS = 30;
if (input.organization) {
// Check if this is the user's first organization
const existingOrgCount = await db.organization.count({
where: {
createdByUserId: user.id,
},
});
const organization = await db.organization.create({
data: {
id: await getId('organization', input.organization),
@@ -33,6 +40,14 @@ async function createOrGetOrganization(
},
});
// Set onboarding = 1 for first organization creation
if (existingOrgCount === 0 && user.onboarding === null) {
await db.user.update({
where: { id: user.id },
data: { onboarding: 1 },
});
}
if (!process.env.SELF_HOSTED) {
await addTrialEndingSoonJob(
organization.id,