chore: fix upsert resume
This commit is contained in:
@@ -153,7 +153,30 @@ export class CenterSchema extends PothosSchema {
|
|||||||
required: true,
|
required: true,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
resolve: async (query, _root, args) => {
|
resolve: async (query, _root, args, ctx) => {
|
||||||
|
if (ctx.isSubscription) {
|
||||||
|
throw new Error('Not allowed in subscription')
|
||||||
|
}
|
||||||
|
if (ctx.http.me?.role !== Role.CUSTOMER) {
|
||||||
|
throw new Error('Not allowed')
|
||||||
|
}
|
||||||
|
// check if user has already created a center
|
||||||
|
const existingCenter = await this.prisma.center.findFirst({
|
||||||
|
where: {
|
||||||
|
centerOwnerId: ctx.http.me?.id,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if (existingCenter) {
|
||||||
|
if (existingCenter.centerStatus === CenterStatus.PENDING) {
|
||||||
|
throw new Error('User has already created a center but is pending approval')
|
||||||
|
}
|
||||||
|
if (existingCenter.centerStatus === CenterStatus.APPROVED) {
|
||||||
|
throw new Error('User has already created a center and is approved')
|
||||||
|
}
|
||||||
|
if (existingCenter.centerStatus === CenterStatus.REJECTED) {
|
||||||
|
throw new Error('User has already created a center and is rejected')
|
||||||
|
}
|
||||||
|
}
|
||||||
return await this.prisma.center.create({
|
return await this.prisma.center.create({
|
||||||
...query,
|
...query,
|
||||||
data: args.input,
|
data: args.input,
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ export class ResumeSchema extends PothosSchema {
|
|||||||
if (ctx.isSubscription) {
|
if (ctx.isSubscription) {
|
||||||
throw new Error('Not allowed')
|
throw new Error('Not allowed')
|
||||||
}
|
}
|
||||||
if (ctx.http.me?.role !== Role.CUSTOMER) {
|
if (ctx.http.me?.role !== Role.CUSTOMER && ctx.http.me?.role !== Role.CENTER_OWNER) {
|
||||||
throw new Error('Not allowed')
|
throw new Error('Not allowed')
|
||||||
}
|
}
|
||||||
const { resumeFile } = args
|
const { resumeFile } = args
|
||||||
|
|||||||
Reference in New Issue
Block a user