fix approve resume
This commit is contained in:
@@ -107,6 +107,49 @@ export class AppConfigSchema extends PothosSchema {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
updateAppConfig: t.prismaField({
|
||||||
|
type: this.appConfig(),
|
||||||
|
description: 'Update an app config',
|
||||||
|
args: {
|
||||||
|
input: t.arg({
|
||||||
|
type: this.builder.generator.getUpdateInput('Config'),
|
||||||
|
required: true,
|
||||||
|
}),
|
||||||
|
where: t.arg({
|
||||||
|
type: this.builder.generator.getWhereUnique('Config'),
|
||||||
|
required: true,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
resolve: async (query, _root, args) => {
|
||||||
|
return await this.prisma.config.update({
|
||||||
|
...query,
|
||||||
|
data: args.input,
|
||||||
|
where: args.where ?? undefined,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
/* The `updateAppConfigs` field in the `AppConfigSchema` class is defining a mutation to update
|
||||||
|
multiple app configs in the database. Here is a breakdown of what it is doing: */
|
||||||
|
// updateAppConfigs: t.prismaField({
|
||||||
|
// type: [this.appConfig()],
|
||||||
|
// description: 'Update multiple app configs',
|
||||||
|
// args: {
|
||||||
|
// data: t.arg({
|
||||||
|
// type: [this.builder.generator.getUpdateInput('Config')],
|
||||||
|
// required: true,
|
||||||
|
// }),
|
||||||
|
// where: t.arg({
|
||||||
|
// type: this.builder.generator.getWhere('Config'),
|
||||||
|
// required: true,
|
||||||
|
// }),
|
||||||
|
// },
|
||||||
|
// resolve: async (query, _root, args) => {
|
||||||
|
// return await this.prisma.config.updateMany({
|
||||||
|
// data: args.data,
|
||||||
|
// where: args.where ?? undefined,
|
||||||
|
// })
|
||||||
|
// },
|
||||||
|
// }),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ export class ResumeSchema extends PothosSchema {
|
|||||||
required: false,
|
required: false,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
resolve: async (query, root, args, ctx, info) => {
|
resolve: async (query, _root, args, ctx, _info) => {
|
||||||
try {
|
try {
|
||||||
if (ctx.isSubscription) {
|
if (ctx.isSubscription) {
|
||||||
throw new Error('Not allowed')
|
throw new Error('Not allowed')
|
||||||
@@ -133,7 +133,7 @@ export class ResumeSchema extends PothosSchema {
|
|||||||
'Retrieve a list of resumes with optional filtering, ordering, and pagination.',
|
'Retrieve a list of resumes with optional filtering, ordering, and pagination.',
|
||||||
type: [this.resume()],
|
type: [this.resume()],
|
||||||
args: this.builder.generator.findManyArgs('Resume'),
|
args: this.builder.generator.findManyArgs('Resume'),
|
||||||
resolve: async (query, root, args) => {
|
resolve: async (query, _root, args) => {
|
||||||
return await this.prisma.resume.findMany({
|
return await this.prisma.resume.findMany({
|
||||||
...query,
|
...query,
|
||||||
skip: args.skip ?? undefined,
|
skip: args.skip ?? undefined,
|
||||||
@@ -148,7 +148,7 @@ export class ResumeSchema extends PothosSchema {
|
|||||||
description: 'Retrieve a single resume by its unique identifier.',
|
description: 'Retrieve a single resume by its unique identifier.',
|
||||||
type: this.resume(),
|
type: this.resume(),
|
||||||
args: this.builder.generator.findUniqueArgs('Resume'),
|
args: this.builder.generator.findUniqueArgs('Resume'),
|
||||||
resolve: async (query, root, args) => {
|
resolve: async (query, _root, args) => {
|
||||||
const resume = await this.prisma.resume.findUnique({
|
const resume = await this.prisma.resume.findUnique({
|
||||||
...query,
|
...query,
|
||||||
where: args.where,
|
where: args.where,
|
||||||
@@ -161,7 +161,7 @@ export class ResumeSchema extends PothosSchema {
|
|||||||
description: 'Retrieve a single resume file by its unique identifier.',
|
description: 'Retrieve a single resume file by its unique identifier.',
|
||||||
type: this.resumeFile(),
|
type: this.resumeFile(),
|
||||||
args: this.builder.generator.findUniqueArgs('ResumeFile'),
|
args: this.builder.generator.findUniqueArgs('ResumeFile'),
|
||||||
resolve: async (query, root, args) => {
|
resolve: async (query, _root, args) => {
|
||||||
const resumeFile = await this.prisma.resumeFile.findUnique({
|
const resumeFile = await this.prisma.resumeFile.findUnique({
|
||||||
...query,
|
...query,
|
||||||
where: args.where,
|
where: args.where,
|
||||||
@@ -177,7 +177,7 @@ export class ResumeSchema extends PothosSchema {
|
|||||||
'Retrieve a list of resume files with optional filtering, ordering, and pagination.',
|
'Retrieve a list of resume files with optional filtering, ordering, and pagination.',
|
||||||
type: [this.resumeFile()],
|
type: [this.resumeFile()],
|
||||||
args: this.builder.generator.findManyArgs('ResumeFile'),
|
args: this.builder.generator.findManyArgs('ResumeFile'),
|
||||||
resolve: async (query, root, args) => {
|
resolve: async (query, _root, args) => {
|
||||||
const resumeFiles = await this.prisma.resumeFile.findMany({
|
const resumeFiles = await this.prisma.resumeFile.findMany({
|
||||||
...query,
|
...query,
|
||||||
skip: args.skip ?? undefined,
|
skip: args.skip ?? undefined,
|
||||||
@@ -209,7 +209,7 @@ export class ResumeSchema extends PothosSchema {
|
|||||||
required: true,
|
required: true,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
resolve: async (query, root, args) => {
|
resolve: async (query, _root, args) => {
|
||||||
const { resumeFile } = args
|
const { resumeFile } = args
|
||||||
const { mimetype } = await resumeFile
|
const { mimetype } = await resumeFile
|
||||||
const { filename, actualFileName } =
|
const { filename, actualFileName } =
|
||||||
@@ -279,18 +279,19 @@ export class ResumeSchema extends PothosSchema {
|
|||||||
}
|
}
|
||||||
const { resumeId, status, adminNote } = args
|
const { resumeId, status, adminNote } = args
|
||||||
return this.prisma.$transaction(async (tx) => {
|
return this.prisma.$transaction(async (tx) => {
|
||||||
const resumeOwner = await tx.user.findUnique({
|
|
||||||
where: { id: resumeId },
|
|
||||||
})
|
|
||||||
if (!resumeOwner) {
|
|
||||||
throw new Error('Resume not found')
|
|
||||||
}
|
|
||||||
const oldResume = await tx.resume.findUnique({
|
const oldResume = await tx.resume.findUnique({
|
||||||
where: { id: resumeId },
|
where: { id: resumeId },
|
||||||
})
|
})
|
||||||
if (!oldResume) {
|
if (!oldResume) {
|
||||||
throw new Error('Resume not found')
|
throw new Error('Resume not found')
|
||||||
}
|
}
|
||||||
|
const resumeOwner = await tx.user.findUnique({
|
||||||
|
where: { id: oldResume.userId },
|
||||||
|
})
|
||||||
|
if (!resumeOwner) {
|
||||||
|
throw new Error('Resume owner not found')
|
||||||
|
}
|
||||||
|
|
||||||
// if resumeOwner.status is REQUESTED and status is REVIEWING then we need update status and return resume
|
// if resumeOwner.status is REQUESTED and status is REVIEWING then we need update status and return resume
|
||||||
if (
|
if (
|
||||||
oldResume.status === ResumeStatus.REQUESTED &&
|
oldResume.status === ResumeStatus.REQUESTED &&
|
||||||
|
|||||||
Reference in New Issue
Block a user