From f0105b31b671d55084b6a99283b52d3f9c8aa32a Mon Sep 17 00:00:00 2001
From: Emmanuel Raviart <emmanuel@raviart.com>
Date: Thu, 9 Jan 2025 09:58:06 +0100
Subject: [PATCH] Corrige le partage de simulation qui ne marchait plus pour le
 budget

---
 .../BudgetSimulationSharingModal.svelte          | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/src/lib/components/BudgetSimulationSharingModal.svelte b/src/lib/components/BudgetSimulationSharingModal.svelte
index 70e165b87..4cd3d90a4 100644
--- a/src/lib/components/BudgetSimulationSharingModal.svelte
+++ b/src/lib/components/BudgetSimulationSharingModal.svelte
@@ -1,6 +1,5 @@
 <script lang="ts">
   import { Dialog } from "bits-ui"
-  import { run } from "svelte/legacy"
 
   import { copyToClipboard } from "$lib/clipboard"
   import DialogContent from "$lib/components/DialogContent.svelte"
@@ -21,10 +20,7 @@
 
   let hasClickedCopy = $state(false)
 
-  let isSimulationShared
-  run(() => {
-    isSimulationShared = shared.budgetSimulation?.isPublic
-  })
+  let isSimulationShared = $derived(shared.budgetSimulation?.isPublic)
 
   let url = $derived(
     new URL(
@@ -98,10 +94,6 @@
     }
     shared.budgetSimulation.isPublic = true
   }
-
-  function onClose() {
-    isOpen = false
-  }
 </script>
 
 <Dialog.Root bind:open={isOpen}>
@@ -128,11 +120,11 @@
             class:cursor-pointer={!isSimulationShared}
           >
             <input
-              type="checkbox"
+              checked={isSimulationShared}
               class="peer sr-only"
-              bind:checked={isSimulationShared}
-              onchange={onChange}
               disabled={isSimulationShared}
+              onchange={onChange}
+              type="checkbox"
             />
             <div
               class="peer relative h-6 w-11 rounded-full border border-le-bleu bg-le-bleu-light after:absolute after:-top-[1px] after:right-[1.2rem] after:h-6 after:w-6 after:rounded-full after:border after:border-le-bleu after:bg-white after:transition-all after:content-[''] peer-checked:border-gray-200 peer-checked:bg-gray-200 peer-checked:after:translate-x-5 peer-checked:after:border-gray-200 peer-focus:outline-none"
-- 
GitLab