@bcrumbs.net/bc-shared 0.0.4 → 0.0.6

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@bcrumbs.net/bc-shared",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "keyword": [
5
5
  "bcrumbs",
6
6
  "bc-shared",
@@ -10,12 +10,11 @@
10
10
  "name": "Ahmad Mhaish"
11
11
  },
12
12
  "peerDependencies": {
13
- "i18next": "^21.6.14",
14
- "react-i18next": "^11.15.6",
15
- "i18next-http-backend": "^1.3.2"
16
- },
17
- "dependencies": {
18
- "date-fns": "^2.28.0"
13
+ "react": "^18.0.0",
14
+ "react-dom": "^18.0.0",
15
+ "i18next": "^21.0.0",
16
+ "react-i18next": "^11.0.0",
17
+ "i18next-http-backend": "^1.0.0"
19
18
  },
20
19
  "module": "./index.esm.js",
21
20
  "type": "module",
package/src/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './lib/config/routes';
2
2
  export * from './lib/components';
3
3
  export * from './lib/utils';
4
+ export * from './lib/hooks';
4
5
  export * from './lib/types';
5
6
  export * from './lib/services/i18n';
6
7
  export * from './lib/services/auth';
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { Permission } from '../../types';
3
+ interface PermissionGuardProps {
4
+ component: React.ComponentType<any>;
5
+ requiredPermissions?: Permission[];
6
+ fallbackRoute?: string;
7
+ path: string;
8
+ exact?: boolean;
9
+ }
10
+ export declare const PermissionGuard: React.FC<PermissionGuardProps>;
11
+ export {};
@@ -1,2 +1,3 @@
1
1
  export * from './RoutesGaurd';
2
2
  export * from './LogoutRoute';
3
+ export * from './RoutesGaurd/PermissionGuard';
@@ -40,4 +40,6 @@ export declare const BCRoutes: {
40
40
  BroadcastCreate: string;
41
41
  ConvsSearch: string;
42
42
  Dashboard: string;
43
+ Contact: string;
44
+ ContactLifeCycle: string;
43
45
  };
@@ -0,0 +1 @@
1
+ export * from './usePermissions';
@@ -0,0 +1,6 @@
1
+ import { Permission } from '../types';
2
+ export declare const usePermissions: () => {
3
+ role: string | undefined;
4
+ permissions: Set<Permission>;
5
+ has: (permission: Permission) => boolean;
6
+ };
@@ -77,7 +77,11 @@ export declare const auth: {
77
77
  * @param {any} [userInfoKey='userInfo'] optionnal parameter to specify a token key
78
78
  * @returns {string} token value
79
79
  */
80
- getUserInfo(fromStorage?: Storage, userInfoKey?: UserInfoKey): any;
80
+ getUserInfo(fromStorage?: Storage, userInfoKey?: UserInfoKey): {
81
+ id: string;
82
+ username: string;
83
+ role: string;
84
+ } | null;
81
85
  /**
82
86
  * set the userInfo value into localstorage
83
87
  *
@@ -87,7 +91,6 @@ export declare const auth: {
87
91
  * @returns {boolean} success/failure flag
88
92
  */
89
93
  setUserInfo(value: User, toStorage?: Storage, userInfoKey?: UserInfoKey): void;
90
- updateUserInfo(value: User, toStorage?: Storage, userInfoKey?: UserInfoKey): any;
91
94
  /**
92
95
  * delete userInfo
93
96
  *
@@ -5,3 +5,8 @@ export declare enum Loading {
5
5
  ERROR = "error"
6
6
  }
7
7
  export type Awaited<T> = T extends PromiseLike<infer U> ? Awaited<U> : T;
8
+ export declare enum Permission {
9
+ MANAGE_WORKSPACE = "MANAGE_WORKSPACE",
10
+ MANAGE_CONVS = "MANAGE_CONVS",
11
+ MANAGE_CLIENTS = "MANAGE_CLIENTS"
12
+ }