X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=ui%2Fweb%2Fsrc%2Fcomposables%2FUtils.ts;h=fffd7a54966a54a2e092d4eef2a4d5360b45036b;hb=0344ad2b24f8b043b5848a0fea8b5a120d6781db;hp=451c4155fd7a114990f28f52fb619fc4932d774d;hpb=427a497022f0a5ff9454c618b6d3620521625923;p=e-mobility-charging-stations-simulator.git diff --git a/ui/web/src/composables/Utils.ts b/ui/web/src/composables/Utils.ts index 451c4155..fffd7a54 100644 --- a/ui/web/src/composables/Utils.ts +++ b/ui/web/src/composables/Utils.ts @@ -32,3 +32,12 @@ export const convertToInt = (value: unknown): number => { } return changedValue } + +export const setToLocalStorage = (key: string, value: T): void => { + localStorage.setItem(key, JSON.stringify(value)) +} + +export const getFromLocalStorage = (key: string, defaultValue: T): T => { + const item = localStorage.getItem(key) + return item != null ? (JSON.parse(item) as T) : defaultValue +}