notifcation

This commit is contained in:
2025-12-09 10:19:28 +03:30
parent 44fd209c92
commit ead1e096a5
16 changed files with 510 additions and 606 deletions
@@ -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) {}