From b83234b82342cc32bc21eee5dee43ee311ba9a30 Mon Sep 17 00:00:00 2001
From: Emmanuel Raviart <emmanuel@raviart.com>
Date: Fri, 11 Oct 2024 21:28:37 +0200
Subject: [PATCH] =?UTF-8?q?Ne=20plante=20pas=20quand=20une=20r=C3=A9forme?=
 =?UTF-8?q?=20introduit=20une=20nouvelle=20variable=20budg=C3=A9taire=20sa?=
 =?UTF-8?q?ns=20inflateur=20donc?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../variables/InflationLawButton.svelte       | 29 ++++++++++++-------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/src/lib/components/variables/InflationLawButton.svelte b/src/lib/components/variables/InflationLawButton.svelte
index 6fd418d69..f0044d989 100644
--- a/src/lib/components/variables/InflationLawButton.svelte
+++ b/src/lib/components/variables/InflationLawButton.svelte
@@ -20,24 +20,31 @@
         reformName,
         {
           ...reformParameter,
-          values: Object.fromEntries([
-            ...Object.entries(reformParameter.values),
-            [
-              "latest",
-              Object.entries(reformParameter.values).sort(
-                ([instant1], [instant2]) => instant2.localeCompare(instant1),
-              )[0][1],
-            ],
-          ]),
+          values:
+            reformParameter.values === undefined
+              ? undefined
+              : Object.fromEntries([
+                  ...Object.entries(reformParameter.values),
+                  [
+                    "latest",
+                    Object.entries(reformParameter.values).sort(
+                      ([instant1], [instant2]) =>
+                        instant2.localeCompare(instant1),
+                    )[0][1],
+                  ],
+                ]),
         },
       ],
     ),
   )
 
   // Latest inflator
-  $: billInflator = inflatorWithLatestByReformName?.[$billName]
+  $: billInflator =
+    $billName === undefined
+      ? undefined
+      : inflatorWithLatestByReformName?.[$billName]
   $: billInflatorValueFormatted =
-    billInflator !== undefined
+    billInflator?.values !== undefined
       ? formatValue(billInflator.values["latest"].value, billInflator.unit)
       : undefined
 </script>
-- 
GitLab