edit:model:user | change user prisma schema from profilePicture to avatar

This commit is contained in:
rafiarrafif
2025-06-21 22:13:01 +07:00
parent 22c24c0202
commit fbd5b68b10
3 changed files with 8 additions and 9 deletions

View File

@ -203,8 +203,8 @@ model User {
phoneNumber Int?
roles UserRole[] @relation("UserRoles")
bioProfile String? @db.Text
profilePicture String? @db.Text
commentPicture String? @db.Text
avatar String? @db.Text
commentBackground String? @db.Text
preference UserPreference? @relation(fields: [preferenceId], references: [id])
preferenceId String? @unique
verifiedAt DateTime?

View File

@ -10,6 +10,6 @@ export const createUserSchema = Joi.object({
phoneCC: Joi.string().min(2).max(2),
phoneNumber: Joi.string().min(7).max(15),
bioProfile: Joi.string().max(300),
profilePicture: Joi.string().uri(),
commentPicture: Joi.string().uri(),
avatar: Joi.string().uri(),
commentBackground: Joi.string().uri(),
});

View File

@ -32,8 +32,7 @@ export const editUserService = async (
// Store the avatar to the file system if provided in the payload
let storeAvatar: string | undefined = undefined;
if (payload.profilePicture)
storeAvatar = await saveAvatar(payload.profilePicture as File);
if (payload.avatar) storeAvatar = await saveAvatar(payload.avatar as File);
// Prepare the fields to update, only include fields that are provided in the payload
const fieldsToUpdate: Partial<Prisma.UserUpdateInput> = {
@ -53,9 +52,9 @@ export const editUserService = async (
...(payload.bioProfile !== undefined
? { bioProfile: payload.bioProfile }
: {}),
...(storeAvatar !== undefined ? { profilePicture: storeAvatar } : {}),
...(payload.commentPicture !== undefined
? { commentPicture: payload.commentPicture }
...(storeAvatar !== undefined ? { avatar: storeAvatar } : {}),
...(payload.commentBackground !== undefined
? { commentPicture: payload.commentBackground }
: {}),
...(payload.deletedAt !== undefined
? { deletedAt: payload.deletedAt }