fix admin note is required in mentor
This commit is contained in:
@@ -64,7 +64,7 @@ export class AppConfigSchema extends PothosSchema {
|
||||
type: this.appConfig(),
|
||||
description: 'Get an app config by key',
|
||||
args: this.builder.generator.findUniqueArgs('Config'),
|
||||
resolve: async (query, root, args) => {
|
||||
resolve: async (query, _root, args) => {
|
||||
return await this.prisma.config.findUnique({
|
||||
...query,
|
||||
where: args.where ?? undefined,
|
||||
@@ -84,7 +84,7 @@ export class AppConfigSchema extends PothosSchema {
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
resolve: async (query, root, args) => {
|
||||
resolve: async (query, _root, args) => {
|
||||
return await this.prisma.config.create({
|
||||
...query,
|
||||
data: args.input,
|
||||
@@ -100,7 +100,7 @@ export class AppConfigSchema extends PothosSchema {
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
resolve: async (query, root, args) => {
|
||||
resolve: async (query, _root, args) => {
|
||||
return await this.prisma.config.createManyAndReturn({
|
||||
...query,
|
||||
data: args.input,
|
||||
|
||||
@@ -13,6 +13,7 @@ export class AppConfigService implements OnModuleInit {
|
||||
const configs = await this.prisma.config.findMany()
|
||||
if (configs.length === 0) {
|
||||
Object.entries(ConfigConstants).forEach(async ([_key, value]) => {
|
||||
try {
|
||||
await this.prisma.config.create({
|
||||
data: {
|
||||
name: value.name,
|
||||
@@ -21,6 +22,7 @@ export class AppConfigService implements OnModuleInit {
|
||||
visible: value.visible,
|
||||
},
|
||||
})
|
||||
} catch (_error) {}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -50,9 +52,20 @@ export class AppConfigService implements OnModuleInit {
|
||||
})
|
||||
}
|
||||
|
||||
async deleteConfig(key: string) {
|
||||
return await this.prisma.config.delete({
|
||||
async resetConfig(key: string) {
|
||||
// reset config to default value
|
||||
await this.prisma.config.update({
|
||||
where: { key },
|
||||
data: ConfigConstants[key],
|
||||
})
|
||||
}
|
||||
|
||||
async resetAllConfigs() {
|
||||
// reset all configs to default values
|
||||
Object.entries(ConfigConstants).forEach(async ([_key, value]) => {
|
||||
await this.prisma.config.create({
|
||||
data: value,
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ export class CenterSchema extends PothosSchema {
|
||||
'CenterRejected',
|
||||
{
|
||||
CENTER_NAME: center.name,
|
||||
ADMIN_NOTE: args.adminNote,
|
||||
ADMIN_NOTE: args.adminNote ?? '',
|
||||
},
|
||||
)
|
||||
} catch (error) {
|
||||
|
||||
@@ -163,7 +163,7 @@ export class CenterMentorSchema extends PothosSchema {
|
||||
// mail to user with params centerId, email
|
||||
await this.mailService.sendTemplateEmail(
|
||||
[args.email],
|
||||
'Invite to center',
|
||||
`Thư mời làm việc tại trung tâm ${center.name}`,
|
||||
'MentorInvitation',
|
||||
{
|
||||
center_name: center.name,
|
||||
@@ -220,10 +220,6 @@ export class CenterMentorSchema extends PothosSchema {
|
||||
throw new Error('Not allowed')
|
||||
}
|
||||
return this.prisma.$transaction(async (prisma) => {
|
||||
// validate input
|
||||
if (args.approved && !args.adminNote) {
|
||||
throw new Error('Admin note is required')
|
||||
}
|
||||
// get mentor info
|
||||
const mentor = await prisma.user.findUnique({
|
||||
where: args.where,
|
||||
|
||||
@@ -135,7 +135,7 @@ export class UserSchema extends PothosSchema {
|
||||
me: t.prismaField({
|
||||
description: 'Retrieve the current user in context.',
|
||||
type: this.user(),
|
||||
resolve: async (query, root, args, ctx) => {
|
||||
resolve: async (_query, _root, _args, ctx) => {
|
||||
if (ctx.isSubscription) {
|
||||
throw new Error('Not allowed')
|
||||
}
|
||||
@@ -148,7 +148,7 @@ export class UserSchema extends PothosSchema {
|
||||
'Retrieve a list of users with optional filtering, ordering, and pagination.',
|
||||
type: [this.user()],
|
||||
args: this.builder.generator.findManyArgs('User'),
|
||||
resolve: async (query, root, args) => {
|
||||
resolve: async (query, _root, args) => {
|
||||
return await this.prisma.user.findMany({
|
||||
...query,
|
||||
take: args.take ?? undefined,
|
||||
@@ -163,7 +163,7 @@ export class UserSchema extends PothosSchema {
|
||||
description: 'Retrieve a single user by their unique identifier.',
|
||||
type: this.user(),
|
||||
args: this.builder.generator.findUniqueArgs('User'),
|
||||
resolve: async (query, root, args) => {
|
||||
resolve: async (query, _root, args) => {
|
||||
return await this.prisma.user.findUniqueOrThrow({
|
||||
...query,
|
||||
where: args.where,
|
||||
@@ -176,7 +176,7 @@ export class UserSchema extends PothosSchema {
|
||||
args: {
|
||||
sessionId: t.arg({ type: 'String', required: true }),
|
||||
},
|
||||
resolve: async (query, root, args) => {
|
||||
resolve: async (query, _root, args) => {
|
||||
// check if the token is valid
|
||||
const session = await clerkClient.sessions.getSession(args.sessionId)
|
||||
Logger.log(session, 'Session')
|
||||
|
||||
Reference in New Issue
Block a user