From 25888db08ca8134b9e18e8f1041e85b55837e653 Mon Sep 17 00:00:00 2001 From: Emmanuel Raviart <emmanuel@raviart.com> Date: Thu, 28 Apr 2022 12:04:52 +0200 Subject: [PATCH] Add housholdEntityKey to session. --- example.env | 3 +++ src/app.d.ts | 1 + src/hooks.ts | 1 + src/lib/auditors/config.ts | 1 + src/lib/components/test_cases/TestCaseCompareView.svelte | 1 + src/lib/components/test_cases/TestCaseSummary.svelte | 1 + src/lib/server/config.ts | 2 ++ 7 files changed, 10 insertions(+) diff --git a/example.env b/example.env index dc5b47329..c6734bf64 100644 --- a/example.env +++ b/example.env @@ -28,6 +28,9 @@ GITHUB_PERSONAL_ACCESS_TOKEN=null # that should not be shown when editing test cases HIDDEN_ENTITIES=menages +# Key for household entity +HOUSEHOLD_KEY="menage" + # Matomo analytics configuration # MATOMO_SITE_ID=123 # MATOMO_URL="https://MATOMO_SERVER/" diff --git a/src/app.d.ts b/src/app.d.ts index 0e572ab33..3085b91f3 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -17,6 +17,7 @@ declare namespace App { familyEntityKey: string hasGithubPersonalAccessToken: boolean hiddenEntitiesKeyPlural?: string[] + householdEntityKey: string matomo?: { prependDomain?: boolean siteId: number diff --git a/src/hooks.ts b/src/hooks.ts index e27db3c3a..c3cac06a5 100644 --- a/src/hooks.ts +++ b/src/hooks.ts @@ -18,6 +18,7 @@ export const getSession: GetSession = async (event): Promise<App.Session> => { familyEntityKey: config.familyEntityKey, hasGithubPersonalAccessToken: githubPersonalAccessToken !== undefined, hiddenEntitiesKeyPlural: config.hiddenEntitiesKeyPlural, + householdEntityKey: config.householdEntityKey, matomo: config.matomo, openfiscaRepository: { branch: openfiscaRepository.branch, diff --git a/src/lib/auditors/config.ts b/src/lib/auditors/config.ts index d82225854..444895cfb 100644 --- a/src/lib/auditors/config.ts +++ b/src/lib/auditors/config.ts @@ -68,6 +68,7 @@ export function auditConfig( for (const key of [ "childrenKey", "familyEntityKey", + "householdEntityKey", "simulationsDir", "title", ]) { diff --git a/src/lib/components/test_cases/TestCaseCompareView.svelte b/src/lib/components/test_cases/TestCaseCompareView.svelte index 53b33b75e..ad6c89c58 100644 --- a/src/lib/components/test_cases/TestCaseCompareView.svelte +++ b/src/lib/components/test_cases/TestCaseCompareView.svelte @@ -53,6 +53,7 @@ EvaluationByName[] > const familyEntity = entityByKey[$session.familyEntityKey] + // const householdEntity = entityByKey[$session.householdEntityKey] const personEntity = entityByKey[personEntityKey] const parametricReform = getContext( "parametricReform", diff --git a/src/lib/components/test_cases/TestCaseSummary.svelte b/src/lib/components/test_cases/TestCaseSummary.svelte index 85b0ba1be..d36015f67 100644 --- a/src/lib/components/test_cases/TestCaseSummary.svelte +++ b/src/lib/components/test_cases/TestCaseSummary.svelte @@ -39,6 +39,7 @@ style: "currency", }) const familyEntity = entityByKey[$session.familyEntityKey] + const householdEntity = entityByKey[$session.householdEntityKey] let isTestCaseCompareModalOpen = false const personEntity = entityByKey[personEntityKey] let slider: Slider | undefined = undefined diff --git a/src/lib/server/config.ts b/src/lib/server/config.ts index 60dfc7162..708ff9c19 100644 --- a/src/lib/server/config.ts +++ b/src/lib/server/config.ts @@ -13,6 +13,7 @@ export interface Config { familyEntityKey: string githubPersonalAccessToken?: string hiddenEntitiesKeyPlural?: string[] + householdEntityKey: string matomo?: { prependDomain?: boolean siteId: number @@ -45,6 +46,7 @@ const [validConfig, error] = validateConfig({ familyEntityKey: process.env["FAMILY_KEY"], githubPersonalAccessToken: process.env["GITHUB_PERSONAL_ACCESS_TOKEN"], hiddenEntitiesKeyPlural: process.env["HIDDEN_ENTITIES"], + householdEntityKey: process.env["HOUSEHOLD_KEY"], matomo: process.env["MATOMO_SITE_ID"] && process.env["MATOMO_URL"] ? { -- GitLab