UNPKG

analytica-frontend-lib

Version:

Repositório público dos componentes utilizados nas plataformas da Analytica Ensino

53 lines (50 loc) 1.65 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/store/appStore.ts var _zustand = require('zustand'); var _middleware = require('zustand/middleware'); var useAppStore = _zustand.create.call(void 0, )( _middleware.persist.call(void 0, (set, get) => ({ institutionId: null, initialized: false, /** * Set the institution ID * @param {string | null} institutionId - The institution ID from meta tag * @returns {void} */ setInstitutionId: (institutionId) => { set({ institutionId }); }, /** * Set the initialized state * @param {boolean} initialized - Whether the app has been initialized * @returns {void} */ setInitialized: (initialized) => { set({ initialized }); }, /** * Initialize the app by reading the institution ID from meta tag. * The meta tag is the source of truth on each load: if the incoming * id differs from the persisted one (e.g. institution changed since * the last session), it overwrites the stale value. * @returns {void} */ initialize: (id) => { const { initialized, institutionId } = get(); if (initialized && institutionId === id) { return; } set({ institutionId: id, initialized: true }); } }), { name: "@app-storage:analytica:v2" /* APP_STORAGE */, storage: _middleware.createJSONStorage.call(void 0, () => localStorage) } ) ); exports.useAppStore = useAppStore; //# sourceMappingURL=chunk-MKN3J57S.js.map