Skip to content

Commit

Permalink
more shared code
Browse files Browse the repository at this point in the history
  • Loading branch information
carolcarpenter committed May 6, 2024
1 parent bc20fb3 commit d2f2b25
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import { Inject, Injectable } from '@angular/core';
import { HotToastService } from '@ngneat/hot-toast';
import jwt_decode from 'jwt-decode';
import * as moment from 'moment';
import { ApplicationPortalStatusCode, PaginationResponse, ScreeningTypeCode } from 'src/app/api/models';
import {
ApplicationPortalStatusCode,
BooleanTypeCode,
PaginationResponse,
ScreeningTypeCode,
} from 'src/app/api/models';
import * as CodeDescTypes from 'src/app/core/code-types/code-desc-types.models';
import { ApplicationPortalStatusTypes, ScreeningTypes, SelectOptions } from '../code-types/model-desc.models';
import { SPD_CONSTANTS } from '../constants/constants';
Expand Down Expand Up @@ -273,6 +278,30 @@ export class UtilService {
}
}

/**
* Convert BooleanTypeCode to boolean
* @param value
* @returns
*/
booleanTypeToBoolean(value: BooleanTypeCode | undefined | null): boolean | null {
if (!value) return null;

if (value == BooleanTypeCode.Yes) return true;
return false;
}

/**
* Convert boolean to BooleanTypeCode
* @param value
* @returns
*/
public booleanToBooleanType(value: boolean | null | undefined): BooleanTypeCode | null {
const isBooleanType = typeof value === 'boolean';
if (!isBooleanType) return null;

return value ? BooleanTypeCode.Yes : BooleanTypeCode.No;
}

//------------------------------------
// Sort

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,18 +587,13 @@ export class ManualSubmissionCommonComponent implements OnInit {
this.isNotVolunteerOrg = orgProfile?.isNotVolunteerOrg ?? false;

if (this.isNotVolunteerOrg) {
const licenseesNeedVulnerableSectorScreening =
orgProfile.licenseesNeedVulnerableSectorScreening === BooleanTypeCode.Yes;
const contractorsNeedVulnerableSectorScreening =
orgProfile.contractorsNeedVulnerableSectorScreening === BooleanTypeCode.Yes;

this.showScreeningType = this.utilService.getShowScreeningType(
licenseesNeedVulnerableSectorScreening,
contractorsNeedVulnerableSectorScreening
this.utilService.booleanTypeToBoolean(orgProfile.licenseesNeedVulnerableSectorScreening) ?? false,
this.utilService.booleanTypeToBoolean(orgProfile.contractorsNeedVulnerableSectorScreening) ?? false
);
this.screeningTypes = this.utilService.getScreeningTypes(
licenseesNeedVulnerableSectorScreening,
contractorsNeedVulnerableSectorScreening
this.utilService.booleanTypeToBoolean(orgProfile.licenseesNeedVulnerableSectorScreening) ?? false,
this.utilService.booleanTypeToBoolean(orgProfile.contractorsNeedVulnerableSectorScreening) ?? false
);
} else {
this.showScreeningType = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
ApplicationInvitePrepopulateDataResponse,
ApplicationInvitesCreateRequest,
ApplicationInvitesCreateResponse,
BooleanTypeCode,
MinistryResponse,
ScreeningTypeCode,
ServiceTypeCode,
Expand Down Expand Up @@ -573,18 +572,13 @@ export class ScreeningRequestAddCommonModalComponent implements OnInit {
this.isNotVolunteerOrg = orgProfile?.isNotVolunteerOrg ?? false;

if (this.isNotVolunteerOrg) {
const licenseesNeedVulnerableSectorScreening =
orgProfile.licenseesNeedVulnerableSectorScreening === BooleanTypeCode.Yes;
const contractorsNeedVulnerableSectorScreening =
orgProfile.contractorsNeedVulnerableSectorScreening === BooleanTypeCode.Yes;

this.showScreeningType = this.utilService.getShowScreeningType(
licenseesNeedVulnerableSectorScreening,
contractorsNeedVulnerableSectorScreening
this.utilService.booleanTypeToBoolean(orgProfile.licenseesNeedVulnerableSectorScreening) ?? false,
this.utilService.booleanTypeToBoolean(orgProfile.contractorsNeedVulnerableSectorScreening) ?? false
);
this.screeningTypes = this.utilService.getScreeningTypes(
licenseesNeedVulnerableSectorScreening,
contractorsNeedVulnerableSectorScreening
this.utilService.booleanTypeToBoolean(orgProfile.licenseesNeedVulnerableSectorScreening) ?? false,
this.utilService.booleanTypeToBoolean(orgProfile.contractorsNeedVulnerableSectorScreening) ?? false
);
} else {
this.showScreeningType = false;
Expand Down

0 comments on commit d2f2b25

Please sign in to comment.