@scrumble-nl/gatherer-frontend 0.2.2 → 1.0.1

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.
Files changed (73) hide show
  1. package/README.md +10 -10
  2. package/lib/commonjs/context/gatherer-context.js +10 -6
  3. package/lib/commonjs/context/gatherer-context.js.map +1 -1
  4. package/lib/commonjs/context/scan-context.js.map +1 -1
  5. package/lib/commonjs/hooks/use-gatherer.js.map +1 -1
  6. package/lib/commonjs/hooks/use-scanner.js.map +1 -1
  7. package/lib/commonjs/pick-list/partials/pick-group-item.js +4 -2
  8. package/lib/commonjs/pick-list/partials/pick-group-item.js.map +1 -1
  9. package/lib/commonjs/picker/partials/modal/pick-modal.js +3 -2
  10. package/lib/commonjs/picker/partials/modal/pick-modal.js.map +1 -1
  11. package/lib/commonjs/picker/partials/modal/pick-quantity-select.js +1 -1
  12. package/lib/commonjs/picker/partials/modal/pick-quantity-select.js.map +1 -1
  13. package/lib/commonjs/picker/partials/pick-amount.js +9 -2
  14. package/lib/commonjs/picker/partials/pick-amount.js.map +1 -1
  15. package/lib/commonjs/picker/partials/product-info.js +11 -5
  16. package/lib/commonjs/picker/partials/product-info.js.map +1 -1
  17. package/lib/commonjs/picker/picker.js +9 -0
  18. package/lib/commonjs/picker/picker.js.map +1 -1
  19. package/lib/commonjs/picker/styles/pick-amount-styles.js +0 -1
  20. package/lib/commonjs/picker/styles/pick-amount-styles.js.map +1 -1
  21. package/lib/commonjs/shared/default-pick-group-item.js.map +1 -1
  22. package/lib/commonjs/types/config/config.d.js.map +1 -1
  23. package/lib/commonjs/types/pick-group/pick-group.d.js.map +1 -1
  24. package/lib/commonjs/types/pick-item/pick-item.d.js.map +1 -1
  25. package/lib/module/context/gatherer-context.js +10 -6
  26. package/lib/module/context/gatherer-context.js.map +1 -1
  27. package/lib/module/context/scan-context.js.map +1 -1
  28. package/lib/module/hooks/use-gatherer.js.map +1 -1
  29. package/lib/module/hooks/use-scanner.js.map +1 -1
  30. package/lib/module/pick-list/partials/pick-group-item.js +4 -2
  31. package/lib/module/pick-list/partials/pick-group-item.js.map +1 -1
  32. package/lib/module/picker/partials/modal/pick-modal.js +3 -2
  33. package/lib/module/picker/partials/modal/pick-modal.js.map +1 -1
  34. package/lib/module/picker/partials/modal/pick-quantity-select.js +1 -1
  35. package/lib/module/picker/partials/modal/pick-quantity-select.js.map +1 -1
  36. package/lib/module/picker/partials/pick-amount.js +9 -2
  37. package/lib/module/picker/partials/pick-amount.js.map +1 -1
  38. package/lib/module/picker/partials/product-info.js +11 -5
  39. package/lib/module/picker/partials/product-info.js.map +1 -1
  40. package/lib/module/picker/picker.js +9 -0
  41. package/lib/module/picker/picker.js.map +1 -1
  42. package/lib/module/picker/styles/pick-amount-styles.js +1 -2
  43. package/lib/module/picker/styles/pick-amount-styles.js.map +1 -1
  44. package/lib/module/shared/default-pick-group-item.js.map +1 -1
  45. package/lib/module/types/config/config.d.js.map +1 -1
  46. package/lib/module/types/pick-group/pick-group.d.js.map +1 -1
  47. package/lib/module/types/pick-item/pick-item.d.js.map +1 -1
  48. package/lib/typescript/context/gatherer-context.d.ts +6 -7
  49. package/lib/typescript/context/scan-context.d.ts +4 -4
  50. package/lib/typescript/hooks/use-gatherer.d.ts +1 -1
  51. package/lib/typescript/picker/partials/modal/pick-modal.d.ts +1 -0
  52. package/lib/typescript/picker/partials/modal/pick-quantity-select.d.ts +1 -1
  53. package/lib/typescript/picker/partials/pick-amount.d.ts +4 -1
  54. package/lib/typescript/picker/partials/product-info.d.ts +8 -1
  55. package/lib/typescript/picker/picker.d.ts +4 -3
  56. package/lib/typescript/picker/styles/pick-amount-styles.d.ts +0 -1
  57. package/lib/typescript/shared/default-pick-group-item.d.ts +1 -1
  58. package/package.json +2 -3
  59. package/src/context/gatherer-context.tsx +23 -25
  60. package/src/context/scan-context.tsx +4 -4
  61. package/src/hooks/use-gatherer.tsx +2 -2
  62. package/src/hooks/use-scanner.tsx +1 -1
  63. package/src/pick-list/partials/pick-group-item.tsx +5 -1
  64. package/src/picker/partials/modal/pick-modal.tsx +3 -2
  65. package/src/picker/partials/modal/pick-quantity-select.tsx +2 -2
  66. package/src/picker/partials/pick-amount.tsx +9 -2
  67. package/src/picker/partials/product-info.tsx +14 -5
  68. package/src/picker/picker.tsx +14 -2
  69. package/src/picker/styles/pick-amount-styles.ts +1 -2
  70. package/src/shared/default-pick-group-item.ts +1 -1
  71. package/src/types/config/config.d.ts +4 -2
  72. package/src/types/pick-group/pick-group.d.ts +0 -5
  73. package/src/types/pick-item/pick-item.d.ts +2 -0
@@ -13,7 +13,7 @@ export const useScanner = (onScan: ScanCallback): Scanner => {
13
13
  }, [onScan]);
14
14
 
15
15
  const startScanner = useCallback((): void => {
16
- registerListener((event: {data: string}) => {
16
+ registerListener(event => {
17
17
  callbackRef.current(event.data.trim());
18
18
  });
19
19
  }, [registerListener]);
@@ -21,7 +21,11 @@ export const PickGroupItem = <T extends PickGroup>(props: props<T>): JSX.Element
21
21
  const {id, is_picked} = props.renderProps.item;
22
22
 
23
23
  const handlePress = (): void => {
24
- props.onPress?.(props.renderProps.item);
24
+ if (props.onPress) {
25
+ props.onPress(props.renderProps.item);
26
+ return;
27
+ }
28
+
25
29
  startPicking(props.renderProps.item.id);
26
30
  };
27
31
 
@@ -9,13 +9,14 @@ import {PickQuantitySelect} from './pick-quantity-select';
9
9
  interface props {
10
10
  visible: boolean;
11
11
  closeModal: () => void;
12
+ onPickItems: (quantityPicked: number) => void;
12
13
  }
13
14
 
14
15
  const {background, container, innerContainer, title} = styles;
15
16
 
16
17
  export const PickModal = (props: props): JSX.Element => {
17
18
  const {t} = useTranslation();
18
- const {visible, closeModal} = props;
19
+ const {visible, closeModal, onPickItems} = props;
19
20
 
20
21
  return (
21
22
  <Modal animationType="fade" transparent visible={visible} onRequestClose={closeModal}>
@@ -23,7 +24,7 @@ export const PickModal = (props: props): JSX.Element => {
23
24
  <View style={container}>
24
25
  <View style={innerContainer}>
25
26
  <Text style={title}>{t('picker.modal.picked')}</Text>
26
- <PickQuantitySelect visible={visible} onPickItems={closeModal} />
27
+ <PickQuantitySelect visible={visible} onPickItems={onPickItems} />
27
28
  </View>
28
29
  </View>
29
30
  </Modal>
@@ -12,7 +12,7 @@ import {useGatherer} from '../../../hooks/use-gatherer';
12
12
 
13
13
  interface props {
14
14
  visible: boolean;
15
- onPickItems: () => void;
15
+ onPickItems: (quantityPicked: number) => void;
16
16
  }
17
17
 
18
18
  const singlePickThreshold = 10;
@@ -95,7 +95,7 @@ export const PickQuantitySelect = (props: props): JSX.Element => {
95
95
 
96
96
  const exitModal = (): void => {
97
97
  stopScanner();
98
- onPickItems();
98
+ onPickItems(selectedQuantity);
99
99
  };
100
100
 
101
101
  return (
@@ -3,11 +3,18 @@ import {View, Text} from 'react-native';
3
3
 
4
4
  import {styles} from '../styles/pick-amount-styles';
5
5
  import {useGatherer} from '../../hooks/use-gatherer';
6
+ import {PRIMARY_COLOR} from '../../shared/constants';
6
7
 
7
8
  const {container, pickBoxContainer, pickText} = styles;
8
9
 
9
- export const PickAmount = (): JSX.Element => {
10
+ export interface pickAmountProps {
11
+ backgroundColor?: string;
12
+ }
13
+
14
+ export const PickAmount = (props: pickAmountProps): JSX.Element => {
10
15
  const {pickItem} = useGatherer();
16
+ const {backgroundColor} = props;
17
+ const backgroundStyle = {backgroundColor: backgroundColor ?? PRIMARY_COLOR};
11
18
 
12
19
  if (!pickItem.quantity) {
13
20
  return <></>;
@@ -15,7 +22,7 @@ export const PickAmount = (): JSX.Element => {
15
22
 
16
23
  return (
17
24
  <View style={container}>
18
- <View style={pickBoxContainer}>
25
+ <View style={[pickBoxContainer, backgroundStyle]}>
19
26
  <Text style={pickText}>{pickItem.quantity ?? 1}</Text>
20
27
  </View>
21
28
  </View>
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, {ReactNode} from 'react';
2
2
  import {View, Text} from 'react-native';
3
3
 
4
4
  import {useTranslation} from 'react-i18next';
@@ -9,20 +9,29 @@ import {DataRow} from '../../shared/layout/data-row';
9
9
 
10
10
  const {container, productName, productInfo} = styles;
11
11
 
12
- export const ProductInfo = (): JSX.Element => {
12
+ export interface productInfoProps {
13
+ name?: string;
14
+ quantity?: number;
15
+ barcode?: string;
16
+ children?: ReactNode;
17
+ }
18
+
19
+ export const ProductInfo = (props: productInfoProps): JSX.Element => {
13
20
  const {pickItem} = useGatherer();
14
21
  const {t} = useTranslation();
22
+ const {name, quantity, barcode, children} = props;
15
23
 
16
24
  return (
17
25
  <View style={container}>
18
- <Text style={productName}>{pickItem?.pickItem.name}</Text>
26
+ <Text style={productName}>{name ?? pickItem?.pickItem.name}</Text>
19
27
  <View style={productInfo}>
20
28
  <DataRow
21
29
  leftTitle={t('picker.product-info.barcode')}
22
- leftContent={pickItem.barcode}
30
+ leftContent={barcode ?? pickItem.barcode}
23
31
  rightTitle={t('picker.product-info.pick-quantity')}
24
- rightContent={pickItem.quantity}
32
+ rightContent={quantity ?? pickItem.quantity}
25
33
  />
34
+ {children ?? <></>}
26
35
  </View>
27
36
  </View>
28
37
  );
@@ -16,7 +16,8 @@ interface props {
16
16
  children: ReactNode;
17
17
  style?: ViewStyle;
18
18
  pickModal?: JSX.Element;
19
- pickGroupId?: number;
19
+ onMultiQuantityPick?: () => void;
20
+ shouldLesserPick?: boolean;
20
21
  }
21
22
 
22
23
  const {container} = styles;
@@ -31,7 +32,13 @@ const Picker = (props: props): JSX.Element => {
31
32
  setPickModalVisible(false);
32
33
  };
33
34
 
34
- const pickModal = props.pickModal ?? <PickModal visible={pickModalVisible} closeModal={closeModal} />;
35
+ const handleMultiQuantityPick = (quantityPicked: number): void => {
36
+ nextPickItem(false, quantityPicked);
37
+ };
38
+
39
+ const pickModal = props.pickModal ?? (
40
+ <PickModal onPickItems={handleMultiQuantityPick} visible={pickModalVisible} closeModal={closeModal} />
41
+ );
35
42
 
36
43
  const handleScan = useCallback(
37
44
  (scan: string): void => {
@@ -39,6 +46,11 @@ const Picker = (props: props): JSX.Element => {
39
46
  if (pickItem.quantity === 1) {
40
47
  nextPickItem(false, 1);
41
48
  } else {
49
+ if (props.pickModal) {
50
+ props.onMultiQuantityPick?.();
51
+ return;
52
+ }
53
+
42
54
  stopScanner();
43
55
  setPickModalVisible(true);
44
56
  }
@@ -1,6 +1,6 @@
1
1
  import {StyleSheet} from 'react-native';
2
2
 
3
- import {BIGGEST_FONT, PRIMARY_COLOR, WHITE} from '../../shared/constants';
3
+ import {BIGGEST_FONT, WHITE} from '../../shared/constants';
4
4
 
5
5
  export const styles = StyleSheet.create({
6
6
  container: {
@@ -12,7 +12,6 @@ export const styles = StyleSheet.create({
12
12
  pickBoxContainer: {
13
13
  width: 75,
14
14
  height: 75,
15
- backgroundColor: PRIMARY_COLOR,
16
15
  justifyContent: 'center',
17
16
  alignItems: 'center',
18
17
  borderRadius: 5,
@@ -1,4 +1,4 @@
1
- export const defaultPickGroupItem: PickGroupItem<any> = {
1
+ export const defaultPickGroupItem: PickItem<any> = {
2
2
  pickItem: {
3
3
  id: 0,
4
4
  ean: '',
@@ -1,13 +1,15 @@
1
1
  type GathererConfig = {
2
2
  instance: import('../../../node_modules/axios').AxiosInstance;
3
3
  scanImplementation: {
4
- registerListener: (event: (...args: any[]) => any) => void;
4
+ registerListener: (event: ScanEvent) => void;
5
5
  clearEventListeners: () => void;
6
6
  registerEventListener?: () => void;
7
- onBarcodeReadFail?: (event: (...args: any[]) => any) => void;
7
+ onBarcodeReadFail?: (event: ScanEvent) => void;
8
8
  };
9
9
  onLastPick: () => void;
10
10
  language?: LanguageConfig;
11
11
  };
12
12
 
13
13
  type LanguageConfig = 'nl' | 'en';
14
+
15
+ type ScanEvent = (event: {data: string}) => void;
@@ -2,8 +2,3 @@ type PickGroup = {
2
2
  id: number;
3
3
  is_picked: boolean;
4
4
  };
5
-
6
- type PickGroupItem<T> = PickItem<T> & {
7
- previous: PickItem<T> | null;
8
- next: PickItem<T> | null;
9
- };
@@ -5,6 +5,8 @@ type PickItem<T extends DefaultPickItem> = {
5
5
  barcode: string;
6
6
  pickItemIndex: number;
7
7
  totalPickItems: number;
8
+ previous: PickItem<T> | null;
9
+ next: PickItem<T> | null;
8
10
  };
9
11
 
10
12
  type DefaultPickItem = {