@nyris/nyris-webapp 0.3.13 → 0.3.14

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 (29) hide show
  1. package/build/asset-manifest.json +11 -11
  2. package/build/index.html +1 -1
  3. package/build/js/settings.example.js +30 -0
  4. package/build/{precache-manifest.793f0a4375602ec8cd0fba83bf0e3e67.js → precache-manifest.fa9930c6ba4e9fb0ebad3869127ef308.js} +9 -9
  5. package/build/service-worker.js +1 -1
  6. package/build/static/css/{main.0c9239ba.chunk.css → main.6633770c.chunk.css} +2 -2
  7. package/build/static/css/main.6633770c.chunk.css.map +1 -0
  8. package/build/static/js/{2.520bb6d6.chunk.js → 2.0798bb8b.chunk.js} +3 -3
  9. package/build/static/js/{2.520bb6d6.chunk.js.LICENSE.txt → 2.0798bb8b.chunk.js.LICENSE.txt} +0 -0
  10. package/build/static/js/2.0798bb8b.chunk.js.map +1 -0
  11. package/build/static/js/main.31212715.chunk.js +2 -0
  12. package/build/static/js/main.31212715.chunk.js.map +1 -0
  13. package/package.json +2 -2
  14. package/public/js/settings.example.js +30 -0
  15. package/src/App.tsx +141 -268
  16. package/src/actions/searchActions.ts +5 -19
  17. package/src/components/CategoryFilter.tsx +13 -16
  18. package/src/components/Codes.tsx +16 -20
  19. package/src/components/ExampleImages.tsx +17 -27
  20. package/src/components/Feedback.tsx +48 -78
  21. package/src/components/PredictedCategories.tsx +12 -15
  22. package/src/components/Result.tsx +113 -186
  23. package/src/epics/index.ts +94 -143
  24. package/src/epics/search.ts +75 -114
  25. package/src/index.tsx +55 -63
  26. package/build/static/css/main.0c9239ba.chunk.css.map +0 -1
  27. package/build/static/js/2.520bb6d6.chunk.js.map +0 -1
  28. package/build/static/js/main.8405239a.chunk.js +0 -2
  29. package/build/static/js/main.8405239a.chunk.js.map +0 -1
@@ -1,34 +1,24 @@
1
- import React from "react";
1
+ import React from 'react';
2
2
 
3
3
  interface ExampleImagesProps {
4
- images: string[];
5
- onExampleImageClicked: (url: string) => void;
4
+ images: string[],
5
+ onExampleImageClicked: (url: string) => void
6
6
  }
7
7
 
8
- const ExampleImages: React.FC<ExampleImagesProps> = ({
9
- images,
10
- onExampleImageClicked,
11
- }) => {
12
- if (images.length === 0) {
13
- return null;
14
- }
15
- return (
16
- <section className="useExampleImg">
17
- You can also try one of these pictures:
18
- <div className="exampleImages">
19
- <div className="exImagesWrap">
20
- {images.map((i) => (
21
- <img
22
- key={i}
23
- src={i}
24
- alt=""
25
- onClick={() => onExampleImageClicked(i)}
26
- />
27
- ))}
28
- </div>
29
- </div>
30
- </section>
31
- );
8
+ const ExampleImages : React.FC<ExampleImagesProps> = ({images, onExampleImageClicked}) => {
9
+ if (images.length === 0) {
10
+ return null;
11
+ }
12
+ return (
13
+ <section className="useExampleImg">
14
+ You can also try one of these pictures:
15
+ <div className="exampleImages">
16
+ <div className="exImagesWrap">
17
+ {images.map((i) => (<img key={i} src={i} alt="" onClick={() => onExampleImageClicked(i)}/>))}
18
+ </div>
19
+ </div>
20
+ </section>
21
+ );
32
22
  };
33
23
 
34
24
  export default ExampleImages;
@@ -1,85 +1,55 @@
1
- import React from "react";
2
- import { NyrisFeedbackState } from "../actions/nyrisAppActions";
3
- import { Animate } from "react-move";
1
+ import React from 'react';
2
+ import {NyrisFeedbackState} from "../actions/nyrisAppActions";
3
+ import {Animate} from "react-move";
4
4
 
5
5
  interface FeedbackProps {
6
- feedbackState: NyrisFeedbackState;
7
- onPositiveFeedback?: () => void;
8
- onNegativeFeedback?: () => void;
9
- onClose?: () => void;
6
+ feedbackState: NyrisFeedbackState,
7
+ onPositiveFeedback?: () => void,
8
+ onNegativeFeedback?: () => void,
9
+ onClose?: () => void
10
10
  }
11
11
 
12
- const Feedback: React.FC<FeedbackProps> = ({
13
- feedbackState,
14
- onPositiveFeedback,
15
- onNegativeFeedback,
16
- onClose,
17
- }) => {
18
- let inner: any = null;
19
- switch (feedbackState) {
20
- case "question":
21
- inner = (
22
- <div className="feedbackForm">
23
- <p>Did you find what you were looking for?</p>
24
- <div
25
- className="btn primary positiveFeedback"
26
- onClick={onPositiveFeedback}
27
- >
28
- Yes
29
- </div>
30
- <div
31
- className="btn secondary negativeFeedback"
32
- onClick={onNegativeFeedback}
33
- >
34
- No
35
- </div>
36
- </div>
37
- );
38
- break;
39
- case "positive":
40
- inner = (
41
- <div className="feedbackMessage positive">
42
- Great, thank you for your feedback!
43
- </div>
44
- );
45
- break;
46
- case "negative":
47
- inner = (
48
- <div className="feedbackMessage negative">
49
- We saved your request so we can track down the issue and improve the
50
- search experience. Your Feedback helps us to make our service better
51
- for everyone, thank you!
52
- <br />
53
- <div className="btn dismiss" onClick={onClose}>
54
- Dismiss
55
- </div>
56
- </div>
57
- );
58
- break;
59
- default:
60
- inner = null;
61
- break;
62
- }
63
- return (
64
- <Animate
65
- show={feedbackState !== "hidden"}
66
- start={{ y: 100, opacity: 0 }}
67
- enter={{ y: [0], opacity: [1] }}
68
- leave={{ y: [100], opacity: [0] }}
69
- >
70
- {({ y, opacity }) => (
71
- <section
72
- className="feedback"
73
- style={{ transform: `translateY(${y}%)`, opacity }}
74
- >
75
- <div className="wrapper">{inner}</div>
76
- <div className="closeFeedbackContainer">
77
- <div className="closeFeedback" onClick={onClose} />
78
- </div>
79
- </section>
80
- )}
81
- </Animate>
82
- );
12
+ const Feedback: React.FC<FeedbackProps> = ({feedbackState, onPositiveFeedback, onNegativeFeedback, onClose}) => {
13
+ let inner : any = null;
14
+ switch (feedbackState) {
15
+ case 'question':
16
+ inner =
17
+ <div className="feedbackForm">
18
+ <p>Did you find what you were looking for?</p>
19
+ <div className="btn primary positiveFeedback" onClick={onPositiveFeedback}>Yes</div>
20
+ <div className="btn secondary negativeFeedback" onClick={onNegativeFeedback}>No</div>
21
+ </div>;
22
+ break;
23
+ case 'positive':
24
+ inner = <div className="feedbackMessage positive">Great, thank you for your feedback!</div>
25
+ break;
26
+ case 'negative':
27
+ inner =
28
+ <div className="feedbackMessage negative">We saved your request so we can track down the
29
+ issue and improve the search experience. Your Feedback helps us to make our service
30
+ better for everyone,
31
+ thank you!<br/>
32
+ <div className="btn dismiss" onClick={onClose}>Dismiss</div>
33
+ </div>;
34
+ break;
35
+ default:
36
+ inner = null;
37
+ break;
38
+ }
39
+ return (
40
+ <Animate show={feedbackState !== 'hidden'} start={{y: 100, opacity: 0}} enter={{y: [0], opacity: [1]}} leave={{y: [100], opacity: [0] }}>
41
+ {({y, opacity}) =>
42
+ <section className="feedback" style={{transform: `translateY(${y}%)`, opacity }}>
43
+ <div className="wrapper">
44
+ {inner}
45
+ </div>
46
+ <div className="closeFeedbackContainer">
47
+ <div className="closeFeedback" onClick={onClose}/>
48
+ </div>
49
+ </section>
50
+ }
51
+ </Animate>
52
+ );
83
53
  };
84
54
 
85
55
  export default Feedback;
@@ -1,17 +1,14 @@
1
- import React from "react";
1
+ import React from 'react';
2
+
3
+ const PredictedCategories = ({cs}: {cs: {name: string, score: number}[]}) =>
4
+ <>
5
+ {cs.map((c) =>
6
+ <small key={c.name}>
7
+ {c.name === "" ? "No category" : c.name.split(" > ").slice(-1)[0]}:
8
+ {(c.score * 100).toFixed(0)}%
9
+ </small>)}
10
+ </>
11
+ ;
12
+
2
13
 
3
- const PredictedCategories = ({
4
- cs,
5
- }: {
6
- cs: { name: string; score: number }[];
7
- }) => (
8
- <>
9
- {cs.map((c) => (
10
- <small key={c.name}>
11
- {c.name === "" ? "No category" : c.name.split(" > ").slice(-1)[0]}:
12
- {(c.score * 100).toFixed(0)}%
13
- </small>
14
- ))}
15
- </>
16
- );
17
14
  export default PredictedCategories;
@@ -1,210 +1,137 @@
1
- import React from "react";
2
- import { OfferNyrisResult as ResultData } from "@nyris/nyris-api";
1
+ import React from 'react';
2
+ import {OfferNyrisResult as ResultData} from "@nyris/nyris-api";
3
3
 
4
4
  // TODO this needs refactoring: Make it one block with parameters for first line, second line, image url ..
5
5
 
6
6
  interface Options {
7
- result: any;
8
- noImageUrl: string;
9
- onImageClick: (e: React.MouseEvent) => void;
10
- onLinkClick: (e: React.MouseEvent) => void;
7
+ result: any,
8
+ noImageUrl: string,
9
+ onImageClick: (e: React.MouseEvent) => void,
10
+ onLinkClick: (e: React.MouseEvent) => void
11
11
  }
12
12
 
13
13
  const renderPrice = (result: ResultData) =>
14
- result.p ? "" + (result.p.vi / 100).toFixed(2) + " " + result.p.c : "";
14
+ result.p ? '' + (result.p.vi / 100).toFixed(2) + ' ' + result.p.c : '';
15
15
 
16
- const renderDefault = ({
17
- result,
18
- noImageUrl,
19
- onImageClick,
20
- onLinkClick,
21
- }: Options) => {
22
- return (
23
- <>
24
- <a
25
- href={result.l}
26
- className="imageLink"
27
- title="Click the image so see similar products"
28
- onClick={onImageClick}
29
- onAuxClick={onLinkClick}
30
- >
31
- <div className="prdctImg">
32
- <div className="imgWrap">
33
- <img
34
- src={(result.img && result.img.url + "?r=512x512") || noImageUrl}
35
- alt={result.title}
36
- />
37
- </div>
38
- </div>
39
- </a>
40
- <div className="prdctDetailsWrap">
41
- <div>
42
- <div className="prdctTitle">{result.title}</div>
43
- <div className="prdctMeta">
44
- <span className="prdctPrice">{renderPrice(result)}</span>
45
- </div>
46
- <a
47
- onClick={onLinkClick}
48
- onAuxClick={onLinkClick}
49
- className="prdctShopLink"
50
- href={result.l}
51
- target="_blank"
52
- rel="noopener noreferrer"
53
- >
54
- Buy Now
55
- </a>
56
- </div>
57
- </div>
58
- </>
59
- );
16
+ const renderDefault = ({result, noImageUrl, onImageClick, onLinkClick}: Options) => {
17
+ return (
18
+ <>
19
+ <a href={result.l} className="imageLink" title="Click the image so see similar products"
20
+ onClick={onImageClick}
21
+ onAuxClick={onLinkClick}>
22
+ <div className="prdctImg">
23
+ <div className="imgWrap">
24
+ <img src={(result.img && result.img.url + '?r=512x512') || noImageUrl} alt={result.title}/>
25
+ </div>
26
+ </div>
27
+ </a>
28
+ <div className="prdctDetailsWrap">
29
+ <div>
30
+ <div className="prdctTitle">{result.title}</div>
31
+ <div className="prdctMeta">
32
+ <span className="prdctPrice">{renderPrice(result)}</span>
33
+ </div>
34
+ <a onClick={onLinkClick} onAuxClick={onLinkClick} className="prdctShopLink" href={result.l}
35
+ target="_blank" rel="noopener noreferrer">Buy Now</a>
36
+ </div>
37
+ </div>
38
+ </>
39
+ );
60
40
  };
61
41
 
62
- const renderSnr = ({
63
- result,
64
- noImageUrl,
65
- onImageClick,
66
- onLinkClick,
67
- }: Options) => (
68
- <>
69
- <a
70
- href={result.l}
71
- className="imageLink"
72
- onClick={onImageClick}
73
- onAuxClick={onLinkClick}
74
- >
75
- <div className="prdctImg">
76
- <div className="imgWrap">
77
- <img
78
- src={(result.img && result.img.url + "?r=512x512") || noImageUrl}
79
- alt={result.title}
80
- />
81
- </div>
82
- </div>
83
- </a>
84
- <div className="prdctDetailsWrap">
85
- <div>
86
- <div className="prdctTitle">{result.sku}</div>
87
- <div
88
- className="prdctMeta"
89
- style={{ height: "5em", whiteSpace: "normal" }}
90
- >
91
- {result.title}
92
- </div>
93
- <a
94
- style={{ backgroundImage: "none", paddingLeft: "10px" }}
95
- className="prdctShopLink"
96
- href={result.l}
97
- target="_blank"
98
- rel="noopener noreferrer"
99
- onClick={onLinkClick}
100
- onAuxClick={onLinkClick}
101
- >
102
- Info
42
+ const renderSnr = ({result, noImageUrl, onImageClick, onLinkClick}: Options) => (
43
+ <>
44
+ <a href={result.l} className="imageLink" onClick={onImageClick} onAuxClick={onLinkClick}>
45
+ <div className="prdctImg">
46
+ <div className="imgWrap">
47
+ <img src={(result.img && result.img.url + '?r=512x512') || noImageUrl} alt={result.title}/>
48
+ </div>
49
+ </div>
103
50
  </a>
104
- </div>
105
- </div>
106
- </>
51
+ <div className="prdctDetailsWrap">
52
+ <div>
53
+ <div className="prdctTitle">{result.sku}</div>
54
+ <div className="prdctMeta" style={{height: '5em', whiteSpace: 'normal'}}>
55
+ {result.title}
56
+ </div>
57
+ <a style={{backgroundImage: 'none', paddingLeft: '10px'}} className="prdctShopLink" href={result.l}
58
+ target="_blank" rel="noopener noreferrer"
59
+ onClick={onLinkClick} onAuxClick={onLinkClick}>Info</a>
60
+ </div>
61
+ </div>
62
+ </>
107
63
  );
108
64
 
109
- const renderSnrMultilink = (
110
- { result, noImageUrl, onImageClick }: Options,
111
- onLinkClick: (url: string) => void
112
- ) => (
113
- <>
114
- <a
115
- href={result.l}
116
- className="imageLink"
117
- onClick={onImageClick}
118
- onAuxClick={onImageClick}
119
- >
120
- <div className="prdctImg">
121
- <div className="imgWrap">
122
- <img
123
- src={(result.img && result.img.url + "?r=512x512") || noImageUrl}
124
- alt={result.title}
125
- />
126
- </div>
127
- </div>
128
- </a>
129
- <div className="prdctDetailsWrap">
130
- <div>
131
- <div className="prdctTitle">{result.sku}</div>
132
- <div
133
- className="prdctMeta"
134
- style={{ height: "5em", whiteSpace: "normal" }}
135
- >
136
- {result.title}
65
+ const renderSnrMultilink = ({result, noImageUrl, onImageClick}: Options, onLinkClick: (url: string) => void) => (
66
+ <>
67
+ <a href={result.l} className="imageLink"
68
+ onClick={onImageClick} onAuxClick={onImageClick}>
69
+ <div className="prdctImg">
70
+ <div className="imgWrap">
71
+ <img src={(result.img && result.img.url + '?r=512x512') || noImageUrl} alt={result.title}/>
72
+ </div>
73
+ </div>
74
+ </a>
75
+ <div className="prdctDetailsWrap">
76
+ <div>
77
+ <div className="prdctTitle">{result.sku}</div>
78
+ <div className="prdctMeta" style={{height: '5em', whiteSpace: 'normal'}}>
79
+ {result.title}
80
+ </div>
81
+ {result.l.map((l: { text: string, href: string }) =>
82
+ <a style={{backgroundImage: 'none', paddingLeft: '10px'}} className="prdctShopLink" href={l.href}
83
+ onClick={() => onLinkClick(l.href)} onAuxClick={() => onLinkClick(l.href)} target="_blank"
84
+ key={l.href}
85
+ rel="noopener noreferrer">{l.text}</a>
86
+ )}
87
+ </div>
137
88
  </div>
138
- {result.l.map((l: { text: string; href: string }) => (
139
- <a
140
- style={{ backgroundImage: "none", paddingLeft: "10px" }}
141
- className="prdctShopLink"
142
- href={l.href}
143
- onClick={() => onLinkClick(l.href)}
144
- onAuxClick={() => onLinkClick(l.href)}
145
- target="_blank"
146
- key={l.href}
147
- rel="noopener noreferrer"
148
- >
149
- {l.text}
150
- </a>
151
- ))}
152
- </div>
153
- </div>
154
- </>
89
+ </>
155
90
  );
156
91
 
157
92
  export interface ResultProps {
158
- result: any;
159
- style: any;
160
- template?: string;
161
- onImageClick: (pos: number, url: string) => void;
162
- onLinkClick: (pos: number, url: string) => void;
163
- noImageUrl?: string;
93
+ result: any,
94
+ style: any,
95
+ template?: string,
96
+ onImageClick: (pos: number, url: string) => void,
97
+ onLinkClick: (pos: number, url: string) => void,
98
+ noImageUrl?: string
164
99
  }
165
100
 
166
- const Result: React.FC<ResultProps> = ({
167
- result,
168
- style,
169
- template,
170
- onImageClick,
171
- onLinkClick,
172
- noImageUrl,
173
- }) => {
174
- let options: Options = {
175
- onImageClick: (e: React.MouseEvent) => {
176
- e.preventDefault();
177
- onImageClick(result.position, result.img.url);
178
- },
179
- onLinkClick: (e: React.MouseEvent) => {
180
- e.preventDefault();
181
- onLinkClick(result.position, result.l);
182
- },
183
- noImageUrl: noImageUrl || "images/ic_cam_large_noimage.png",
184
- result,
185
- };
101
+ const Result: React.FC<ResultProps> = ({result, style, template, onImageClick, onLinkClick, noImageUrl}) => {
102
+ let options: Options = {
103
+ onImageClick: (e: React.MouseEvent) => {
104
+ e.preventDefault();
105
+ onImageClick(result.position, result.img.url);
106
+ },
107
+ onLinkClick: (e: React.MouseEvent) => {
108
+ e.preventDefault();
109
+ onLinkClick(result.position, result.l);
110
+ },
111
+ noImageUrl: noImageUrl || 'images/ic_cam_large_noimage.png',
112
+ result
113
+ };
186
114
 
187
- let resultInner = null;
188
- switch (template) {
189
- case "snr":
190
- resultInner = renderSnr(options);
191
- break;
192
- case "snr-multilink":
193
- resultInner = renderSnrMultilink(options, (url) =>
194
- onLinkClick(result.position, url)
195
- );
196
- break;
197
- case "default":
198
- default:
199
- resultInner = renderDefault(options);
200
- break;
201
- }
115
+ let resultInner = null;
116
+ switch (template) {
117
+ case "snr":
118
+ resultInner = renderSnr(options);
119
+ break;
120
+ case "snr-multilink":
121
+ resultInner = renderSnrMultilink(options, (url) => onLinkClick(result.position, url));
122
+ break;
123
+ case 'default':
124
+ default:
125
+ resultInner = renderDefault(options);
126
+ break;
127
+ }
202
128
 
203
- return (
204
- <div className="prdctItem" style={{ ...style }}>
205
- {resultInner}
206
- </div>
207
- );
129
+ return (
130
+ <div className="prdctItem" style={{...style}}>
131
+ {resultInner}
132
+ </div>
133
+ );
208
134
  };
209
135
 
136
+
210
137
  export default Result;