Skip to content

Commit

Permalink
FE - controlling member crc integration and bug fixes (#1339)
Browse files Browse the repository at this point in the history
# Description

This PR includes the following proposed change(s):

- controlling member crc integration
- various bug fixes
- SPDBT-2956 - fix display of photo

---------

Co-authored-by: Peggy <[email protected]>
  • Loading branch information
carolcarpenter and peggy-quartech authored Aug 26, 2024
1 parent 428c8c3 commit d2da61c
Show file tree
Hide file tree
Showing 22 changed files with 703 additions and 397 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* tslint:disable */
/* eslint-disable */
import { HttpClient, HttpContext, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import { StrictHttpResponse } from '../../strict-http-response';
import { RequestBuilder } from '../../request-builder';

import { LicenceDocumentTypeCode } from '../../models/licence-document-type-code';

export interface ApiControllingMemberCrcApplicationsAnonymousFilesPost$Params {
body?: {
'Documents'?: Array<Blob>;
'LicenceDocumentTypeCode'?: LicenceDocumentTypeCode;
}
}

export function apiControllingMemberCrcApplicationsAnonymousFilesPost(http: HttpClient, rootUrl: string, params?: ApiControllingMemberCrcApplicationsAnonymousFilesPost$Params, context?: HttpContext): Observable<StrictHttpResponse<string>> {
const rb = new RequestBuilder(rootUrl, apiControllingMemberCrcApplicationsAnonymousFilesPost.PATH, 'post');
if (params) {
rb.body(params.body, 'multipart/form-data');
}

return http.request(
rb.build({ responseType: 'json', accept: 'application/json', context })
).pipe(
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
map((r: HttpResponse<any>) => {
return r as StrictHttpResponse<string>;
})
);
}

apiControllingMemberCrcApplicationsAnonymousFilesPost.PATH = '/api/controlling-member-crc-applications/anonymous/files';
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* tslint:disable */
/* eslint-disable */
import { HttpClient, HttpContext, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import { StrictHttpResponse } from '../../strict-http-response';
import { RequestBuilder } from '../../request-builder';

import { GoogleRecaptcha } from '../../models/google-recaptcha';
import { IActionResult } from '../../models/i-action-result';

export interface ApiControllingMemberCrcApplicationsAnonymousKeyCodePost$Params {
body?: GoogleRecaptcha
}

export function apiControllingMemberCrcApplicationsAnonymousKeyCodePost(http: HttpClient, rootUrl: string, params?: ApiControllingMemberCrcApplicationsAnonymousKeyCodePost$Params, context?: HttpContext): Observable<StrictHttpResponse<IActionResult>> {
const rb = new RequestBuilder(rootUrl, apiControllingMemberCrcApplicationsAnonymousKeyCodePost.PATH, 'post');
if (params) {
rb.body(params.body, 'application/*+json');
}

return http.request(
rb.build({ responseType: 'json', accept: 'application/json', context })
).pipe(
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
map((r: HttpResponse<any>) => {
return r as StrictHttpResponse<IActionResult>;
})
);
}

apiControllingMemberCrcApplicationsAnonymousKeyCodePost.PATH = '/api/controlling-member-crc-applications/anonymous/keyCode';
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* eslint-disable */
import { Address } from '../models/address';
import { Alias } from '../models/alias';
import { DocumentExpiredInfo } from '../models/document-expired-info';
import { GenderCode } from '../models/gender-code';
import { PoliceOfficerRoleCode } from '../models/police-officer-role-code';
export interface ControllingMemberCrcAppSubmitRequest {
Expand All @@ -11,6 +12,8 @@ export interface ControllingMemberCrcAppSubmitRequest {
bcDriversLicenceNumber?: string | null;
criminalHistoryDetail?: string | null;
dateOfBirth?: string;
documentExpiredInfos?: Array<DocumentExpiredInfo> | null;
documentKeyCodes?: Array<string> | null;
emailAddress?: string | null;
genderCode?: GenderCode;
givenName?: string | null;
Expand All @@ -24,6 +27,7 @@ export interface ControllingMemberCrcAppSubmitRequest {
middleName1?: string | null;
middleName2?: string | null;
otherOfficerRole?: string | null;
parentBizLicApplicationId?: string | null;
phoneNumber?: string | null;
policeOfficerRoleCode?: PoliceOfficerRoleCode;
residentialAddress?: Address;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
/* eslint-disable */
import { LicenceStatusCode } from '../models/licence-status-code';
import { LicenceTermCode } from '../models/licence-term-code';
import { WorkerCategoryTypeCode } from '../models/worker-category-type-code';
import { WorkerLicenceTypeCode } from '../models/worker-licence-type-code';
export interface LicenceBasicResponse {
categoryCodes?: Array<WorkerCategoryTypeCode> | null;
expiryDate?: string;
licenceAppId?: string | null;
licenceHolderId?: string | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import { BodyArmourPermitReasonCode } from '../models/body-armour-permit-reason-
import { Document } from '../models/document';
import { LicenceStatusCode } from '../models/licence-status-code';
import { LicenceTermCode } from '../models/licence-term-code';
import { WorkerCategoryTypeCode } from '../models/worker-category-type-code';
import { WorkerLicenceTypeCode } from '../models/worker-licence-type-code';
export interface LicenceResponse {
armouredVehiclePermitReasonCodes?: Array<ArmouredVehiclePermitReasonCode> | null;
bodyArmourPermitReasonCodes?: Array<BodyArmourPermitReasonCode> | null;
categoryCodes?: Array<WorkerCategoryTypeCode> | null;
employerName?: string | null;
employerPrimaryAddress?: Address;
expiryDate?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,91 @@ import { BaseService } from '../base-service';
import { ApiConfiguration } from '../api-configuration';
import { StrictHttpResponse } from '../strict-http-response';

import { apiControllingMemberCrcApplicationsAnonymousFilesPost } from '../fn/controlling-member-crc-app/api-controlling-member-crc-applications-anonymous-files-post';
import { ApiControllingMemberCrcApplicationsAnonymousFilesPost$Params } from '../fn/controlling-member-crc-app/api-controlling-member-crc-applications-anonymous-files-post';
import { apiControllingMemberCrcApplicationsAnonymousKeyCodePost } from '../fn/controlling-member-crc-app/api-controlling-member-crc-applications-anonymous-key-code-post';
import { ApiControllingMemberCrcApplicationsAnonymousKeyCodePost$Params } from '../fn/controlling-member-crc-app/api-controlling-member-crc-applications-anonymous-key-code-post';
import { apiControllingMemberCrcApplicationsAnonymousSubmitPost } from '../fn/controlling-member-crc-app/api-controlling-member-crc-applications-anonymous-submit-post';
import { ApiControllingMemberCrcApplicationsAnonymousSubmitPost$Params } from '../fn/controlling-member-crc-app/api-controlling-member-crc-applications-anonymous-submit-post';
import { ControllingMemberCrcAppCommandResponse } from '../models/controlling-member-crc-app-command-response';
import { IActionResult } from '../models/i-action-result';

@Injectable({ providedIn: 'root' })
export class ControllingMemberCrcAppService extends BaseService {
constructor(config: ApiConfiguration, http: HttpClient) {
super(config, http);
}

/** Path part for operation `apiControllingMemberCrcApplicationsAnonymousKeyCodePost()` */
static readonly ApiControllingMemberCrcApplicationsAnonymousKeyCodePostPath = '/api/controlling-member-crc-applications/anonymous/keyCode';

/**
* Upload licence application first step: frontend needs to make this first request to get a Guid code.
* the keycode will be set in the cookies.
*
*
*
* This method provides access to the full `HttpResponse`, allowing access to response headers.
* To access only the response body, use `apiControllingMemberCrcApplicationsAnonymousKeyCodePost()` instead.
*
* This method sends `application/*+json` and handles request body of type `application/*+json`.
*/
apiControllingMemberCrcApplicationsAnonymousKeyCodePost$Response(params?: ApiControllingMemberCrcApplicationsAnonymousKeyCodePost$Params, context?: HttpContext): Observable<StrictHttpResponse<IActionResult>> {
return apiControllingMemberCrcApplicationsAnonymousKeyCodePost(this.http, this.rootUrl, params, context);
}

/**
* Upload licence application first step: frontend needs to make this first request to get a Guid code.
* the keycode will be set in the cookies.
*
*
*
* This method provides access only to the response body.
* To access the full response (for headers, for example), `apiControllingMemberCrcApplicationsAnonymousKeyCodePost$Response()` instead.
*
* This method sends `application/*+json` and handles request body of type `application/*+json`.
*/
apiControllingMemberCrcApplicationsAnonymousKeyCodePost(params?: ApiControllingMemberCrcApplicationsAnonymousKeyCodePost$Params, context?: HttpContext): Observable<IActionResult> {
return this.apiControllingMemberCrcApplicationsAnonymousKeyCodePost$Response(params, context).pipe(
map((r: StrictHttpResponse<IActionResult>): IActionResult => r.body)
);
}

/** Path part for operation `apiControllingMemberCrcApplicationsAnonymousFilesPost()` */
static readonly ApiControllingMemberCrcApplicationsAnonymousFilesPostPath = '/api/controlling-member-crc-applications/anonymous/files';

/**
* Upload licence application files: frontend use the keyCode (in cookies) to upload following files.
* Uploading file only save files in cache, the files are not connected to the application yet.
*
*
*
* This method provides access to the full `HttpResponse`, allowing access to response headers.
* To access only the response body, use `apiControllingMemberCrcApplicationsAnonymousFilesPost()` instead.
*
* This method sends `multipart/form-data` and handles request body of type `multipart/form-data`.
*/
apiControllingMemberCrcApplicationsAnonymousFilesPost$Response(params?: ApiControllingMemberCrcApplicationsAnonymousFilesPost$Params, context?: HttpContext): Observable<StrictHttpResponse<string>> {
return apiControllingMemberCrcApplicationsAnonymousFilesPost(this.http, this.rootUrl, params, context);
}

/**
* Upload licence application files: frontend use the keyCode (in cookies) to upload following files.
* Uploading file only save files in cache, the files are not connected to the application yet.
*
*
*
* This method provides access only to the response body.
* To access the full response (for headers, for example), `apiControllingMemberCrcApplicationsAnonymousFilesPost$Response()` instead.
*
* This method sends `multipart/form-data` and handles request body of type `multipart/form-data`.
*/
apiControllingMemberCrcApplicationsAnonymousFilesPost(params?: ApiControllingMemberCrcApplicationsAnonymousFilesPost$Params, context?: HttpContext): Observable<string> {
return this.apiControllingMemberCrcApplicationsAnonymousFilesPost$Response(params, context).pipe(
map((r: StrictHttpResponse<string>): string => r.body)
);
}

/** Path part for operation `apiControllingMemberCrcApplicationsAnonymousSubmitPost()` */
static readonly ApiControllingMemberCrcApplicationsAnonymousSubmitPostPath = '/api/controlling-member-crc-applications/anonymous/submit';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ApplicationTypeCode, PoliceOfficerRoleCode } from '@app/api/models';
import { BooleanTypeCode } from '@app/core/code-types/model-desc.models';
import { FormControlValidators } from '@app/core/validators/form-control.validators';
import { FormGroupValidators } from '@app/core/validators/form-group.validators';
import { BehaviorSubject } from 'rxjs';
import { BehaviorSubject, Observable, of, Subscriber } from 'rxjs';

export abstract class ApplicationHelper {
private _waitUntilInitialized$ = new BehaviorSubject<boolean>(false);
Expand Down Expand Up @@ -358,17 +358,26 @@ export abstract class ApplicationHelper {
* Set the current photo of yourself
* @returns
*/
setPhotographOfYourself(image: Blob | null): void {
setPhotographOfYourself(image: Blob | null): Observable<boolean> {
if (!image || image.size == 0) {
this.photographOfYourself = null;
return;
return of(false);
}

const reader = new FileReader();
reader.readAsDataURL(image);
reader.onload = (_event) => {
this.photographOfYourself = reader.result;
};
return new Observable<boolean>((observer: Subscriber<boolean>) => {
const reader = new FileReader();

// if success
reader.onload = (ev: ProgressEvent): void => {
this.photographOfYourself = reader.result;
observer.next(true);
};
// if failed
reader.onerror = (ev: any): void => {
observer.error(false);
};
reader.readAsDataURL(image);
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { LicenceDocumentTypeCode } from '@app/api/models';
import { ControllingMemberCrcAppSubmitRequest, LicenceDocumentTypeCode } from '@app/api/models';
import { ApplicationHelper } from '@app/core/services/application.helper';
import { ConfigService } from '@app/core/services/config.service';
import { FileUtilService } from '@app/core/services/file-util.service';
import { UtilService } from '@app/core/services/util.service';
import { FileUtilService, SpdFile } from '@app/core/services/file-util.service';
import { LicenceDocumentsToSave, UtilService } from '@app/core/services/util.service';
import { FormatDatePipe } from '@app/shared/pipes/format-date.pipe';
import { BooleanTypeCode } from '../code-types/model-desc.models';
import { SPD_CONSTANTS } from '../constants/constants';
Expand Down Expand Up @@ -127,19 +127,21 @@ export abstract class ControllingMemberCrcHelper extends ApplicationHelper {
super(formBuilder);
}

getSaveBodyBaseAnonymous(controllingMemberCrcFormValue: any): any {
getSaveBodyBaseAnonymous(controllingMemberCrcFormValue: any): ControllingMemberCrcAppSubmitRequest {
const baseData = this.getSaveBodyBase(controllingMemberCrcFormValue, false);
console.debug('[getSaveBodyBaseAnonymous] baseData', baseData);

return baseData;
}

private getSaveBodyBase(controllingMemberCrcFormValue: any, _isAuthenticated: boolean): any {
private getSaveBodyBase(
controllingMemberCrcFormValue: any,
_isAuthenticated: boolean
): ControllingMemberCrcAppSubmitRequest {
const bcDriversLicenceData = { ...controllingMemberCrcFormValue.bcDriversLicenceData };
const residentialAddressData = { ...controllingMemberCrcFormValue.residentialAddressData };
const citizenshipData = { ...controllingMemberCrcFormValue.citizenshipData };
const policeBackgroundData = { ...controllingMemberCrcFormValue.policeBackgroundData };
// const fingerprintProofData = { ...controllingMemberCrcFormValue.fingerprintProofData };
const mentalHealthConditionsData = { ...controllingMemberCrcFormValue.mentalHealthConditionsData };
const personalInformationData = {
...controllingMemberCrcFormValue.personalInformationData,
Expand All @@ -151,16 +153,13 @@ export abstract class ControllingMemberCrcHelper extends ApplicationHelper {
SPD_CONSTANTS.date.backendDateFormat
);

const accessCode = ''; // TODO addess accessCode

const hasBcDriversLicence = this.utilService.booleanTypeToBoolean(bcDriversLicenceData.hasBcDriversLicence);
const hasBankruptcyHistory = this.utilService.booleanTypeToBoolean(
bcSecurityLicenceHistoryData.hasBankruptcyHistory
);
const hasCriminalHistory = this.utilService.booleanTypeToBoolean(bcSecurityLicenceHistoryData.hasCriminalHistory);

const body = {
accessCode,
givenName: personalInformationData.givenName,
surname: personalInformationData.surname,
middleName1: personalInformationData.middleName1,
Expand Down Expand Up @@ -192,7 +191,6 @@ export abstract class ControllingMemberCrcHelper extends ApplicationHelper {
criminalHistoryDetail: hasCriminalHistory ? bcSecurityLicenceHistoryData.criminalHistoryDetail : null,
//-----------------------------------
isTreatedForMHC: this.utilService.booleanTypeToBoolean(mentalHealthConditionsData.isTreatedForMHC),
// hasNewMentalHealthCondition: this.utilService.booleanTypeToBoolean(mentalHealthConditionsData.isTreatedForMHC), // used by the backend for an Update or Renewal
//-----------------------------------
isPoliceOrPeaceOfficer: this.utilService.booleanTypeToBoolean(policeBackgroundData.isPoliceOrPeaceOfficer),
policeOfficerRoleCode: policeBackgroundData.policeOfficerRoleCode,
Expand All @@ -202,4 +200,72 @@ export abstract class ControllingMemberCrcHelper extends ApplicationHelper {
console.debug('[getSaveBodyBase] body returned', body);
return body;
}

getDocsToSaveBlobs(
body: ControllingMemberCrcAppSubmitRequest,
controllingMembersModelFormValue: any
): Array<LicenceDocumentsToSave> {
const documents: Array<LicenceDocumentsToSave> = [];

const citizenshipData = { ...controllingMembersModelFormValue.citizenshipData };
const fingerprintProofData = { ...controllingMembersModelFormValue.fingerprintProofData };
const policeBackgroundData = { ...controllingMembersModelFormValue.policeBackgroundData };
const mentalHealthConditionsData = { ...controllingMembersModelFormValue.mentalHealthConditionsData };

if (fingerprintProofData.attachments) {
const docs: Array<Blob> = [];
fingerprintProofData.attachments.forEach((doc: SpdFile) => {
docs.push(doc);
});
documents.push({ licenceDocumentTypeCode: LicenceDocumentTypeCode.ProofOfFingerprint, documents: docs });
}

if (body.isPoliceOrPeaceOfficer && policeBackgroundData.attachments) {
const docs: Array<Blob> = [];
policeBackgroundData.attachments.forEach((doc: SpdFile) => {
docs.push(doc);
});
documents.push({
licenceDocumentTypeCode: LicenceDocumentTypeCode.PoliceBackgroundLetterOfNoConflict,
documents: docs,
});
}

if (body.isTreatedForMHC && mentalHealthConditionsData.attachments) {
const docs: Array<Blob> = [];
mentalHealthConditionsData.attachments.forEach((doc: SpdFile) => {
docs.push(doc);
});
documents.push({ licenceDocumentTypeCode: LicenceDocumentTypeCode.MentalHealthCondition, documents: docs });
}

if (citizenshipData.attachments) {
const docs: Array<Blob> = [];
citizenshipData.attachments.forEach((doc: SpdFile) => {
docs.push(doc);
});
const citizenshipLicenceDocumentTypeCode =
citizenshipData.isCanadianCitizen == BooleanTypeCode.Yes
? citizenshipData.canadianCitizenProofTypeCode
: citizenshipData.notCanadianCitizenProofTypeCode;
documents.push({ licenceDocumentTypeCode: citizenshipLicenceDocumentTypeCode, documents: docs });
}

const isIncludeAdditionalGovermentIdStepData = this.utilService.getSwlShowAdditionalGovIdData(
citizenshipData.isCanadianCitizen == BooleanTypeCode.Yes,
citizenshipData.canadianCitizenProofTypeCode,
citizenshipData.notCanadianCitizenProofTypeCode
);

if (isIncludeAdditionalGovermentIdStepData && citizenshipData.governmentIssuedAttachments) {
const docs: Array<Blob> = [];
citizenshipData.governmentIssuedAttachments.forEach((doc: SpdFile) => {
docs.push(doc);
});
documents.push({ licenceDocumentTypeCode: citizenshipData.governmentIssuedPhotoTypeCode, documents: docs });
}

console.debug('[getDocsToSaveBlobs] documentsToSave', documents);
return documents;
}
}
Loading

0 comments on commit d2da61c

Please sign in to comment.