@nyris/nyris-webapp 0.3.46 → 0.3.47

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.46",
3
+ "version": "0.3.47",
4
4
  "homepage": "./",
5
5
  "dependencies": {
6
6
  "@algolia/autocomplete-js": "^1.7.1",
@@ -13,8 +13,8 @@
13
13
  "@material-ui/data-grid": "^4.0.0-alpha.37",
14
14
  "@material-ui/icons": "^4.4.1",
15
15
  "@material-ui/lab": "^4.0.0-alpha.60",
16
- "@nyris/nyris-api": "^0.3.46",
17
- "@nyris/nyris-react-components": "^0.3.46",
16
+ "@nyris/nyris-api": "^0.3.47",
17
+ "@nyris/nyris-react-components": "^0.3.47",
18
18
  "@reduxjs/toolkit": "^1.6.1",
19
19
  "@splidejs/react-splide": "^0.7.12",
20
20
  "@types/blueimp-load-image": "^2.23.4",
@@ -57,7 +57,7 @@
57
57
  "react-scripts": "^3.4.1",
58
58
  "react-select": "^5.2.2",
59
59
  "react-table": "^7.7.0",
60
- "react-webcam": "^7.0.1",
60
+ "react-webcam": "^7.2.0",
61
61
  "redux": "^4.0.4",
62
62
  "redux-observable": "^1.1.0",
63
63
  "redux-thunk": "^2.4.1",
@@ -41,7 +41,6 @@ function ImagePreviewMobileComponent({
41
41
  const { t } = useTranslation();
42
42
  const { refine }: any = rest;
43
43
  const [editActive, setEditActive] = useState(false);
44
- const [showShrinkAnimation, setShrinkAnimation] = useState(false);
45
44
  const settings = useAppSelector(state => state.settings);
46
45
  const { preFilter } = useAppSelector(state => state.search);
47
46
  const isAlgoliaEnabled = settings.algolia?.enabled;
@@ -51,7 +50,6 @@ function ImagePreviewMobileComponent({
51
50
 
52
51
  const handleArrowClick = () => {
53
52
  setEditActive(s => !s);
54
- setShrinkAnimation(true);
55
53
  };
56
54
 
57
55
  const searchQuery = query.get('query') || '';
@@ -117,12 +115,14 @@ function ImagePreviewMobileComponent({
117
115
  marginBottom: '15px',
118
116
  }}
119
117
  >
120
- {editActive && (
121
- <div>
122
- <Box className="box-preview">
123
- <Box
124
- className="preview-item expand-animation"
125
- style={{ backgroundColor: 'transparent' }}
118
+ <div>
119
+ <Box className="box-preview">
120
+ <Box>
121
+ <div
122
+ className="preview-item"
123
+ style={{
124
+ backgroundColor: 'transparent',
125
+ }}
126
126
  >
127
127
  <Preview
128
128
  key={requestImage?.id}
@@ -133,104 +133,51 @@ function ImagePreviewMobileComponent({
133
133
  image={requestImage?.canvas}
134
134
  selection={imageSelection || DEFAULT_REGION}
135
135
  regions={filteredRegions}
136
- maxWidth={240}
137
- maxHeight={240}
138
- dotColor={'#FBD914'}
139
- minCropWidth={60}
140
- minCropHeight={60}
136
+ minWidth={80}
137
+ minHeight={80}
138
+ maxWidth={255}
139
+ maxHeight={255}
140
+ dotColor={editActive ? '#FBD914' : ''}
141
+ minCropWidth={editActive ? 60 : 5}
142
+ minCropHeight={editActive ? 60 : 5}
141
143
  rounded={false}
142
- expandAnimation={true}
143
- />
144
- </Box>
145
- {(showAdjustInfoBasedOnConfidence || showAdjustInfo) && (
146
- <Box
147
- className="box-title_col-left"
148
- alignItems="center"
149
- style={{
150
- backgroundColor: '#3E36DC',
151
- display: 'flex',
152
- columnGap: '6px',
153
- padding: '5px',
154
- width: 'fit-content',
144
+ expandAnimation={editActive}
145
+ shrinkAnimation={!editActive}
146
+ onExpand={() => {
147
+ setEditActive(true);
155
148
  }}
156
- >
157
- <IconInfo color="white" />
158
- <Typography
159
- style={{
160
- fontSize: 10,
161
- color: '#fff',
162
- }}
163
- >
164
- {showAdjustInfo
165
- ? t('Crop the image for better results')
166
- : 'Crop the image for better results'}
167
- </Typography>
168
- </Box>
169
- )}
149
+ showGrip={editActive}
150
+ />
151
+ </div>
170
152
  </Box>
171
- <Hidden>
172
- <Box
173
- sx={{
174
- position: 'absolute',
175
- left: '15px',
176
- top: '25px',
177
- padding: '4px',
178
- }}
179
- onClick={onImageRemove}
180
- >
181
- <Box
182
- sx={{
183
- width: '24px',
184
- height: '24px',
185
- justifyContent: 'center',
186
- alignItems: 'center',
187
- display: 'flex',
188
- borderRadius: '100%',
189
- }}
190
- >
191
- <Trash color="white" fill="white" />
192
- </Box>
193
- </Box>
194
- </Hidden>
195
-
196
- <Hidden mdUp>
153
+ {(showAdjustInfoBasedOnConfidence || showAdjustInfo) && (
197
154
  <Box
198
- className="slideDown"
199
- sx={{
200
- position: 'absolute',
201
- bottom: '25px',
202
- right: '20px',
155
+ className="box-title_col-left"
156
+ alignItems="center"
157
+ style={{
158
+ backgroundColor: '#3E36DC',
159
+ display: 'flex',
160
+ columnGap: '6px',
161
+ padding: '5px',
162
+ width: 'fit-content',
163
+ minWidth: '180px',
203
164
  }}
204
- onClick={handleArrowClick}
205
165
  >
206
- <Box
207
- bgcolor={'white'}
208
- sx={{
209
- width: '24px',
210
- height: '24px',
211
- justifyContent: 'center',
212
- alignItems: 'center',
213
- display: 'flex',
214
- borderRadius: '100%',
166
+ <IconInfo color="white" />
167
+ <Typography
168
+ style={{
169
+ fontSize: 10,
170
+ color: '#fff',
215
171
  }}
216
172
  >
217
- <ArrowUp color="black" />
218
- </Box>
173
+ {showAdjustInfo
174
+ ? t('Crop the image for better results')
175
+ : 'Crop the image for better results'}
176
+ </Typography>
219
177
  </Box>
220
- </Hidden>
221
- </div>
222
- )}
223
- {!editActive && (
224
- <Box
225
- className={showShrinkAnimation ? 'shrink-animation' : ''}
226
- sx={{
227
- display: 'flex',
228
- alignItems: 'center',
229
- justifyContent: 'center',
230
- height: 80,
231
- width: '100%',
232
- }}
233
- >
178
+ )}
179
+ </Box>
180
+ <>
234
181
  <Hidden>
235
182
  <Box
236
183
  sx={{
@@ -242,7 +189,6 @@ function ImagePreviewMobileComponent({
242
189
  onClick={onImageRemove}
243
190
  >
244
191
  <Box
245
- // className={showShrinkAnimation ? 'slideUp' : ''}
246
192
  sx={{
247
193
  width: '24px',
248
194
  height: '24px',
@@ -256,49 +202,19 @@ function ImagePreviewMobileComponent({
256
202
  </Box>
257
203
  </Box>
258
204
  </Hidden>
259
- <Box
260
- sx={{
261
- display: 'flex',
262
- height: '100%',
263
- width: '100%',
264
- justifyContent: 'center',
265
- alignItems: 'center',
266
- }}
267
- onClick={handleArrowClick}
268
- >
269
- {requestImage && requestImage?.canvas?.toDataURL && (
270
- <img
271
- src={requestImage?.canvas?.toDataURL()}
272
- style={{
273
- width: '80px',
274
- height: '80px',
275
- objectFit: 'contain',
276
- background: 'white',
277
- }}
278
- alt="preview"
279
- />
280
- )}
281
205
 
282
- <div
283
- className={
284
- showShrinkAnimation
285
- ? 'shrink-animation circle-layer'
286
- : 'circle-layer'
287
- }
288
- ></div>
289
- </Box>
290
206
  <Hidden mdUp>
291
207
  <Box
208
+ className="slideDown"
292
209
  sx={{
293
210
  position: 'absolute',
294
- right: '25px',
295
- padding: '4px',
211
+ bottom: '25px',
212
+ right: '20px',
296
213
  }}
297
214
  onClick={handleArrowClick}
298
215
  >
299
216
  <Box
300
217
  bgcolor={'white'}
301
- className={showShrinkAnimation ? 'slideUp' : ''}
302
218
  sx={{
303
219
  width: '24px',
304
220
  height: '24px',
@@ -308,12 +224,13 @@ function ImagePreviewMobileComponent({
308
224
  borderRadius: '100%',
309
225
  }}
310
226
  >
311
- <ArrowDown color="black" fill="black" />
227
+ {editActive && <ArrowUp color="black" />}
228
+ {!editActive && <ArrowDown color="black" fill="black" />}
312
229
  </Box>
313
230
  </Box>
314
231
  </Hidden>
315
- </Box>
316
- )}
232
+ </>
233
+ </div>
317
234
  </Box>
318
235
  );
319
236
  }
@@ -6,6 +6,7 @@ import InquiryModal from './InquiryModal';
6
6
  import { useAppSelector } from 'Store/Store';
7
7
  import { ReactComponent as EmailIcon } from 'common/assets/icons/icon_email.svg';
8
8
  import { ReactComponent as CallIcon } from 'common/assets/icons/call.svg';
9
+ import { useTranslation } from 'react-i18next';
9
10
 
10
11
  function InquiryBanner({
11
12
  requestImage,
@@ -31,6 +32,8 @@ function InquiryBanner({
31
32
  const { secondaryColor } =
32
33
  useAppSelector(state => state.settings.theme) || {};
33
34
 
35
+ const { t } = useTranslation();
36
+
34
37
  return (
35
38
  <>
36
39
  {isInquiryModalOpen && (
@@ -94,8 +97,8 @@ function InquiryBanner({
94
97
  }}
95
98
  >
96
99
  {isMobile
97
- ? 'No matches found?'
98
- : 'No matches found for your request?'}
100
+ ? `${t('No matches found')}?`
101
+ : `${t('No matches found for your request')}?`}
99
102
  </Box>
100
103
  <Box
101
104
  style={{
@@ -82,28 +82,35 @@ function SidePanel({
82
82
  >
83
83
  <div
84
84
  style={{
85
+ display: 'flex',
86
+ justifyContent: 'center',
85
87
  backgroundColor: '#F3F3F5',
86
88
  width: '100%',
87
89
  paddingTop: '16px',
88
90
  paddingBottom: '16px',
89
91
  }}
90
92
  >
91
- <Preview
92
- key={requestImage?.id}
93
- onSelectionChange={(r: RectCoords) => {
94
- setImageSelection(r);
95
- debouncedOnImageSelectionChange(r);
93
+ <div
94
+ style={{
95
+ width: '288px',
96
+ height: 'fit-content',
96
97
  }}
97
- image={requestImage?.canvas}
98
- selection={imageSelection || DEFAULT_REGION}
99
- regions={filteredRegions}
100
- maxWidth={288}
101
- maxHeight={288}
102
- dotColor={'#FBD914'}
103
- minCropWidth={60}
104
- minCropHeight={60}
105
- rounded={true}
106
- />
98
+ >
99
+ <Preview
100
+ key={requestImage?.id}
101
+ onSelectionChange={(r: RectCoords) => {
102
+ setImageSelection(r);
103
+ debouncedOnImageSelectionChange(r);
104
+ }}
105
+ image={requestImage?.canvas}
106
+ selection={imageSelection || DEFAULT_REGION}
107
+ regions={filteredRegions}
108
+ dotColor={'#FBD914'}
109
+ minCropWidth={60}
110
+ minCropHeight={60}
111
+ rounded={true}
112
+ />
113
+ </div>
107
114
  </div>
108
115
  </Box>
109
116
  </Box>
@@ -514,6 +514,12 @@
514
514
 
515
515
  video {
516
516
  overflow: hidden;
517
+ height: 100%;
518
+ width: 100%;
519
+ object-fit: cover;
520
+ min-width: 100%;
521
+ min-height: 100%;
522
+
517
523
  }
518
524
  }
519
525
 
@@ -706,6 +712,7 @@
706
712
  border-radius: 100%;
707
713
  padding: 30px;
708
714
  .outer {
715
+ display: block;
709
716
  border-radius: 100%;
710
717
  padding: 3px;
711
718
  background: linear-gradient(180deg, #AAABB5 0%, #FFFFFF 100%);
@@ -6,7 +6,6 @@ import { RectCoords } from '@nyris/nyris-api';
6
6
  import ReverseCamera from 'common/assets/icons/reverse_camera.svg';
7
7
  import { isEmpty } from 'lodash';
8
8
  import React, { useCallback, useRef, useState } from 'react';
9
- import { useDropzone } from 'react-dropzone';
10
9
  import { useHistory } from 'react-router-dom';
11
10
  import Webcam from 'react-webcam';
12
11
  import { createImage, find, findRegions } from 'services/image';
@@ -43,9 +42,9 @@ function CameraCustom(props: Props) {
43
42
 
44
43
  const videoConstraints = {
45
44
  width: 1080,
46
- height: 1080,
47
- aspectRatio: 1.33333333333,
45
+ aspectRatio: 1.11111,
48
46
  };
47
+
49
48
  const handleClick = useCallback(() => {
50
49
  setFacingMode(prevState =>
51
50
  prevState === FACING_MODE_USER
@@ -63,7 +62,6 @@ function CameraCustom(props: Props) {
63
62
  let region: RectCoords | undefined;
64
63
  let imageConvert = await createImage(image);
65
64
  dispatch(setRequestImage(imageConvert));
66
- dispatch(setImageSearchInput(image));
67
65
  dispatch(onToggleModalItemDetail(false));
68
66
  handlerCloseModal();
69
67
 
@@ -114,60 +112,6 @@ function CameraCustom(props: Props) {
114
112
  onToggleModal();
115
113
  };
116
114
 
117
- const { getInputProps } = useDropzone({
118
- onDrop: async (fs: File[]) => {
119
- let payload: any;
120
- let filters: any[] = [];
121
- let region: RectCoords | undefined;
122
- dispatch(updateStatusLoading(true));
123
- dispatch(setImageSearchInput(URL.createObjectURL(fs[0])));
124
- let image = await createImage(fs[0]);
125
- dispatch(setRequestImage(image));
126
- if (settings.regions) {
127
- let res = await findRegions(image, settings);
128
- dispatch(setRegions(res.regions));
129
- region = res.selectedRegion;
130
- dispatch(setSelectedRegion(region));
131
- }
132
-
133
- const preFilterValues = [
134
- {
135
- key: settings.visualSearchFilterKey,
136
- values: Object.keys(preFilter) as string[],
137
- },
138
- ];
139
- return find({
140
- image,
141
- settings,
142
- filters: !isEmpty(preFilter) ? preFilterValues : undefined,
143
- region,
144
- })
145
- .then((res: any) => {
146
- res?.results.map((item: any) => {
147
- filters.push({
148
- sku: item.sku,
149
- score: item.score,
150
- });
151
- });
152
- payload = {
153
- ...res,
154
- filters,
155
- };
156
- dispatch(setSearchResults(payload));
157
- setTimeout(() => {
158
- dispatch(updateStatusLoading(false));
159
- handlerCloseModal();
160
- history.push('/result');
161
- }, 500);
162
- })
163
- .catch((e: any) => {
164
- console.log('err camera_custom', e);
165
- dispatch(updateStatusLoading(false));
166
- handlerCloseModal();
167
- });
168
- },
169
- });
170
-
171
115
  return (
172
116
  <Box className="box-camera-custom">
173
117
  <Drawer
@@ -222,6 +166,7 @@ function CameraCustom(props: Props) {
222
166
  onClick={() => {
223
167
  const imageSrc = getScreenshot();
224
168
  handlerFindImage(imageSrc);
169
+ dispatch(setImageSearchInput(imageSrc));
225
170
  }}
226
171
  className="btn-capture-camera"
227
172
  >
@@ -285,12 +230,17 @@ function CameraCustom(props: Props) {
285
230
  id="icon-button-file"
286
231
  type="file"
287
232
  style={{ display: 'none' }}
288
- {...getInputProps({
289
- accept: 'image/png,image/jpeg',
290
- onClick: e => {
291
- e.stopPropagation();
292
- },
293
- })}
233
+ onChange={(fs: any) => {
234
+ const file = fs.target?.files[0];
235
+ if (!file) return;
236
+ dispatch(setImageSearchInput(URL.createObjectURL(file)));
237
+ handlerFindImage(file);
238
+ }}
239
+ accept="image/jpeg,image/png,image/webp"
240
+ onClick={event => {
241
+ // @ts-ignore
242
+ event.target.value = '';
243
+ }}
294
244
  />
295
245
  <label htmlFor="icon-button-file">
296
246
  <IconButton
@@ -25,6 +25,8 @@ export const translations = {
25
25
  'No products were found matching your search criteria.',
26
26
  'Please upload an image or enter a keyword to search.':
27
27
  'Please upload an image or enter a keyword to search.',
28
+ 'No matches found': 'No matches found',
29
+ 'No matches found for your request': 'No matches found for your request',
28
30
  },
29
31
  },
30
32
  de: {
@@ -53,6 +55,9 @@ export const translations = {
53
55
  'Keine Produkte entsprechen Ihren Suchkriterien.',
54
56
  'Please upload an image or enter a keyword to search.':
55
57
  'Für die Suche bitte Bild hochladen oder Stichwort eingeben.',
58
+ 'No matches found': 'Keine Treffer für Ihre Anfrage gefunden',
59
+ 'No matches found for your request':
60
+ 'Keine Treffer für Ihre Anfrage gefunden',
56
61
  },
57
62
  },
58
63
  pt: {
@@ -82,6 +87,8 @@ export const translations = {
82
87
  'Nenhum produto foi encontrado com estes critérios ',
83
88
  'Please upload an image or enter a keyword to search.':
84
89
  'Faça o upload de uma imagem ou busque via texto',
90
+ 'No matches found': 'No matches found',
91
+ 'No matches found for your request': 'No matches found for your request',
85
92
  },
86
93
  },
87
94
  };