@nyris/nyris-webapp 0.3.32 → 0.3.33

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": "@nyris/nyris-webapp",
3
- "version": "0.3.32",
3
+ "version": "0.3.33",
4
4
  "homepage": "./",
5
5
  "dependencies": {
6
6
  "@algolia/autocomplete-js": "^1.7.1",
@@ -12,8 +12,8 @@
12
12
  "@material-ui/data-grid": "^4.0.0-alpha.37",
13
13
  "@material-ui/icons": "^4.4.1",
14
14
  "@material-ui/lab": "^4.0.0-alpha.60",
15
- "@nyris/nyris-api": "^0.3.32",
16
- "@nyris/nyris-react-components": "^0.3.32",
15
+ "@nyris/nyris-api": "^0.3.33",
16
+ "@nyris/nyris-react-components": "^0.3.33",
17
17
  "@reduxjs/toolkit": "^1.6.1",
18
18
  "@splidejs/react-splide": "^0.7.12",
19
19
  "@types/blueimp-load-image": "^2.23.4",
@@ -30,7 +30,6 @@
30
30
  "blueimp-load-image": "^2.24.0",
31
31
  "classnames": "^2.2.6",
32
32
  "framer-motion": "^4.1.17",
33
- "heic2any": "0.0.4",
34
33
  "history": "^4.10.1",
35
34
  "i18next": "^22.4.14",
36
35
  "jotai": "^1.4.7",
@@ -114,7 +114,7 @@ function DetailItem(props: Props) {
114
114
  style={{ width: '300px', height: '300px', padding: '8px' }}
115
115
  />
116
116
  )}
117
- {!isMobile && dataImageCarousel.length > 0 && (
117
+ {dataImageCarousel.length > 0 && (
118
118
  <Button
119
119
  className="icon-style"
120
120
  onClick={() => {
@@ -314,36 +314,42 @@ function DetailItem(props: Props) {
314
314
  style={{ color: '#2B2C46', marginTop: 12 }}
315
315
  gridGap={20}
316
316
  >
317
- <Box
318
- style={{
319
- backgroundColor: `${settings.theme?.secondaryColor}26`,
320
- padding: '5px 10px',
321
- borderRadius: 4,
322
- width: '100%',
323
- }}
324
- >
325
- <div style={{ fontSize: 15, fontWeight: 500 }}>
326
- {dataItem[settings.field.warehouseNumber]}
327
- </div>
328
- <div style={{ fontSize: 17, fontWeight: 700 }}>
329
- {dataItem[settings.field.warehouseNumberValue] || 'N/A'}
330
- </div>
331
- </Box>
332
- <Box
333
- style={{
334
- backgroundColor: `${settings.theme?.secondaryColor}26`,
335
- padding: '5px 10px',
336
- borderRadius: 4,
337
- width: '100%',
338
- }}
339
- >
340
- <div style={{ fontSize: 15, fontWeight: 500 }}>
341
- {dataItem[settings.field.warehouseShelfNumber]}
342
- </div>
343
- <div style={{ fontSize: 17, fontWeight: 700 }}>
344
- {dataItem[settings.field.warehouseShelfNumberValue] || 'N/A'}
345
- </div>
346
- </Box>
317
+ {settings.field.warehouseNumber && (
318
+ <Box
319
+ style={{
320
+ backgroundColor: `${settings.theme?.secondaryColor}26`,
321
+ padding: '5px 10px',
322
+ borderRadius: 4,
323
+ width: '100%',
324
+ }}
325
+ >
326
+ <div style={{ fontSize: 15, fontWeight: 500 }}>
327
+ {dataItem[settings.field.warehouseNumber]}
328
+ </div>
329
+ <div style={{ fontSize: 17, fontWeight: 700 }}>
330
+ {dataItem[settings.field.warehouseNumberValue] || 'N/A'}
331
+ </div>
332
+ </Box>
333
+ )}
334
+
335
+ {settings.field.warehouseShelfNumber && (
336
+ <Box
337
+ style={{
338
+ backgroundColor: `${settings.theme?.secondaryColor}26`,
339
+ padding: '5px 10px',
340
+ borderRadius: 4,
341
+ width: '100%',
342
+ }}
343
+ >
344
+ <div style={{ fontSize: 15, fontWeight: 500 }}>
345
+ {dataItem[settings.field.warehouseShelfNumber]}
346
+ </div>
347
+ <div style={{ fontSize: 17, fontWeight: 700 }}>
348
+ {dataItem[settings.field.warehouseShelfNumberValue] ||
349
+ 'N/A'}
350
+ </div>
351
+ </Box>
352
+ )}
347
353
  </Box>
348
354
  )}
349
355
 
@@ -19,7 +19,6 @@ import { useState } from 'react';
19
19
  import IconUpload from 'common/assets/images/Icon_Upload.svg';
20
20
  import { RectCoords } from '@nyris/nyris-api';
21
21
  import { useTranslation } from 'react-i18next';
22
- import heic2any from 'heic2any';
23
22
 
24
23
  interface Props {
25
24
  acceptTypes: any;
@@ -38,74 +37,55 @@ function DragDropFile(props: Props) {
38
37
  } = searchState;
39
38
  const [isLoadingLoadFile, setLoadingLoadFile] = useState<any>(false);
40
39
  const { t } = useTranslation();
41
- const handleVisualSearch = async (blob: Blob) => {
42
- history.push('/result');
43
- dispatch(updateStatusLoading(true));
44
- dispatch(loadingActionResults());
45
- onChangeLoading(true);
46
- let payload: any;
47
- let filters: any[] = [];
48
- setLoadingLoadFile(true);
49
- dispatch(setImageSearchInput(URL.createObjectURL(blob)));
50
- // @ts-ignore
51
- let image = await createImage(blob);
52
-
53
- dispatch(setRequestImage(image));
54
- const preFilter = [
55
- {
56
- key: settings.visualSearchFilterKey,
57
- values: [`${keyFilter}`],
58
- },
59
- ];
60
- let region: RectCoords | undefined;
61
- if (settings.regions) {
62
- let res = await findRegions(image, settings);
63
- dispatch(setRegions(res.regions));
64
- region = res.selectedRegion;
65
- dispatch(setSelectedRegion(region));
66
- }
67
-
68
- return findByImage({
69
- image,
70
- settings,
71
- region,
72
- filters: keyFilter ? preFilter : undefined,
73
- }).then((res: any) => {
74
- res?.results.map((item: any) => {
75
- filters.push({
76
- sku: item.sku,
77
- score: item.score,
78
- });
79
- });
80
- payload = {
81
- ...res,
82
- filters,
83
- };
84
- dispatch(setSearchResults(payload));
85
- setLoadingLoadFile(false);
86
- onChangeLoading(false);
87
- dispatch(updateStatusLoading(false));
88
- return dispatch(showFeedback());
89
- });
90
- };
91
40
  const { getRootProps, getInputProps, isDragActive } = useDropzone({
92
41
  onDrop: async (fs: File[]) => {
93
- var file = fs[0];
94
- if (file.type === 'image/heic') {
95
- heic2any({
96
- blob: file as Blob,
97
- toType: 'image/png',
98
- quality: 1.0,
99
- })
100
- .then(function (resultBlob) {
101
- handleVisualSearch(resultBlob as Blob);
102
- })
103
- .catch(function (error) {
104
- console.error('Error converting HEIC to PNG:', error);
105
- });
106
- } else {
107
- handleVisualSearch(fs[0]);
42
+ history.push('/result');
43
+ dispatch(updateStatusLoading(true));
44
+ dispatch(loadingActionResults());
45
+ onChangeLoading(true);
46
+ let payload: any;
47
+ let filters: any[] = [];
48
+ setLoadingLoadFile(true);
49
+ console.log('fs', fs);
50
+ dispatch(setImageSearchInput(URL.createObjectURL(fs[0])));
51
+ let image = await createImage(fs[0]);
52
+ dispatch(setRequestImage(image));
53
+ const preFilter = [
54
+ {
55
+ key: settings.visualSearchFilterKey,
56
+ values: [`${keyFilter}`],
57
+ },
58
+ ];
59
+ let region: RectCoords | undefined;
60
+ if (settings.regions) {
61
+ let res = await findRegions(image, settings);
62
+ dispatch(setRegions(res.regions));
63
+ region = res.selectedRegion;
64
+ dispatch(setSelectedRegion(region));
108
65
  }
66
+
67
+ return findByImage({
68
+ image,
69
+ settings,
70
+ region,
71
+ filters: keyFilter ? preFilter : undefined,
72
+ }).then((res: any) => {
73
+ res?.results.map((item: any) => {
74
+ filters.push({
75
+ sku: item.sku,
76
+ score: item.score,
77
+ });
78
+ });
79
+ payload = {
80
+ ...res,
81
+ filters,
82
+ };
83
+ dispatch(setSearchResults(payload));
84
+ setLoadingLoadFile(false);
85
+ onChangeLoading(false);
86
+ dispatch(updateStatusLoading(false));
87
+ return dispatch(showFeedback());
88
+ });
109
89
  },
110
90
  });
111
91
 
@@ -1,6 +1,6 @@
1
1
  import { Box } from '@material-ui/core';
2
2
  import ItemResult from 'components/results/ItemResult';
3
- import { groupBy } from 'lodash';
3
+ import { groupBy, uniqueId } from 'lodash';
4
4
  import React, { memo, useEffect, useMemo, useState } from 'react';
5
5
  import { connectStateResults } from 'react-instantsearch-dom';
6
6
  import { useAppSelector } from 'Store/Store';
@@ -52,9 +52,13 @@ function ProductListComponent({
52
52
  let newArrayShowGroup: any = [];
53
53
  let newArrayShowItem: any = [];
54
54
 
55
- const groupHits = hits.filter(
56
- (hit: { group_id: string }) => hit.group_id && hit.group_id !== '',
57
- );
55
+ const groupHits = hits.map((hit: { group_id: string }) => {
56
+ if (!hit.group_id) {
57
+ return { ...hit, group_id: uniqueId('random-group-id') };
58
+ }
59
+ return hit;
60
+ });
61
+
58
62
  const groups = groupBy(groupHits, 'group_id');
59
63
  setHitGroups(groups);
60
64
  newArrayShowGroup = Object.values(groups);
@@ -79,6 +83,7 @@ function ProductListComponent({
79
83
  newArrayShowItem.push(payload);
80
84
  }
81
85
  });
86
+
82
87
  return newArrayShowItem;
83
88
  };
84
89
 
@@ -31,7 +31,6 @@ import PreFilterComponent from 'components/pre-filter';
31
31
  import { RectCoords } from '@nyris/nyris-api';
32
32
  import { truncateString } from 'helpers/truncateString';
33
33
  import { useTranslation } from 'react-i18next';
34
- import heic2any from 'heic2any';
35
34
 
36
35
  const SearchBox = (props: any) => {
37
36
  const { refine, onToggleFilterMobile }: any = props;
@@ -88,76 +87,58 @@ const SearchBox = (props: any) => {
88
87
  }, 500),
89
88
  [],
90
89
  );
91
- const handleVisualSearch = async (blob: Blob) => {
92
- dispatch(updateStatusLoading(true));
93
- dispatch(loadingActionResults());
94
- if (history.location.pathname !== '/result') {
95
- history.push('/result');
96
- }
97
- let payload: any;
98
- let filters: any[] = [];
99
- let region: RectCoords | undefined;
100
- dispatch(setImageSearchInput(URL.createObjectURL(blob)));
101
- // @ts-ignore
102
- let image = await createImage(blob);
103
- dispatch(setRequestImage(image));
104
- const preFilter = [
105
- {
106
- key: settings.visualSearchFilterKey,
107
- values: [`${keyFilter}`],
108
- },
109
- ];
110
90
 
111
- if (settings.regions) {
112
- let res = await findRegions(image, settings);
113
- dispatch(setRegions(res.regions));
114
- region = res.selectedRegion;
115
- dispatch(setSelectedRegion(region));
116
- }
117
-
118
- return findByImage({
119
- image,
120
- settings,
121
- filters: keyFilter ? preFilter : undefined,
122
- region,
123
- })
124
- .then((res: any) => {
125
- res?.results.map((item: any) => {
126
- filters.push({
127
- sku: item.sku,
128
- score: item.score,
129
- });
130
- });
131
- payload = {
132
- ...res,
133
- filters,
134
- };
135
- dispatch(setSearchResults(payload));
136
- dispatch(updateStatusLoading(false));
137
- })
138
- .catch((e: any) => {
139
- console.log('error input search', e);
140
- dispatch(updateStatusLoading(false));
141
- });
142
- };
143
91
  const { getInputProps } = useDropzone({
144
92
  onDrop: async (fs: File[]) => {
145
- var file = fs[0];
146
- if (file.type === 'image/heic') {
147
- heic2any({
148
- blob: file as Blob,
149
- toType: 'image/png',
150
- quality: 1.0,
151
- })
152
- .then(function (resultBlob) {
153
- handleVisualSearch(resultBlob as Blob);
154
- })
155
- .catch(function (error) {
156
- console.error('Error converting HEIC to PNG:', error);
157
- });
158
- } else {
159
- handleVisualSearch(fs[0]);
93
+ dispatch(updateStatusLoading(true));
94
+ dispatch(loadingActionResults());
95
+ if (history.location.pathname !== '/result') {
96
+ history.push('/result');
160
97
  }
98
+ let payload: any;
99
+ let filters: any[] = [];
100
+ let region: RectCoords | undefined;
101
+ dispatch(setImageSearchInput(URL.createObjectURL(fs[0])));
102
+ let image = await createImage(fs[0]);
103
+ dispatch(setRequestImage(image));
104
+ const preFilter = [
105
+ {
106
+ key: settings.visualSearchFilterKey,
107
+ values: [`${keyFilter}`],
108
+ },
109
+ ];
110
+
111
+ if (settings.regions) {
112
+ let res = await findRegions(image, settings);
113
+ dispatch(setRegions(res.regions));
114
+ region = res.selectedRegion;
115
+ dispatch(setSelectedRegion(region));
116
+ }
117
+
118
+ return findByImage({
119
+ image,
120
+ settings,
121
+ filters: keyFilter ? preFilter : undefined,
122
+ region,
123
+ })
124
+ .then((res: any) => {
125
+ res?.results.map((item: any) => {
126
+ filters.push({
127
+ sku: item.sku,
128
+ score: item.score,
129
+ });
130
+ });
131
+ payload = {
132
+ ...res,
133
+ filters,
134
+ };
135
+ dispatch(setSearchResults(payload));
136
+ dispatch(updateStatusLoading(false));
137
+ })
138
+ .catch((e: any) => {
139
+ console.log('error input search', e);
140
+ dispatch(updateStatusLoading(false));
141
+ });
161
142
  },
162
143
  });
163
144
 
@@ -2,9 +2,9 @@ import { Box, Button, Grid, Tooltip, Typography } from '@material-ui/core';
2
2
  import ChevronRightOutlinedIcon from '@material-ui/icons/ChevronRightOutlined';
3
3
  import IconOpenLink from 'common/assets/icons/Union.svg';
4
4
  import { ReactComponent as IconShare } from 'common/assets/icons/Fill.svg';
5
- import { ReactComponent as Expand } from 'common/assets/icons/expand.svg';
6
5
  import { ReactComponent as IconDisLike } from 'common/assets/icons/icon_dislike.svg';
7
6
  import { ReactComponent as IconLike } from 'common/assets/icons/icon_like.svg';
7
+ import { ReactComponent as IconSearchImage } from 'common/assets/icons/icon_search_image2.svg';
8
8
  import React, { memo, useEffect, useState } from 'react';
9
9
  import NoImage from 'common/assets/images/unnamed.png';
10
10
  import { AppState } from 'types';
@@ -143,13 +143,17 @@ function ItemResult(props: Props) {
143
143
  </Button>
144
144
  </Box>
145
145
  )}
146
- {!isHover && (
146
+ {!isHover && main_image_link && (
147
147
  <Box className="box-icon-modal">
148
148
  <Button
149
149
  style={{ width: '100%', height: '100%', padding: 0, zIndex: 9 }}
150
- onClick={() => handlerToggleModal(dataItem)}
150
+ onClick={() => {
151
+ if (urlImage.length > 1) {
152
+ onSearchImage(main_image_link);
153
+ }
154
+ }}
151
155
  >
152
- <Expand color={settings.theme?.secondaryColor} />
156
+ <IconSearchImage color={settings.theme?.secondaryColor} />
153
157
  </Button>
154
158
  </Box>
155
159
  )}
@@ -158,9 +162,7 @@ function ItemResult(props: Props) {
158
162
  style={{ width: '100%', height: '100%' }}
159
163
  onClick={(e: any) => {
160
164
  e.preventDefault();
161
- if (urlImage.length > 1) {
162
- onSearchImage(main_image_link);
163
- }
165
+ handlerToggleModal(dataItem);
164
166
  }}
165
167
  >
166
168
  {main_image_link ? (
@@ -367,53 +369,58 @@ function ItemResult(props: Props) {
367
369
  style={{ color: '#2B2C46', marginTop: '12px' }}
368
370
  gridGap={10}
369
371
  >
370
- <Box
371
- style={{
372
- backgroundColor: `${settings.theme?.secondaryColor}26`,
373
- padding: '5px 10px',
374
- borderRadius: 4,
375
- width: '100%',
376
- }}
377
- >
378
- <div style={{ fontSize: 10, fontWeight: 500 }}>
379
- {dataItem.custom_id_key_2}
380
- </div>
381
- <div
372
+ {settings.field.warehouseNumber && (
373
+ <Box
382
374
  style={{
383
- fontSize: 13,
384
- fontWeight: 700,
385
- whiteSpace: 'nowrap',
386
- overflow: 'hidden',
387
- textOverflow: 'ellipsis',
375
+ backgroundColor: `${settings.theme?.secondaryColor}26`,
376
+ padding: '5px 10px',
377
+ borderRadius: 4,
378
+ width: '100%',
388
379
  }}
389
380
  >
390
- {dataItem.custom_id_value_2 || 'N/A'}
391
- </div>
392
- </Box>
381
+ <div style={{ fontSize: 10, fontWeight: 500 }}>
382
+ {dataItem[settings.field.warehouseNumber]}
383
+ </div>
384
+ <div
385
+ style={{
386
+ fontSize: 13,
387
+ fontWeight: 700,
388
+ whiteSpace: 'nowrap',
389
+ overflow: 'hidden',
390
+ textOverflow: 'ellipsis',
391
+ }}
392
+ >
393
+ {dataItem[settings.field.warehouseNumberValue] || 'N/A'}
394
+ </div>
395
+ </Box>
396
+ )}
393
397
 
394
- <Box
395
- style={{
396
- backgroundColor: `${settings.theme?.secondaryColor}26`,
397
- padding: '5px 10px',
398
- borderRadius: 4,
399
- width: '100%',
400
- }}
401
- >
402
- <div style={{ fontSize: 10, fontWeight: 500 }}>
403
- {dataItem.custom_id_key_1}
404
- </div>
405
- <div
398
+ {settings.field.warehouseShelfNumber && (
399
+ <Box
406
400
  style={{
407
- fontSize: 13,
408
- fontWeight: 700,
409
- whiteSpace: 'nowrap',
410
- overflow: 'hidden',
411
- textOverflow: 'ellipsis',
401
+ backgroundColor: `${settings.theme?.secondaryColor}26`,
402
+ padding: '5px 10px',
403
+ borderRadius: 4,
404
+ width: '100%',
412
405
  }}
413
406
  >
414
- {dataItem.custom_id_value_1 || 'N/A'}
415
- </div>
416
- </Box>
407
+ <div style={{ fontSize: 10, fontWeight: 500 }}>
408
+ {dataItem[settings.field.warehouseShelfNumber]}
409
+ </div>
410
+ <div
411
+ style={{
412
+ fontSize: 13,
413
+ fontWeight: 700,
414
+ whiteSpace: 'nowrap',
415
+ overflow: 'hidden',
416
+ textOverflow: 'ellipsis',
417
+ }}
418
+ >
419
+ {dataItem[settings.field.warehouseShelfNumberValue] ||
420
+ 'N/A'}
421
+ </div>
422
+ </Box>
423
+ )}
417
424
  </Box>
418
425
  )}
419
426
 
@@ -478,25 +485,6 @@ function ItemResult(props: Props) {
478
485
  </Box>
479
486
  </Grid>
480
487
  )}
481
- {/* <Grid item>
482
- <Box display={'flex'} alignItems={'center'}>
483
- <Button className="btn-item">
484
- <Box
485
- className=""
486
- display={'flex'}
487
- justifyContent={'center'}
488
- alignItems={'center'}
489
- >
490
- <img
491
- src={IconShare}
492
- alt="image_item"
493
- className="icon_support"
494
- style={{ width: '1rem' }}
495
- />
496
- </Box>
497
- </Button>
498
- </Box>
499
- </Grid> */}
500
488
  </Grid>
501
489
  </Box>
502
490
  )}