Skip to content

Commit

Permalink
chore: code tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismclarke committed Feb 27, 2025
1 parent a347481 commit 410b055
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apps/picsa-tools/forecasts-tool/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"types": []
},
"files": ["src/main.ts"],
"include": ["src/**/*.d.ts"],
"exclude": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts"]
}
6 changes: 6 additions & 0 deletions apps/picsa-tools/forecasts-tool/tsconfig.editor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.json",
"include": ["src/**/*.ts"],
"compilerOptions": {},
"exclude": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts"]
}
32 changes: 32 additions & 0 deletions apps/picsa-tools/forecasts-tool/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"compilerOptions": {
"target": "es2022",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.editor.json"
},
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"extends": "../../../tsconfig.base.json",
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}
11 changes: 11 additions & 0 deletions apps/picsa-tools/forecasts-tool/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"module": "commonjs",
"target": "es2016",
"types": ["jest", "node"]
},
"files": ["src/test-setup.ts"],
"include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
}
14 changes: 14 additions & 0 deletions libs/configuration/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@ export interface IUserSettings {
language_code: ILocaleCode;
/** Specify if using farmer or extension app user_type */
user_type: 'farmer' | 'extension';
/**
* User location, stored as an array to allow for hierarchy by osm admin level,
* https://wiki.openstreetmap.org/wiki/Key:admin_level
* @example [null,null,'malawi','northern','karonga']
*/
location: (string | undefined)[];
}

const USER_CONFIGURATION_DEFAULT: IUserSettings = {
country_code: null as any,
deployment_id: null as any,
language_code: null as any,
user_type: null as any,
location: [],
};

@Injectable({ providedIn: 'root' })
Expand Down Expand Up @@ -47,6 +54,13 @@ export class ConfigurationService {
document.body.dataset['theme'] = 'picsa-default';
}
});

effect(() => {
// ensure sublocation kept in sync with country selected
const { country_code, location } = this.userSettings();
if (location[2] === country_code) return;
this.userSettings.update((v) => ({ ...v, location: [undefined, undefined, country_code] }));
});
}

public resetUserSettings() {
Expand Down

0 comments on commit 410b055

Please sign in to comment.