notifcation
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { IsString, IsNotEmpty, IsBoolean, IsObject, IsOptional, ValidateNested } from 'class-validator';
|
||||
import { IsString, IsNotEmpty, IsBoolean, IsOptional, ValidateNested } from 'class-validator';
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
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' })
|
||||
@@ -14,22 +16,16 @@ class ChannelsDto {
|
||||
push?: boolean;
|
||||
}
|
||||
|
||||
export class CreateNotificationPreferenceDto {
|
||||
export class CreatePreferenceDto {
|
||||
@ApiProperty({ description: 'Notification type (e.g., ORDER_CONFIRMED, PAYMENT_FAILED)' })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
notificationType: string;
|
||||
@Enum(() => NotificationType)
|
||||
notificationType!: NotificationType;
|
||||
|
||||
@ApiProperty({ description: 'Notification channels configuration', type: ChannelsDto })
|
||||
@ValidateNested()
|
||||
@Type(() => ChannelsDto)
|
||||
@IsObject()
|
||||
@IsNotEmpty()
|
||||
channels: ChannelsDto;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Whether the preference is enabled', default: true })
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
enabled?: boolean;
|
||||
@Enum(() => NotificationTitle)
|
||||
title!: NotificationTitle;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/swagger';
|
||||
import { CreatePreferenceDto } from './create-preference.dto';
|
||||
|
||||
export class UpdatePreferenceDto extends PartialType(CreatePreferenceDto) {}
|
||||
Reference in New Issue
Block a user