implement cron mechanic for refund strageries and make workshop reliable
This commit is contained in:
@@ -3,6 +3,7 @@ import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-cor
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { MinioService } from 'src/Minio/minio.service'
|
||||
import { Role } from '@prisma/client'
|
||||
|
||||
@Injectable()
|
||||
export class WorkshopSchema extends PothosSchema {
|
||||
@@ -115,7 +116,7 @@ export class WorkshopSchema extends PothosSchema {
|
||||
type: this.workshop(),
|
||||
args: {
|
||||
input: t.arg({
|
||||
type: this.builder.generator.getCreateInput('Workshop'),
|
||||
type: this.builder.generator.getCreateInput('Workshop', ['workshopMeetingRoom']),
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
@@ -123,11 +124,25 @@ export class WorkshopSchema extends PothosSchema {
|
||||
resolve: async (query, _root, args, ctx, _info) => {
|
||||
if (ctx.isSubscription) throw new Error('Workshops cannot be created in subscription context')
|
||||
if (!ctx.http.me) throw new Error('User is not authenticated to create a workshop')
|
||||
if (ctx.http.me.role !== Role.CENTER_OWNER) throw new Error('Only center owners can create workshops')
|
||||
if (!args.input.service.connect) throw new Error('Service is required to create a workshop')
|
||||
// check if service is active
|
||||
const service = await this.prisma.service.findUnique({
|
||||
where: { id: args.input.service.connect.id },
|
||||
})
|
||||
if (!service || !service.isActive) throw new Error('Service is not active')
|
||||
|
||||
return await this.prisma.workshop.create({
|
||||
const workshop = await this.prisma.workshop.create({
|
||||
...query,
|
||||
data: args.input,
|
||||
})
|
||||
// create workshop meeting room
|
||||
await this.prisma.workshopMeetingRoom.create({
|
||||
data: {
|
||||
workshopId: workshop.id,
|
||||
},
|
||||
})
|
||||
return workshop
|
||||
},
|
||||
}),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user