tycho-components 0.0.11-SNAPSHOT → 0.0.11-SNAPSHOT-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,4 +1,4 @@
1
- import User from '../../configs/User';
1
+ import { User } from '../../configs/User';
2
2
  import { Comment, CommentRequest } from './Comment';
3
3
  declare function markRead(id: string): Promise<import("axios").AxiosResponse<Comment, any>>;
4
4
  declare function update(id: string, comment: CommentRequest): Promise<import("axios").AxiosResponse<Comment, any>>;
@@ -4,7 +4,7 @@ export declare enum UserStatus {
4
4
  SUPER = "SUPER",
5
5
  VISITOR = "VISITOR"
6
6
  }
7
- type User = {
7
+ export type User = {
8
8
  uid: string;
9
9
  name: string;
10
10
  sub: string;
@@ -13,4 +13,3 @@ type User = {
13
13
  status: UserStatus;
14
14
  permissions: string[];
15
15
  };
16
- export default User;
@@ -1,5 +1,5 @@
1
1
  import ToastMessage from '../../AppToast/ToastMessage';
2
- import User from '../User';
2
+ import { User } from '../User';
3
3
  import { StoreAction } from './types';
4
4
  export declare const logged: (data: User | undefined) => StoreAction;
5
5
  export declare const message: (data: ToastMessage) => StoreAction;
@@ -1,5 +1,5 @@
1
1
  import ToastMessage from '../../AppToast/ToastMessage';
2
- import User from '../User';
2
+ import { User } from '../User';
3
3
  export type UserStore = {
4
4
  logged: User | undefined;
5
5
  message: ToastMessage;
@@ -0,0 +1,5 @@
1
+ export declare const useLoggedUtils: () => {
2
+ getLogged: () => import("./User").User | undefined;
3
+ isSuper: () => boolean | undefined;
4
+ isLogged: () => boolean;
5
+ };
@@ -0,0 +1,20 @@
1
+ import { useContext } from 'react';
2
+ import CommonContext from './CommonContext';
3
+ import { UserStatus } from './User';
4
+ export const useLoggedUtils = () => {
5
+ const { state } = useContext(CommonContext);
6
+ const getLogged = () => {
7
+ return state.logged;
8
+ };
9
+ const isLogged = () => {
10
+ return state.logged !== undefined;
11
+ };
12
+ const isSuper = () => {
13
+ return state.logged && state.logged.status === UserStatus.SUPER;
14
+ };
15
+ return {
16
+ getLogged,
17
+ isSuper,
18
+ isLogged,
19
+ };
20
+ };
@@ -1,4 +1,4 @@
1
- import User from '../configs/User';
1
+ import { User } from '../configs/User';
2
2
  declare const SecurityUtils: {
3
3
  hasAccess: (uid: string, roles: string[]) => boolean;
4
4
  parseJwt: (token: string) => User;
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';
@@ -21,3 +22,5 @@ export type { FormFieldOption } from './AppEditable/FormFieldOption';
21
22
  export type { AppEditableField } from './AppEditable/AppEditableField';
22
23
  export type { FieldOperations, FormField } from './AppEditable/FormField';
23
24
  export type { KeyboardLayout } from './VirtualKeyboard/KeyboardCustomLayout';
25
+ export type { User } from './configs/User';
26
+ export type { UserStatus } from './configs/User';
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",
4
+ "version": "0.0.11-SNAPSHOT-2",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {