tycho-components 0.44.0 → 0.44.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.
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, useReducer } from 'react';
|
|
3
|
+
import CookieStorage from './CookieStorage';
|
|
4
|
+
import SecurityUtils from '../functions/SecurityUtils';
|
|
3
5
|
import reducer from './store/reducer';
|
|
4
6
|
import store from './store/store';
|
|
5
7
|
const CommonContext = createContext({});
|
|
8
|
+
function readLoggedFromCookie() {
|
|
9
|
+
try {
|
|
10
|
+
const token = CookieStorage.getJwtToken();
|
|
11
|
+
if (!token)
|
|
12
|
+
return undefined;
|
|
13
|
+
return SecurityUtils.parseJwt(token);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function createInitialState(initial) {
|
|
20
|
+
const logged = readLoggedFromCookie();
|
|
21
|
+
if (!logged)
|
|
22
|
+
return initial;
|
|
23
|
+
return { ...initial, logged };
|
|
24
|
+
}
|
|
6
25
|
export function CommonProvider({ children }) {
|
|
7
|
-
const [state, dispatch] = useReducer(reducer, store);
|
|
26
|
+
const [state, dispatch] = useReducer(reducer, store, createInitialState);
|
|
8
27
|
return (_jsx(CommonContext.Provider, { value: { state, dispatch }, children: children }));
|
|
9
28
|
}
|
|
10
29
|
export default CommonContext;
|
package/dist/configs/brand.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tycho-components",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.44.
|
|
4
|
+
"version": "0.44.2",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -30,6 +30,11 @@
|
|
|
30
30
|
"import": "./dist/configs/index.js",
|
|
31
31
|
"require": "./dist/configs/index.js"
|
|
32
32
|
},
|
|
33
|
+
"./configs/brand": {
|
|
34
|
+
"types": "./dist/configs/brand.d.ts",
|
|
35
|
+
"import": "./dist/configs/brand.js",
|
|
36
|
+
"require": "./dist/configs/brand.js"
|
|
37
|
+
},
|
|
33
38
|
"./functions": {
|
|
34
39
|
"types": "./dist/functions/index.d.ts",
|
|
35
40
|
"import": "./dist/functions/index.js",
|