console.error('Error at adding charging stations:', error)
})
.finally(() => {
+ resetToggleButtonState('add-charging-stations', true)
$router.push({ name: 'charging-stations' })
})
}
import { getCurrentInstance, ref, watch } from 'vue'
import Button from '@/components/buttons/Button.vue'
-import { convertToBoolean, randomUUID } from '@/composables'
+import { convertToBoolean, randomUUID, resetToggleButtonState } from '@/composables'
const state = ref<{
autoStart: boolean
console.error('Error at setting supervision url:', error)
})
.finally(() => {
+ resetToggleButtonState(`${props.hashId}-set-supervision-url`, true)
$router.push({ name: 'charging-stations' })
})
}
import { ref } from 'vue'
import Button from '@/components/buttons/Button.vue'
+import { resetToggleButtonState } from '@/composables'
-defineProps<{
+const props = defineProps<{
chargingStationId: string
hashId: string
}>()
console.error('Error at starting transaction:', error)
})
.finally(() => {
+ resetToggleButtonState(
+ `${props.hashId}-${props.connectorId}-start-transaction`,
+ true
+ )
$router.push({ name: 'charging-stations' })
})
})
.catch((error: Error) => {
$toast.error('Error at authorizing RFID tag')
console.error('Error at authorizing RFID tag:', error)
+ resetToggleButtonState(`${props.hashId}-${props.connectorId}-start-transaction`, true)
$router.push({ name: 'charging-stations' })
})
} else {
console.error('Error at starting transaction:', error)
})
.finally(() => {
+ resetToggleButtonState(`${props.hashId}-${props.connectorId}-start-transaction`, true)
$router.push({ name: 'charging-stations' })
})
}
import { ref } from 'vue'
import Button from '@/components/buttons/Button.vue'
-import { convertToBoolean, convertToInt } from '@/composables'
+import { convertToBoolean, convertToInt, resetToggleButtonState } from '@/composables'
-defineProps<{
+const props = defineProps<{
chargingStationId: string
connectorId: string
hashId: string
return localStorage
}
+/**
+ * Resets the state of a toggle button by removing its entry from localStorage.
+ * @param id - The identifier of the toggle button
+ * @param shared - Whether the toggle button is shared
+ */
+export const resetToggleButtonState = (id: string, shared = false): void => {
+ const key = shared ? `shared-toggle-button-${id}` : `toggle-button-${id}`
+ deleteFromLocalStorage(key)
+}
+
export const randomUUID = (): `${string}-${string}-${string}-${string}-${string}` => {
return crypto.randomUUID()
}
getFromLocalStorage,
getLocalStorage,
randomUUID,
+ resetToggleButtonState,
setToLocalStorage,
useUIClient,
} from './Utils'