techsbcn-storybook 0.9.2 → 0.10.0

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/README.md CHANGED
@@ -116,7 +116,6 @@ declare var __DEV__: boolean;
116
116
 
117
117
  // inside your code...
118
118
  if (__DEV__) {
119
- console.log('foo');
120
119
  }
121
120
  ```
122
121
 
@@ -14,7 +14,7 @@ export interface NavigationProps {
14
14
  }
15
15
  interface VerticalNavProps {
16
16
  items: NavigationProps[];
17
- userPermisions?: string[];
17
+ userPermisions?: string[] | string;
18
18
  onHide?: () => void;
19
19
  }
20
20
  export declare const VerticalNav: React.FC<VerticalNavProps>;
@@ -2,7 +2,7 @@ import { NavigationProps } from './VerticalNav';
2
2
  import React from 'react';
3
3
  interface VerticalNavItemProps {
4
4
  item: NavigationProps;
5
- userPermisions?: string[];
5
+ userPermisions?: string[] | string;
6
6
  onHide?: () => void;
7
7
  }
8
8
  declare const _default: React.NamedExoticComponent<VerticalNavItemProps>;
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { NavigationProps } from './VerticalNav';
3
3
  interface VerticalNavItemCollapseProps {
4
4
  item: NavigationProps;
5
- userPermisions?: string[];
5
+ userPermisions?: string[] | string;
6
6
  onHide?: () => void;
7
7
  }
8
8
  declare const _default: React.NamedExoticComponent<VerticalNavItemCollapseProps>;
@@ -5,5 +5,5 @@ interface ColourOption {
5
5
  }
6
6
  export declare const colourOptions: ColourOption[];
7
7
  export declare const ResponseHandler: (response: any) => any;
8
- export declare const SearchSimple: (filters: SearchFilters) => Promise<SearchResult<SearchSimpleResult>>;
8
+ export declare const SearchSimple: (_filters: SearchFilters) => Promise<SearchResult<SearchSimpleResult>>;
9
9
  export {};
@@ -0,0 +1,5 @@
1
+ export declare enum Scope {
2
+ SUPERADMIN = 1,
3
+ ADMIN = 2,
4
+ DRIVER = 3
5
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './SelectMock';
2
2
  export * from './UserList';
3
3
  export * from './Values';
4
+ export * from './enums/scopes';
@@ -1,4 +1,4 @@
1
1
  import { Meta, Story } from '@storybook/react';
2
2
  declare const meta: Meta;
3
3
  export default meta;
4
- export declare const Default: Story<import("@storybook/react").Args>;
4
+ export declare const Examples: Story<import("@storybook/react").Args>;
@@ -108,7 +108,7 @@ var DoubleFilter = function DoubleFilter(filters) {
108
108
  };
109
109
 
110
110
  var SearchComponent = function SearchComponent(props) {
111
- var _useState = React.useState(false),
111
+ var _useState = React.useState(!props.searchBar && !!props.filters),
112
112
  isOpen = _useState[0],
113
113
  setIsOpen = _useState[1];
114
114
 
@@ -207,7 +207,7 @@ var SearchComponent = function SearchComponent(props) {
207
207
  },
208
208
  display: "flex",
209
209
  width: "100%"
210
- }, props.searchBar, props.filters && React__default.createElement(material.Box, {
210
+ }, props.searchBar, props.filters && props.searchBar && React__default.createElement(material.Box, {
211
211
  onClick: function onClick() {
212
212
  return setIsOpen(!isOpen);
213
213
  },
@@ -608,6 +608,10 @@ var MainLayoutSimple = function MainLayoutSimple(props) {
608
608
  var checkPermission = function checkPermission(persmisionAvailable, userRoles) {
609
609
  if (persmisionAvailable === null || persmisionAvailable === undefined || persmisionAvailable.length === 0) {
610
610
  return true;
611
+ } else {
612
+ if (userRoles === undefined || userRoles === null || userRoles === 0) {
613
+ return false;
614
+ }
611
615
  }
612
616
 
613
617
  if (userRoles && Array.isArray(userRoles) && Array.isArray(persmisionAvailable)) {
@@ -616,6 +620,14 @@ var checkPermission = function checkPermission(persmisionAvailable, userRoles) {
616
620
  });
617
621
  }
618
622
 
623
+ if (userRoles && !Array.isArray(userRoles) && !Array.isArray(persmisionAvailable)) {
624
+ return userRoles === persmisionAvailable;
625
+ }
626
+
627
+ if (userRoles && !Array.isArray(userRoles) && Array.isArray(persmisionAvailable)) {
628
+ return persmisionAvailable.indexOf(userRoles) >= 0;
629
+ }
630
+
619
631
  return userRoles.indexOf(persmisionAvailable) >= 0;
620
632
  };
621
633