mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-26 06:09:41 +00:00
feat: update customer profile picture and notifications settings
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsDateString, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
import { IsDateString, IsNotEmpty, IsOptional, IsString, IsUUID } from 'class-validator';
|
||||
import { i18nValidationMessage as i18n } from 'nestjs-i18n';
|
||||
import { IsAbove18 } from '~/core/decorators/validations';
|
||||
export class UpdateCustomerRequestDto {
|
||||
@ -26,4 +26,8 @@ export class UpdateCustomerRequestDto {
|
||||
@IsAbove18({ message: i18n('validation.IsAbove18', { path: 'general', property: 'customer.dateOfBirth' }) })
|
||||
@IsOptional()
|
||||
dateOfBirth!: Date;
|
||||
|
||||
@ApiProperty({ example: '123e4567-e89b-12d3-a456-426614174000' })
|
||||
@IsUUID('4', { message: i18n('validation.IsUUID', { path: 'general', property: 'customer.profilePictureId' }) })
|
||||
profilePictureId!: string;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { Customer } from '~/customer/entities';
|
||||
import { DocumentMetaResponseDto } from '~/document/dtos/response';
|
||||
import { NotificationSettingsResponseDto } from './notification-settings.response.dto';
|
||||
|
||||
export class CustomerResponseDto {
|
||||
@ApiProperty()
|
||||
@ -50,6 +52,12 @@ export class CustomerResponseDto {
|
||||
@ApiProperty()
|
||||
isGuardian!: boolean;
|
||||
|
||||
@ApiProperty()
|
||||
notificationSettings!: NotificationSettingsResponseDto;
|
||||
|
||||
@ApiPropertyOptional({ type: DocumentMetaResponseDto })
|
||||
profilePicture!: DocumentMetaResponseDto | null;
|
||||
|
||||
constructor(customer: Customer) {
|
||||
this.id = customer.id;
|
||||
this.customerStatus = customer.customerStatus;
|
||||
@ -67,5 +75,7 @@ export class CustomerResponseDto {
|
||||
this.gender = customer.gender;
|
||||
this.isJunior = customer.isJunior;
|
||||
this.isGuardian = customer.isGuardian;
|
||||
this.notificationSettings = new NotificationSettingsResponseDto(customer.notificationSettings);
|
||||
this.profilePicture = customer.profilePicture ? new DocumentMetaResponseDto(customer.profilePicture) : null;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { UserNotificationSettings } from '~/auth/entities';
|
||||
import { CustomerNotificationSettings } from '~/customer/entities/customer-notification-settings.entity';
|
||||
|
||||
export class NotificationSettingsResponseDto {
|
||||
@ApiProperty()
|
||||
@ -11,7 +11,7 @@ export class NotificationSettingsResponseDto {
|
||||
@ApiProperty()
|
||||
isSmsEnabled!: boolean;
|
||||
|
||||
constructor(notificationSettings: UserNotificationSettings) {
|
||||
constructor(notificationSettings: CustomerNotificationSettings) {
|
||||
this.isEmailEnabled = notificationSettings.isEmailEnabled;
|
||||
this.isPushEnabled = notificationSettings.isPushEnabled;
|
||||
this.isSmsEnabled = notificationSettings.isSmsEnabled;
|
||||
|
Reference in New Issue
Block a user