tycho-components 0.0.11-SNAPSHOT-1 → 0.0.11-SNAPSHOT-3

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.
@@ -0,0 +1,7 @@
1
+ import { User } from './User';
2
+ export declare const useLoggedUtils: () => {
3
+ getLogged: () => User | undefined;
4
+ isSuper: () => boolean | undefined;
5
+ isLogged: () => boolean;
6
+ setLogged: (user: User) => void;
7
+ };
@@ -0,0 +1,25 @@
1
+ import { useContext } from 'react';
2
+ import CommonContext from './CommonContext';
3
+ import { UserStatus } from './User';
4
+ import { logged } from './store/actions';
5
+ export const useLoggedUtils = () => {
6
+ const { state, dispatch } = useContext(CommonContext);
7
+ const getLogged = () => {
8
+ return state.logged;
9
+ };
10
+ const isLogged = () => {
11
+ return state.logged !== undefined;
12
+ };
13
+ const isSuper = () => {
14
+ return state.logged && state.logged.status === UserStatus.SUPER;
15
+ };
16
+ const setLogged = (user) => {
17
+ dispatch(logged(user));
18
+ };
19
+ return {
20
+ getLogged,
21
+ isSuper,
22
+ isLogged,
23
+ setLogged,
24
+ };
25
+ };
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export { default as CommentComponent } from './Comments';
10
10
  export { default as HeaderNotifications } from './Comments/HeaderNotifications';
11
11
  export { CommonProvider } from './configs/CommonContext';
12
12
  export { useMessageUtils } from './configs/useMessageUtils';
13
+ export { useLoggedUtils } from './configs/useLoggedUtils';
13
14
  export { validateFormField } from './AppEditable/FormField';
14
15
  export { convertEnum, convertList } from './AppEditable/FormFieldOption';
15
16
  export { commonResources } from './configs/Localization';
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ export { default as CommentComponent } from './Comments';
10
10
  export { default as HeaderNotifications } from './Comments/HeaderNotifications';
11
11
  export { CommonProvider } from './configs/CommonContext';
12
12
  export { useMessageUtils } from './configs/useMessageUtils';
13
+ export { useLoggedUtils } from './configs/useLoggedUtils';
13
14
  export { validateFormField } from './AppEditable/FormField';
14
15
  export { convertEnum, convertList } from './AppEditable/FormFieldOption';
15
16
  export { commonResources } from './configs/Localization';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.0.11-SNAPSHOT-1",
4
+ "version": "0.0.11-SNAPSHOT-3",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {