diff --git a/.gitignore b/.gitignore index c1deda8cb6..f265209880 100644 --- a/.gitignore +++ b/.gitignore @@ -57,9 +57,7 @@ Thumbs.db fecoverage # localhost config variations -/server/config/localhost.*.yaml -/server/config/localhost-*.yaml -/server/config/localhost.yaml +backend/server/config/localhost.yaml // nodemon localisations nodemon.json diff --git a/backend/server/config/example.yaml b/backend/server/config/example.yaml index 717d618d16..0e291c00ee 100644 --- a/backend/server/config/example.yaml +++ b/backend/server/config/example.yaml @@ -15,12 +15,16 @@ jwt: ttl: login: 60 db: + host: localhost pool: min: 15 max: 15 ssl: false username: sfcadmin +redis: + url: redis://localhost:6379 + log: sequelize: false diff --git a/backend/server/config/localhost.yaml b/backend/server/config/localhost.yaml deleted file mode 100644 index 0a4065d423..0000000000 --- a/backend/server/config/localhost.yaml +++ /dev/null @@ -1,41 +0,0 @@ -aws: - region: eu-west-1 - secrets: - use: false - wallet: dev/api - sns: - enabled: true - registrations: arn:aws:sns:eu-west-1:364648107127:registrations-dev - feedback: arn:aws:sns:eu-west-1:364648107127:feedback-dev - -slack: - level: 0 # disables Slack notifications -jwt: - iss: 'localhost' - ttl: - login: 60 -db: - host: localhost - pool: - min: 15 - max: 15 - ssl: false - -redis: - url: redis://localhost:6379 - -log: - sequelize: false - -bulkupload: - region: eu-west-2 - bucketname: sfcbulkuploadfiles - validation: - timeout: 600 - completion: - timeout: 600 -sentry: - sample_rate: 0.0 -satisfactionSurvey: - timeSpan: 1 - unit: m diff --git a/frontend/src/app/core/resolvers/cqcStatusCheck/cqcStatusCheck.resolver.spec.ts b/frontend/src/app/core/resolvers/cqcStatusCheck/cqcStatusCheck.resolver.spec.ts index 0dbe15fcb7..6236252bdc 100644 --- a/frontend/src/app/core/resolvers/cqcStatusCheck/cqcStatusCheck.resolver.spec.ts +++ b/frontend/src/app/core/resolvers/cqcStatusCheck/cqcStatusCheck.resolver.spec.ts @@ -1,14 +1,16 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { TestBed } from '@angular/core/testing'; -import { ActivatedRoute } from '@angular/router'; +import { ActivatedRoute, convertToParamMap } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; +import { Establishment } from '@core/model/establishment.model'; import { EstablishmentService } from '@core/services/establishment.service'; import { MockEstablishmentService } from '@core/test-utils/MockEstablishmentService'; +import { of } from 'rxjs'; import { CqcStatusCheckResolver } from './cqcStatusCheck.resolver'; describe('CqcStatusCheckResolver', () => { - const setup = () => { + const setup = (establishmentuid = null) => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule, RouterTestingModule.withRoutes([])], providers: [ @@ -17,14 +19,22 @@ describe('CqcStatusCheckResolver', () => { provide: EstablishmentService, useClass: MockEstablishmentService, }, + { + provide: ActivatedRoute, + useValue: { snapshot: { paramMap: convertToParamMap({ establishmentuid }) } }, + }, ], }); + const resolver = TestBed.inject(CqcStatusCheckResolver); const route = TestBed.inject(ActivatedRoute); const establishmentService = TestBed.inject(EstablishmentService); + const getCqcRegistrationStatusSpy = spyOn(establishmentService, 'getCQCRegistrationStatus').and.callFake(() => + of({ cqcStatusMatch: false }), + ); - return { resolver, route, establishmentService }; + return { resolver, establishmentService, route, establishmentuid, getCqcRegistrationStatusSpy }; }; it('should be created', async () => { @@ -32,14 +42,59 @@ describe('CqcStatusCheckResolver', () => { expect(resolver).toBeTruthy(); }); - it('should call getCQCRegistrationStatus', async () => { - const { resolver, route, establishmentService } = await setup(); - const getCqcRegistrationStatusSpy = spyOn(establishmentService, 'getCQCRegistrationStatus').and.callThrough(); - resolver.resolve(route.snapshot); + it('should call getEstablishment with establishment ID in service when no uid in params', async () => { + const { resolver, establishmentService, route, getCqcRegistrationStatusSpy } = await setup(); + const establishment = { + locationId: '1-11111111', + postcode: 'ABC123', + mainService: { name: 'Care' }, + } as Establishment; + + const getEstablishmentSpy = spyOn(establishmentService, 'getEstablishment').and.callFake(() => of(establishment)); + + resolver.resolve(route.snapshot).subscribe(() => { + expect(getEstablishmentSpy).toHaveBeenCalledWith(establishmentService.establishmentId); + + expect(getCqcRegistrationStatusSpy).toHaveBeenCalledWith(establishment.locationId, { + postcode: establishment.postcode, + mainService: establishment.mainService.name, + }); + }); + }); + + it('should call getCQCRegistrationStatus when workplace has location ID', async () => { + const establishmentuid = 'ab131231dsa2321321a'; + const { resolver, establishmentService, route, getCqcRegistrationStatusSpy } = await setup(establishmentuid); + const establishment = { + locationId: '1-11111111', + postcode: 'ABC123', + mainService: { name: 'Care' }, + } as Establishment; + + const getEstablishmentSpy = spyOn(establishmentService, 'getEstablishment').and.callFake(() => of(establishment)); + + resolver.resolve(route.snapshot).subscribe(() => { + expect(getEstablishmentSpy).toHaveBeenCalledWith(establishmentuid); + + expect(getCqcRegistrationStatusSpy).toHaveBeenCalledWith(establishment.locationId, { + postcode: establishment.postcode, + mainService: establishment.mainService.name, + }); + }); + }); + + it('should not call getCQCRegistrationStatus when workplace does not have location ID', async () => { + const { resolver, establishmentService, route, establishmentuid, getCqcRegistrationStatusSpy } = await setup(); + const establishment = { + locationId: null, + postcode: 'ABC123', + mainService: { name: 'Care' }, + } as Establishment; + + spyOn(establishmentService, 'getEstablishment').and.callFake(() => of(establishment)); - expect(getCqcRegistrationStatusSpy).toHaveBeenCalledWith('1-11111111', { - postcode: 'AB1 2CD', - mainService: 'Care', + resolver.resolve(route.snapshot).subscribe(() => { + expect(getCqcRegistrationStatusSpy).not.toHaveBeenCalled(); }); }); }); diff --git a/frontend/src/app/core/resolvers/cqcStatusCheck/cqcStatusCheck.resolver.ts b/frontend/src/app/core/resolvers/cqcStatusCheck/cqcStatusCheck.resolver.ts index 255ac88594..014e47199b 100644 --- a/frontend/src/app/core/resolvers/cqcStatusCheck/cqcStatusCheck.resolver.ts +++ b/frontend/src/app/core/resolvers/cqcStatusCheck/cqcStatusCheck.resolver.ts @@ -1,32 +1,35 @@ import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, Resolve } from '@angular/router'; import { EstablishmentService } from '@core/services/establishment.service'; -import { of } from 'rxjs'; -import { catchError, tap } from 'rxjs/operators'; +import { Observable, of } from 'rxjs'; +import { catchError, switchMap } from 'rxjs/operators'; + +export class CQCRegistrationStatusResponse { + cqcStatusMatch: boolean; +} @Injectable() export class CqcStatusCheckResolver implements Resolve { constructor(private establishmentService: EstablishmentService) {} - resolve(route: ActivatedRouteSnapshot) { - const { locationId, postcode, mainService } = this.establishmentService.primaryWorkplace; + resolve(route: ActivatedRouteSnapshot): Observable { + const workplaceUid = route.paramMap.get('establishmentuid') + ? route.paramMap.get('establishmentuid') + : this.establishmentService.establishmentId; - if (locationId) { - return this.establishmentService - .getCQCRegistrationStatus(locationId, { - postcode, - mainService: mainService.name, - }) - .pipe( - tap(({ cqcStatusMatch }) => { - this.establishmentService.setCheckCQCDetailsBanner(cqcStatusMatch === false); - }), - ) - .pipe( - catchError(() => { - return of(null); - }), - ); - } + return this.establishmentService.getEstablishment(workplaceUid).pipe( + switchMap(({ locationId, postcode, mainService }) => { + if (locationId) { + return this.establishmentService.getCQCRegistrationStatus(locationId, { + postcode, + mainService: mainService.name, + }); + } + return of(null); + }), + catchError(() => { + return of(null); + }), + ); } } diff --git a/frontend/src/app/core/services/establishment.service.ts b/frontend/src/app/core/services/establishment.service.ts index 1675a92e1b..5cd54ee377 100644 --- a/frontend/src/app/core/services/establishment.service.ts +++ b/frontend/src/app/core/services/establishment.service.ts @@ -72,7 +72,6 @@ export class EstablishmentService { private _establishment$: BehaviorSubject = new BehaviorSubject(null); private returnTo$ = new BehaviorSubject(null); private _primaryWorkplace$: BehaviorSubject = new BehaviorSubject(null); - private _checkCQCDetailsBanner$: BehaviorSubject = new BehaviorSubject(false); public previousEstablishmentId: string; public isSameLoggedInUser: boolean; public mainServiceCQC: boolean = null; @@ -144,7 +143,6 @@ export class EstablishmentService { this._establishment$.next(establishment); if (this.primaryWorkplace && establishment.uid === this.primaryWorkplace.uid) { this.setPrimaryWorkplace(this.establishment); - this.setCheckCQCDetailsBanner(false); } } @@ -154,7 +152,6 @@ export class EstablishmentService { this._inStaffRecruitmentFlow = false; this.standAloneAccount = false; this.setPrimaryWorkplace(null); - this.setCheckCQCDetailsBanner(false); } public get establishmentId() { @@ -196,18 +193,6 @@ export class EstablishmentService { this.returnTo$.next(returnTo); } - public get checkCQCDetailsBanner$(): Observable { - return this._checkCQCDetailsBanner$.asObservable(); - } - - public get checkCQCDetailsBanner(): boolean { - return this._checkCQCDetailsBanner$.value; - } - - public setCheckCQCDetailsBanner(data: boolean) { - this._checkCQCDetailsBanner$.next(data); - } - public get inStaffRecruitmentFlow() { if (this._inStaffRecruitmentFlow) { return this._inStaffRecruitmentFlow; diff --git a/frontend/src/app/core/test-utils/MockEstablishmentService.ts b/frontend/src/app/core/test-utils/MockEstablishmentService.ts index cc439bb3cf..6e326978ce 100644 --- a/frontend/src/app/core/test-utils/MockEstablishmentService.ts +++ b/frontend/src/app/core/test-utils/MockEstablishmentService.ts @@ -391,20 +391,3 @@ export class MockEstablishmentServiceWithNoEmployerType extends MockEstablishmen return; } } - -@Injectable() -export class MockEstablishmentServiceCheckCQCDetails extends MockEstablishmentService { - private cqcDetailsBanner; - - public static factory(checkCqcDetailsBanner = false) { - return (httpClient: HttpClient) => { - const service = new MockEstablishmentServiceCheckCQCDetails(httpClient); - service.cqcDetailsBanner = checkCqcDetailsBanner; - return service; - }; - } - - public get checkCQCDetailsBanner(): boolean { - return this.cqcDetailsBanner; - } -} diff --git a/frontend/src/app/features/dashboard/dashboard.component.ts b/frontend/src/app/features/dashboard/dashboard.component.ts index f50b1afe60..9a1eee92b2 100644 --- a/frontend/src/app/features/dashboard/dashboard.component.ts +++ b/frontend/src/app/features/dashboard/dashboard.component.ts @@ -3,9 +3,9 @@ import { ActivatedRoute } from '@angular/router'; import { Establishment } from '@core/model/establishment.model'; import { TrainingCounts } from '@core/model/trainingAndQualifications.model'; import { Worker } from '@core/model/worker.model'; -import { BenchmarksServiceBase } from '@core/services/benchmarks-base.service'; import { AlertService } from '@core/services/alert.service'; import { AuthService } from '@core/services/auth.service'; +import { BenchmarksServiceBase } from '@core/services/benchmarks-base.service'; import { EstablishmentService } from '@core/services/establishment.service'; import { PermissionsService } from '@core/services/permissions/permissions.service'; import { UserService } from '@core/services/user.service'; @@ -55,7 +55,7 @@ export class DashboardComponent implements OnInit, OnDestroy { async ngOnInit(): Promise { this.showBanner = history.state?.showBanner; this.authService.isOnAdminScreen = false; - this.showCQCDetailsBanner = this.establishmentService.checkCQCDetailsBanner; + this.showCQCDetailsBanner = this.route.snapshot.data?.cqcStatusCheck?.cqcStatusMatch === false; this.workplace = this.establishmentService.primaryWorkplace; this.showSharingPermissionsBanner = this.workplace.showSharingPermissionsBanner; this.workplaceUid = this.workplace ? this.workplace.uid : null; @@ -63,7 +63,6 @@ export class DashboardComponent implements OnInit, OnDestroy { this.newDataAreaFlag = this.featureFlagsService.newBenchmarksDataArea; this.canSeeNewDataArea = [1, 2, 8].includes(this.workplace.mainService.reportingID); - if (this.workplace) { this.getPermissions(); this.totalStaffRecords = this.route.snapshot.data.totalStaffRecords; diff --git a/frontend/src/app/features/new-dashboard/home-tab/home-tab.component.html b/frontend/src/app/features/new-dashboard/home-tab/home-tab.component.html index 183bd50e1c..d148b498d5 100644 --- a/frontend/src/app/features/new-dashboard/home-tab/home-tab.component.html +++ b/frontend/src/app/features/new-dashboard/home-tab/home-tab.component.html @@ -10,6 +10,7 @@ [workersNotCompleted]="workersNotCompleted" [(navigateToTab)]="navigateToTab" [canViewEstablishment]="canViewEstablishment" + [showCheckCqcDetails]="showCheckCqcDetails" [noOfWorkersWhoRequireInternationalRecruitment]="noOfWorkersWhoRequireInternationalRecruitment" > diff --git a/frontend/src/app/features/new-dashboard/home-tab/home-tab.component.spec.ts b/frontend/src/app/features/new-dashboard/home-tab/home-tab.component.spec.ts index 5fc6699a66..6fb10b00e6 100644 --- a/frontend/src/app/features/new-dashboard/home-tab/home-tab.component.spec.ts +++ b/frontend/src/app/features/new-dashboard/home-tab/home-tab.component.spec.ts @@ -16,14 +16,12 @@ import { TabsService } from '@core/services/tabs.service'; import { UserService } from '@core/services/user.service'; import { WindowToken } from '@core/services/window'; import { WindowRef } from '@core/services/window.ref'; -import { MockEstablishmentServiceCheckCQCDetails } from '@core/test-utils/MockEstablishmentService'; +import { MockEstablishmentService } from '@core/test-utils/MockEstablishmentService'; import { MockFeatureFlagsService } from '@core/test-utils/MockFeatureFlagService'; import { MockPermissionsService } from '@core/test-utils/MockPermissionsService'; import { MockUserService } from '@core/test-utils/MockUserService'; import { NewArticleListComponent } from '@features/articles/new-article-list/new-article-list.component'; -import { - OwnershipChangeMessageDialogComponent, -} from '@shared/components/ownership-change-message/ownership-change-message-dialog.component'; +import { OwnershipChangeMessageDialogComponent } from '@shared/components/ownership-change-message/ownership-change-message-dialog.component'; import { SummarySectionComponent } from '@shared/components/summary-section/summary-section.component'; import { FeatureFlagsService } from '@shared/services/feature-flags.service'; import { SharedModule } from '@shared/shared.module'; @@ -44,7 +42,7 @@ const MockWindow = { describe('NewHomeTabComponent', () => { const setup = async ( - checkCqcDetails = false, + cqcStatusMatch = true, establishment = Establishment, comparisonDataAvailable = true, noOfWorkplaces = 9, @@ -82,6 +80,7 @@ describe('NewHomeTabComponent', () => { trainingCounts: {} as TrainingCounts, workersNotCompleted: [], }, + cqcStatusCheck: { cqcStatusMatch }, }, }, queryParams: of({ view: null }), @@ -90,8 +89,7 @@ describe('NewHomeTabComponent', () => { }, { provide: EstablishmentService, - useFactory: MockEstablishmentServiceCheckCQCDetails.factory(checkCqcDetails), - deps: [HttpClient], + useClass: MockEstablishmentService, }, { provide: WindowToken, useValue: MockWindow }, ], @@ -907,9 +905,9 @@ describe('NewHomeTabComponent', () => { expect(tabsServiceSpy).toHaveBeenCalledWith('workplace'); }); - it('should show a warning link which should navigate to the workplace tab', async () => { + it('should show a warning link which should navigate to the workplace tab when showAddWorkplaceDetailsBanner is true', async () => { const establishment = { ...Establishment, showAddWorkplaceDetailsBanner: true }; - const { getByText, tabsServiceSpy } = await setup(true, establishment); + const { getByText, tabsServiceSpy } = await setup(false, establishment); const link = getByText('Add more details to your workplace'); @@ -917,6 +915,12 @@ describe('NewHomeTabComponent', () => { fireEvent.click(link); expect(tabsServiceSpy).toHaveBeenCalledWith('workplace'); }); + + it('should show a CQC message when showAddWorkplaceDetailsBanner is false and cqcStatusMatch is false', async () => { + const { getByText } = await setup(false); + + expect(getByText('You need to check your CQC details')).toBeTruthy(); + }); }); describe('staff records summary section', () => { diff --git a/frontend/src/app/features/new-dashboard/parent-home-tab/parent-home-tab.component.html b/frontend/src/app/features/new-dashboard/parent-home-tab/parent-home-tab.component.html index 33d1347747..bcdd62ff43 100644 --- a/frontend/src/app/features/new-dashboard/parent-home-tab/parent-home-tab.component.html +++ b/frontend/src/app/features/new-dashboard/parent-home-tab/parent-home-tab.component.html @@ -23,6 +23,7 @@ [canViewEstablishment]="canViewEstablishment" [showMissingCqcMessage]="showMissingCqcMessage" [workplacesCount]="workplacesCount" + [showCheckCqcDetails]="showCheckCqcDetails" [noOfWorkersWhoRequireInternationalRecruitment]="noOfWorkersWhoRequireInternationalRecruitment" >
diff --git a/frontend/src/app/features/new-dashboard/parent-home-tab/parent-home-tab.component.spec.ts b/frontend/src/app/features/new-dashboard/parent-home-tab/parent-home-tab.component.spec.ts index 2f9d1540d5..96eb15869f 100644 --- a/frontend/src/app/features/new-dashboard/parent-home-tab/parent-home-tab.component.spec.ts +++ b/frontend/src/app/features/new-dashboard/parent-home-tab/parent-home-tab.component.spec.ts @@ -17,7 +17,7 @@ import { UserService } from '@core/services/user.service'; import { WindowToken } from '@core/services/window'; import { WindowRef } from '@core/services/window.ref'; import { MockArticlesService } from '@core/test-utils/MockArticlesService'; -import { MockEstablishmentServiceCheckCQCDetails } from '@core/test-utils/MockEstablishmentService'; +import { MockEstablishmentService } from '@core/test-utils/MockEstablishmentService'; import { MockFeatureFlagsService } from '@core/test-utils/MockFeatureFlagService'; import { MockPermissionsService } from '@core/test-utils/MockPermissionsService'; import { MockUserService } from '@core/test-utils/MockUserService'; @@ -45,7 +45,7 @@ describe('ParentHomeTabComponent', () => { const articles = MockArticlesService.articlesFactory(); const setup = async ( - checkCqcDetails = false, + cqcStatusMatch = true, establishment = Establishment, comparisonDataAvailable = true, noOfWorkplaces = 9, @@ -84,6 +84,7 @@ describe('ParentHomeTabComponent', () => { trainingCounts: {} as TrainingCounts, workersNotCompleted: [], }, + cqcStatusCheck: { cqcStatusMatch }, }, }, queryParams: of({ view: null }), @@ -92,8 +93,7 @@ describe('ParentHomeTabComponent', () => { }, { provide: EstablishmentService, - useFactory: MockEstablishmentServiceCheckCQCDetails.factory(checkCqcDetails), - deps: [HttpClient], + useClass: MockEstablishmentService, }, { provide: ArticlesService, useClass: MockArticlesService }, { provide: WindowToken, useValue: MockWindow }, @@ -334,6 +334,16 @@ describe('ParentHomeTabComponent', () => { expect(link).toBeTruthy(); expect(tabsServiceSpy).toHaveBeenCalledWith('workplace'); }); + + it('should show a CQC message when showAddWorkplaceDetailsBanner is false and cqcStatusMatch is false', async () => { + const { component, fixture, getByText } = await setup(false); + + component.canViewListOfWorkers = true; + component.canViewEstablishment = true; + fixture.detectChanges(); + + expect(getByText('You need to check your CQC details')).toBeTruthy(); + }); }); describe('staff records summary section', () => { diff --git a/frontend/src/app/features/new-dashboard/workplace-tab/workplace-tab.component.spec.ts b/frontend/src/app/features/new-dashboard/workplace-tab/workplace-tab.component.spec.ts index 05f926597f..cded289d7b 100644 --- a/frontend/src/app/features/new-dashboard/workplace-tab/workplace-tab.component.spec.ts +++ b/frontend/src/app/features/new-dashboard/workplace-tab/workplace-tab.component.spec.ts @@ -1,7 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { ReactiveFormsModule } from '@angular/forms'; -import { Router, RouterModule } from '@angular/router'; +import { ActivatedRoute, Router, RouterModule } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { PermissionType } from '@core/model/permissions.model'; import { Roles } from '@core/model/roles.enum'; @@ -14,7 +14,7 @@ import { WindowToken } from '@core/services/window'; import { WindowRef } from '@core/services/window.ref'; import { MockAuthService } from '@core/test-utils/MockAuthService'; import { MockBreadcrumbService } from '@core/test-utils/MockBreadcrumbService'; -import { MockEstablishmentServiceCheckCQCDetails } from '@core/test-utils/MockEstablishmentService'; +import { MockEstablishmentService } from '@core/test-utils/MockEstablishmentService'; import { MockFeatureFlagsService } from '@core/test-utils/MockFeatureFlagService'; import { MockPermissionsService } from '@core/test-utils/MockPermissionsService'; import { MockUserService } from '@core/test-utils/MockUserService'; @@ -33,10 +33,11 @@ const MockWindow = { }, }, }; + describe('NewWorkplaceTabComponent', () => { const setup = async ( permissions = ['canEditEstablishment'], - checkCqcDetails = false, + cqcStatusMatch = true, establishment = Establishment, isAdmin = true, subsidiaries = 0, @@ -60,10 +61,8 @@ describe('NewWorkplaceTabComponent', () => { }, { provide: EstablishmentService, - useFactory: MockEstablishmentServiceCheckCQCDetails.factory(checkCqcDetails), - deps: [HttpClient], + useClass: MockEstablishmentService, }, - { provide: WindowRef, useClass: WindowRef, @@ -79,6 +78,16 @@ describe('NewWorkplaceTabComponent', () => { useFactory: MockAuthService.factory(true, isAdmin), deps: [HttpClient, Router, EstablishmentService, UserService, PermissionsService], }, + { + provide: ActivatedRoute, + useValue: { + snapshot: { + data: { + cqcStatusCheck: { cqcStatusMatch }, + }, + }, + }, + }, { provide: WindowToken, useValue: MockWindow }, ], componentProperties: { @@ -133,12 +142,18 @@ describe('NewWorkplaceTabComponent', () => { expect(queryByText('Start to add more details about your workplace')).toBeFalsy(); }); - it('should show the check cqc details banner when checkCQCDetails is true', async () => { - const { getByTestId } = await setup(['canEditEstablishment'], true); + it('should show the check cqc details banner when cqcStatusMatch is false in route data', async () => { + const { getByTestId } = await setup(['canEditEstablishment'], false); expect(getByTestId('check-cqc-details-banner')).toBeTruthy(); }); + it('should not show the check cqc details banner when cqcStatusMatch is true in route data', async () => { + const { queryByTestId } = await setup(['canEditEstablishment'], true); + + expect(queryByTestId('check-cqc-details-banner')).toBeFalsy(); + }); + it('should not show the check cqc details banner when there are not the correct permissions', async () => { const { queryByTestId } = await setup([], true); diff --git a/frontend/src/app/features/new-dashboard/workplace-tab/workplace-tab.component.ts b/frontend/src/app/features/new-dashboard/workplace-tab/workplace-tab.component.ts index 2d5f798c7a..b506751548 100644 --- a/frontend/src/app/features/new-dashboard/workplace-tab/workplace-tab.component.ts +++ b/frontend/src/app/features/new-dashboard/workplace-tab/workplace-tab.component.ts @@ -1,4 +1,5 @@ import { Component, Input, OnDestroy, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; import { JourneyType } from '@core/breadcrumb/breadcrumb.model'; import { Establishment } from '@core/model/establishment.model'; import { URLStructure } from '@core/model/url.model'; @@ -27,6 +28,7 @@ export class NewWorkplaceTabComponent implements OnInit, OnDestroy { private permissionsService: PermissionsService, private alertService: AlertService, private tabsService: TabsService, + private route: ActivatedRoute, ) {} ngOnInit(): void { @@ -34,7 +36,7 @@ export class NewWorkplaceTabComponent implements OnInit, OnDestroy { this.breadcrumbService.show(JourneyType.WORKPLACE_TAB); this.canEditEstablishment = this.permissionsService.can(this.workplace?.uid, 'canEditEstablishment'); this.addWorkplaceDetailsBanner = this.workplace.showAddWorkplaceDetailsBanner; - this.showCqcDetailsBanner = this.establishmentService.checkCQCDetailsBanner; + this.showCqcDetailsBanner = this.route.snapshot.data?.cqcStatusCheck?.cqcStatusMatch === false; } public navigateToTab(event: Event, selectedTab: string): void { diff --git a/frontend/src/app/features/subsidiary/home/view-subsidiary-home.component.html b/frontend/src/app/features/subsidiary/home/view-subsidiary-home.component.html index 7f0b39b58a..c901445a88 100644 --- a/frontend/src/app/features/subsidiary/home/view-subsidiary-home.component.html +++ b/frontend/src/app/features/subsidiary/home/view-subsidiary-home.component.html @@ -16,6 +16,7 @@ [(navigateToTab)]="navigateToTab" [canViewEstablishment]="canViewEstablishment" [isParentSubsidiaryView]="true" + [showCheckCqcDetails]="showCheckCqcDetails" [noOfWorkersWhoRequireInternationalRecruitment]="noOfWorkersWhoRequireInternationalRecruitment" >
diff --git a/frontend/src/app/features/subsidiary/home/view-subsidiary-home.component.spec.ts b/frontend/src/app/features/subsidiary/home/view-subsidiary-home.component.spec.ts index 14cb275bf8..f09ea13648 100644 --- a/frontend/src/app/features/subsidiary/home/view-subsidiary-home.component.spec.ts +++ b/frontend/src/app/features/subsidiary/home/view-subsidiary-home.component.spec.ts @@ -15,7 +15,7 @@ import { TabsService } from '@core/services/tabs.service'; import { UserService } from '@core/services/user.service'; import { WindowToken } from '@core/services/window'; import { WindowRef } from '@core/services/window.ref'; -import { MockEstablishmentServiceCheckCQCDetails } from '@core/test-utils/MockEstablishmentService'; +import { MockEstablishmentService } from '@core/test-utils/MockEstablishmentService'; import { MockFeatureFlagsService } from '@core/test-utils/MockFeatureFlagService'; import { MockPermissionsService } from '@core/test-utils/MockPermissionsService'; import { MockUserService } from '@core/test-utils/MockUserService'; @@ -40,7 +40,7 @@ const MockWindow = { describe('ViewSubsidiaryHomeComponent', () => { const setup = async ( - checkCqcDetails = false, + cqcStatusMatch = true, establishment = Establishment, comparisonDataAvailable = true, noOfWorkplaces = 9, @@ -89,6 +89,7 @@ describe('ViewSubsidiaryHomeComponent', () => { trainingCounts: {} as TrainingCounts, workersNotCompleted: [], }, + cqcStatusCheck: { cqcStatusMatch }, }, }, queryParams: of({ view: null }), @@ -97,8 +98,7 @@ describe('ViewSubsidiaryHomeComponent', () => { }, { provide: EstablishmentService, - useFactory: MockEstablishmentServiceCheckCQCDetails.factory(checkCqcDetails), - deps: [HttpClient], + useClass: MockEstablishmentService, }, { provide: WindowToken, useValue: MockWindow }, ], @@ -350,7 +350,7 @@ describe('ViewSubsidiaryHomeComponent', () => { it('should show a warning link which should navigate to the workplace tab', async () => { const establishment = { ...Establishment, showAddWorkplaceDetailsBanner: true }; - const { getByText, tabsServiceSpy } = await setup(true, establishment); + const { getByText, tabsServiceSpy } = await setup(false, establishment); const link = getByText('Add more details to your workplace'); diff --git a/frontend/src/app/features/subsidiary/home/view-subsidiary-home.component.ts b/frontend/src/app/features/subsidiary/home/view-subsidiary-home.component.ts index 3bac5ff9bd..31708490d3 100644 --- a/frontend/src/app/features/subsidiary/home/view-subsidiary-home.component.ts +++ b/frontend/src/app/features/subsidiary/home/view-subsidiary-home.component.ts @@ -64,6 +64,7 @@ export class ViewSubsidiaryHomeComponent implements OnInit { public locationId: string; public workplacesCount: number; public tilesData: BenchmarksResponse; + public showCheckCqcDetails: boolean; public noOfWorkersWhoRequireInternationalRecruitment: number; constructor( @@ -83,6 +84,7 @@ export class ViewSubsidiaryHomeComponent implements OnInit { this.workerCount = this.route.snapshot.data.workers?.workerCount; this.trainingCounts = this.route.snapshot.data.workers?.trainingCounts; this.workersNotCompleted = this.route.snapshot.data.workers?.workersNotCompleted; + this.showCheckCqcDetails = this.route.snapshot.data?.cqcStatusCheck?.cqcStatusMatch === false; this.noOfWorkersWhoRequireInternationalRecruitment = this.route.snapshot.data.noOfWorkersWhoRequireInternationalRecruitment?.noOfWorkersWhoRequireAnswers; diff --git a/frontend/src/app/features/subsidiary/subsidiary-routing.module.ts b/frontend/src/app/features/subsidiary/subsidiary-routing.module.ts index 2d62e9ede1..f4549fddcf 100644 --- a/frontend/src/app/features/subsidiary/subsidiary-routing.module.ts +++ b/frontend/src/app/features/subsidiary/subsidiary-routing.module.ts @@ -7,6 +7,7 @@ import { CheckPermissionsGuard } from '@core/guards/permissions/check-permission import { HasPermissionsGuard } from '@core/guards/permissions/has-permissions/has-permissions.guard'; import { ArticleListResolver } from '@core/resolvers/article-list.resolver'; import { BenchmarksResolver } from '@core/resolvers/benchmarks.resolver'; +import { CqcStatusCheckResolver } from '@core/resolvers/cqcStatusCheck/cqcStatusCheck.resolver'; import { AllUsersForEstablishmentResolver } from '@core/resolvers/dashboard/all-users-for-establishment.resolver'; import { TotalStaffRecordsResolver } from '@core/resolvers/dashboard/total-staff-records.resolver'; import { ExpiresSoonAlertDatesResolver } from '@core/resolvers/expiresSoonAlertDates.resolver'; @@ -123,6 +124,7 @@ const routes: Routes = [ rankingsResolver: RankingsResolver, usefulLinksPay: UsefulLinkPayResolver, usefulLinkRecruitment: UsefulLinkRecruitmentResolver, + cqcStatusCheck: CqcStatusCheckResolver, noOfWorkersWhoRequireInternationalRecruitment: GetNoOfWorkersWhoRequireInternationalRecruitmentAnswersResolver, }, children: [ diff --git a/frontend/src/app/features/subsidiary/training-and-qualifications/view-subsidiary-training-and-qualifications.component.ts b/frontend/src/app/features/subsidiary/training-and-qualifications/view-subsidiary-training-and-qualifications.component.ts index 58ea95e062..e352cfcd64 100644 --- a/frontend/src/app/features/subsidiary/training-and-qualifications/view-subsidiary-training-and-qualifications.component.ts +++ b/frontend/src/app/features/subsidiary/training-and-qualifications/view-subsidiary-training-and-qualifications.component.ts @@ -56,7 +56,6 @@ export class ViewSubsidiaryTrainingAndQualificationsComponent implements OnInit ) {} ngOnInit(): void { - this.establishmentService.setCheckCQCDetailsBanner(false); this.breadcrumbService.show(JourneyType.SUBSIDIARY); this.workers = this.route.snapshot.data.workers?.workers; @@ -86,7 +85,7 @@ export class ViewSubsidiaryTrainingAndQualificationsComponent implements OnInit this.trainingTotals(); } } - + public getParentPermissions(): void { const parentUid = this.workplace.parentUid; diff --git a/frontend/src/app/features/subsidiary/workplace/view-subsidiary-workplace.component.spec.ts b/frontend/src/app/features/subsidiary/workplace/view-subsidiary-workplace.component.spec.ts new file mode 100644 index 0000000000..0d07ce9362 --- /dev/null +++ b/frontend/src/app/features/subsidiary/workplace/view-subsidiary-workplace.component.spec.ts @@ -0,0 +1,156 @@ +import { HttpClient } from '@angular/common/http'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { ReactiveFormsModule } from '@angular/forms'; +import { ActivatedRoute, Router, RouterModule } from '@angular/router'; +import { RouterTestingModule } from '@angular/router/testing'; +import { PermissionType } from '@core/model/permissions.model'; +import { Roles } from '@core/model/roles.enum'; +import { AuthService } from '@core/services/auth.service'; +import { BreadcrumbService } from '@core/services/breadcrumb.service'; +import { EstablishmentService } from '@core/services/establishment.service'; +import { PermissionsService } from '@core/services/permissions/permissions.service'; +import { UserService } from '@core/services/user.service'; +import { WindowToken } from '@core/services/window'; +import { WindowRef } from '@core/services/window.ref'; +import { MockAuthService } from '@core/test-utils/MockAuthService'; +import { MockBreadcrumbService } from '@core/test-utils/MockBreadcrumbService'; +import { MockEstablishmentService } from '@core/test-utils/MockEstablishmentService'; +import { MockFeatureFlagsService } from '@core/test-utils/MockFeatureFlagService'; +import { MockPermissionsService } from '@core/test-utils/MockPermissionsService'; +import { MockUserService } from '@core/test-utils/MockUserService'; +import { FeatureFlagsService } from '@shared/services/feature-flags.service'; +import { SharedModule } from '@shared/shared.module'; +import { render } from '@testing-library/angular'; + +import { Establishment } from '../../../../mockdata/establishment'; +import { NewDashboardHeaderComponent } from '../../../shared/components/new-dashboard-header/dashboard-header.component'; +import { ViewSubsidiaryWorkplaceComponent } from './view-subsidiary-workplace.component'; + +const MockWindow = { + dataLayer: { + push: () => { + return; + }, + }, +}; + +describe('ViewSubsidiaryWorkplaceComponent', () => { + const setup = async ( + permissions = ['canEditEstablishment'], + cqcStatusMatch = true, + establishment = Establishment, + ) => { + const role = Roles.Edit; + const { fixture, getByText, queryByText, getByTestId, queryByTestId } = await render( + ViewSubsidiaryWorkplaceComponent, + { + imports: [SharedModule, RouterModule, RouterTestingModule, HttpClientTestingModule, ReactiveFormsModule], + providers: [ + { + provide: FeatureFlagsService, + useClass: MockFeatureFlagsService, + }, + { + provide: PermissionsService, + useFactory: MockPermissionsService.factory(permissions as PermissionType[]), + deps: [HttpClient, Router, UserService], + }, + { + provide: BreadcrumbService, + useClass: MockBreadcrumbService, + }, + { + provide: EstablishmentService, + useClass: MockEstablishmentService, + }, + { + provide: WindowRef, + useClass: WindowRef, + }, + + { + provide: UserService, + useFactory: MockUserService.factory(0, role), + deps: [HttpClient], + }, + { + provide: AuthService, + useFactory: MockAuthService.factory(true, false), + deps: [HttpClient, Router, EstablishmentService, UserService, PermissionsService], + }, + { + provide: ActivatedRoute, + useValue: { + snapshot: { + data: { + cqcStatusCheck: { cqcStatusMatch }, + establishment, + }, + }, + }, + }, + { provide: WindowToken, useValue: MockWindow }, + ], + declarations: [NewDashboardHeaderComponent], + }, + ); + + const component = fixture.componentInstance; + + return { + component, + getByText, + queryByText, + getByTestId, + queryByTestId, + }; + }; + + it('should create', async () => { + const { component } = await setup(); + expect(component).toBeTruthy(); + }); + + describe('banners', () => { + it('should show the add more details banner with correct href when the showAddWorkplaceDetailsBanner is true and have the correct permissions', async () => { + const establishment = { ...Establishment, showAddWorkplaceDetailsBanner: true }; + const { getByText } = await setup(['canEditEstablishment'], false, establishment); + + const banner = getByText('Start to add more details about your workplace'); + + expect(banner).toBeTruthy(); + expect(banner.getAttribute('href')).toEqual(`/workplace/${establishment.uid}/start`); + }); + + it('should not show the add more details banner when the showAddWorkplaceDetailsBanner is false', async () => { + const { queryByText } = await setup(); + + expect(queryByText('Start to add more details about your workplace')).toBeFalsy(); + }); + + it('should not show the add more details banner when there are not the correct permissions', async () => { + const establishment = { ...Establishment, showAddWorkplaceDetailsBanner: true }; + const { queryByText } = await setup([], false, establishment); + + expect(queryByText('Start to add more details about your workplace')).toBeFalsy(); + }); + + it('should show the check cqc details banner when cqcStatusMatch is false in route data', async () => { + const { getByTestId } = await setup(['canEditEstablishment'], false); + + expect(getByTestId('check-cqc-details-banner')).toBeTruthy(); + }); + + it('should not show the check cqc details banner when cqcStatusMatch is true in route data', async () => { + const { queryByTestId } = await setup(['canEditEstablishment'], true); + + expect(queryByTestId('check-cqc-details-banner')).toBeFalsy(); + }); + + it('should not show the check cqc details banner when there are not the correct permissions', async () => { + const { queryByTestId } = await setup([], true); + + expect(queryByTestId('check-cqc-details-banner')).toBeFalsy(); + }); + }); +}); diff --git a/frontend/src/app/features/subsidiary/workplace/view-subsidiary-workplace.component.ts b/frontend/src/app/features/subsidiary/workplace/view-subsidiary-workplace.component.ts index b26b5d2129..b33c9e5238 100644 --- a/frontend/src/app/features/subsidiary/workplace/view-subsidiary-workplace.component.ts +++ b/frontend/src/app/features/subsidiary/workplace/view-subsidiary-workplace.component.ts @@ -36,6 +36,7 @@ export class ViewSubsidiaryWorkplaceComponent implements OnInit { this.workplace = this.route.snapshot.data.establishment; this.workerCount = this.route.snapshot.data.workers?.workerCount; this.addWorkplaceDetailsBanner = this.workplace.showAddWorkplaceDetailsBanner; + this.showCqcDetailsBanner = this.route.snapshot.data?.cqcStatusCheck?.cqcStatusMatch === false; this.canEditEstablishment = this.permissionsService.can(this.workplace?.uid, 'canEditEstablishment'); } diff --git a/frontend/src/app/features/workplace/select-main-service/select-main-service-cqc.component.ts b/frontend/src/app/features/workplace/select-main-service/select-main-service-cqc.component.ts index f382240e15..44ac13aa77 100644 --- a/frontend/src/app/features/workplace/select-main-service/select-main-service-cqc.component.ts +++ b/frontend/src/app/features/workplace/select-main-service/select-main-service-cqc.component.ts @@ -51,7 +51,7 @@ export class SelectMainServiceCqcComponent extends Question { if (this.form.valid) { this.establishmentService.mainServiceCQC = this.form.get('cqc').value; - this.router.navigate(['/workplace', this.establishmentService.establishmentId, 'main-service']); + this.router.navigate(['/workplace', this.establishment.uid, 'main-service']); } else { this.errorSummaryService.scrollToErrorSummary(); } diff --git a/frontend/src/app/features/workplace/view-workplace/view-workplace.component.ts b/frontend/src/app/features/workplace/view-workplace/view-workplace.component.ts index 05889a6d58..729d94a8b0 100644 --- a/frontend/src/app/features/workplace/view-workplace/view-workplace.component.ts +++ b/frontend/src/app/features/workplace/view-workplace/view-workplace.component.ts @@ -5,8 +5,8 @@ import { Establishment } from '@core/model/establishment.model'; import { TrainingCounts } from '@core/model/trainingAndQualifications.model'; import { URLStructure } from '@core/model/url.model'; import { Worker } from '@core/model/worker.model'; -import { BenchmarksServiceBase } from '@core/services/benchmarks-base.service'; import { AlertService } from '@core/services/alert.service'; +import { BenchmarksServiceBase } from '@core/services/benchmarks-base.service'; import { BreadcrumbService } from '@core/services/breadcrumb.service'; import { DialogService } from '@core/services/dialog.service'; import { EstablishmentService } from '@core/services/establishment.service'; @@ -32,7 +32,7 @@ export class ViewWorkplaceComponent implements OnInit, OnDestroy { public totalStaffRecords: number; private subscriptions: Subscription = new Subscription(); public trainingAlert: number; - public showCQCDetailsBanner: boolean = this.establishmentService.checkCQCDetailsBanner; + public showCQCDetailsBanner: boolean; public workers: Worker[]; public trainingCounts: TrainingCounts; public workerCount: number; @@ -58,7 +58,6 @@ export class ViewWorkplaceComponent implements OnInit, OnDestroy { ngOnInit(): void { this.showBanner = history.state?.showBanner; - this.establishmentService.setCheckCQCDetailsBanner(false); this.breadcrumbService.show(JourneyType.ALL_WORKPLACES); this.primaryEstablishment = this.establishmentService.primaryWorkplace; this.workplace = this.establishmentService.establishment; @@ -68,21 +67,8 @@ export class ViewWorkplaceComponent implements OnInit, OnDestroy { this.canDeleteEstablishment = this.permissionsService.can(this.workplace.uid, 'canDeleteEstablishment'); this.newDataAreaFlag = this.featureFlagsService.newBenchmarksDataArea; this.canSeeNewDataArea = [1, 2, 8].includes(this.workplace.mainService.reportingID); + this.showCQCDetailsBanner = this.route.snapshot.data?.cqcStatusCheck?.cqcStatusMatch === false; - if (this.workplace && this.workplace.locationId) { - this.subscriptions.add( - this.establishmentService - .getCQCRegistrationStatus(this.workplace.locationId, { - postcode: this.workplace.postcode, - mainService: this.workplace.mainService.name, - }) - .subscribe((response) => { - this.establishmentService.setCheckCQCDetailsBanner(response.cqcStatusMatch === false); - }), - ); - } - - this.getShowCQCDetailsBanner(); this.showSharingPermissionsBanner = this.workplace.showSharingPermissionsBanner; if (this.canViewListOfWorkers) { @@ -149,14 +135,6 @@ export class ViewWorkplaceComponent implements OnInit, OnDestroy { ); } - private getShowCQCDetailsBanner(): void { - this.subscriptions.add( - this.establishmentService.checkCQCDetailsBanner$.subscribe((showBanner) => { - this.showCQCDetailsBanner = showBanner; - }), - ); - } - private showStaffRecordBanner(): void { this.alertService.addAlert({ type: 'success', diff --git a/frontend/src/app/shared/components/check-cqc-details/check-cqc-details.component.spec.ts b/frontend/src/app/shared/components/check-cqc-details/check-cqc-details.component.spec.ts index 3926416c75..550f79cb75 100644 --- a/frontend/src/app/shared/components/check-cqc-details/check-cqc-details.component.spec.ts +++ b/frontend/src/app/shared/components/check-cqc-details/check-cqc-details.component.spec.ts @@ -2,7 +2,6 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { RouterModule } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { EstablishmentService } from '@core/services/establishment.service'; -import { MockEstablishmentService } from '@core/test-utils/MockEstablishmentService'; import { SharedModule } from '@shared/shared.module'; import { render } from '@testing-library/angular'; @@ -10,18 +9,23 @@ import { CheckCQCDetailsComponent } from './check-cqc-details.component'; describe('CheckCQCDetailsComponent', () => { const setup = async () => { + const locationId = '1-11111111'; + const { fixture, getByText } = await render(CheckCQCDetailsComponent, { imports: [SharedModule, RouterModule, RouterTestingModule, HttpClientTestingModule], providers: [ { provide: EstablishmentService, - useClass: MockEstablishmentService, + useValue: { + establishment: { locationId }, + }, }, ], }); + const component = fixture.componentInstance; - return { component, fixture, getByText }; + return { component, fixture, getByText, locationId }; }; it('should render a CheckCQCDetailsComponent', async () => { @@ -30,10 +34,10 @@ describe('CheckCQCDetailsComponent', () => { }); it('should render the link with a href that navigates to the correct cqc page', async () => { - const { component, getByText } = await setup(); + const { getByText, locationId } = await setup(); expect(getByText('Please check your CQC details').getAttribute('href')).toEqual( - `https://www.cqc.org.uk/location/${component.locationId}`, + `https://www.cqc.org.uk/location/${locationId}`, ); }); }); diff --git a/frontend/src/app/shared/components/check-cqc-details/check-cqc-details.component.ts b/frontend/src/app/shared/components/check-cqc-details/check-cqc-details.component.ts index 96d33debc7..4e5c04f33f 100644 --- a/frontend/src/app/shared/components/check-cqc-details/check-cqc-details.component.ts +++ b/frontend/src/app/shared/components/check-cqc-details/check-cqc-details.component.ts @@ -11,6 +11,6 @@ export class CheckCQCDetailsComponent implements OnInit { constructor(private establishmentService: EstablishmentService) {} ngOnInit(): void { - this.locationId = this.establishmentService.primaryWorkplace.locationId; + this.locationId = this.establishmentService.establishment.locationId; } } diff --git a/frontend/src/app/shared/components/summary-section/summary-section.component.spec.ts b/frontend/src/app/shared/components/summary-section/summary-section.component.spec.ts index d02176ea17..61f3577a9f 100644 --- a/frontend/src/app/shared/components/summary-section/summary-section.component.spec.ts +++ b/frontend/src/app/shared/components/summary-section/summary-section.component.spec.ts @@ -1,4 +1,3 @@ -import { HttpClient } from '@angular/common/http'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { getTestBed } from '@angular/core/testing'; import { Router, RouterModule } from '@angular/router'; @@ -7,7 +6,7 @@ import { TrainingCounts } from '@core/model/trainingAndQualifications.model'; import { Worker } from '@core/model/worker.model'; import { EstablishmentService } from '@core/services/establishment.service'; import { TabsService } from '@core/services/tabs.service'; -import { MockEstablishmentServiceCheckCQCDetails } from '@core/test-utils/MockEstablishmentService'; +import { MockEstablishmentService } from '@core/test-utils/MockEstablishmentService'; import { MockTabsService } from '@core/test-utils/MockTabsService'; import { workerBuilder } from '@core/test-utils/MockWorkerService'; import { SharedModule } from '@shared/shared.module'; @@ -39,8 +38,7 @@ describe('Summary section', () => { }, { provide: EstablishmentService, - useFactory: MockEstablishmentServiceCheckCQCDetails.factory(checkCqcDetails), - deps: [HttpClient], + useClass: MockEstablishmentService, }, ], componentProperties: { @@ -58,6 +56,7 @@ describe('Summary section', () => { showMissingCqcMessage: false, workplacesCount: 0, isParentSubsidiaryView, + showCheckCqcDetails: checkCqcDetails, noOfWorkersWhoRequireInternationalRecruitment, }, }); diff --git a/frontend/src/app/shared/components/summary-section/summary-section.component.ts b/frontend/src/app/shared/components/summary-section/summary-section.component.ts index d261273a44..c011599626 100644 --- a/frontend/src/app/shared/components/summary-section/summary-section.component.ts +++ b/frontend/src/app/shared/components/summary-section/summary-section.component.ts @@ -24,6 +24,7 @@ export class SummarySectionComponent implements OnInit, OnChanges { @Input() showMissingCqcMessage: boolean; @Input() workplacesCount: number; @Input() isParentSubsidiaryView: boolean; + @Input() showCheckCqcDetails: boolean; @Input() noOfWorkersWhoRequireInternationalRecruitment: number; public sections = [ @@ -87,7 +88,7 @@ export class SummarySectionComponent implements OnInit, OnChanges { this.sections[0].redFlag = false; if (showAddWorkplaceDetailsBanner) { this.sections[0].message = 'Add more details to your workplace'; - } else if (this.establishmentService.checkCQCDetailsBanner) { + } else if (this.showCheckCqcDetails) { this.sections[0].message = 'You need to check your CQC details'; } else if (!numberOfStaff) { this.sections[0].message = `You've not added your total number of staff`; diff --git a/frontend/src/app/shared/components/workplace-tab/workplace-tab.component.ts b/frontend/src/app/shared/components/workplace-tab/workplace-tab.component.ts index c49682bbf2..79b663178d 100644 --- a/frontend/src/app/shared/components/workplace-tab/workplace-tab.component.ts +++ b/frontend/src/app/shared/components/workplace-tab/workplace-tab.component.ts @@ -19,7 +19,7 @@ export class WorkplaceTabComponent implements OnInit, OnDestroy { public updateWorkplaceAlert: boolean; public locationId: string; - public showCQCDetailsBanner: boolean = this.establishmentService.checkCQCDetailsBanner; + public showCQCDetailsBanner: boolean; public showSharingPermissionsBanner: boolean; constructor( @@ -36,31 +36,7 @@ export class WorkplaceTabComponent implements OnInit, OnDestroy { this.workplace.showAddWorkplaceDetailsBanner && this.permissionsService.can(this.workplace.uid, 'canEditEstablishment'); - if (this.workplace.locationId) { - this.setCheckCQCDetailsBannerInEstablishmentService(); - } - this.getShowCQCDetailsBanner(); - } - - private getShowCQCDetailsBanner(): void { - this.subscriptions.add( - this.establishmentService.checkCQCDetailsBanner$.subscribe((showBanner) => { - this.showCQCDetailsBanner = showBanner; - }), - ); - } - - private setCheckCQCDetailsBannerInEstablishmentService(): void { - this.subscriptions.add( - this.establishmentService - .getCQCRegistrationStatus(this.workplace.locationId, { - postcode: this.workplace.postcode, - mainService: this.workplace.mainService.name, - }) - .subscribe((response) => { - this.establishmentService.setCheckCQCDetailsBanner(response.cqcStatusMatch === false); - }), - ); + this.showCQCDetailsBanner = this.route.snapshot.data?.cqcStatusCheck?.cqcStatusMatch === false; } public navigateToShareDataPage(e: Event): void { diff --git a/frontend/src/app/shared/directives/new-home-tab/new-home-tab.directive.ts b/frontend/src/app/shared/directives/new-home-tab/new-home-tab.directive.ts index eef178ba24..52f045c0c6 100644 --- a/frontend/src/app/shared/directives/new-home-tab/new-home-tab.directive.ts +++ b/frontend/src/app/shared/directives/new-home-tab/new-home-tab.directive.ts @@ -84,6 +84,7 @@ export class NewHomeTabDirective implements OnInit, OnDestroy, OnChanges { public workplacesCount: number; public isParentSubsidiaryView: boolean; public article: Article; + public showCheckCqcDetails: boolean; public noOfWorkersWhoRequireInternationalRecruitment: number; constructor( @@ -107,6 +108,7 @@ export class NewHomeTabDirective implements OnInit, OnDestroy, OnChanges { this.workerCount = this.route.snapshot.data.workers?.workerCount; this.trainingCounts = this.route.snapshot.data.workers?.trainingCounts; this.workersNotCompleted = this.route.snapshot.data.workers?.workersNotCompleted; + this.showCheckCqcDetails = this.route.snapshot.data?.cqcStatusCheck?.cqcStatusMatch === false; this.noOfWorkersWhoRequireInternationalRecruitment = this.route.snapshot.data.noOfWorkersWhoRequireInternationalRecruitment?.noOfWorkersWhoRequireAnswers;