@scrumble-nl/gatherer-frontend 0.2.3 → 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 (68) 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/picker/partials/modal/pick-modal.js +3 -2
  8. package/lib/commonjs/picker/partials/modal/pick-modal.js.map +1 -1
  9. package/lib/commonjs/picker/partials/modal/pick-quantity-select.js +1 -1
  10. package/lib/commonjs/picker/partials/modal/pick-quantity-select.js.map +1 -1
  11. package/lib/commonjs/picker/partials/pick-amount.js +9 -2
  12. package/lib/commonjs/picker/partials/pick-amount.js.map +1 -1
  13. package/lib/commonjs/picker/partials/product-info.js +11 -5
  14. package/lib/commonjs/picker/partials/product-info.js.map +1 -1
  15. package/lib/commonjs/picker/picker.js +9 -0
  16. package/lib/commonjs/picker/picker.js.map +1 -1
  17. package/lib/commonjs/picker/styles/pick-amount-styles.js +0 -1
  18. package/lib/commonjs/picker/styles/pick-amount-styles.js.map +1 -1
  19. package/lib/commonjs/shared/default-pick-group-item.js.map +1 -1
  20. package/lib/commonjs/types/config/config.d.js.map +1 -1
  21. package/lib/commonjs/types/pick-group/pick-group.d.js.map +1 -1
  22. package/lib/commonjs/types/pick-item/pick-item.d.js.map +1 -1
  23. package/lib/module/context/gatherer-context.js +10 -6
  24. package/lib/module/context/gatherer-context.js.map +1 -1
  25. package/lib/module/context/scan-context.js.map +1 -1
  26. package/lib/module/hooks/use-gatherer.js.map +1 -1
  27. package/lib/module/hooks/use-scanner.js.map +1 -1
  28. package/lib/module/picker/partials/modal/pick-modal.js +3 -2
  29. package/lib/module/picker/partials/modal/pick-modal.js.map +1 -1
  30. package/lib/module/picker/partials/modal/pick-quantity-select.js +1 -1
  31. package/lib/module/picker/partials/modal/pick-quantity-select.js.map +1 -1
  32. package/lib/module/picker/partials/pick-amount.js +9 -2
  33. package/lib/module/picker/partials/pick-amount.js.map +1 -1
  34. package/lib/module/picker/partials/product-info.js +11 -5
  35. package/lib/module/picker/partials/product-info.js.map +1 -1
  36. package/lib/module/picker/picker.js +9 -0
  37. package/lib/module/picker/picker.js.map +1 -1
  38. package/lib/module/picker/styles/pick-amount-styles.js +1 -2
  39. package/lib/module/picker/styles/pick-amount-styles.js.map +1 -1
  40. package/lib/module/shared/default-pick-group-item.js.map +1 -1
  41. package/lib/module/types/config/config.d.js.map +1 -1
  42. package/lib/module/types/pick-group/pick-group.d.js.map +1 -1
  43. package/lib/module/types/pick-item/pick-item.d.js.map +1 -1
  44. package/lib/typescript/context/gatherer-context.d.ts +6 -7
  45. package/lib/typescript/context/scan-context.d.ts +4 -4
  46. package/lib/typescript/hooks/use-gatherer.d.ts +1 -1
  47. package/lib/typescript/picker/partials/modal/pick-modal.d.ts +1 -0
  48. package/lib/typescript/picker/partials/modal/pick-quantity-select.d.ts +1 -1
  49. package/lib/typescript/picker/partials/pick-amount.d.ts +4 -1
  50. package/lib/typescript/picker/partials/product-info.d.ts +8 -1
  51. package/lib/typescript/picker/picker.d.ts +4 -3
  52. package/lib/typescript/picker/styles/pick-amount-styles.d.ts +0 -1
  53. package/lib/typescript/shared/default-pick-group-item.d.ts +1 -1
  54. package/package.json +2 -3
  55. package/src/context/gatherer-context.tsx +23 -25
  56. package/src/context/scan-context.tsx +4 -4
  57. package/src/hooks/use-gatherer.tsx +2 -2
  58. package/src/hooks/use-scanner.tsx +1 -1
  59. package/src/picker/partials/modal/pick-modal.tsx +3 -2
  60. package/src/picker/partials/modal/pick-quantity-select.tsx +2 -2
  61. package/src/picker/partials/pick-amount.tsx +9 -2
  62. package/src/picker/partials/product-info.tsx +14 -5
  63. package/src/picker/picker.tsx +14 -2
  64. package/src/picker/styles/pick-amount-styles.ts +1 -2
  65. package/src/shared/default-pick-group-item.ts +1 -1
  66. package/src/types/config/config.d.ts +4 -2
  67. package/src/types/pick-group/pick-group.d.ts +0 -5
  68. package/src/types/pick-item/pick-item.d.ts +2 -0
@@ -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 = {