@campxdev/campx-web-utils 0.3.2 → 0.3.4
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/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@campxdev/campx-web-utils",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"main": "./export.ts",
|
|
5
5
|
"private": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
|
-
"@campxdev/react-blueprint": ">=^1.5.
|
|
7
|
+
"@campxdev/react-blueprint": ">=^1.5.8",
|
|
8
8
|
"@emotion/react": ">=^11.13.3",
|
|
9
9
|
"@emotion/styled": ">=^11.13.0",
|
|
10
10
|
"@mui/icons-material": ">=6.1.5",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@mui/x-date-pickers": ">=7.22.1"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@campxdev/react-blueprint": "1.5.
|
|
16
|
+
"@campxdev/react-blueprint": "1.5.8",
|
|
17
17
|
"@hookform/resolvers": "^3.9.0",
|
|
18
18
|
"@mui/x-date-pickers": "^7.22.1",
|
|
19
19
|
"axios": "^1.7.2",
|
package/src/layout/AppLayout.tsx
CHANGED
|
@@ -2,8 +2,10 @@ import { AppHeader, Sidebar, Spinner } from '@campxdev/react-blueprint';
|
|
|
2
2
|
import { SideMenuItemProps } from '@campxdev/react-blueprint/src/components/Navigation/Sidebar/Sidebar';
|
|
3
3
|
import { Box, Stack, useTheme } from '@mui/material';
|
|
4
4
|
import { motion } from 'framer-motion';
|
|
5
|
+
import Cookies from 'js-cookie';
|
|
5
6
|
import { Suspense, useState } from 'react';
|
|
6
|
-
import {
|
|
7
|
+
import { axios } from '../config/axios';
|
|
8
|
+
import { ApplicationStore, ErrorBoundary } from '../context/export';
|
|
7
9
|
|
|
8
10
|
interface Props {
|
|
9
11
|
children?: React.ReactNode;
|
|
@@ -19,6 +21,22 @@ export const AppLayout: React.FC<Props> = ({
|
|
|
19
21
|
const [collapsed, setCollapsed] = useState(true);
|
|
20
22
|
const theme = useTheme();
|
|
21
23
|
|
|
24
|
+
const user = ApplicationStore.useState((s) => s.user);
|
|
25
|
+
|
|
26
|
+
function logout() {
|
|
27
|
+
axios
|
|
28
|
+
.post('/auth-server/auth/logout')
|
|
29
|
+
.then((res) => {
|
|
30
|
+
Cookies.remove('campx_tenant');
|
|
31
|
+
Cookies.remove('campx_session_key');
|
|
32
|
+
Cookies.remove('campx_institution');
|
|
33
|
+
window.location.href = '/';
|
|
34
|
+
})
|
|
35
|
+
.catch((err) => {
|
|
36
|
+
// toast("Unable To Logout.");
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
22
40
|
return (
|
|
23
41
|
<Stack
|
|
24
42
|
sx={{ backgroundColor: theme.palette.surface.defaultBackground }}
|
|
@@ -40,8 +58,10 @@ export const AppLayout: React.FC<Props> = ({
|
|
|
40
58
|
actions={[]}
|
|
41
59
|
collapsed={collapsed}
|
|
42
60
|
showActiveDevices={false}
|
|
61
|
+
onLogoutClick={logout}
|
|
43
62
|
clientName={''}
|
|
44
|
-
userFullName={''}
|
|
63
|
+
userFullName={user ? user.fullName : ''}
|
|
64
|
+
designation={user?.email}
|
|
45
65
|
/>
|
|
46
66
|
<Box
|
|
47
67
|
sx={{
|
package/src/utils/export.ts
CHANGED
package/src/utils/breadcrumbs.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export const getBreadcrumbsCharacter = () => {
|
|
2
|
-
const unicodeChar = String.fromCharCode(0x21e5);
|
|
3
|
-
const testElement = document.createElement('span');
|
|
4
|
-
testElement.innerHTML = unicodeChar;
|
|
5
|
-
document.body.appendChild(testElement);
|
|
6
|
-
const isRendered = testElement.offsetWidth > 0;
|
|
7
|
-
document.body.removeChild(testElement);
|
|
8
|
-
|
|
9
|
-
const fallbackChar = '~~';
|
|
10
|
-
const s = isRendered ? unicodeChar : fallbackChar;
|
|
11
|
-
|
|
12
|
-
return s;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
type GetUrlSegment = {
|
|
16
|
-
name: string;
|
|
17
|
-
id: string | number;
|
|
18
|
-
};
|
|
19
|
-
export const getUrlSegment = ({ name, id }: GetUrlSegment) => {
|
|
20
|
-
return `${name}${getBreadcrumbsCharacter()}${id}`;
|
|
21
|
-
};
|