🛂 (billing) Add isPastDue field in workspace (#1046)
Closes #1039 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Workspaces now include additional status indicator: `isPastDue`. - New pages for handling workspaces that are past due. Meaning, an invoice is unpaid. - **Bug Fixes** - Fixed issues with workspace status checks and redirections for suspended workspaces. - **Refactor** - Refactored workspace-related API functions to accommodate new status fields. - Improved permission checks for reading and writing typebots based on workspace status. - **Chores** - Database schema updated to include `isPastDue` field for workspaces. - Implemented new webhook event handling for subscription and invoice updates. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -97,6 +97,7 @@ model Workspace {
|
||||
customSeatsLimit Int?
|
||||
isQuarantined Boolean @default(false)
|
||||
isSuspended Boolean @default(false)
|
||||
isPastDue Boolean @default(false)
|
||||
themeTemplates ThemeTemplate[]
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Workspace" ADD COLUMN "isPastDue" BOOLEAN NOT NULL DEFAULT false;
|
||||
@@ -91,6 +91,7 @@ model Workspace {
|
||||
customSeatsLimit Int?
|
||||
isQuarantined Boolean @default(false)
|
||||
isSuspended Boolean @default(false)
|
||||
isPastDue Boolean @default(false)
|
||||
themeTemplates ThemeTemplate[]
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +105,18 @@ const workspaceAutoQuarantinedEventSchema = workspaceEvent.merge(
|
||||
})
|
||||
)
|
||||
|
||||
export const workspacePastDueEventSchema = workspaceEvent.merge(
|
||||
z.object({
|
||||
name: z.literal('Workspace past due'),
|
||||
})
|
||||
)
|
||||
|
||||
export const workspaceNotPastDueEventSchema = workspaceEvent.merge(
|
||||
z.object({
|
||||
name: z.literal('Workspace past due status removed'),
|
||||
})
|
||||
)
|
||||
|
||||
export const eventSchema = z.discriminatedUnion('name', [
|
||||
workspaceCreatedEventSchema,
|
||||
userCreatedEventSchema,
|
||||
@@ -115,6 +127,8 @@ export const eventSchema = z.discriminatedUnion('name', [
|
||||
workspaceLimitReachedEventSchema,
|
||||
workspaceAutoQuarantinedEventSchema,
|
||||
subscriptionAutoUpdatedEventSchema,
|
||||
workspacePastDueEventSchema,
|
||||
workspaceNotPastDueEventSchema,
|
||||
])
|
||||
|
||||
export type TelemetryEvent = z.infer<typeof eventSchema>
|
||||
|
||||
@@ -50,6 +50,7 @@ export const workspaceSchema = z.object({
|
||||
customSeatsLimit: z.number().nullable(),
|
||||
isQuarantined: z.boolean(),
|
||||
isSuspended: z.boolean(),
|
||||
isPastDue: z.boolean(),
|
||||
}) satisfies z.ZodType<WorkspacePrisma>
|
||||
|
||||
export type Workspace = z.infer<typeof workspaceSchema>
|
||||
|
||||
Reference in New Issue
Block a user