-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cb2-13762): add test codes to test names (#1568)
* feat(cb2-13762): remove test code * fix(cb2-8973): move to resolver approach * fix(cb2-8973): fix unit tests
- Loading branch information
1 parent
87e85cb
commit 24bd169
Showing
7 changed files
with
60 additions
and
26 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { inject } from '@angular/core'; | ||
import { ResolveFn } from '@angular/router'; | ||
import { TestTypesService } from '@api/test-types'; | ||
import { Store, select } from '@ngrx/store'; | ||
import { TechnicalRecordService } from '@services/technical-record/technical-record.service'; | ||
import { techRecord } from '@store/technical-records'; | ||
import { Observable, map, switchMap } from 'rxjs'; | ||
|
||
export const testCodeResolver: ResolveFn<Observable<string | undefined>> = (route) => { | ||
const store = inject(Store); | ||
const testTypesService = inject(TestTypesService); | ||
const techRecordService = inject(TechnicalRecordService); | ||
const testTypeId: string | undefined = route.queryParams['testType']; | ||
|
||
// fetch test code from back-end (because its not provided by reference data) | ||
return store.pipe( | ||
select(techRecord), | ||
switchMap((record) => { | ||
return testTypesService.getTestTypesid( | ||
String(testTypeId), | ||
['defaultTestCode'], | ||
record!.techRecord_vehicleType, | ||
techRecordService.getVehicleSize(record!) as string, | ||
record!.techRecord_vehicleConfiguration!, | ||
record!.techRecord_noOfAxles!, | ||
record!.techRecord_euVehicleCategory!, | ||
techRecordService.getVehicleClassDescription(record!) as string, | ||
techRecordService.getVehicleSubClass(record!)?.[0] as string | ||
); | ||
}), | ||
map((response) => response.defaultTestCode) | ||
); | ||
}; |
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
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