update service and category

This commit is contained in:
2024-11-11 18:55:24 +07:00
parent 705c4b53d8
commit e0a8b0aaa0
8 changed files with 130 additions and 20 deletions

View File

@@ -48,6 +48,20 @@ export class UserSchema extends PothosSchema {
bankAccountNumber: t.exposeString('bankAccountNumber', {
description: 'The bank account number of the user.',
}),
packageValue: t.exposeFloat('packageValue', {
description: 'The package value of the user.',
validate: (value) => {
if (typeof value !== 'number') {
return false
}
// value can be only 0 to 1
if (value < 0 || value > 1) {
return false
}
return true
},
nullable: true,
}),
role: t.exposeString('role', {
nullable: true,
description: 'The role of the user.',
@@ -284,15 +298,16 @@ export class UserSchema extends PothosSchema {
}
const buffer = Buffer.concat(chunks)
const { id: userId, imageUrl } = await clerkClient.users.updateUserProfileImage(id, {
file: new Blob([buffer]),
});
const { id: userId, imageUrl } =
await clerkClient.users.updateUserProfileImage(id, {
file: new Blob([buffer]),
})
await this.prisma.user.update({
where: { id: userId },
data: {
avatarUrl: imageUrl,
},
});
})
}
}