feat: enhance PersonalMilestone and Service schemas with new functionalities
- Added a new mutation to update personal milestones and change schedule status to IN_PROGRESS in PersonalMilestoneSchema. - Refactored service notification logic to send messages to moderators upon service approval in ServiceSchema, improving communication flow. - Cleaned up commented-out code for better readability and maintainability. These changes enhance the GraphQL API by improving milestone management and service notification processes, ensuring better user experience and state management.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common'
|
||||
import { PersonalMilestoneStatus } from '@prisma/client'
|
||||
import { PersonalMilestoneStatus, ScheduleStatus } from '@prisma/client'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
@@ -126,7 +126,7 @@ export class PersonalMilestoneSchema extends PothosSchema {
|
||||
throw new Error('Cannot get your info')
|
||||
}
|
||||
const userId = ctx.http.me.id
|
||||
return await this.prisma.personalMilestone.createManyAndReturn({
|
||||
const result = await this.prisma.personalMilestone.createManyAndReturn({
|
||||
data: args.data.map((data) => ({
|
||||
...data,
|
||||
userId,
|
||||
@@ -134,6 +134,44 @@ export class PersonalMilestoneSchema extends PothosSchema {
|
||||
})),
|
||||
skipDuplicates: true,
|
||||
})
|
||||
// update schedule status to IN_PROGRESS
|
||||
await this.prisma.schedule.update({
|
||||
where: { id: args.scheduleId },
|
||||
data: { status: ScheduleStatus.IN_PROGRESS },
|
||||
})
|
||||
return result
|
||||
},
|
||||
}),
|
||||
updatePersonalMilestone: t.prismaField({
|
||||
type: this.personalMilestone(),
|
||||
args: {
|
||||
where: t.arg({
|
||||
type: this.builder.generator.getWhereUnique('PersonalMilestone'),
|
||||
description: 'The where clause for the personal milestone.',
|
||||
required: true,
|
||||
}),
|
||||
data: t.arg({
|
||||
type: this.builder.generator.getUpdateInput('PersonalMilestone'),
|
||||
description: 'The data for the personal milestone.',
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
description: 'Update a personal milestone.',
|
||||
resolve: async (_query, _root, args, ctx, _info) => {
|
||||
if (ctx.isSubscription) {
|
||||
throw new Error('Not allowed')
|
||||
}
|
||||
if (!ctx.http.me) {
|
||||
throw new Error('Cannot get your info')
|
||||
}
|
||||
const userId = ctx.http.me.id
|
||||
return this.prisma.personalMilestone.update({
|
||||
where: {
|
||||
...args.where,
|
||||
userId,
|
||||
},
|
||||
data: args.data,
|
||||
})
|
||||
},
|
||||
}),
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user