Enhance ServiceSchema by adding commission and descriptions for approve and adminNote arguments. Implement default commission logic when service is approved without a specified commission.
This commit is contained in:
@@ -296,10 +296,17 @@ export class ServiceSchema extends PothosSchema {
|
||||
approve: t.arg({
|
||||
type: 'Boolean',
|
||||
required: true,
|
||||
description: 'The approve status of the service.',
|
||||
}),
|
||||
adminNote: t.arg({
|
||||
type: 'String',
|
||||
required: false,
|
||||
description: 'The admin note of the service.',
|
||||
}),
|
||||
commission: t.arg({
|
||||
type: 'Float',
|
||||
required: false,
|
||||
description: 'The commission of the service. present as float 0 to 1 and required if approve is true',
|
||||
}),
|
||||
},
|
||||
resolve: async (query, _root, args, ctx, _info) => {
|
||||
@@ -317,6 +324,10 @@ export class ServiceSchema extends PothosSchema {
|
||||
if (service.status !== ServiceStatus.PENDING) {
|
||||
throw new Error('Service is already approved or rejected')
|
||||
}
|
||||
let commission = args.commission
|
||||
if (args.approve && !commission) {
|
||||
commission = 0.05
|
||||
}
|
||||
// update service status
|
||||
const updatedService = await prisma.service.update({
|
||||
...query,
|
||||
@@ -329,6 +340,7 @@ export class ServiceSchema extends PothosSchema {
|
||||
notedByUserId: ctx.http.me?.id ?? '',
|
||||
},
|
||||
},
|
||||
commission: commission ?? 0,
|
||||
},
|
||||
})
|
||||
// mail to all mentor or center owner for the center
|
||||
|
||||
Reference in New Issue
Block a user