academe-kit 0.11.0 → 0.11.2
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/index.cjs +14 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.esm.js +14 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/types/components/ProtectedApp/index.d.ts +7 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -9825,15 +9825,21 @@ const useProtectedAppColors = () => {
|
|
|
9825
9825
|
const context = React2.useContext(ProtectedAppContext);
|
|
9826
9826
|
return context || themes.dark.textColors;
|
|
9827
9827
|
};
|
|
9828
|
-
const ProtectedApp = ({ children, requiredClientRoles, requiredRealmRoles, theme = "dark", }) => {
|
|
9828
|
+
const ProtectedApp = ({ children, requiredClientRoles, requiredRealmRoles, theme = "dark", pending = false, }) => {
|
|
9829
9829
|
const { isInitialized, goToLogin, hasClientRole, hasRealmRole, isAuthenticated, signOut, } = useAcademeAuth();
|
|
9830
9830
|
const themeConfig = themes[theme];
|
|
9831
9831
|
const { backgroundColor, textColors } = themeConfig;
|
|
9832
9832
|
const handleContactSupport = () => {
|
|
9833
9833
|
window.open("https://wa.me/558540428133", "_blank");
|
|
9834
9834
|
};
|
|
9835
|
+
// Tela de loading de tela cheia reutilizada em duas fases do boot:
|
|
9836
|
+
// (1) enquanto o Keycloak inicializa (`!isInitialized`) e (2) enquanto o app
|
|
9837
|
+
// ainda carrega dados pós-auth (`pending`). Por ser o MESMO elemento na mesma
|
|
9838
|
+
// posição da árvore, o React reconcilia entre as fases sem remontar o Spinner
|
|
9839
|
+
// — a animação fica contínua (um loading só, sem "piscar").
|
|
9840
|
+
const loadingScreen = (jsxRuntime.jsx("div", { className: `!flex !w-screen !h-screen !items-center !justify-center ${backgroundColor}`, children: jsxRuntime.jsx(Spinner, { className: "!size-10", style: { color: "#892CDD" } }) }));
|
|
9835
9841
|
if (!isInitialized) {
|
|
9836
|
-
return
|
|
9842
|
+
return loadingScreen;
|
|
9837
9843
|
}
|
|
9838
9844
|
if (!isAuthenticated()) {
|
|
9839
9845
|
goToLogin();
|
|
@@ -9847,6 +9853,12 @@ const ProtectedApp = ({ children, requiredClientRoles, requiredRealmRoles, theme
|
|
|
9847
9853
|
!requiredRealmRoles?.some((role) => hasRealmRole(role))) {
|
|
9848
9854
|
return (jsxRuntime.jsxs("div", { className: `flex flex-col w-screen h-screen items-center justify-center ${backgroundColor}`, children: [jsxRuntime.jsx(CircleAlert, { className: `size-10 ${textColors.iconColor}` }), jsxRuntime.jsx("h1", { className: `text-2xl font-bold mt-4 text-center ${textColors.textPrimary}`, children: "Oops, voc\u00EA n\u00E3o tem permiss\u00E3o para acessar aqui." }), jsxRuntime.jsx("span", { className: `text-center ${textColors.textSecondary}`, children: "Se voc\u00EA acredita que isso \u00E9 um erro, entre em contato com o suporte." }), jsxRuntime.jsxs("div", { className: "flex gap-3 mt-4", children: [jsxRuntime.jsx(Button, { variant: "primary", size: "md", onClick: handleContactSupport, children: "Falar com o suporte" }), jsxRuntime.jsx(Button, { variant: "outline", size: "md", onClick: signOut, children: "Sair da conta" })] })] }));
|
|
9849
9855
|
}
|
|
9856
|
+
// Auth e roles OK, mas o app ainda carrega dados pós-auth (ex.: a lista de
|
|
9857
|
+
// instituições do dash). Mantém o MESMO `loadingScreen` do passo `!isInitialized`,
|
|
9858
|
+
// então o spinner não remonta entre as fases — continua sendo um loading só.
|
|
9859
|
+
if (pending) {
|
|
9860
|
+
return loadingScreen;
|
|
9861
|
+
}
|
|
9850
9862
|
return (jsxRuntime.jsx(ProtectedAppContext.Provider, { value: textColors, children: children }));
|
|
9851
9863
|
};
|
|
9852
9864
|
|