-
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(notifications): refactored notifications module
refactored notifications UI and API modules
- Loading branch information
Showing
51 changed files
with
875 additions
and
787 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 0 additions & 39 deletions
39
apps/api/src/app/notifications/dto/create-notification.dto.ts
This file was deleted.
Oops, something went wrong.
13 changes: 9 additions & 4 deletions
13
apps/api/src/app/notifications/interfaces/notification.actions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
// Actions | ||
export class AddNotification { | ||
static readonly type = '[Notifications] Add'; | ||
constructor(public readonly payload: any) {} | ||
} | ||
|
||
export class DeleteNotification { | ||
static readonly type = '[Notifications] Delete'; | ||
constructor(public readonly payload: any) {} | ||
} | ||
|
||
export class MarkAsRead { | ||
static readonly type = '[Notifications] MarkAsRead'; | ||
constructor(public readonly payload: any) {} | ||
} | ||
|
||
export class MarkAllAsRead { | ||
static readonly type = '[Notifications] MarkAllAsRead'; | ||
} |
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
apps/api/src/app/notifications/notification/dto/create-notification.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { ApiModelProperty, ApiModelPropertyOptional } from '@nestjs/swagger'; | ||
import { IsAscii, IsBoolean, IsEnum, IsNotEmpty, IsOptional, IsString, MaxLength, MinLength } from 'class-validator'; | ||
import { NotificationColor, NotificationIcon, TargetType } from '../notification.entity'; | ||
|
||
export class CreateNotificationDto { | ||
@ApiModelProperty({ type: String, minLength: 10, maxLength: 100 }) | ||
@IsNotEmpty() | ||
@IsString() | ||
readonly title: string; | ||
|
||
@ApiModelProperty({ type: String, minLength: 10, maxLength: 100 }) | ||
@IsNotEmpty() | ||
@IsString() | ||
readonly body: string; | ||
|
||
@ApiModelProperty({ type: String, minLength: 3, maxLength: 50 }) | ||
@IsNotEmpty() | ||
@IsAscii() | ||
@MinLength(3) | ||
@MaxLength(50) | ||
readonly target: string; | ||
|
||
@ApiModelProperty({ type: String, enum: TargetType }) | ||
@IsNotEmpty() | ||
@IsEnum(TargetType) | ||
readonly targetType: TargetType; | ||
|
||
@ApiModelPropertyOptional({ type: String, enum: NotificationIcon, default: NotificationIcon.notifications }) | ||
@IsOptional() | ||
@IsEnum(NotificationIcon) | ||
readonly icon?: NotificationIcon; | ||
|
||
@ApiModelPropertyOptional({ type: String, enum: NotificationColor, default: NotificationColor.PRIMARY }) | ||
@IsOptional() | ||
@IsEnum(NotificationColor) | ||
readonly color?: NotificationColor; | ||
|
||
@ApiModelPropertyOptional({ type: Boolean, default: false }) | ||
@IsOptional() | ||
@IsBoolean() | ||
readonly native?: boolean; | ||
} |
14 changes: 14 additions & 0 deletions
14
apps/api/src/app/notifications/notification/dto/send-notification.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { ApiModelProperty, ApiModelPropertyOptional } from '@nestjs/swagger'; | ||
import { IsNotEmpty, IsOptional, IsString } from 'class-validator'; | ||
|
||
export class SendNotificationDto { | ||
@ApiModelProperty({ type: String }) | ||
@IsNotEmpty() | ||
@IsString() | ||
id: string; | ||
|
||
@ApiModelPropertyOptional({ type: String }) | ||
@IsOptional() | ||
@IsString() | ||
target?: string; | ||
} |
22 changes: 22 additions & 0 deletions
22
apps/api/src/app/notifications/notification/notification.controller.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { NotificationController } from './notification.controller'; | ||
import { NotificationService } from './notification.service'; | ||
|
||
describe('Notification Controller', () => { | ||
let module: TestingModule; | ||
beforeAll(async () => { | ||
module = await Test.createTestingModule({ | ||
controllers: [NotificationController], | ||
providers: [ | ||
{ | ||
provide: NotificationService, | ||
useValue: {}, // TODO: Mock | ||
}, | ||
], | ||
}).compile(); | ||
}); | ||
it('should be defined', () => { | ||
const controller: NotificationController = module.get<NotificationController>(NotificationController); | ||
expect(controller).toBeDefined(); | ||
}); | ||
}); |
Oops, something went wrong.