fix(ui): handle missing version in simulator state
[e-mobility-charging-stations-simulator.git] / ui / web / src / components / buttons / ToggleButton.vue
index 0c36be2292f1406096f1149fcf887b09dda966a6..6d72ba10f04a3e874f63b4757b11d14dbc2ee112 100644 (file)
@@ -17,14 +17,16 @@ const props = defineProps<{
   off?: () => void
 }>()
 
+const $emit = defineEmits(['clicked'])
+
 const id = props.shared === true ? `shared-toggle-button-${props.id}` : `toggle-button-${props.id}`
 
-const state = ref({
+const state = ref<{ status: boolean }>({
   status: getFromLocalStorage<boolean>(id, props.status ?? false)
 })
 
 const click = (): void => {
-  if (props.shared) {
+  if (props.shared === true) {
     for (const key in localStorage) {
       if (key !== id && key.startsWith('shared-toggle-button-')) {
         setToLocalStorage<boolean>(key, false)
@@ -39,11 +41,13 @@ const click = (): void => {
   } else {
     props.off?.()
   }
+  $emit('clicked', getFromLocalStorage<boolean>(id, props.status ?? false))
 }
 </script>
 
 <style>
 .on {
   background-color: lightgrey;
+  border-style: inset;
 }
 </style>