@nyris/nyris-webapp 0.3.26 → 0.3.29

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.26",
3
+ "version": "0.3.29",
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.26",
16
- "@nyris/nyris-react-components": "^0.3.26",
15
+ "@nyris/nyris-api": "^0.3.29",
16
+ "@nyris/nyris-react-components": "^0.3.29",
17
17
  "@reduxjs/toolkit": "^1.6.1",
18
18
  "@splidejs/react-splide": "^0.7.12",
19
19
  "@types/blueimp-load-image": "^2.23.4",
@@ -35,7 +35,7 @@ function DetailItem(props: Props) {
35
35
  handlerFeedback,
36
36
  } = props;
37
37
  const [collapDescription, setCollapDescription] = useState(false);
38
- const { title, sku, main_offer_link, brand } = dataItem;
38
+ const { title, sku, main_offer_link, product_link, brand } = dataItem;
39
39
  const [dataImageCarousel, setDataImageCarouSel] = useState<any[]>([]);
40
40
  const isMobile = useMediaQuery({ query: '(max-width: 776px)' });
41
41
  const { settings } = useAppSelector<AppState>((state: any) => state);
@@ -272,7 +272,10 @@ function DetailItem(props: Props) {
272
272
  minHeight: !settings.warehouseVariant ? 48 : 64,
273
273
  }}
274
274
  onClick={() =>
275
- window.open(`${main_offer_link}`, '_blank')
275
+ window.open(
276
+ `${product_link || main_offer_link}`,
277
+ '_blank',
278
+ )
276
279
  }
277
280
  >
278
281
  <Typography
@@ -349,17 +352,13 @@ function DetailItem(props: Props) {
349
352
  >
350
353
  <Grid
351
354
  container
352
- justifyContent="space-between"
355
+ justifyContent={
356
+ settings.shareOption ? 'space-between' : 'space-around'
357
+ }
353
358
  alignItems="center"
354
359
  >
355
360
  <Grid item>
356
- <Box
357
- display={'flex'}
358
- justifyContent={
359
- settings.shareOption ? 'space-between' : 'space-around'
360
- }
361
- alignItems={'center'}
362
- >
361
+ <Box display={'flex'} alignItems={'center'}>
363
362
  <Button
364
363
  className="btn-item"
365
364
  onClick={() => {
@@ -35,9 +35,10 @@ function CameraCustom(props: Props) {
35
35
  const [facingMode, setFacingMode] = useState(FACING_MODE_USER);
36
36
  const [scaleCamera, setScaleCamera] = useState<number>(1);
37
37
  const stateGlobal = useAppSelector(state => state);
38
- const { settings } = stateGlobal;
38
+ const { search, settings } = stateGlobal;
39
39
  const history = useHistory();
40
40
  const dispatch = useAppDispatch();
41
+ const { keyFilter } = search;
41
42
 
42
43
  const videoConstraints = {
43
44
  width: 1080,
@@ -55,23 +56,55 @@ function CameraCustom(props: Props) {
55
56
  const handlerFindImage = async (image: any) => {
56
57
  dispatch(updateStatusLoading(true));
57
58
  dispatch(loadingActionResults());
58
-
59
+ if (history.location.pathname !== '/result') {
60
+ history.push('/result');
61
+ }
59
62
  let region: RectCoords | undefined;
60
63
  let imageConvert = await createImage(image);
61
64
  dispatch(setRequestImage(imageConvert));
62
65
  dispatch(setImageSearchInput(image));
63
66
  dispatch(onToggleModalItemDetail(false));
67
+ handlerCloseModal();
68
+
64
69
  if (settings.regions) {
65
70
  let res = await findRegions(imageConvert, settings);
66
71
  dispatch(setRegions(res.regions));
67
72
  region = res.selectedRegion;
68
73
  dispatch(setSelectedRegion(region));
69
74
  }
70
- setTimeout(() => {
71
- dispatch(updateStatusLoading(false));
72
- handlerCloseModal();
73
- history.push('/result');
74
- }, 500);
75
+
76
+ const preFilter = [
77
+ {
78
+ key: settings.visualSearchFilterKey,
79
+ values: [`${keyFilter}`],
80
+ },
81
+ ];
82
+ let filters: any[] = [];
83
+
84
+ findByImage({
85
+ image: imageConvert,
86
+ settings,
87
+ filters: keyFilter ? preFilter : undefined,
88
+ region,
89
+ })
90
+ .then((res: any) => {
91
+ res?.results.map((item: any) => {
92
+ filters.push({
93
+ sku: item.sku,
94
+ score: item.score,
95
+ });
96
+ });
97
+ const payload = {
98
+ ...res,
99
+ filters,
100
+ };
101
+ dispatch(setSearchResults(payload));
102
+ dispatch(updateStatusLoading(false));
103
+ })
104
+ .catch((e: any) => {
105
+ console.log('error input search', e);
106
+ dispatch(updateStatusLoading(false));
107
+ });
75
108
  };
76
109
 
77
110
  const handlerCloseModal = () => {
@@ -281,7 +281,11 @@ const SearchBox = (props: any) => {
281
281
  history.push('/');
282
282
  }}
283
283
  >
284
- <Tooltip title="clear text search" placement="top" arrow={true}>
284
+ <Tooltip
285
+ title={t('Clear text search')}
286
+ placement="top"
287
+ arrow={true}
288
+ >
285
289
  <ClearOutlinedIcon style={{ fontSize: 16, color: '#2B2C46' }} />
286
290
  </Tooltip>
287
291
  </Button>
@@ -321,7 +325,7 @@ const SearchBox = (props: any) => {
321
325
  })}
322
326
  />
323
327
  <Tooltip
324
- title="Search with an image"
328
+ title={t('Search with an image')}
325
329
  placement="top"
326
330
  arrow={true}
327
331
  >
@@ -53,7 +53,7 @@ function ItemResult(props: Props) {
53
53
  const [isOpenModalShare, setOpenModalShare] = useState<boolean>(false);
54
54
  const [feedback, setFeedback] = useState('none');
55
55
  const { t } = useTranslation();
56
- const { sku, title, brand, main_offer_link, collap } = dataItem;
56
+ const { sku, title, brand, main_offer_link, product_link, collap } = dataItem;
57
57
  useEffect(() => {
58
58
  if (main_image_link) {
59
59
  handlerCheckUrlImage(main_image_link);
@@ -323,7 +323,10 @@ function ItemResult(props: Props) {
323
323
  padding: 0,
324
324
  }}
325
325
  onClick={() =>
326
- window.open(`${main_offer_link}`, '_blank')
326
+ window.open(
327
+ `${product_link || main_offer_link}`,
328
+ '_blank',
329
+ )
327
330
  }
328
331
  >
329
332
  <Typography
@@ -39,6 +39,7 @@ import {
39
39
  import { useAppDispatch, useAppSelector } from 'Store/Store';
40
40
  import { showHits } from '../../constants';
41
41
  import { DEFAULT_REGION } from '../../constants';
42
+ import { useTranslation } from 'react-i18next';
42
43
 
43
44
  interface Props {
44
45
  allSearchResults: any;
@@ -56,7 +57,7 @@ function ResultComponent(props: Props) {
56
57
  const [imageSelection, setImageSelection] = useState<any>(null);
57
58
  const executeScroll = () => refBoxResult.current.scrollIntoView('-100px');
58
59
  const [filterString, setFilterString] = useState<string>();
59
-
60
+ const { t } = useTranslation();
60
61
  useEffect(() => {
61
62
  if (selectedRegion) {
62
63
  setImageSelection(selectedRegion);
@@ -171,7 +172,7 @@ function ResultComponent(props: Props) {
171
172
  ? search?.results
172
173
  .slice()
173
174
  .reverse()
174
- .map((f: any, i: number) => `sku:'${f.sku}'<score=${i}>`)
175
+ .map((f: any, i: number) => `sku:'${f.sku}'<score=${i}> `)
175
176
  : '';
176
177
  const filterSkusString = [...nonEmptyFilter, ...filterSkus].join(' OR ');
177
178
 
@@ -312,7 +313,10 @@ function ResultComponent(props: Props) {
312
313
  </Box>
313
314
  <Box className="box-title_col-left">
314
315
  <Typography style={{ fontSize: 11, color: '#fff' }}>
315
- Adjust the selection frame for better results.
316
+ {t(
317
+ 'Adjust the selection frame for better results',
318
+ )}
319
+ .
316
320
  </Typography>
317
321
  </Box>
318
322
  </Box>
@@ -447,7 +451,7 @@ function ResultComponent(props: Props) {
447
451
  className="box-change-hit-items"
448
452
  >
449
453
  <span style={{ paddingRight: '10px' }}>
450
- Items per page:
454
+ {t('Items per page')}:
451
455
  </span>
452
456
  <HitsPerPage items={showHits} defaultRefinement={20} />
453
457
  </Box>
@@ -7,6 +7,11 @@ export const translations = {
7
7
  'Manufacturer Number': 'Manufacturer Number',
8
8
  'Close group': 'Close group',
9
9
  'Show group': 'Show group',
10
+ 'Adjust the selection frame for better results':
11
+ 'Adjust the selection frame for better results',
12
+ 'Items per page': 'Items per page',
13
+ 'Search with an image': 'Search with an image',
14
+ 'Clear text search': 'Clear text search',
10
15
  },
11
16
  },
12
17
  de: {
@@ -17,6 +22,11 @@ export const translations = {
17
22
  'Manufacturer Number': 'Herst. Teile-Nr.',
18
23
  'Close group': 'Schließe Gruppe',
19
24
  'Show group': 'Zeige Gruppe',
25
+ 'Adjust the selection frame for better results':
26
+ 'Anpassen des Rahmens für bessere Ergebnisse',
27
+ 'Items per page': 'Artikel pro Seite',
28
+ 'Search with an image': 'Bildsuche',
29
+ 'Clear text search': 'Suchtext löschen',
20
30
  },
21
31
  },
22
32
  };