@scrumble-nl/gatherer-frontend 0.2.3 → 1.0.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.
Files changed (99) 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 +1 -3
  7. package/lib/commonjs/hooks/use-scanner.js.map +1 -1
  8. package/lib/commonjs/picker/partials/modal/pick-modal.js +3 -2
  9. package/lib/commonjs/picker/partials/modal/pick-modal.js.map +1 -1
  10. package/lib/commonjs/picker/partials/modal/pick-quantity-select.js +1 -1
  11. package/lib/commonjs/picker/partials/modal/pick-quantity-select.js.map +1 -1
  12. package/lib/commonjs/picker/partials/pick-amount.js +9 -2
  13. package/lib/commonjs/picker/partials/pick-amount.js.map +1 -1
  14. package/lib/commonjs/picker/partials/product-info.js +11 -5
  15. package/lib/commonjs/picker/partials/product-info.js.map +1 -1
  16. package/lib/commonjs/picker/partials/progress-bar.js +7 -3
  17. package/lib/commonjs/picker/partials/progress-bar.js.map +1 -1
  18. package/lib/commonjs/picker/picker.js +10 -0
  19. package/lib/commonjs/picker/picker.js.map +1 -1
  20. package/lib/commonjs/picker/styles/pick-amount-styles.js +0 -1
  21. package/lib/commonjs/picker/styles/pick-amount-styles.js.map +1 -1
  22. package/lib/commonjs/picker/styles/product-info-styles.js +4 -2
  23. package/lib/commonjs/picker/styles/product-info-styles.js.map +1 -1
  24. package/lib/commonjs/picker/styles/progress-bar-styles.js +0 -1
  25. package/lib/commonjs/picker/styles/progress-bar-styles.js.map +1 -1
  26. package/lib/commonjs/shared/default-pick-group-item.js.map +1 -1
  27. package/lib/commonjs/shared/layout/data-format.js +5 -0
  28. package/lib/commonjs/shared/layout/data-format.js.map +1 -1
  29. package/lib/commonjs/shared/layout/styles/layout-styles.js +4 -1
  30. package/lib/commonjs/shared/layout/styles/layout-styles.js.map +1 -1
  31. package/lib/commonjs/types/config/config.d.js.map +1 -1
  32. package/lib/commonjs/types/pick-group/pick-group.d.js.map +1 -1
  33. package/lib/commonjs/types/pick-item/pick-item.d.js.map +1 -1
  34. package/lib/module/context/gatherer-context.js +10 -6
  35. package/lib/module/context/gatherer-context.js.map +1 -1
  36. package/lib/module/context/scan-context.js.map +1 -1
  37. package/lib/module/hooks/use-gatherer.js.map +1 -1
  38. package/lib/module/hooks/use-scanner.js +1 -3
  39. package/lib/module/hooks/use-scanner.js.map +1 -1
  40. package/lib/module/picker/partials/modal/pick-modal.js +3 -2
  41. package/lib/module/picker/partials/modal/pick-modal.js.map +1 -1
  42. package/lib/module/picker/partials/modal/pick-quantity-select.js +1 -1
  43. package/lib/module/picker/partials/modal/pick-quantity-select.js.map +1 -1
  44. package/lib/module/picker/partials/pick-amount.js +9 -2
  45. package/lib/module/picker/partials/pick-amount.js.map +1 -1
  46. package/lib/module/picker/partials/product-info.js +11 -5
  47. package/lib/module/picker/partials/product-info.js.map +1 -1
  48. package/lib/module/picker/partials/progress-bar.js +8 -4
  49. package/lib/module/picker/partials/progress-bar.js.map +1 -1
  50. package/lib/module/picker/picker.js +10 -0
  51. package/lib/module/picker/picker.js.map +1 -1
  52. package/lib/module/picker/styles/pick-amount-styles.js +1 -2
  53. package/lib/module/picker/styles/pick-amount-styles.js.map +1 -1
  54. package/lib/module/picker/styles/product-info-styles.js +4 -2
  55. package/lib/module/picker/styles/product-info-styles.js.map +1 -1
  56. package/lib/module/picker/styles/progress-bar-styles.js +1 -2
  57. package/lib/module/picker/styles/progress-bar-styles.js.map +1 -1
  58. package/lib/module/shared/default-pick-group-item.js.map +1 -1
  59. package/lib/module/shared/layout/data-format.js +5 -0
  60. package/lib/module/shared/layout/data-format.js.map +1 -1
  61. package/lib/module/shared/layout/styles/layout-styles.js +5 -2
  62. package/lib/module/shared/layout/styles/layout-styles.js.map +1 -1
  63. package/lib/module/types/config/config.d.js.map +1 -1
  64. package/lib/module/types/pick-group/pick-group.d.js.map +1 -1
  65. package/lib/module/types/pick-item/pick-item.d.js.map +1 -1
  66. package/lib/typescript/context/gatherer-context.d.ts +6 -7
  67. package/lib/typescript/context/scan-context.d.ts +4 -4
  68. package/lib/typescript/hooks/use-gatherer.d.ts +1 -1
  69. package/lib/typescript/picker/partials/modal/pick-modal.d.ts +1 -0
  70. package/lib/typescript/picker/partials/modal/pick-quantity-select.d.ts +1 -1
  71. package/lib/typescript/picker/partials/pick-amount.d.ts +4 -1
  72. package/lib/typescript/picker/partials/product-info.d.ts +8 -1
  73. package/lib/typescript/picker/partials/progress-bar.d.ts +3 -0
  74. package/lib/typescript/picker/picker.d.ts +4 -3
  75. package/lib/typescript/picker/styles/pick-amount-styles.d.ts +0 -1
  76. package/lib/typescript/picker/styles/product-info-styles.d.ts +2 -0
  77. package/lib/typescript/picker/styles/progress-bar-styles.d.ts +0 -1
  78. package/lib/typescript/shared/default-pick-group-item.d.ts +1 -1
  79. package/lib/typescript/shared/layout/styles/layout-styles.d.ts +3 -0
  80. package/package.json +2 -3
  81. package/src/context/gatherer-context.tsx +23 -25
  82. package/src/context/scan-context.tsx +4 -4
  83. package/src/hooks/use-gatherer.tsx +2 -2
  84. package/src/hooks/use-scanner.tsx +1 -3
  85. package/src/picker/partials/modal/pick-modal.tsx +3 -2
  86. package/src/picker/partials/modal/pick-quantity-select.tsx +2 -2
  87. package/src/picker/partials/pick-amount.tsx +9 -2
  88. package/src/picker/partials/product-info.tsx +14 -5
  89. package/src/picker/partials/progress-bar.tsx +8 -4
  90. package/src/picker/picker.tsx +15 -2
  91. package/src/picker/styles/pick-amount-styles.ts +1 -2
  92. package/src/picker/styles/product-info-styles.ts +3 -1
  93. package/src/picker/styles/progress-bar-styles.ts +1 -2
  94. package/src/shared/default-pick-group-item.ts +1 -1
  95. package/src/shared/layout/data-format.tsx +5 -1
  96. package/src/shared/layout/styles/layout-styles.ts +5 -2
  97. package/src/types/config/config.d.ts +4 -2
  98. package/src/types/pick-group/pick-group.d.ts +0 -5
  99. package/src/types/pick-item/pick-item.d.ts +2 -0
@@ -1,19 +1,18 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  import { AxiosInstance } from 'axios';
3
- export interface IGathererContext {
4
- scanImplementation: any;
5
- pickItem: PickGroupItem<any>;
3
+ export interface IGathererContext<T extends DefaultPickItem> {
4
+ pickItem: PickItem<T>;
6
5
  currentPickGroupId: number;
7
6
  onLastPick: () => void;
8
7
  instance: AxiosInstance;
9
- savePickGroupData: (data: PickGroupItem<any>) => void;
10
- startPicking: (pickGroupId: number) => Promise<PickGroupItem<DefaultPickItem>>;
11
- switchPickItem: (dir: ControlDir) => Promise<PickGroupItem<DefaultPickItem>>;
8
+ savePickGroupData: (data: PickItem<T>) => void;
9
+ startPicking: (pickGroupId: number) => Promise<PickItem<T>>;
10
+ switchPickItem: (dir: ControlDir) => Promise<PickItem<T>>;
12
11
  }
13
12
  interface props {
14
13
  children: ReactNode;
15
14
  config: GathererConfig;
16
15
  }
17
- export declare const GathererContext: React.Context<IGathererContext>;
16
+ export declare const GathererContext: React.Context<IGathererContext<any>>;
18
17
  export declare const GathererContextProvider: <T extends DefaultPickItem>(props: props) => JSX.Element;
19
18
  export {};
@@ -1,16 +1,16 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  export type IScanContext = {
3
- registerListener: (event: (...args: any[]) => any) => void;
3
+ registerListener: (event: ScanEvent) => void;
4
4
  clearEventListeners: () => void;
5
5
  registerEventListener?: () => void;
6
- onBarcodeReadFail?: (event: (...args: any[]) => any) => void;
6
+ onBarcodeReadFail?: (event: ScanEvent) => void;
7
7
  };
8
8
  interface props {
9
9
  scanner: {
10
- registerListener: (event: (...args: any[]) => any) => void;
10
+ registerListener: (event: ScanEvent) => void;
11
11
  clearEventListeners: () => void;
12
12
  registerEventListener?: () => void;
13
- onBarcodeReadFail?: (event: (...args: any[]) => any) => void;
13
+ onBarcodeReadFail?: (event: ScanEvent) => void;
14
14
  };
15
15
  children: ReactNode;
16
16
  }
@@ -1,2 +1,2 @@
1
1
  import type { IGathererContext } from '../context/gatherer-context';
2
- export declare const useGatherer: () => IGathererContext;
2
+ export declare const useGatherer: <T extends DefaultPickItem = DefaultPickItem>() => IGathererContext<T>;
@@ -1,6 +1,7 @@
1
1
  interface props {
2
2
  visible: boolean;
3
3
  closeModal: () => void;
4
+ onPickItems: (quantityPicked: number) => void;
4
5
  }
5
6
  export declare const PickModal: (props: props) => JSX.Element;
6
7
  export {};
@@ -1,6 +1,6 @@
1
1
  interface props {
2
2
  visible: boolean;
3
- onPickItems: () => void;
3
+ onPickItems: (quantityPicked: number) => void;
4
4
  }
5
5
  export declare const PickQuantitySelect: (props: props) => JSX.Element;
6
6
  export {};
@@ -1 +1,4 @@
1
- export declare const PickAmount: () => JSX.Element;
1
+ export interface pickAmountProps {
2
+ backgroundColor?: string;
3
+ }
4
+ export declare const PickAmount: (props: pickAmountProps) => JSX.Element;
@@ -1 +1,8 @@
1
- export declare const ProductInfo: () => JSX.Element;
1
+ import { ReactNode } from 'react';
2
+ export interface productInfoProps {
3
+ name?: string;
4
+ quantity?: number;
5
+ barcode?: string;
6
+ children?: ReactNode;
7
+ }
8
+ export declare const ProductInfo: (props: productInfoProps) => JSX.Element;
@@ -1,5 +1,8 @@
1
1
  export interface progressProps {
2
2
  total?: number;
3
3
  current?: number;
4
+ color?: string;
5
+ textColor?: string;
6
+ unfilledColor?: string;
4
7
  }
5
8
  export declare const ProgressBar: (props: progressProps) => JSX.Element;
@@ -4,14 +4,15 @@ interface props {
4
4
  children: ReactNode;
5
5
  style?: ViewStyle;
6
6
  pickModal?: JSX.Element;
7
- pickGroupId?: number;
7
+ onMultiQuantityPick?: () => void;
8
+ shouldLesserPick?: boolean;
8
9
  }
9
10
  declare const Picker: {
10
11
  (props: props): JSX.Element;
11
12
  Row: (props: import("../shared/layout/data-row").rowProps) => JSX.Element;
12
13
  Column: (props: import("../shared/layout/data-column").columnProps) => JSX.Element;
13
14
  Progress: (props: import("./partials/progress-bar").progressProps) => JSX.Element;
14
- PickAmount: () => JSX.Element;
15
- ProductInfo: () => JSX.Element;
15
+ PickAmount: (props: import("./partials/pick-amount").pickAmountProps) => JSX.Element;
16
+ ProductInfo: (props: import("./partials/product-info").productInfoProps) => JSX.Element;
16
17
  };
17
18
  export { Picker };
@@ -8,7 +8,6 @@ export declare const styles: {
8
8
  pickBoxContainer: {
9
9
  width: number;
10
10
  height: number;
11
- backgroundColor: string;
12
11
  justifyContent: "center";
13
12
  alignItems: "center";
14
13
  borderRadius: number;
@@ -6,8 +6,10 @@ export declare const styles: {
6
6
  };
7
7
  productName: {
8
8
  textAlign: "center";
9
+ marginTop: number;
9
10
  marginBottom: number;
10
11
  fontSize: number;
12
+ fontWeight: "bold";
11
13
  };
12
14
  productInfo: {
13
15
  flex: number;
@@ -1,6 +1,5 @@
1
1
  export declare const styles: {
2
2
  progressText: {
3
- color: string;
4
3
  fontSize: number;
5
4
  alignSelf: "center";
6
5
  position: "absolute";
@@ -1 +1 @@
1
- export declare const defaultPickGroupItem: PickGroupItem<any>;
1
+ export declare const defaultPickGroupItem: PickItem<any>;
@@ -13,4 +13,7 @@ export declare const styles: {
13
13
  fontStyle: "italic";
14
14
  fontSize: number;
15
15
  };
16
+ dataText: {
17
+ fontSize: number;
18
+ };
16
19
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scrumble-nl/gatherer-frontend",
3
- "version": "0.2.3",
3
+ "version": "1.0.2",
4
4
  "main": "lib/commonjs/index",
5
5
  "module": "lib/module/index",
6
6
  "types": "lib/typescript/index.d.ts",
@@ -49,8 +49,7 @@
49
49
  "axios": "^0.27.2",
50
50
  "i18next": "^22.0.6",
51
51
  "react-i18next": "^12.0.0",
52
- "react-native-progress": "^5.0.0",
53
- "react-native-vector-icons": "^9.2.0"
52
+ "react-native-progress": "^5.0.0"
54
53
  },
55
54
  "devDependencies": {
56
55
  "@arkweid/lefthook": "^0.7.7",
@@ -7,15 +7,14 @@ import {ScanContextProvider} from './scan-context';
7
7
  import {defaultPickGroupItem} from '../shared/default-pick-group-item';
8
8
  import {NEXT_PICK_ITEM_URL, PREV_PICK_ITEM_URL, START_PICKING_URL} from '../shared/api/api-urls';
9
9
 
10
- export interface IGathererContext {
11
- scanImplementation: any;
12
- pickItem: PickGroupItem<any>;
10
+ export interface IGathererContext<T extends DefaultPickItem> {
11
+ pickItem: PickItem<T>;
13
12
  currentPickGroupId: number;
14
13
  onLastPick: () => void;
15
14
  instance: AxiosInstance;
16
- savePickGroupData: (data: PickGroupItem<any>) => void;
17
- startPicking: (pickGroupId: number) => Promise<PickGroupItem<DefaultPickItem>>;
18
- switchPickItem: (dir: ControlDir) => Promise<PickGroupItem<DefaultPickItem>>;
15
+ savePickGroupData: (data: PickItem<T>) => void;
16
+ startPicking: (pickGroupId: number) => Promise<PickItem<T>>;
17
+ switchPickItem: (dir: ControlDir) => Promise<PickItem<T>>;
19
18
  }
20
19
 
21
20
  interface props {
@@ -23,8 +22,7 @@ interface props {
23
22
  config: GathererConfig;
24
23
  }
25
24
 
26
- export const GathererContext = createContext<IGathererContext>({
27
- scanImplementation: undefined,
25
+ export const GathererContext = createContext<IGathererContext<any>>({
28
26
  currentPickGroupId: 0,
29
27
  onLastPick: () => undefined,
30
28
  instance: axios.create(),
@@ -36,23 +34,19 @@ export const GathererContext = createContext<IGathererContext>({
36
34
 
37
35
  export const GathererContextProvider = <T extends DefaultPickItem>(props: props): JSX.Element => {
38
36
  const {scanImplementation, instance, onLastPick, language} = props.config;
39
- const [pickItem, setPickItem] = useState<PickGroupItem<T>>(defaultPickGroupItem);
40
- const prevPickItem = useRef<PickItem<T> | null>(null);
41
- const nextPickItem = useRef<PickItem<T> | null>(null);
37
+ const [pickItem, setPickItem] = useState<PickItem<T>>(defaultPickGroupItem);
42
38
  const currentPickGroupId = useRef<number>(0);
43
39
 
44
40
  useEffect(() => {
45
41
  scanImplementation.registerEventListener?.();
46
42
  }, [scanImplementation]);
47
43
 
48
- const savePickGroupData = useCallback((data: PickGroupItem<T>): void => {
44
+ const savePickGroupData = useCallback((data: PickItem<T>): void => {
49
45
  setPickItem(data);
50
- prevPickItem.current = data.previous;
51
- nextPickItem.current = data.next;
52
46
  }, []);
53
47
 
54
48
  const startPicking = useCallback(
55
- async (pickGroupId: number): Promise<PickGroupItem<T>> => {
49
+ async (pickGroupId: number): Promise<PickItem<T>> => {
56
50
  return new Promise((resolve, reject) => {
57
51
  instance
58
52
  .post(START_PICKING_URL, {pick_group_id: pickGroupId})
@@ -68,9 +62,21 @@ export const GathererContextProvider = <T extends DefaultPickItem>(props: props)
68
62
  );
69
63
 
70
64
  const switchPickItem = useCallback(
71
- async (dir: ControlDir): Promise<PickGroupItem<T>> => {
65
+ async (dir: ControlDir): Promise<PickItem<T>> => {
72
66
  const url = dir === 'prev' ? PREV_PICK_ITEM_URL : NEXT_PICK_ITEM_URL;
73
67
 
68
+ setPickItem(prevState => {
69
+ if (dir === 'prev' && prevState.previous) {
70
+ return prevState.previous;
71
+ }
72
+
73
+ if (dir === 'next' && prevState.next) {
74
+ return prevState.next;
75
+ }
76
+
77
+ return prevState;
78
+ });
79
+
74
80
  return new Promise((resolve, reject) => {
75
81
  instance
76
82
  .post(url, {
@@ -104,15 +110,7 @@ export const GathererContextProvider = <T extends DefaultPickItem>(props: props)
104
110
  scanImplementation,
105
111
  currentPickGroupId: currentPickGroupId.current,
106
112
  }),
107
- [
108
- pickItem,
109
- instance,
110
- onLastPick,
111
- startPicking,
112
- switchPickItem,
113
- savePickGroupData,
114
- scanImplementation,
115
- ],
113
+ [instance, onLastPick, pickItem, savePickGroupData, scanImplementation, startPicking, switchPickItem],
116
114
  );
117
115
 
118
116
  return (
@@ -1,18 +1,18 @@
1
1
  import React, {createContext, ReactNode} from 'react';
2
2
 
3
3
  export type IScanContext = {
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
 
10
10
  interface props {
11
11
  scanner: {
12
- registerListener: (event: (...args: any[]) => any) => void;
12
+ registerListener: (event: ScanEvent) => void;
13
13
  clearEventListeners: () => void;
14
14
  registerEventListener?: () => void;
15
- onBarcodeReadFail?: (event: (...args: any[]) => any) => void;
15
+ onBarcodeReadFail?: (event: ScanEvent) => void;
16
16
  };
17
17
  children: ReactNode;
18
18
  }
@@ -3,6 +3,6 @@ import {useContext} from 'react';
3
3
  import {GathererContext} from '../context/gatherer-context';
4
4
  import type {IGathererContext} from '../context/gatherer-context';
5
5
 
6
- export const useGatherer = (): IGathererContext => {
7
- return useContext<IGathererContext>(GathererContext);
6
+ export const useGatherer = <T extends DefaultPickItem = DefaultPickItem>(): IGathererContext<T> => {
7
+ return useContext<IGathererContext<T>>(GathererContext);
8
8
  };
@@ -13,9 +13,7 @@ export const useScanner = (onScan: ScanCallback): Scanner => {
13
13
  }, [onScan]);
14
14
 
15
15
  const startScanner = useCallback((): void => {
16
- registerListener((event: {data: string}) => {
17
- callbackRef.current(event.data.trim());
18
- });
16
+ registerListener(event => callbackRef.current(event.data.trim()));
19
17
  }, [registerListener]);
20
18
 
21
19
  const stopScanner = useCallback((): void => {
@@ -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
  );
@@ -5,11 +5,14 @@ import {Bar} from 'react-native-progress';
5
5
 
6
6
  import {useGatherer} from '../../hooks/use-gatherer';
7
7
  import {styles} from '../styles/progress-bar-styles';
8
- import {LIGHT_GREY, TEXT_COLOR} from '../../shared/constants';
8
+ import {LIGHT_GREY, TEXT_COLOR, WHITE} from '../../shared/constants';
9
9
 
10
10
  export interface progressProps {
11
11
  total?: number;
12
12
  current?: number;
13
+ color?: string;
14
+ textColor?: string;
15
+ unfilledColor?: string;
13
16
  }
14
17
 
15
18
  const {progressText} = styles;
@@ -19,6 +22,7 @@ export const ProgressBar = (props: progressProps): JSX.Element => {
19
22
  const totalProducts = (props.total || pickItem.totalPickItems) ?? 1;
20
23
  const current = ((props.current || pickItem.pickItemIndex) ?? 0) + 1;
21
24
  const progress = current / totalProducts;
25
+ const textStyle = {...progressText, color: props.textColor ?? WHITE};
22
26
 
23
27
  return (
24
28
  <View>
@@ -27,11 +31,11 @@ export const ProgressBar = (props: progressProps): JSX.Element => {
27
31
  animated
28
32
  width={null}
29
33
  height={20}
30
- color={TEXT_COLOR}
31
- unfilledColor={LIGHT_GREY}
34
+ color={props.color ?? TEXT_COLOR}
35
+ unfilledColor={props.unfilledColor ?? LIGHT_GREY}
32
36
  borderWidth={0}
33
37
  />
34
- <Text style={progressText}>
38
+ <Text style={textStyle}>
35
39
  {current} / {totalProducts}
36
40
  </Text>
37
41
  </View>
@@ -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,14 @@ 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
+ closeModal();
38
+ };
39
+
40
+ const pickModal = props.pickModal ?? (
41
+ <PickModal onPickItems={handleMultiQuantityPick} visible={pickModalVisible} closeModal={closeModal} />
42
+ );
35
43
 
36
44
  const handleScan = useCallback(
37
45
  (scan: string): void => {
@@ -39,6 +47,11 @@ const Picker = (props: props): JSX.Element => {
39
47
  if (pickItem.quantity === 1) {
40
48
  nextPickItem(false, 1);
41
49
  } else {
50
+ if (props.pickModal) {
51
+ props.onMultiQuantityPick?.();
52
+ return;
53
+ }
54
+
42
55
  stopScanner();
43
56
  setPickModalVisible(true);
44
57
  }
@@ -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,
@@ -10,8 +10,10 @@ export const styles = StyleSheet.create({
10
10
  },
11
11
  productName: {
12
12
  textAlign: 'center',
13
- marginBottom: 30,
13
+ marginTop: 10,
14
+ marginBottom: 25,
14
15
  fontSize: BIG_FONT,
16
+ fontWeight: 'bold',
15
17
  },
16
18
  productInfo: {
17
19
  flex: 1,
@@ -1,10 +1,9 @@
1
1
  import {StyleSheet} from 'react-native';
2
2
 
3
- import {SMALLEST_FONT, WHITE} from '../../shared/constants';
3
+ import {SMALLEST_FONT} from '../../shared/constants';
4
4
 
5
5
  export const styles = StyleSheet.create({
6
6
  progressText: {
7
- color: WHITE,
8
7
  fontSize: SMALLEST_FONT,
9
8
  alignSelf: 'center',
10
9
  position: 'absolute',
@@ -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,15 +1,19 @@
1
1
  import React from 'react';
2
2
  import {Text} from 'react-native';
3
3
 
4
+ import {styles} from './styles/layout-styles';
5
+
4
6
  interface props {
5
7
  data: JSX.Element | string | number;
6
8
  }
7
9
 
10
+ const {dataText} = styles;
11
+
8
12
  export const DataFormat = (props: props): JSX.Element => {
9
13
  const {data} = props;
10
14
 
11
15
  if (typeof data === 'string' || typeof data === 'number') {
12
- return <Text numberOfLines={1}>{data}</Text>;
16
+ return <Text style={dataText} numberOfLines={1}>{data}</Text>;
13
17
  }
14
18
 
15
19
  return data;
@@ -1,6 +1,6 @@
1
1
  import {StyleSheet} from 'react-native';
2
2
 
3
- import {GREY, SMALL_FONT} from '../../constants';
3
+ import {GREY} from '../../constants';
4
4
 
5
5
  export const styles = StyleSheet.create({
6
6
  dataRow: {
@@ -15,6 +15,9 @@ export const styles = StyleSheet.create({
15
15
  dataTitle: {
16
16
  color: GREY,
17
17
  fontStyle: 'italic',
18
- fontSize: SMALL_FONT,
18
+ fontSize: 14,
19
+ },
20
+ dataText: {
21
+ fontSize: 18,
19
22
  },
20
23
  });
@@ -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 = {