push code ne
This commit is contained in:
@@ -44,6 +44,9 @@ export class CenterSchema extends PothosSchema {
|
||||
description: t.exposeString('description', {
|
||||
description: 'The description of the center.',
|
||||
}),
|
||||
adminNote: t.relation('adminNote', {
|
||||
description: 'The admin note of the center.',
|
||||
}),
|
||||
logoUrl: t.exposeString('logoUrl', {
|
||||
description: 'The URL of the center logo.',
|
||||
}),
|
||||
@@ -68,8 +71,8 @@ export class CenterSchema extends PothosSchema {
|
||||
chatRoom: t.relation('chatRoom', {
|
||||
description: 'The chat room associated with the center.',
|
||||
}),
|
||||
centerStaff: t.relation('centerStaff', {
|
||||
description: 'The staff members of the center.',
|
||||
centerMentor: t.relation('centerMentors', {
|
||||
description: 'The mentors of the center.',
|
||||
}),
|
||||
resume: t.relation('resume', {
|
||||
description: 'The resume of the center.',
|
||||
@@ -114,8 +117,8 @@ export class CenterSchema extends PothosSchema {
|
||||
});
|
||||
},
|
||||
}),
|
||||
// get current center of centerstaff by providing userId
|
||||
centerByCenterStaff: t.prismaField({
|
||||
// get current center of centermentor by providing userId
|
||||
centerByCenterMentor: t.prismaField({
|
||||
type: this.center(),
|
||||
description: 'Retrieve a single center by its unique identifier.',
|
||||
args: {
|
||||
@@ -124,9 +127,9 @@ export class CenterSchema extends PothosSchema {
|
||||
resolve: async (query, root, args, ctx, info) => {
|
||||
return await this.prisma.center.findFirst({
|
||||
where: {
|
||||
centerStaff: {
|
||||
centerMentors: {
|
||||
some: {
|
||||
staffId: args.userId,
|
||||
mentorId: args.userId,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -192,7 +195,7 @@ export class CenterSchema extends PothosSchema {
|
||||
}),
|
||||
approveOrRejectCenter: t.prismaField({
|
||||
type: this.center(),
|
||||
description: 'Approve a center and promote centerstaff to staff',
|
||||
description: 'Approve a center and promote centermentor to mentor',
|
||||
args: {
|
||||
centerId: t.arg({
|
||||
type: 'String',
|
||||
@@ -218,10 +221,10 @@ export class CenterSchema extends PothosSchema {
|
||||
if (center.centerStatus !== CenterStatus.PENDING) {
|
||||
throw new Error('Center is already approved or rejected');
|
||||
}
|
||||
// find center owner and promote to staff
|
||||
// find user and promote to center owner
|
||||
const centerOwnerId = center.centerOwnerId;
|
||||
if (!centerOwnerId) {
|
||||
throw new Error('Center owner not found');
|
||||
throw new Error('User not found');
|
||||
}
|
||||
const centerOwner = await prisma.user.findUnique({
|
||||
where: {
|
||||
@@ -229,7 +232,7 @@ export class CenterSchema extends PothosSchema {
|
||||
},
|
||||
});
|
||||
if (!centerOwner) {
|
||||
throw new Error('Center owner not found');
|
||||
throw new Error('User not found');
|
||||
}
|
||||
await prisma.user.update({
|
||||
where: {
|
||||
|
||||
Reference in New Issue
Block a user