@ssplib/react-components 0.0.83 → 0.0.84
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export default function NavBar({ links, title, img, pos, next, el, menuItems, }: {
|
|
2
|
+
export default function NavBar({ links, title, img, pos, next, el, menuItems, logoutMsg, logoutURL, }: {
|
|
3
3
|
links: {
|
|
4
4
|
name: string;
|
|
5
5
|
path: string;
|
|
@@ -9,5 +9,7 @@ export default function NavBar({ links, title, img, pos, next, el, menuItems, }:
|
|
|
9
9
|
menuItems: JSX.Element | JSX.Element[];
|
|
10
10
|
next?: boolean;
|
|
11
11
|
el?: JSX.Element;
|
|
12
|
+
logoutMsg?: string;
|
|
13
|
+
logoutURL?: string;
|
|
12
14
|
pos?: 'fixed' | 'inherit';
|
|
13
15
|
}): JSX.Element;
|
|
@@ -37,7 +37,7 @@ const link_1 = __importDefault(require("next/link"));
|
|
|
37
37
|
const router_1 = require("next/router");
|
|
38
38
|
const react_1 = __importStar(require("react"));
|
|
39
39
|
const auth_1 = require("../../context/auth");
|
|
40
|
-
function NavBar({ links, title, img, pos = 'fixed', next = true, el, menuItems, }) {
|
|
40
|
+
function NavBar({ links, title, img, pos = 'fixed', next = true, el, menuItems, logoutMsg = 'Sair', logoutURL = '/', }) {
|
|
41
41
|
let router = undefined;
|
|
42
42
|
if (next)
|
|
43
43
|
router = (0, router_1.useRouter)();
|
|
@@ -107,11 +107,11 @@ function NavBar({ links, title, img, pos = 'fixed', next = true, el, menuItems,
|
|
|
107
107
|
menuItems,
|
|
108
108
|
react_1.default.createElement(material_1.MenuItem, { onClick: (e) => {
|
|
109
109
|
setAvatarAnchor(null);
|
|
110
|
-
logout();
|
|
110
|
+
logout(logoutURL);
|
|
111
111
|
} },
|
|
112
112
|
react_1.default.createElement(material_1.Stack, { direction: 'row', spacing: 1 },
|
|
113
113
|
react_1.default.createElement(LogoutOutlined_1.default, { sx: { fill: '#545454' } }),
|
|
114
|
-
react_1.default.createElement(material_1.Typography, { textTransform: 'capitalize' },
|
|
114
|
+
react_1.default.createElement(material_1.Typography, { textTransform: 'capitalize' }, logoutMsg))))),
|
|
115
115
|
react_1.default.createElement(material_1.Stack, { direction: 'row', spacing: 0.4, alignItems: 'center', onClick: (e) => setAvatarAnchor(e.currentTarget), sx: { userSelect: 'none' } },
|
|
116
116
|
react_1.default.createElement(material_1.Typography, null, "Ol\u00E1,"),
|
|
117
117
|
react_1.default.createElement(material_1.Typography, { fontWeight: 600 }, user.name),
|
package/components/page/Login.js
CHANGED
|
@@ -59,10 +59,10 @@ function Login({ imgURL = '', name = 'Login', children, loginURL, captchaSiteKey
|
|
|
59
59
|
React.createElement(Typography_1.default, { component: 'h1', variant: 'h5', paddingY: 3 }, name),
|
|
60
60
|
React.createElement(material_1.Stack, { spacing: 3, width: 300 },
|
|
61
61
|
React.createElement(material_1.Stack, { spacing: 1 }, children),
|
|
62
|
-
React.createElement(
|
|
63
|
-
React.createElement(react_google_recaptcha_1.default, { ref: captcha, hl: 'pt', sitekey: captchaSiteKey, onExpired: () => setCaptchaSolved(false), onChange: (e) => {
|
|
62
|
+
captchaSiteKey && (React.createElement(react_google_recaptcha_1.default, { ref: captcha, hl: 'pt', sitekey: captchaSiteKey, onExpired: () => setCaptchaSolved(false), onChange: (e) => {
|
|
64
63
|
setCaptchaToken(e), e && setCaptchaSolved(true);
|
|
65
|
-
} }),
|
|
64
|
+
} })),
|
|
65
|
+
React.createElement(lab_1.LoadingButton, { type: 'submit', fullWidth: true, variant: 'contained', loading: loading, disabled: !captchaSolved }, "Login"),
|
|
66
66
|
error && (React.createElement(Box_1.default, { bgcolor: '#ce4257', padding: 2, borderRadius: 2, color: 'white' },
|
|
67
67
|
React.createElement(Typography_1.default, null, "Dados incorretos. Tente novamente!"))))))));
|
|
68
68
|
}
|
|
@@ -62,7 +62,7 @@ function OAuthProvider({ children, AUTH_URL, oidcConfig, redirectURL, validateTo
|
|
|
62
62
|
},
|
|
63
63
|
}).then((res) => {
|
|
64
64
|
if (!res.ok) {
|
|
65
|
-
logout();
|
|
65
|
+
logout('/');
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
@@ -124,12 +124,12 @@ function OAuthProvider({ children, AUTH_URL, oidcConfig, redirectURL, validateTo
|
|
|
124
124
|
router.replace(redirectURL).finally(() => setUserLoaded(true));
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
|
-
function logout() {
|
|
127
|
+
function logout(url) {
|
|
128
128
|
setUserLoaded(false);
|
|
129
129
|
setUser(null);
|
|
130
130
|
(0, cookies_next_1.deleteCookie)(exports.cookieName);
|
|
131
131
|
localStorage.removeItem(userImgName);
|
|
132
|
-
router.replace(
|
|
132
|
+
router.replace(url).finally(() => setUserLoaded(true));
|
|
133
133
|
}
|
|
134
134
|
return react_1.default.createElement(auth_1.AuthContext.Provider, { value: { user, isAuth, userLoaded, login, adLogin: () => { }, logout, saveUserData, type: 'govbr' } }, children);
|
|
135
135
|
}
|
package/package.json
CHANGED
package/types/auth.d.ts
CHANGED
|
@@ -69,5 +69,5 @@ export interface AuthReturnData {
|
|
|
69
69
|
login: () => void;
|
|
70
70
|
adLogin: (loginURL: string, data: any, setLoading: React.Dispatch<React.SetStateAction<boolean>>, setError: React.Dispatch<React.SetStateAction<boolean>>, captchaToken: string) => void;
|
|
71
71
|
saveUserData: (token: AuthReturn) => void;
|
|
72
|
-
logout: () => void;
|
|
72
|
+
logout: (url: string) => void;
|
|
73
73
|
}
|