up
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user