feat(workspaces): create workspace seat function
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { WorkspaceSeat } from '@/modules/gatekeeper/domain/billing'
|
||||
import { WorkspaceFeatureName } from '@/modules/gatekeeper/domain/workspacePricing'
|
||||
import {
|
||||
PlanStatuses,
|
||||
@@ -30,3 +31,7 @@ export type GetWorkspacePlanByProjectId = ({
|
||||
}: {
|
||||
projectId: string
|
||||
}) => Promise<WorkspacePlan | null>
|
||||
|
||||
export type CreateWorkspaceSeat = (
|
||||
args: Pick<WorkspaceSeat, 'workspaceId' | 'userId' | 'type'>
|
||||
) => Promise<WorkspaceSeat>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { WorkspaceSeat } from '@/modules/gatekeeper/domain/billing'
|
||||
import { CreateWorkspaceSeat } from '@/modules/gatekeeper/domain/operations'
|
||||
import { Knex } from 'knex'
|
||||
|
||||
const tables = {
|
||||
@@ -17,3 +18,13 @@ export const countSeatsByTypeInWorkspaceFactory =
|
||||
.count('id')
|
||||
return parseInt(count.toString())
|
||||
}
|
||||
|
||||
export const createWorkspaceSeatFactory =
|
||||
({ db }: { db: Knex }): CreateWorkspaceSeat =>
|
||||
async ({ userId, workspaceId, type }) => {
|
||||
return await tables.workspaceSeats(db).insert({
|
||||
workspaceId,
|
||||
userId,
|
||||
type
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user