From 9b18adf5a614c11c8fb37db98ac01d5822723f98 Mon Sep 17 00:00:00 2001 From: Zuhal-Ayob Date: Mon, 4 Dec 2023 15:07:59 +0000 Subject: [PATCH] remove the empty return for cssr --- server/models/classes/establishment.js | 25 ++++++++++++------- .../services/establishment/establishment.js | 8 ------ .../workplace-info-panel.component.ts | 1 - 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/server/models/classes/establishment.js b/server/models/classes/establishment.js index 4478afcaba..0d57976410 100644 --- a/server/models/classes/establishment.js +++ b/server/models/classes/establishment.js @@ -98,6 +98,7 @@ class Establishment extends EntityValidator { this._pensionContribution = null; this._sickPay = null; this._recruitmentJourneyExistingUserBanner = false; + this._primaryAuthorityCssr = null; // interim reasons for leaving - https://trello.com/c/vNHbfdms this._reasonsForLeaving = null; @@ -390,6 +391,9 @@ class Establishment extends EntityValidator { return this._recruitmentJourneyExistingUserBanner; } + get primaryAuthorityCssr() { + return this._primaryAuthorityCssr; + } // used by save to initialise a new Establishment; returns true if having initialised this Establishment _initialise() { if (this._uid === null) { @@ -607,6 +611,9 @@ class Establishment extends EntityValidator { if ('recruitmentJourneyExistingUserBanner' in document) { this._recruitmentJourneyExistingUserBanner = document.recruitmentJourneyExistingUserBanner; } + if ('primaryAuthorityCssr' in document) { + this._primaryAuthorityCssr = document.primaryAuthorityCssr; + } } // allow for deep restoration of entities (associations - namely Worker here) @@ -832,6 +839,7 @@ class Establishment extends EntityValidator { pensionContribution: this._pensionContribution, careWorkersLeaveDaysPerYear: this._careWorkersLeaveDaysPerYear, recruitmentJourneyExistingUserBanner: this._recruitmentJourneyExistingUserBanner, + primaryAuthorityCssr: this._primaryAuthorityCssr, }; // need to create the Establishment record and the Establishment Audit event @@ -1033,6 +1041,7 @@ class Establishment extends EntityValidator { pensionContribution: this._pensionContribution, careWorkersLeaveDaysPerYear: this._careWorkersLeaveDaysPerYear, recruitmentJourneyExistingUserBanner: bulkUploaded ? true : this._recruitmentJourneyExistingUserBanner, + primaryAuthorityCssr: this._primaryAuthorityCssr, }; // Every time the establishment is saved, need to calculate @@ -1293,7 +1302,6 @@ class Establishment extends EntityValidator { } const fetchResults = await models.establishment.findOne(fetchQuery); - console.log({ fetchResults: fetchResults }); if (fetchResults && fetchResults.id && Number.isInteger(fetchResults.id)) { // update self - don't use setters because they modify the change state this._isNew = false; @@ -1348,6 +1356,8 @@ class Establishment extends EntityValidator { this._pensionContribution = fetchResults.pensionContribution; this._careWorkersLeaveDaysPerYear = fetchResults.careWorkersLeaveDaysPerYear; this._careWorkersCashLoyaltyForFirstTwoYears = fetchResults.careWorkersCashLoyaltyForFirstTwoYears; + + this._primaryAuthorityCssr = this.primaryAuthorityCssr; // if history of the User is also required; attach the association // and order in reverse chronological - note, order on id (not when) // because ID is primay key and hence indexed @@ -1517,16 +1527,13 @@ class Establishment extends EntityValidator { const cssrResults = await models.pcodedata.getLinkedCssrRecordsFromPostcode(this._postcode); - if (!cssrResults || cssrResults.length == 0) { - console.log('Could not retrieve cssr record'); - return {}; + if (cssrResults.length > 0) { + fetchResults.primaryAuthorityCssr = { + id: cssrResults[0].cssrRecord.id, + name: cssrResults[0].cssrRecord.name, + }; } - fetchResults.primaryAuthorityCssr = { - id: cssrResults[0].cssrRecord.id, - name: cssrResults[0].cssrRecord.name, - }; - if (fetchResults.auditEvents) { this._auditEvents = fetchResults.auditEvents; } diff --git a/server/services/establishment/establishment.js b/server/services/establishment/establishment.js index d93cfe6182..68117206c0 100644 --- a/server/services/establishment/establishment.js +++ b/server/services/establishment/establishment.js @@ -189,7 +189,6 @@ const addEstablishment = async (req, res) => { // gets requested establishment // optional parameter - "history" must equal "none" (default), "property", "timeline" or "full" const getEstablishment = async (req, res) => { - console.log('getEstablishment request'); const establishmentId = req.params.id; const showHistory = @@ -198,12 +197,6 @@ const getEstablishment = async (req, res) => { const showPropertyHistoryOnly = req.query.history === 'property'; const thisEstablishment = new Establishment.Establishment(req.username); - console.log({ - thisEstablishment: thisEstablishment, - establishmentId: establishmentId, - showHistory: showHistory, - history: req.query.history, - }); try { if (await thisEstablishment.restore(establishmentId, showHistory && req.query.history !== 'property')) { // the property based framework for "other services" and "capacity services" @@ -231,7 +224,6 @@ const getEstablishment = async (req, res) => { } if (!jsonResponse.isParent && jsonResponse.parentUid !== null) { const parentEstablishmentName = await thisEstablishment.fetchParentDetails(jsonResponse.parentUid); - console.log({ parentEstablishmentName: parentEstablishmentName }); if (parentEstablishmentName) { jsonResponse.parentName = parentEstablishmentName.parentName; } diff --git a/src/app/features/workplace/workplace-info-panel/workplace-info-panel.component.ts b/src/app/features/workplace/workplace-info-panel/workplace-info-panel.component.ts index 1134ada5ec..835f4d248a 100644 --- a/src/app/features/workplace/workplace-info-panel/workplace-info-panel.component.ts +++ b/src/app/features/workplace/workplace-info-panel/workplace-info-panel.component.ts @@ -138,7 +138,6 @@ export class WorkplaceInfoPanelComponent implements OnInit, OnDestroy { event.preventDefault(); this.establishmentService.getEstablishment(this.workplace.uid).subscribe((data) => { - console.log({ workplaceDATA: data }); if (data.employerType == null) { this.establishmentService.setEmployerTypeHasValue(false); this.router.navigate(['/workplace', this.workplace.uid, 'type-of-employer']);