feat(ui): add support for multiple UI server configurations
[e-mobility-charging-stations-simulator.git] / ui / web / src / composables / Utils.ts
index 451c4155fd7a114990f28f52fb619fc4932d774d..fffd7a54966a54a2e092d4eef2a4d5360b45036b 100644 (file)
@@ -32,3 +32,12 @@ export const convertToInt = (value: unknown): number => {
   }
   return changedValue
 }
+
+export const setToLocalStorage = <T>(key: string, value: T): void => {
+  localStorage.setItem(key, JSON.stringify(value))
+}
+
+export const getFromLocalStorage = <T>(key: string, defaultValue: T): T => {
+  const item = localStorage.getItem(key)
+  return item != null ? (JSON.parse(item) as T) : defaultValue
+}