diff --git a/src/utils/index.ts b/src/utils/index.ts index cdfe8a18..7174cdcb 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -69,6 +69,23 @@ export class SessionStorageUtil { } } +export class LocalStorageStorageUtil { + static setItem(key: string, value: T) { + localStorage.setItem(key, JSON.stringify(value)); + } + + static getItem(key: string): T | undefined { + const item = localStorage.getItem(key); + if (item) { + return JSON.parse(item); + } + } + + static removeItem(key: string) { + localStorage.removeItem(key); + } +} + export const clearNebulaConnection = () => { SessionStorageUtil.removeItem('nebulaConnect'); cookies.remove('nsid');