Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/min app version cp #1660

Merged
merged 5 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/app/providers/app-config/__mocks__/app-config.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class AppConfigProviderMock {
},
tests: {
testSubmissionUrl: localEnvironmentMock.tests.testSubmissionUrl,
examinerRecordsUrl: localEnvironmentMock.tests.examinerRecordsUrl,
autoSendInterval: localEnvironmentMock.tests.autoSendInterval,
},
user: {
Expand Down
3 changes: 2 additions & 1 deletion src/app/providers/app-config/app-config.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export type AppConfig = {
},
tests: {
testSubmissionUrl: string,
autoSendInterval: number,
examinerRecordsUrl: string,
autoSendInterval: number
},
user: {
findUserUrl: string,
Expand Down
13 changes: 11 additions & 2 deletions src/app/providers/app-config/app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { SaveLog } from '@store/logs/logs.actions';
import { getAppConfigState } from '@store/app-config/app-config.reducer';
import { MdmConfig } from '@dvsa/mes-config-schema/mdm-config';
import { RemoteConfig } from '@dvsa/mes-config-schema/remote-config';
import { getEnumKeyByValue } from '@shared/helpers/enum-keys';
import { AppConfig } from './app-config.model';

import { SchemaValidatorProvider } from '../schema-validator/schema-validator';
Expand Down Expand Up @@ -196,7 +197,7 @@ export class AppConfigProvider {
return data;
})
.then((data) => this.mapRemoteConfig(data))
.catch((error: HttpErrorResponse | ValidationError[]) => {
.catch((error: HttpErrorResponse | ValidationError[] | string) => {
if (error instanceof HttpErrorResponse) {
this.store$.dispatch(SaveLog({
payload: this.logHelper.createLog(LogType.ERROR, 'Loading remote config', error.message),
Expand All @@ -211,7 +212,14 @@ export class AppConfigProvider {
return Promise.reject(AppConfigError.UNKNOWN_ERROR);
}

const configError: string = (error || [])
if (typeof error === 'string') {
const [, errorEnumVal] = getEnumKeyByValue(AppConfigError, error);
if (!!errorEnumVal) {
return Promise.reject(errorEnumVal);
}
}

const configError = ((error || []) as ValidationError[])
.map((err: ValidationError) => err.message)
.join(', ');

Expand Down Expand Up @@ -327,6 +335,7 @@ export class AppConfigProvider {
},
tests: {
testSubmissionUrl: data.tests.testSubmissionUrl,
examinerRecordsUrl: data.tests.examinerRecordsUrl,
autoSendInterval: data.tests.autoSendInterval,
},
user: {
Expand Down
1 change: 1 addition & 0 deletions src/store/app-config/app-config.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const initialState: AppConfig = {
},
tests: {
testSubmissionUrl: null,
examinerRecordsUrl: null,
autoSendInterval: null,
},
user: {
Expand Down
Loading