analytica-frontend-lib 1.1.92 → 1.1.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BreadcrumbMenu/breadcrumbStore/index.d.mts +77 -0
- package/dist/BreadcrumbMenu/breadcrumbStore/index.d.ts +77 -0
- package/dist/BreadcrumbMenu/breadcrumbStore/index.js +146 -0
- package/dist/BreadcrumbMenu/breadcrumbStore/index.js.map +1 -0
- package/dist/BreadcrumbMenu/breadcrumbStore/index.mjs +120 -0
- package/dist/BreadcrumbMenu/breadcrumbStore/index.mjs.map +1 -0
- package/dist/BreadcrumbMenu/index.d.mts +31 -0
- package/dist/BreadcrumbMenu/index.d.ts +31 -0
- package/dist/BreadcrumbMenu/index.js +308 -0
- package/dist/BreadcrumbMenu/index.js.map +1 -0
- package/dist/BreadcrumbMenu/index.mjs +289 -0
- package/dist/BreadcrumbMenu/index.mjs.map +1 -0
- package/dist/BreadcrumbMenu/useBreadcrumbBuilder/index.d.mts +48 -0
- package/dist/BreadcrumbMenu/useBreadcrumbBuilder/index.d.ts +48 -0
- package/dist/BreadcrumbMenu/useBreadcrumbBuilder/index.js +189 -0
- package/dist/BreadcrumbMenu/useBreadcrumbBuilder/index.js.map +1 -0
- package/dist/BreadcrumbMenu/useBreadcrumbBuilder/index.mjs +164 -0
- package/dist/BreadcrumbMenu/useBreadcrumbBuilder/index.mjs.map +1 -0
- package/dist/BreadcrumbMenu/useUrlParams/index.d.mts +28 -0
- package/dist/BreadcrumbMenu/useUrlParams/index.d.ts +28 -0
- package/dist/BreadcrumbMenu/useUrlParams/index.js +43 -0
- package/dist/BreadcrumbMenu/useUrlParams/index.js.map +1 -0
- package/dist/BreadcrumbMenu/useUrlParams/index.mjs +18 -0
- package/dist/BreadcrumbMenu/useUrlParams/index.mjs.map +1 -0
- package/dist/index.css +3 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +185 -3
- package/dist/index.d.ts +185 -3
- package/dist/index.js +546 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +537 -6
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +3 -0
- package/dist/styles.css.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -36,6 +36,7 @@ __export(src_exports, {
|
|
|
36
36
|
AlternativesList: () => AlternativesList,
|
|
37
37
|
AuthProvider: () => AuthProvider,
|
|
38
38
|
Badge: () => Badge_default,
|
|
39
|
+
BreadcrumbMenu: () => BreadcrumbMenu,
|
|
39
40
|
Button: () => Button_default,
|
|
40
41
|
Calendar: () => Calendar_default,
|
|
41
42
|
CardAccordation: () => CardAccordation,
|
|
@@ -155,8 +156,15 @@ __export(src_exports, {
|
|
|
155
156
|
getSubjectName: () => getSubjectName,
|
|
156
157
|
syncDropdownState: () => syncDropdownState,
|
|
157
158
|
useApiConfig: () => useApiConfig,
|
|
159
|
+
useAppContent: () => useAppContent,
|
|
160
|
+
useAppInitialization: () => useAppInitialization,
|
|
161
|
+
useAppStore: () => useAppStore,
|
|
158
162
|
useAuth: () => useAuth,
|
|
159
163
|
useAuthGuard: () => useAuthGuard,
|
|
164
|
+
useAuthStore: () => useAuthStore,
|
|
165
|
+
useBreadcrumb: () => useBreadcrumb,
|
|
166
|
+
useBreadcrumbBuilder: () => useBreadcrumbBuilder,
|
|
167
|
+
useInstitutionId: () => useInstitutionId,
|
|
160
168
|
useMobile: () => useMobile,
|
|
161
169
|
useQuizStore: () => useQuizStore,
|
|
162
170
|
useRouteAuth: () => useRouteAuth,
|
|
@@ -164,6 +172,7 @@ __export(src_exports, {
|
|
|
164
172
|
useThemeStore: () => useThemeStore,
|
|
165
173
|
useToastStore: () => ToastStore_default,
|
|
166
174
|
useUrlAuthentication: () => useUrlAuthentication,
|
|
175
|
+
useUrlParams: () => useUrlParams,
|
|
167
176
|
withAuth: () => withAuth
|
|
168
177
|
});
|
|
169
178
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -9926,7 +9935,7 @@ var HeaderAlternative = (0, import_react31.forwardRef)(
|
|
|
9926
9935
|
);
|
|
9927
9936
|
|
|
9928
9937
|
// src/components/Auth/zustandAuthAdapter.ts
|
|
9929
|
-
function createZustandAuthAdapter(
|
|
9938
|
+
function createZustandAuthAdapter(useAuthStore2) {
|
|
9930
9939
|
return {
|
|
9931
9940
|
/**
|
|
9932
9941
|
* Check if the user is authenticated based on sessionInfo and tokens
|
|
@@ -9934,7 +9943,7 @@ function createZustandAuthAdapter(useAuthStore) {
|
|
|
9934
9943
|
* @returns {Promise<boolean>} Promise that resolves to authentication status
|
|
9935
9944
|
*/
|
|
9936
9945
|
checkAuth: async () => {
|
|
9937
|
-
const { sessionInfo, tokens } =
|
|
9946
|
+
const { sessionInfo, tokens } = useAuthStore2.getState();
|
|
9938
9947
|
return Boolean(sessionInfo && tokens);
|
|
9939
9948
|
},
|
|
9940
9949
|
/**
|
|
@@ -9942,26 +9951,26 @@ function createZustandAuthAdapter(useAuthStore) {
|
|
|
9942
9951
|
*
|
|
9943
9952
|
* @returns {unknown} Current user data from the store
|
|
9944
9953
|
*/
|
|
9945
|
-
getUser: () =>
|
|
9954
|
+
getUser: () => useAuthStore2.getState().user,
|
|
9946
9955
|
/**
|
|
9947
9956
|
* Get the current session information from the store
|
|
9948
9957
|
*
|
|
9949
9958
|
* @returns {unknown} Current session info from the store
|
|
9950
9959
|
*/
|
|
9951
|
-
getSessionInfo: () =>
|
|
9960
|
+
getSessionInfo: () => useAuthStore2.getState().sessionInfo,
|
|
9952
9961
|
/**
|
|
9953
9962
|
* Get the current authentication tokens from the store
|
|
9954
9963
|
*
|
|
9955
9964
|
* @returns {unknown} Current tokens from the store
|
|
9956
9965
|
*/
|
|
9957
|
-
getTokens: () =>
|
|
9966
|
+
getTokens: () => useAuthStore2.getState().tokens,
|
|
9958
9967
|
/**
|
|
9959
9968
|
* Sign out the user by calling the store's signOut function if available
|
|
9960
9969
|
*
|
|
9961
9970
|
* @returns {void}
|
|
9962
9971
|
*/
|
|
9963
9972
|
signOut: () => {
|
|
9964
|
-
const signOutFn =
|
|
9973
|
+
const signOutFn = useAuthStore2.getState().signOut;
|
|
9965
9974
|
if (typeof signOutFn === "function") signOutFn();
|
|
9966
9975
|
}
|
|
9967
9976
|
};
|
|
@@ -12514,6 +12523,528 @@ var QuizListResultByMateria = ({
|
|
|
12514
12523
|
] })
|
|
12515
12524
|
] });
|
|
12516
12525
|
};
|
|
12526
|
+
|
|
12527
|
+
// src/components/BreadcrumbMenu/BreadcrumbMenu.tsx
|
|
12528
|
+
var import_react_router_dom3 = require("react-router-dom");
|
|
12529
|
+
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
12530
|
+
var BreadcrumbMenu = ({
|
|
12531
|
+
breadcrumbs,
|
|
12532
|
+
onBreadcrumbClick,
|
|
12533
|
+
className = "!px-0 py-4 flex-wrap w-full"
|
|
12534
|
+
}) => {
|
|
12535
|
+
const navigate = (0, import_react_router_dom3.useNavigate)();
|
|
12536
|
+
const handleClick = (breadcrumb, index) => {
|
|
12537
|
+
if (onBreadcrumbClick) {
|
|
12538
|
+
onBreadcrumbClick(breadcrumb, index);
|
|
12539
|
+
}
|
|
12540
|
+
navigate(breadcrumb.url);
|
|
12541
|
+
};
|
|
12542
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
12543
|
+
Menu,
|
|
12544
|
+
{
|
|
12545
|
+
value: `breadcrumb-${breadcrumbs.length - 1}`,
|
|
12546
|
+
defaultValue: "breadcrumb-0",
|
|
12547
|
+
variant: "breadcrumb",
|
|
12548
|
+
className,
|
|
12549
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(MenuContent, { className: "w-full flex flex-row flex-wrap gap-2 !px-0", children: breadcrumbs.map((breadcrumb, index) => {
|
|
12550
|
+
const isLast = index === breadcrumbs.length - 1;
|
|
12551
|
+
const hasSeparator = !isLast;
|
|
12552
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
12553
|
+
MenuItem,
|
|
12554
|
+
{
|
|
12555
|
+
variant: "breadcrumb",
|
|
12556
|
+
value: `breadcrumb-${index}`,
|
|
12557
|
+
className: "!p-0 whitespace-nowrap",
|
|
12558
|
+
onClick: () => handleClick(breadcrumb, index),
|
|
12559
|
+
separator: hasSeparator,
|
|
12560
|
+
children: breadcrumb.name
|
|
12561
|
+
},
|
|
12562
|
+
breadcrumb.id
|
|
12563
|
+
);
|
|
12564
|
+
}) })
|
|
12565
|
+
}
|
|
12566
|
+
);
|
|
12567
|
+
};
|
|
12568
|
+
|
|
12569
|
+
// src/components/BreadcrumbMenu/useBreadcrumbBuilder.ts
|
|
12570
|
+
var import_react38 = require("react");
|
|
12571
|
+
|
|
12572
|
+
// src/components/BreadcrumbMenu/breadcrumbStore.ts
|
|
12573
|
+
var import_zustand10 = require("zustand");
|
|
12574
|
+
var useBreadcrumbStore = (0, import_zustand10.create)((set, get) => ({
|
|
12575
|
+
breadcrumbs: {},
|
|
12576
|
+
setBreadcrumbs: (namespace, items) => {
|
|
12577
|
+
set((state) => ({
|
|
12578
|
+
breadcrumbs: {
|
|
12579
|
+
...state.breadcrumbs,
|
|
12580
|
+
[namespace]: items
|
|
12581
|
+
}
|
|
12582
|
+
}));
|
|
12583
|
+
},
|
|
12584
|
+
addBreadcrumb: (namespace, item) => {
|
|
12585
|
+
set((state) => {
|
|
12586
|
+
const current = state.breadcrumbs[namespace] || [];
|
|
12587
|
+
return {
|
|
12588
|
+
breadcrumbs: {
|
|
12589
|
+
...state.breadcrumbs,
|
|
12590
|
+
[namespace]: [...current, item]
|
|
12591
|
+
}
|
|
12592
|
+
};
|
|
12593
|
+
});
|
|
12594
|
+
},
|
|
12595
|
+
updateBreadcrumb: (namespace, itemId, updates) => {
|
|
12596
|
+
set((state) => {
|
|
12597
|
+
const current = state.breadcrumbs[namespace] || [];
|
|
12598
|
+
return {
|
|
12599
|
+
breadcrumbs: {
|
|
12600
|
+
...state.breadcrumbs,
|
|
12601
|
+
[namespace]: current.map(
|
|
12602
|
+
(item) => item.id === itemId ? { ...item, ...updates } : item
|
|
12603
|
+
)
|
|
12604
|
+
}
|
|
12605
|
+
};
|
|
12606
|
+
});
|
|
12607
|
+
},
|
|
12608
|
+
removeBreadcrumbFrom: (namespace, itemId) => {
|
|
12609
|
+
set((state) => {
|
|
12610
|
+
const current = state.breadcrumbs[namespace] || [];
|
|
12611
|
+
const index = current.findIndex((item) => item.id === itemId);
|
|
12612
|
+
if (index === -1) return state;
|
|
12613
|
+
return {
|
|
12614
|
+
breadcrumbs: {
|
|
12615
|
+
...state.breadcrumbs,
|
|
12616
|
+
[namespace]: current.slice(0, index)
|
|
12617
|
+
}
|
|
12618
|
+
};
|
|
12619
|
+
});
|
|
12620
|
+
},
|
|
12621
|
+
sliceBreadcrumbs: (namespace, index) => {
|
|
12622
|
+
set((state) => {
|
|
12623
|
+
const current = state.breadcrumbs[namespace] || [];
|
|
12624
|
+
return {
|
|
12625
|
+
breadcrumbs: {
|
|
12626
|
+
...state.breadcrumbs,
|
|
12627
|
+
[namespace]: current.slice(0, index + 1)
|
|
12628
|
+
}
|
|
12629
|
+
};
|
|
12630
|
+
});
|
|
12631
|
+
},
|
|
12632
|
+
clearBreadcrumbs: (namespace) => {
|
|
12633
|
+
set((state) => {
|
|
12634
|
+
const { [namespace]: _, ...rest } = state.breadcrumbs;
|
|
12635
|
+
return {
|
|
12636
|
+
breadcrumbs: rest
|
|
12637
|
+
};
|
|
12638
|
+
});
|
|
12639
|
+
},
|
|
12640
|
+
getBreadcrumbs: (namespace) => {
|
|
12641
|
+
return get().breadcrumbs[namespace] || [];
|
|
12642
|
+
}
|
|
12643
|
+
}));
|
|
12644
|
+
var useBreadcrumb = (namespace) => {
|
|
12645
|
+
const store = useBreadcrumbStore();
|
|
12646
|
+
const breadcrumbs = store.breadcrumbs[namespace] || [];
|
|
12647
|
+
return {
|
|
12648
|
+
breadcrumbs,
|
|
12649
|
+
/**
|
|
12650
|
+
* Define todos os breadcrumbs de uma vez
|
|
12651
|
+
*/
|
|
12652
|
+
setBreadcrumbs: (items) => {
|
|
12653
|
+
store.setBreadcrumbs(namespace, items);
|
|
12654
|
+
},
|
|
12655
|
+
/**
|
|
12656
|
+
* Adiciona um novo breadcrumb ao final
|
|
12657
|
+
*/
|
|
12658
|
+
addBreadcrumb: (item) => {
|
|
12659
|
+
store.addBreadcrumb(namespace, item);
|
|
12660
|
+
},
|
|
12661
|
+
/**
|
|
12662
|
+
* Atualiza um breadcrumb existente
|
|
12663
|
+
*/
|
|
12664
|
+
updateBreadcrumb: (itemId, updates) => {
|
|
12665
|
+
store.updateBreadcrumb(namespace, itemId, updates);
|
|
12666
|
+
},
|
|
12667
|
+
/**
|
|
12668
|
+
* Remove um breadcrumb e todos os seguintes
|
|
12669
|
+
*/
|
|
12670
|
+
removeBreadcrumbFrom: (itemId) => {
|
|
12671
|
+
store.removeBreadcrumbFrom(namespace, itemId);
|
|
12672
|
+
},
|
|
12673
|
+
/**
|
|
12674
|
+
* Mantém apenas os breadcrumbs até o índice especificado (inclusivo)
|
|
12675
|
+
*/
|
|
12676
|
+
sliceBreadcrumbs: (index) => {
|
|
12677
|
+
store.sliceBreadcrumbs(namespace, index);
|
|
12678
|
+
},
|
|
12679
|
+
/**
|
|
12680
|
+
* Limpa todos os breadcrumbs
|
|
12681
|
+
*/
|
|
12682
|
+
clearBreadcrumbs: () => {
|
|
12683
|
+
store.clearBreadcrumbs(namespace);
|
|
12684
|
+
}
|
|
12685
|
+
};
|
|
12686
|
+
};
|
|
12687
|
+
|
|
12688
|
+
// src/components/BreadcrumbMenu/useBreadcrumbBuilder.ts
|
|
12689
|
+
var isBreadcrumbWithData = (level) => {
|
|
12690
|
+
return "data" in level;
|
|
12691
|
+
};
|
|
12692
|
+
var useBreadcrumbBuilder = (config) => {
|
|
12693
|
+
const { namespace, root, levels } = config;
|
|
12694
|
+
const { breadcrumbs, setBreadcrumbs, sliceBreadcrumbs } = useBreadcrumb(namespace);
|
|
12695
|
+
const levelDependencies = levels.map(
|
|
12696
|
+
(level) => isBreadcrumbWithData(level) ? level.data : null
|
|
12697
|
+
);
|
|
12698
|
+
const levelUrlIds = levels.map((level) => level.urlId);
|
|
12699
|
+
(0, import_react38.useEffect)(() => {
|
|
12700
|
+
const newBreadcrumbs = [root];
|
|
12701
|
+
const previousIds = [];
|
|
12702
|
+
for (const level of levels) {
|
|
12703
|
+
const { urlId } = level;
|
|
12704
|
+
if (isBreadcrumbWithData(level)) {
|
|
12705
|
+
const { data, getId, getName, getUrl } = level;
|
|
12706
|
+
if (!data) break;
|
|
12707
|
+
const dataId = getId(data);
|
|
12708
|
+
if (urlId === void 0 || dataId !== urlId) break;
|
|
12709
|
+
newBreadcrumbs.push({
|
|
12710
|
+
id: dataId,
|
|
12711
|
+
name: getName(data),
|
|
12712
|
+
url: getUrl(data, previousIds)
|
|
12713
|
+
});
|
|
12714
|
+
previousIds.push(dataId);
|
|
12715
|
+
} else {
|
|
12716
|
+
const { breadcrumb } = level;
|
|
12717
|
+
if (urlId === void 0) break;
|
|
12718
|
+
newBreadcrumbs.push(breadcrumb);
|
|
12719
|
+
previousIds.push(breadcrumb.id);
|
|
12720
|
+
}
|
|
12721
|
+
}
|
|
12722
|
+
setBreadcrumbs(newBreadcrumbs);
|
|
12723
|
+
}, [namespace, ...levelDependencies, ...levelUrlIds, root.id]);
|
|
12724
|
+
return {
|
|
12725
|
+
breadcrumbs,
|
|
12726
|
+
sliceBreadcrumbs
|
|
12727
|
+
};
|
|
12728
|
+
};
|
|
12729
|
+
|
|
12730
|
+
// src/components/BreadcrumbMenu/useUrlParams.ts
|
|
12731
|
+
var import_react39 = require("react");
|
|
12732
|
+
var import_react_router_dom4 = require("react-router-dom");
|
|
12733
|
+
var useUrlParams = (config) => {
|
|
12734
|
+
const location = (0, import_react_router_dom4.useLocation)();
|
|
12735
|
+
return (0, import_react39.useMemo)(() => {
|
|
12736
|
+
const segments = location.pathname.split("/").filter(Boolean);
|
|
12737
|
+
const params = {};
|
|
12738
|
+
for (const [key, index] of Object.entries(config)) {
|
|
12739
|
+
params[key] = segments[index];
|
|
12740
|
+
}
|
|
12741
|
+
return params;
|
|
12742
|
+
}, [location.pathname, config]);
|
|
12743
|
+
};
|
|
12744
|
+
|
|
12745
|
+
// src/hooks/useAppInitialization.ts
|
|
12746
|
+
var import_react41 = require("react");
|
|
12747
|
+
|
|
12748
|
+
// src/hooks/useInstitution.ts
|
|
12749
|
+
var import_react40 = require("react");
|
|
12750
|
+
function useInstitutionId() {
|
|
12751
|
+
const [institutionId, setInstitutionId] = (0, import_react40.useState)(() => {
|
|
12752
|
+
return document.querySelector('meta[name="institution-id"]')?.getAttribute("content") ?? null;
|
|
12753
|
+
});
|
|
12754
|
+
(0, import_react40.useEffect)(() => {
|
|
12755
|
+
const metaTag = document.querySelector('meta[name="institution-id"]');
|
|
12756
|
+
if (!metaTag) return;
|
|
12757
|
+
const observer = new MutationObserver(() => {
|
|
12758
|
+
const newValue = metaTag.getAttribute("content");
|
|
12759
|
+
setInstitutionId(newValue);
|
|
12760
|
+
});
|
|
12761
|
+
observer.observe(metaTag, {
|
|
12762
|
+
attributes: true,
|
|
12763
|
+
attributeFilter: ["content"]
|
|
12764
|
+
});
|
|
12765
|
+
return () => observer.disconnect();
|
|
12766
|
+
}, []);
|
|
12767
|
+
return institutionId;
|
|
12768
|
+
}
|
|
12769
|
+
|
|
12770
|
+
// src/store/appStore.ts
|
|
12771
|
+
var import_zustand11 = require("zustand");
|
|
12772
|
+
var import_middleware4 = require("zustand/middleware");
|
|
12773
|
+
var useAppStore = (0, import_zustand11.create)()(
|
|
12774
|
+
(0, import_middleware4.persist)(
|
|
12775
|
+
(set, get) => ({
|
|
12776
|
+
institutionId: null,
|
|
12777
|
+
initialized: false,
|
|
12778
|
+
/**
|
|
12779
|
+
* Set the institution ID
|
|
12780
|
+
* @param {string | null} institutionId - The institution ID from meta tag
|
|
12781
|
+
* @returns {void}
|
|
12782
|
+
*/
|
|
12783
|
+
setInstitutionId: (institutionId) => {
|
|
12784
|
+
set({ institutionId });
|
|
12785
|
+
},
|
|
12786
|
+
/**
|
|
12787
|
+
* Set the initialized state
|
|
12788
|
+
* @param {boolean} initialized - Whether the app has been initialized
|
|
12789
|
+
* @returns {void}
|
|
12790
|
+
*/
|
|
12791
|
+
setInitialized: (initialized) => {
|
|
12792
|
+
set({ initialized });
|
|
12793
|
+
},
|
|
12794
|
+
/**
|
|
12795
|
+
* Initialize the app by reading the institution ID from meta tag
|
|
12796
|
+
* @returns {void}
|
|
12797
|
+
*/
|
|
12798
|
+
initialize: (id) => {
|
|
12799
|
+
const { initialized } = get();
|
|
12800
|
+
if (initialized) {
|
|
12801
|
+
return;
|
|
12802
|
+
}
|
|
12803
|
+
set({
|
|
12804
|
+
institutionId: id,
|
|
12805
|
+
initialized: true
|
|
12806
|
+
});
|
|
12807
|
+
}
|
|
12808
|
+
}),
|
|
12809
|
+
{
|
|
12810
|
+
name: "@app-storage:analytica:v2" /* APP_STORAGE */,
|
|
12811
|
+
storage: (0, import_middleware4.createJSONStorage)(() => localStorage)
|
|
12812
|
+
}
|
|
12813
|
+
)
|
|
12814
|
+
);
|
|
12815
|
+
|
|
12816
|
+
// src/store/authStore.ts
|
|
12817
|
+
var import_zustand12 = require("zustand");
|
|
12818
|
+
var import_middleware5 = require("zustand/middleware");
|
|
12819
|
+
var useAuthStore = (0, import_zustand12.create)()(
|
|
12820
|
+
(0, import_middleware5.persist)(
|
|
12821
|
+
(set, get) => ({
|
|
12822
|
+
user: null,
|
|
12823
|
+
tokens: null,
|
|
12824
|
+
isAuthenticated: false,
|
|
12825
|
+
profiles: [],
|
|
12826
|
+
selectedProfile: null,
|
|
12827
|
+
sessionInfo: null,
|
|
12828
|
+
/**
|
|
12829
|
+
* Set the current user
|
|
12830
|
+
* @param {User | null} user - The user object or null to clear
|
|
12831
|
+
* @returns {void}
|
|
12832
|
+
*/
|
|
12833
|
+
setUser: (user) => {
|
|
12834
|
+
set({ user, isAuthenticated: !!user });
|
|
12835
|
+
},
|
|
12836
|
+
/**
|
|
12837
|
+
* Set the authentication tokens
|
|
12838
|
+
* @param {AuthTokens | null} tokens - The authentication tokens or null to clear
|
|
12839
|
+
* @returns {void}
|
|
12840
|
+
*/
|
|
12841
|
+
setTokens: (tokens) => {
|
|
12842
|
+
set({ tokens });
|
|
12843
|
+
},
|
|
12844
|
+
/**
|
|
12845
|
+
* Set user profiles
|
|
12846
|
+
* @param {UserProfile[]} profiles - Array of user profiles
|
|
12847
|
+
* @returns {void}
|
|
12848
|
+
*/
|
|
12849
|
+
setProfiles: (profiles) => {
|
|
12850
|
+
set({ profiles });
|
|
12851
|
+
},
|
|
12852
|
+
/**
|
|
12853
|
+
* Set the selected profile
|
|
12854
|
+
* @param {UserProfile | null} profile - The selected profile or null to clear
|
|
12855
|
+
* @returns {void}
|
|
12856
|
+
*/
|
|
12857
|
+
setSelectedProfile: (profile) => {
|
|
12858
|
+
set({ selectedProfile: profile });
|
|
12859
|
+
},
|
|
12860
|
+
/**
|
|
12861
|
+
* Set the session info
|
|
12862
|
+
* @param {SessionInfo | null} sessionInfo - The session info or null to clear
|
|
12863
|
+
* @returns {void}
|
|
12864
|
+
*/
|
|
12865
|
+
setSessionInfo: (sessionInfo) => {
|
|
12866
|
+
set({ sessionInfo });
|
|
12867
|
+
},
|
|
12868
|
+
/**
|
|
12869
|
+
* Sign in user with complete auth data
|
|
12870
|
+
* @param {User} user - The user object
|
|
12871
|
+
* @param {AuthTokens} tokens - The authentication tokens
|
|
12872
|
+
* @param {UserProfile[]} profiles - Array of user profiles
|
|
12873
|
+
* @returns {void}
|
|
12874
|
+
*/
|
|
12875
|
+
signIn: (user, tokens, profiles) => {
|
|
12876
|
+
set({
|
|
12877
|
+
user,
|
|
12878
|
+
tokens,
|
|
12879
|
+
profiles,
|
|
12880
|
+
isAuthenticated: true
|
|
12881
|
+
});
|
|
12882
|
+
},
|
|
12883
|
+
/**
|
|
12884
|
+
* Sign out user and clear all auth data
|
|
12885
|
+
* @returns {void}
|
|
12886
|
+
*/
|
|
12887
|
+
signOut: () => {
|
|
12888
|
+
set({
|
|
12889
|
+
user: null,
|
|
12890
|
+
tokens: null,
|
|
12891
|
+
isAuthenticated: false,
|
|
12892
|
+
profiles: [],
|
|
12893
|
+
selectedProfile: null,
|
|
12894
|
+
sessionInfo: null
|
|
12895
|
+
});
|
|
12896
|
+
},
|
|
12897
|
+
/**
|
|
12898
|
+
* Update user session data (after login completion)
|
|
12899
|
+
* @param {Partial<User>} sessionData - Partial user data to update
|
|
12900
|
+
* @returns {void}
|
|
12901
|
+
*/
|
|
12902
|
+
updateUserSession: (sessionData) => {
|
|
12903
|
+
const { user } = get();
|
|
12904
|
+
if (user) {
|
|
12905
|
+
const updatedUser = { ...user, ...sessionData };
|
|
12906
|
+
set({ user: updatedUser });
|
|
12907
|
+
}
|
|
12908
|
+
}
|
|
12909
|
+
}),
|
|
12910
|
+
{
|
|
12911
|
+
name: "@auth-storage:analytica:v2" /* AUTH_STORAGE */,
|
|
12912
|
+
storage: (0, import_middleware5.createJSONStorage)(() => localStorage)
|
|
12913
|
+
}
|
|
12914
|
+
)
|
|
12915
|
+
);
|
|
12916
|
+
|
|
12917
|
+
// src/hooks/useAppInitialization.ts
|
|
12918
|
+
function useAppInitialization() {
|
|
12919
|
+
const getInstitutionId = useInstitutionId();
|
|
12920
|
+
const { initialize, initialized, institutionId } = useAppStore();
|
|
12921
|
+
const authFunctions = (0, import_react41.useMemo)(
|
|
12922
|
+
() => ({
|
|
12923
|
+
checkAuth: async () => {
|
|
12924
|
+
const { sessionInfo, tokens } = useAuthStore.getState();
|
|
12925
|
+
return Boolean(sessionInfo && tokens);
|
|
12926
|
+
},
|
|
12927
|
+
signOut: () => {
|
|
12928
|
+
const { signOut } = useAuthStore.getState();
|
|
12929
|
+
signOut();
|
|
12930
|
+
},
|
|
12931
|
+
getUser: () => {
|
|
12932
|
+
const { user } = useAuthStore.getState();
|
|
12933
|
+
return user;
|
|
12934
|
+
},
|
|
12935
|
+
getSessionInfo: () => {
|
|
12936
|
+
const { sessionInfo } = useAuthStore.getState();
|
|
12937
|
+
return sessionInfo;
|
|
12938
|
+
},
|
|
12939
|
+
getTokens: () => {
|
|
12940
|
+
const { tokens } = useAuthStore.getState();
|
|
12941
|
+
return tokens;
|
|
12942
|
+
}
|
|
12943
|
+
}),
|
|
12944
|
+
[]
|
|
12945
|
+
);
|
|
12946
|
+
return {
|
|
12947
|
+
// Estado da inicialização
|
|
12948
|
+
getInstitutionId,
|
|
12949
|
+
initialize,
|
|
12950
|
+
initialized,
|
|
12951
|
+
institutionId,
|
|
12952
|
+
// Funções de autenticação
|
|
12953
|
+
authFunctions
|
|
12954
|
+
};
|
|
12955
|
+
}
|
|
12956
|
+
|
|
12957
|
+
// src/hooks/useAppContent.ts
|
|
12958
|
+
var import_react42 = require("react");
|
|
12959
|
+
var import_react_router_dom5 = require("react-router-dom");
|
|
12960
|
+
function useAppContent(config) {
|
|
12961
|
+
const navigate = (0, import_react_router_dom5.useNavigate)();
|
|
12962
|
+
const { setTokens, setSessionInfo, setSelectedProfile } = useAuthStore();
|
|
12963
|
+
const {
|
|
12964
|
+
api,
|
|
12965
|
+
getInstitutionId,
|
|
12966
|
+
initialize,
|
|
12967
|
+
initialized,
|
|
12968
|
+
endpoint = "/auth/session-info",
|
|
12969
|
+
maxRetries = 1,
|
|
12970
|
+
retryDelay = 2e3,
|
|
12971
|
+
onClearParamsFromURL,
|
|
12972
|
+
onError,
|
|
12973
|
+
onNotFoundNavigation
|
|
12974
|
+
} = config;
|
|
12975
|
+
const apiConfig = useApiConfig(api);
|
|
12976
|
+
useTheme();
|
|
12977
|
+
const handleNotFoundNavigation = () => {
|
|
12978
|
+
if (onNotFoundNavigation) {
|
|
12979
|
+
onNotFoundNavigation();
|
|
12980
|
+
} else {
|
|
12981
|
+
navigate("/painel");
|
|
12982
|
+
}
|
|
12983
|
+
};
|
|
12984
|
+
const handleSetSelectedProfile = (0, import_react42.useCallback)(
|
|
12985
|
+
(profile) => {
|
|
12986
|
+
setSelectedProfile(profile);
|
|
12987
|
+
},
|
|
12988
|
+
[setSelectedProfile]
|
|
12989
|
+
);
|
|
12990
|
+
const handleClearParamsFromURL = (0, import_react42.useCallback)(() => {
|
|
12991
|
+
if (onClearParamsFromURL) {
|
|
12992
|
+
onClearParamsFromURL();
|
|
12993
|
+
} else {
|
|
12994
|
+
globalThis.location.replace("/painel");
|
|
12995
|
+
}
|
|
12996
|
+
}, [onClearParamsFromURL]);
|
|
12997
|
+
const handleError = (0, import_react42.useCallback)(
|
|
12998
|
+
(error) => {
|
|
12999
|
+
if (onError) {
|
|
13000
|
+
onError(error);
|
|
13001
|
+
} else {
|
|
13002
|
+
console.error("Erro ao obter informa\xE7\xF5es da sess\xE3o:", error);
|
|
13003
|
+
navigate("/", { replace: true });
|
|
13004
|
+
}
|
|
13005
|
+
},
|
|
13006
|
+
[navigate, onError]
|
|
13007
|
+
);
|
|
13008
|
+
const urlAuthConfig = (0, import_react42.useMemo)(
|
|
13009
|
+
() => ({
|
|
13010
|
+
setTokens,
|
|
13011
|
+
setSessionInfo,
|
|
13012
|
+
setSelectedProfile: handleSetSelectedProfile,
|
|
13013
|
+
api: apiConfig,
|
|
13014
|
+
endpoint,
|
|
13015
|
+
clearParamsFromURL: handleClearParamsFromURL,
|
|
13016
|
+
maxRetries,
|
|
13017
|
+
retryDelay,
|
|
13018
|
+
onError: handleError
|
|
13019
|
+
}),
|
|
13020
|
+
[
|
|
13021
|
+
setTokens,
|
|
13022
|
+
setSessionInfo,
|
|
13023
|
+
handleSetSelectedProfile,
|
|
13024
|
+
apiConfig,
|
|
13025
|
+
endpoint,
|
|
13026
|
+
handleClearParamsFromURL,
|
|
13027
|
+
maxRetries,
|
|
13028
|
+
retryDelay,
|
|
13029
|
+
handleError
|
|
13030
|
+
]
|
|
13031
|
+
);
|
|
13032
|
+
useUrlAuthentication(urlAuthConfig);
|
|
13033
|
+
const { sessionInfo } = useAuth();
|
|
13034
|
+
const institutionIdToUse = (0, import_react42.useMemo)(() => {
|
|
13035
|
+
return sessionInfo?.institutionId || getInstitutionId;
|
|
13036
|
+
}, [sessionInfo?.institutionId, getInstitutionId]);
|
|
13037
|
+
(0, import_react42.useEffect)(() => {
|
|
13038
|
+
if (institutionIdToUse && !initialized) {
|
|
13039
|
+
initialize(institutionIdToUse);
|
|
13040
|
+
}
|
|
13041
|
+
}, [institutionIdToUse, initialize, initialized]);
|
|
13042
|
+
return {
|
|
13043
|
+
handleNotFoundNavigation,
|
|
13044
|
+
urlAuthConfig,
|
|
13045
|
+
institutionIdToUse
|
|
13046
|
+
};
|
|
13047
|
+
}
|
|
12517
13048
|
// Annotate the CommonJS export names for ESM import in node:
|
|
12518
13049
|
0 && (module.exports = {
|
|
12519
13050
|
ANSWER_STATUS,
|
|
@@ -12522,6 +13053,7 @@ var QuizListResultByMateria = ({
|
|
|
12522
13053
|
AlternativesList,
|
|
12523
13054
|
AuthProvider,
|
|
12524
13055
|
Badge,
|
|
13056
|
+
BreadcrumbMenu,
|
|
12525
13057
|
Button,
|
|
12526
13058
|
Calendar,
|
|
12527
13059
|
CardAccordation,
|
|
@@ -12641,8 +13173,15 @@ var QuizListResultByMateria = ({
|
|
|
12641
13173
|
getSubjectName,
|
|
12642
13174
|
syncDropdownState,
|
|
12643
13175
|
useApiConfig,
|
|
13176
|
+
useAppContent,
|
|
13177
|
+
useAppInitialization,
|
|
13178
|
+
useAppStore,
|
|
12644
13179
|
useAuth,
|
|
12645
13180
|
useAuthGuard,
|
|
13181
|
+
useAuthStore,
|
|
13182
|
+
useBreadcrumb,
|
|
13183
|
+
useBreadcrumbBuilder,
|
|
13184
|
+
useInstitutionId,
|
|
12646
13185
|
useMobile,
|
|
12647
13186
|
useQuizStore,
|
|
12648
13187
|
useRouteAuth,
|
|
@@ -12650,6 +13189,7 @@ var QuizListResultByMateria = ({
|
|
|
12650
13189
|
useThemeStore,
|
|
12651
13190
|
useToastStore,
|
|
12652
13191
|
useUrlAuthentication,
|
|
13192
|
+
useUrlParams,
|
|
12653
13193
|
withAuth
|
|
12654
13194
|
});
|
|
12655
13195
|
//# sourceMappingURL=index.js.map
|