-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add statuses to notifications
- Loading branch information
Daniel Haselhan
committed
Sep 5, 2023
1 parent
82118d8
commit 1276c91
Showing
22 changed files
with
1,133 additions
and
111 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
1 change: 0 additions & 1 deletion
1
.../src/app/features/notifications/view-submission/view-notification-submission.component.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
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
40 changes: 40 additions & 0 deletions
40
...s/src/alcs/notification/notification-submission-status/notification-status-type.entity.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,40 @@ | ||
import { AutoMap } from '@automapper/classes'; | ||
import { Column, Entity, OneToMany } from 'typeorm'; | ||
import { BaseCodeEntity } from '../../../common/entities/base.code.entity'; | ||
import { NotificationSubmissionToSubmissionStatus } from './notification-status.entity'; | ||
|
||
@Entity() | ||
export class NotificationSubmissionStatusType extends BaseCodeEntity { | ||
constructor(data?: Partial<NotificationSubmissionStatusType>) { | ||
super(); | ||
if (data) { | ||
Object.assign(this, data); | ||
} | ||
} | ||
|
||
@AutoMap(() => Number) | ||
@Column({ type: 'smallint', default: 0 }) | ||
weight: number; | ||
|
||
@OneToMany( | ||
() => NotificationSubmissionToSubmissionStatus, | ||
(s) => s.statusType, | ||
) | ||
public submissionStatuses: NotificationSubmissionToSubmissionStatus[]; | ||
|
||
@AutoMap() | ||
@Column() | ||
alcsBackgroundColor: string; | ||
|
||
@AutoMap() | ||
@Column() | ||
alcsColor: string; | ||
|
||
@AutoMap() | ||
@Column() | ||
portalBackgroundColor: string; | ||
|
||
@AutoMap() | ||
@Column() | ||
portalColor: string; | ||
} |
40 changes: 40 additions & 0 deletions
40
...apps/alcs/src/alcs/notification/notification-submission-status/notification-status.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,40 @@ | ||
import { AutoMap } from '@automapper/classes'; | ||
import { BaseCodeDto } from '../../../common/dtos/base.dto'; | ||
|
||
export enum NOTIFICATION_STATUS { | ||
IN_PROGRESS = 'PROG', | ||
SUBMITTED_TO_ALC = 'SUBM', //Submitted to ALC | ||
ALC_RESPONSE_SENT = 'ALCR', //Response sent to applicant | ||
CANCELLED = 'CANC', | ||
} | ||
|
||
export class NotificationStatusDto extends BaseCodeDto { | ||
@AutoMap() | ||
alcsBackgroundColor: string; | ||
|
||
@AutoMap() | ||
alcsColor: string; | ||
|
||
@AutoMap() | ||
portalBackgroundColor: string; | ||
|
||
@AutoMap() | ||
portalColor: string; | ||
|
||
@AutoMap() | ||
weight: number; | ||
} | ||
|
||
export class NotificationSubmissionToSubmissionStatusDto { | ||
@AutoMap() | ||
submissionUuid: string; | ||
|
||
@AutoMap() | ||
effectiveDate: number; | ||
|
||
@AutoMap() | ||
statusTypeCode: string; | ||
|
||
@AutoMap(() => NotificationStatusDto) | ||
status: NotificationStatusDto; | ||
} |
50 changes: 50 additions & 0 deletions
50
...s/alcs/src/alcs/notification/notification-submission-status/notification-status.entity.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,50 @@ | ||
import { AutoMap } from '@automapper/classes'; | ||
import { | ||
BaseEntity, | ||
Column, | ||
Entity, | ||
JoinColumn, | ||
ManyToOne, | ||
PrimaryColumn, | ||
} from 'typeorm'; | ||
import { NotificationSubmission } from '../../../portal/notification-submission/notification-submission.entity'; | ||
import { NotificationSubmissionStatusType } from './notification-status-type.entity'; | ||
|
||
@Entity() | ||
export class NotificationSubmissionToSubmissionStatus extends BaseEntity { | ||
constructor(data?: Partial<NotificationSubmissionToSubmissionStatus>) { | ||
super(); | ||
if (data) { | ||
Object.assign(this, data); | ||
} | ||
} | ||
|
||
@AutoMap(() => Date) | ||
@Column({ type: 'timestamptz', nullable: true }) | ||
effectiveDate: Date | null; | ||
|
||
@AutoMap() | ||
@PrimaryColumn({ type: 'uuid' }) | ||
submissionUuid: string; | ||
|
||
@AutoMap() | ||
@ManyToOne( | ||
() => NotificationSubmission, | ||
(submission) => submission.submissionStatuses, | ||
) | ||
@JoinColumn({ name: 'submission_uuid' }) | ||
submission: NotificationSubmission; | ||
|
||
@AutoMap() | ||
@PrimaryColumn() | ||
statusTypeCode: string; | ||
|
||
@AutoMap() | ||
@ManyToOne( | ||
() => NotificationSubmissionStatusType, | ||
(status) => status.submissionStatuses, | ||
{ eager: true }, | ||
) | ||
@JoinColumn({ name: 'status_type_code' }) | ||
statusType: NotificationSubmissionStatusType; | ||
} |
87 changes: 87 additions & 0 deletions
87
...fication/notification-submission-status/notification-submission-status.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,87 @@ | ||
import { classes } from '@automapper/classes'; | ||
import { AutomapperModule } from '@automapper/nestjs'; | ||
import { createMock, DeepMocked } from '@golevelup/nestjs-testing'; | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { ClsService } from 'nestjs-cls'; | ||
import { mockKeyCloakProviders } from '../../../../test/mocks/mockTypes'; | ||
import { NotificationSubmissionProfile } from '../../../common/automapper/notification-submission.automapper.profile'; | ||
import { NotificationSubmissionToSubmissionStatus } from './notification-status.entity'; | ||
import { NotificationSubmissionStatusController } from './notification-submission-status.controller'; | ||
import { NotificationSubmissionStatusService } from './notification-submission-status.service'; | ||
|
||
describe('NotificationSubmissionStatusController', () => { | ||
let controller: NotificationSubmissionStatusController; | ||
let mockNoticeOfIntentSubmissionStatusService: DeepMocked<NotificationSubmissionStatusService>; | ||
|
||
beforeEach(async () => { | ||
mockNoticeOfIntentSubmissionStatusService = createMock(); | ||
|
||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [NotificationSubmissionStatusController], | ||
providers: [ | ||
NotificationSubmissionProfile, | ||
{ | ||
provide: NotificationSubmissionStatusService, | ||
useValue: mockNoticeOfIntentSubmissionStatusService, | ||
}, | ||
{ | ||
provide: ClsService, | ||
useValue: {}, | ||
}, | ||
...mockKeyCloakProviders, | ||
], | ||
imports: [ | ||
AutomapperModule.forRoot({ | ||
strategyInitializer: classes(), | ||
}), | ||
], | ||
}).compile(); | ||
|
||
controller = module.get<NotificationSubmissionStatusController>( | ||
NotificationSubmissionStatusController, | ||
); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(controller).toBeDefined(); | ||
}); | ||
|
||
it('should call service to get statuses by file number', async () => { | ||
const fakeFileNumber = 'fake'; | ||
|
||
mockNoticeOfIntentSubmissionStatusService.getCurrentStatusesByFileNumber.mockResolvedValue( | ||
[new NotificationSubmissionToSubmissionStatus()], | ||
); | ||
|
||
const result = await controller.getStatusesByFileNumber(fakeFileNumber); | ||
|
||
expect( | ||
mockNoticeOfIntentSubmissionStatusService.getCurrentStatusesByFileNumber, | ||
).toBeCalledTimes(1); | ||
expect( | ||
mockNoticeOfIntentSubmissionStatusService.getCurrentStatusesByFileNumber, | ||
).toBeCalledWith(fakeFileNumber); | ||
expect(result.length).toEqual(1); | ||
expect(result).toBeDefined(); | ||
}); | ||
|
||
it('should call service to get current submission status by file number', async () => { | ||
const fakeFileNumber = 'fake'; | ||
|
||
mockNoticeOfIntentSubmissionStatusService.getCurrentStatusByFileNumber.mockResolvedValue( | ||
new NotificationSubmissionToSubmissionStatus(), | ||
); | ||
|
||
const result = await controller.getCurrentStatusByFileNumber( | ||
fakeFileNumber, | ||
); | ||
|
||
expect( | ||
mockNoticeOfIntentSubmissionStatusService.getCurrentStatusByFileNumber, | ||
).toBeCalledTimes(1); | ||
expect( | ||
mockNoticeOfIntentSubmissionStatusService.getCurrentStatusByFileNumber, | ||
).toBeCalledWith(fakeFileNumber); | ||
expect(result).toBeDefined(); | ||
}); | ||
}); |
45 changes: 45 additions & 0 deletions
45
.../notification/notification-submission-status/notification-submission-status.controller.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,45 @@ | ||
import { Mapper } from '@automapper/core'; | ||
import { InjectMapper } from '@automapper/nestjs'; | ||
import { Controller, Get, Param } from '@nestjs/common'; | ||
import { ANY_AUTH_ROLE } from '../../../common/authorization/roles'; | ||
import { UserRoles } from '../../../common/authorization/roles.decorator'; | ||
import { NotificationSubmissionToSubmissionStatusDto } from './notification-status.dto'; | ||
import { NotificationSubmissionToSubmissionStatus } from './notification-status.entity'; | ||
import { NotificationSubmissionStatusService } from './notification-submission-status.service'; | ||
|
||
@Controller('notification-submission-status') | ||
@UserRoles(...ANY_AUTH_ROLE) | ||
export class NotificationSubmissionStatusController { | ||
constructor( | ||
private notificationSubmissionStatusService: NotificationSubmissionStatusService, | ||
@InjectMapper() private mapper: Mapper, | ||
) {} | ||
|
||
@Get('/:fileNumber') | ||
async getStatusesByFileNumber(@Param('fileNumber') fileNumber) { | ||
const statuses = | ||
await this.notificationSubmissionStatusService.getCurrentStatusesByFileNumber( | ||
fileNumber, | ||
); | ||
|
||
return this.mapper.mapArrayAsync( | ||
statuses, | ||
NotificationSubmissionToSubmissionStatus, | ||
NotificationSubmissionToSubmissionStatusDto, | ||
); | ||
} | ||
|
||
@Get('/current-status/:fileNumber') | ||
async getCurrentStatusByFileNumber(@Param('fileNumber') fileNumber) { | ||
const status = | ||
await this.notificationSubmissionStatusService.getCurrentStatusByFileNumber( | ||
fileNumber, | ||
); | ||
|
||
return this.mapper.mapAsync( | ||
status, | ||
NotificationSubmissionToSubmissionStatus, | ||
NotificationSubmissionToSubmissionStatusDto, | ||
); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...alcs/notification/notification-submission-status/notification-submission-status.module.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,21 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { NotificationSubmission } from '../../../portal/notification-submission/notification-submission.entity'; | ||
import { NotificationSubmissionStatusType } from './notification-status-type.entity'; | ||
import { NotificationSubmissionToSubmissionStatus } from './notification-status.entity'; | ||
import { NotificationSubmissionStatusController } from './notification-submission-status.controller'; | ||
import { NotificationSubmissionStatusService } from './notification-submission-status.service'; | ||
|
||
@Module({ | ||
imports: [ | ||
TypeOrmModule.forFeature([ | ||
NotificationSubmissionToSubmissionStatus, | ||
NotificationSubmissionStatusType, | ||
NotificationSubmission, | ||
]), | ||
], | ||
providers: [NotificationSubmissionStatusService], | ||
exports: [NotificationSubmissionStatusService], | ||
controllers: [NotificationSubmissionStatusController], | ||
}) | ||
export class NotificationSubmissionStatusModule {} |
Oops, something went wrong.