diff --git a/src/lib/components/BudgetSimulationSharingModal.svelte b/src/lib/components/BudgetSimulationSharingModal.svelte index 70e165b87f61df7d05bba9484ab7511cd7653e45..4cd3d90a4d74eb45e3b28c3dd55dec6f4404ebee 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"