9h sang tao code tiep
This commit is contained in:
@@ -62,7 +62,7 @@ export class CenterMentorSchema extends PothosSchema {
|
||||
return await this.prisma.centerMentor.findMany({
|
||||
...query,
|
||||
skip: args.skip ?? undefined,
|
||||
take: args.take ?? 10,
|
||||
take: args.take ?? undefined,
|
||||
orderBy: args.orderBy ?? undefined,
|
||||
where: args.filter ?? undefined,
|
||||
});
|
||||
@@ -168,6 +168,36 @@ export class CenterMentorSchema extends PothosSchema {
|
||||
});
|
||||
},
|
||||
}),
|
||||
testInviteCenterMentor: t.prismaField({
|
||||
type: this.centerMentor(),
|
||||
args: {
|
||||
email: t.arg({ type: 'String', required: true }),
|
||||
centerId: t.arg({ type: 'String', required: true }),
|
||||
},
|
||||
description: 'Test invite center mentor.',
|
||||
resolve: async (query, root, args, ctx, info) => {
|
||||
return this.prisma.$transaction(async (prisma) => {
|
||||
// sign token
|
||||
const token = this.jwtUtils.signTokenRS256(
|
||||
{ centerId: args.centerId, email: args.email },
|
||||
'1d',
|
||||
);
|
||||
// build invite url
|
||||
const inviteUrl = `${process.env.CENTER_BASE_URL}/invite?token=${token}`;
|
||||
// mail to user with params centerId, email
|
||||
await this.mailService.sendTemplateEmail(
|
||||
args.email,
|
||||
'Invite to center',
|
||||
'MentorInvitation',
|
||||
{
|
||||
center_name: args.centerId,
|
||||
invite_url: inviteUrl,
|
||||
},
|
||||
);
|
||||
return null;
|
||||
});
|
||||
},
|
||||
}),
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user