wip
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user