This commit is contained in:
2025-12-09 10:40:16 +03:30
parent ead1e096a5
commit a5f29956e6
5 changed files with 162 additions and 102 deletions
@@ -1,31 +1,24 @@
import { IsString, IsNotEmpty, IsBoolean, IsOptional, ValidateNested } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsNotEmpty, IsEnum } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
import { NotificationTitle } from '../entities/notification.entity';
import { Enum } from '@mikro-orm/core';
import { NotificationType } from '../interfaces/notification.interface';
class ChannelsDto {
@ApiPropertyOptional({ description: 'Enable SMS channel' })
@IsBoolean()
@IsOptional()
sms?: boolean;
@ApiPropertyOptional({ description: 'Enable push notification channel' })
@IsBoolean()
@IsOptional()
push?: boolean;
}
export class CreatePreferenceDto {
@ApiProperty({ description: 'Notification type (e.g., ORDER_CONFIRMED, PAYMENT_FAILED)' })
@IsString()
@ApiProperty({
description: 'Notification type (SMS, PUSH, BOTH, or NONE)',
enum: NotificationType,
example: NotificationType.SMS
})
@IsEnum(NotificationType)
@IsNotEmpty()
@Enum(() => NotificationType)
notificationType!: NotificationType;
@ApiProperty({ description: 'Notification channels configuration', type: ChannelsDto })
@ValidateNested()
@ApiProperty({
description: 'Notification title/type (e.g., order.created, review.created)',
enum: NotificationTitle,
example: NotificationTitle.ORDER_CREATED
})
@IsEnum(NotificationTitle)
@IsNotEmpty()
@Enum(() => NotificationTitle)
title!: NotificationTitle;
}