@nyris/nyris-webapp 0.3.5 → 0.3.6

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 (203) hide show
  1. package/build/asset-manifest.json +18 -32
  2. package/build/index.html +1 -1
  3. package/build/{precache-manifest.bbb31f2ce7710d7eb3175b1b48241d24.js → precache-manifest.bffed513ca17d8ac16af1cc3aaa7d908.js} +13 -89
  4. package/build/service-worker.js +1 -1
  5. package/build/static/css/2.43a1c8b7.chunk.css +2 -0
  6. package/build/static/css/2.43a1c8b7.chunk.css.map +1 -0
  7. package/build/static/css/main.2a76dc8a.chunk.css +2 -0
  8. package/build/static/css/main.2a76dc8a.chunk.css.map +1 -0
  9. package/build/static/js/2.4e9a4ce1.chunk.js +3 -0
  10. package/build/static/js/2.4e9a4ce1.chunk.js.LICENSE.txt +79 -0
  11. package/build/static/js/2.4e9a4ce1.chunk.js.map +1 -0
  12. package/build/static/js/main.ec93aa4d.chunk.js +2 -0
  13. package/build/static/js/main.ec93aa4d.chunk.js.map +1 -0
  14. package/build/static/js/{runtime-main.b418ff16.js → runtime-main.f5553a9b.js} +1 -1
  15. package/build/static/js/{runtime-main.b418ff16.js.map → runtime-main.f5553a9b.js.map} +1 -1
  16. package/package.json +7 -30
  17. package/src/App.css +64 -20
  18. package/src/App.test.tsx +49 -0
  19. package/src/App.tsx +253 -15
  20. package/src/AppMD.tsx +320 -0
  21. package/src/Demo2.tsx +220 -0
  22. package/src/actions/nyrisAppActions.ts +76 -0
  23. package/src/actions/searchActions.ts +218 -0
  24. package/src/components/ExampleImages.tsx +17 -32
  25. package/src/components/Feedback.tsx +48 -87
  26. package/src/components/FiltersList.tsx +69 -0
  27. package/src/components/Header.tsx +17 -32
  28. package/src/components/Result.tsx +113 -186
  29. package/src/components/Sidebar.tsx +40 -0
  30. package/src/defaults.ts +3 -4
  31. package/src/epics/feedback.ts +59 -0
  32. package/src/epics/index.ts +154 -0
  33. package/src/epics/search.ts +203 -0
  34. package/src/epics/types.ts +12 -0
  35. package/src/{common/assets/fonts → fonts}/roboto-bold-webfont.woff +0 -0
  36. package/src/{common/assets/fonts → fonts}/roboto-bold-webfont.woff2 +0 -0
  37. package/src/{common/assets/fonts → fonts}/roboto-italic-webfont.woff +0 -0
  38. package/src/{common/assets/fonts → fonts}/roboto-italic-webfont.woff2 +0 -0
  39. package/src/{common/assets/fonts → fonts}/roboto-regular-webfont.woff +0 -0
  40. package/src/{common/assets/fonts → fonts}/roboto-regular-webfont.woff2 +0 -0
  41. package/src/{common/assets/fonts → fonts}/robotocondensed-bold-webfont.woff +0 -0
  42. package/src/{common/assets/fonts → fonts}/robotocondensed-bold-webfont.woff2 +0 -0
  43. package/src/{common/assets/fonts → fonts}/robotocondensed-bolditalic-webfont.woff +0 -0
  44. package/src/{common/assets/fonts → fonts}/robotocondensed-bolditalic-webfont.woff2 +0 -0
  45. package/src/{common/assets/images → images}/fav/android-icon-192x192.png +0 -0
  46. package/src/{common/assets/images → images}/fav/apple-icon-114x114.png +0 -0
  47. package/src/{common/assets/images → images}/fav/apple-icon-120x120.png +0 -0
  48. package/src/{common/assets/images → images}/fav/apple-icon-144x144.png +0 -0
  49. package/src/{common/assets/images → images}/fav/apple-icon-152x152.png +0 -0
  50. package/src/{common/assets/images → images}/fav/apple-icon-180x180.png +0 -0
  51. package/src/{common/assets/images → images}/fav/apple-icon-57x57.png +0 -0
  52. package/src/{common/assets/images → images}/fav/apple-icon-60x60.png +0 -0
  53. package/src/{common/assets/images → images}/fav/apple-icon-72x72.png +0 -0
  54. package/src/{common/assets/images → images}/fav/apple-icon-76x76.png +0 -0
  55. package/src/{common/assets/images → images}/fav/browserconfig.xml +0 -0
  56. package/src/{common/assets/images → images}/fav/favicon-16x16.png +0 -0
  57. package/src/{common/assets/images → images}/fav/favicon-32x32.png +0 -0
  58. package/src/{common/assets/images → images}/fav/favicon-96x96.png +0 -0
  59. package/src/{common/assets/images → images}/fav/manifest.json +0 -0
  60. package/src/{common/assets/images → images}/ic_cam.png +0 -0
  61. package/src/{common/assets/images → images}/ic_cam.svg +0 -0
  62. package/src/{common/assets/images → images}/ic_cam_large.png +0 -0
  63. package/src/{common/assets/images → images}/ic_cam_large.svg +0 -0
  64. package/src/{common/assets/images → images}/ic_cam_large_noimage.png +0 -0
  65. package/src/{common/assets/images → images}/ic_close_feedback.png +0 -0
  66. package/src/{common/assets/images → images}/ic_close_feedback.svg +0 -0
  67. package/src/{common/assets/images → images}/ic_shopNow.png +0 -0
  68. package/src/{common/assets/images → images}/ic_shopNow.svg +0 -0
  69. package/src/{common/assets/images → images}/ic_shopNowLight.png +0 -0
  70. package/src/{common/assets/images → images}/ic_shopNowLight.svg +0 -0
  71. package/src/{common/assets/images → images}/nyris_logo.png +0 -0
  72. package/src/{common/assets/images → images}/rewe.svg +0 -0
  73. package/src/{common/assets/images → images}/sectionTransBack.png +0 -0
  74. package/src/{common/assets/images → images}/sectionTransBack.svg +0 -0
  75. package/src/{common/assets/images → images}/sectionTransTop.png +0 -0
  76. package/src/{common/assets/images → images}/sectionTransTop.svg +0 -0
  77. package/src/index.css +416 -573
  78. package/src/index.tsx +189 -39
  79. package/src/types.ts +7 -51
  80. package/tsconfig.json +8 -3
  81. package/build/js/settings.example.js +0 -31
  82. package/build/js/test.js +0 -56
  83. package/build/static/css/2.8285176a.chunk.css +0 -2
  84. package/build/static/css/2.8285176a.chunk.css.map +0 -1
  85. package/build/static/css/main.6676fe1f.chunk.css +0 -2
  86. package/build/static/css/main.6676fe1f.chunk.css.map +0 -1
  87. package/build/static/js/2.4a55bc61.chunk.js +0 -3
  88. package/build/static/js/2.4a55bc61.chunk.js.LICENSE.txt +0 -124
  89. package/build/static/js/2.4a55bc61.chunk.js.map +0 -1
  90. package/build/static/js/main.2660f94a.chunk.js +0 -2
  91. package/build/static/js/main.2660f94a.chunk.js.map +0 -1
  92. package/build/static/media/Fill.37094b44.svg +0 -3
  93. package/build/static/media/Montserrat-Bold.5a052e98.otf +0 -0
  94. package/build/static/media/Montserrat-Light.21789e89.otf +0 -0
  95. package/build/static/media/Montserrat-Medium.a53e0373.otf +0 -0
  96. package/build/static/media/Montserrat-Regular.71cdc681.otf +0 -0
  97. package/build/static/media/Montserrat-SemiBold.f613d915.otf +0 -0
  98. package/build/static/media/Rectangle.4dd8b747.png +0 -0
  99. package/build/static/media/admin.9529c7f6.svg +0 -3
  100. package/build/static/media/bg-support-page.6ac55268.svg +0 -9
  101. package/build/static/media/book_mark.8e294c0b.svg +0 -3
  102. package/build/static/media/icon_dislike.94607ca6.svg +0 -3
  103. package/build/static/media/icon_like.a4fb1b18.svg +0 -3
  104. package/build/static/media/icon_modal_image.3068d0ea.svg +0 -21
  105. package/build/static/media/icon_search_image.c2c728c0.svg +0 -3
  106. package/build/static/media/nyris_logo.22d8f250.svg +0 -3
  107. package/build/static/media/reload_icon.4b579a74.svg +0 -3
  108. package/build/static/media/save_search.bebaeebf.svg +0 -3
  109. package/build/static/media/support.289c3a3c.svg +0 -3
  110. package/build/static/media/translate_icon.f0492297.svg +0 -3
  111. package/public/js/settings.example.js +0 -31
  112. package/public/js/test.js +0 -56
  113. package/src/Router.tsx +0 -97
  114. package/src/Store/Auth.ts +0 -44
  115. package/src/Store/Nyris.ts +0 -77
  116. package/src/Store/Search.ts +0 -243
  117. package/src/Store/Store.ts +0 -53
  118. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Bold.otf +0 -0
  119. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Light.otf +0 -0
  120. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Medium.otf +0 -0
  121. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Regular.otf +0 -0
  122. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-SemiBold.otf +0 -0
  123. package/src/common/assets/icons/Fill.png +0 -0
  124. package/src/common/assets/icons/Fill.svg +0 -3
  125. package/src/common/assets/icons/Icon_wechat.png +0 -0
  126. package/src/common/assets/icons/Icon_whatsapp.png +0 -0
  127. package/src/common/assets/icons/admin.png +0 -0
  128. package/src/common/assets/icons/admin.svg +0 -3
  129. package/src/common/assets/icons/book_mark.png +0 -0
  130. package/src/common/assets/icons/book_mark.svg +0 -3
  131. package/src/common/assets/icons/icon_barcode.png +0 -0
  132. package/src/common/assets/icons/icon_camera.png +0 -0
  133. package/src/common/assets/icons/icon_dislike.svg +0 -3
  134. package/src/common/assets/icons/icon_disslike.png +0 -0
  135. package/src/common/assets/icons/icon_email.png +0 -0
  136. package/src/common/assets/icons/icon_like.png +0 -0
  137. package/src/common/assets/icons/icon_like.svg +0 -3
  138. package/src/common/assets/icons/icon_modal_image.png +0 -0
  139. package/src/common/assets/icons/icon_modal_image.svg +0 -21
  140. package/src/common/assets/icons/icon_picture.png +0 -0
  141. package/src/common/assets/icons/icon_search_image.png +0 -0
  142. package/src/common/assets/icons/icon_search_image.svg +0 -3
  143. package/src/common/assets/icons/nyris_logo.svg +0 -3
  144. package/src/common/assets/icons/reload_icon.png +0 -0
  145. package/src/common/assets/icons/reload_icon.svg +0 -3
  146. package/src/common/assets/icons/save_search.png +0 -0
  147. package/src/common/assets/icons/save_search.svg +0 -3
  148. package/src/common/assets/icons/setting_search_icon.png +0 -0
  149. package/src/common/assets/icons/support.png +0 -0
  150. package/src/common/assets/icons/support.svg +0 -3
  151. package/src/common/assets/icons/translate_icon.png +0 -0
  152. package/src/common/assets/icons/translate_icon.svg +0 -3
  153. package/src/common/assets/icons/view_off.png +0 -0
  154. package/src/common/assets/images/Rectangle.png +0 -0
  155. package/src/common/assets/images/bg-support-page.svg +0 -9
  156. package/src/common/assets/images/image_test.png +0 -0
  157. package/src/components/CustomHits/index.tsx +0 -57
  158. package/src/components/DetailItem.tsx +0 -175
  159. package/src/components/DragDropFile.tsx +0 -192
  160. package/src/components/FilterComponent.tsx +0 -33
  161. package/src/components/Footer.tsx +0 -29
  162. package/src/components/FooterMD.tsx +0 -54
  163. package/src/components/FooterNewVersion.tsx +0 -12
  164. package/src/components/FooterResult.tsx +0 -47
  165. package/src/components/HeaderMd.tsx +0 -38
  166. package/src/components/HeaderNewVersion.tsx +0 -92
  167. package/src/components/Layout.tsx +0 -46
  168. package/src/components/LoadingScreen/index.tsx +0 -29
  169. package/src/components/Navigation.tsx +0 -34
  170. package/src/components/Panigation/Pagination.tsx +0 -140
  171. package/src/components/Panigation/cx.js +0 -3
  172. package/src/components/Panigation/isModifierClick.js +0 -10
  173. package/src/components/Saved/AllItem.tsx +0 -32
  174. package/src/components/Saved/Category.tsx +0 -16
  175. package/src/components/carousel/DefaultCarousel.tsx +0 -48
  176. package/src/components/common.d.ts +0 -9
  177. package/src/components/common.scss +0 -54
  178. package/src/components/default-select.tsx +0 -44
  179. package/src/components/hitItem/hits.tsx +0 -50
  180. package/src/components/hitItem/infinitiHits.tsx +0 -33
  181. package/src/components/input/inputSearch.tsx +0 -77
  182. package/src/components/modal/DefaultModal.tsx +0 -28
  183. package/src/components/results/ItemResult.tsx +0 -155
  184. package/src/components/search/ListSearch.tsx +0 -209
  185. package/src/modules/LandingPage/App.tsx +0 -318
  186. package/src/modules/LandingPage/AppMD.tsx +0 -399
  187. package/src/modules/LandingPage/common.scss +0 -1304
  188. package/src/modules/LandingPage/index.tsx +0 -169
  189. package/src/modules/LandingPage/indexNewVersion.tsx +0 -110
  190. package/src/modules/LandingPage/propsType.ts +0 -43
  191. package/src/page/Auth/login.tsx +0 -7
  192. package/src/page/Exception/404.tsx +0 -11
  193. package/src/page/History/index.tsx +0 -76
  194. package/src/page/Profile/index.tsx +0 -87
  195. package/src/page/Saved/MockData.ts +0 -223
  196. package/src/page/Saved/index.tsx +0 -166
  197. package/src/page/Support/index.tsx +0 -160
  198. package/src/page/result/MockData.ts +0 -36
  199. package/src/page/result/index.tsx +0 -418
  200. package/src/services/Feedback.ts +0 -64
  201. package/src/services/image.ts +0 -40
  202. package/src/services/session.ts +0 -17
  203. package/src/services/types.ts +0 -50
@@ -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;
@@ -0,0 +1,40 @@
1
+ import React, { useState } from 'react';
2
+ import {RiMenuLine} from 'react-icons/ri';
3
+ import { Filter } from '../../../nyris-api/index';
4
+ import FiltersList from './FiltersList';
5
+
6
+ interface SidebarProps {
7
+ filters: Filter[]
8
+ }
9
+
10
+ const Sidebar: React.FC<SidebarProps> = ({filters}) =>{
11
+ const [isExpanded, setIsExpanded] = useState(false);
12
+ const handleToggler =()=>{
13
+ if(isExpanded){
14
+ setIsExpanded(false);
15
+ return;
16
+ }
17
+ setIsExpanded(true);
18
+ }
19
+ return (
20
+
21
+ <div className={isExpanded ? "sidebar" : "Sidebar collapsed"}>
22
+ <div className="sidebarContent" >
23
+ <div className="sidebarHeader">
24
+ <RiMenuLine className="sidebar-icon" onClick={handleToggler}/>
25
+ <h1 className={isExpanded ? "sidebar-logo" : "sidebar-logo collapsedHide"}> Select Filters </h1>
26
+ </div>
27
+ <div className={isExpanded ? "Sidebar-items" : "Sidebar-items collapsedHide"}>
28
+ {filters && filters.map((x) => {
29
+ return <FiltersList filter={x}/>
30
+ })
31
+ }
32
+ </div>
33
+ </div>
34
+ </div>
35
+
36
+
37
+ )
38
+ }
39
+
40
+ export default Sidebar
package/src/defaults.ts CHANGED
@@ -17,10 +17,7 @@ export const defaultSettings : AppSettings = {
17
17
  '^https?://(www.)?vimeo.com/',
18
18
  '^https?://(www.)?dailymotion.com/',
19
19
  '^https?://(www.)?dai.ly/'
20
- ],
21
- themePage: {
22
- default: { active: true }
23
- }
20
+ ]
24
21
  };
25
22
 
26
23
  export const defaultMdSettings = {
@@ -30,8 +27,10 @@ export const defaultMdSettings = {
30
27
  appBarTitle: '',
31
28
  primaryColor: '#e2001a',
32
29
  secondaryColor: '#777777',
30
+
33
31
  resultFirstRowProperty: 'title',
34
32
  resultSecondRowProperty: 'sku',
35
33
  resultLinkText: 'Info',
34
+
36
35
  customFontFamily: 'Helvetica',
37
36
  };
@@ -0,0 +1,59 @@
1
+ import {combineEpics, ofType} from "redux-observable";
2
+ import {debounceTime, ignoreElements, tap, withLatestFrom} from "rxjs/operators";
3
+ import {EpicConf} from "./types";
4
+
5
+ const feedbackSuccessEpic: EpicConf = (action$, state$, {api}) => action$.pipe(
6
+ ofType('FEEDBACK_SUBMIT_POSITIVE', "FEEDBACK_SUBMIT_NEGATIVE"),
7
+ withLatestFrom(state$),
8
+ tap(async ([{type}, state]) => {
9
+ const success = type === 'FEEDBACK_SUBMIT_POSITIVE';
10
+ const sessionId = state.search.sessionId || state.search.requestId;
11
+ if (sessionId && state.search.requestId) {
12
+ await api.sendFeedback(sessionId, state.search.requestId, {
13
+ event: 'feedback', data: {success}
14
+ });
15
+ }
16
+ }),
17
+ ignoreElements()
18
+ );
19
+
20
+ const feedbackRegionEpic: EpicConf = (action$, state$, {api}) => action$.pipe(
21
+ ofType('REGION_CHANGED'),
22
+ debounceTime(1200),
23
+ withLatestFrom(state$),
24
+ tap(async ([action, state]) => {
25
+ if (action.type === 'REGION_CHANGED') {
26
+ let {normalizedRect: {x1, x2, y1, y2}} = action;
27
+ const sessionId = state.search.sessionId || state.search.requestId;
28
+ if (sessionId && state.search.requestId) {
29
+ await api.sendFeedback(sessionId, state.search.requestId, {
30
+ event: 'region', data: {rect: {x: x1, y: y1, w: x2 - x1, h: y2 - y1}}
31
+ });
32
+ }
33
+ }
34
+ }),
35
+ ignoreElements()
36
+ );
37
+
38
+ const feedbackClickEpic: EpicConf = (action$, state$, {api}) => action$.pipe(
39
+ ofType('RESULT_LINK_CLICKED', 'RESULT_IMAGE_CLICKED'),
40
+ withLatestFrom(state$),
41
+ tap(async ([action, state]) => {
42
+ if (action.type === 'RESULT_LINK_CLICKED' || action.type === 'RESULT_IMAGE_CLICKED') {
43
+ let {position} = action;
44
+ const sessionId = state.search.sessionId || state.search.requestId;
45
+ if (sessionId && state.search.requestId) {
46
+ await api.sendFeedback(sessionId, state.search.requestId, {
47
+ event: 'click', data: {positions: [position]}
48
+ });
49
+ }
50
+ }
51
+ }),
52
+ ignoreElements()
53
+ );
54
+
55
+ export default combineEpics(
56
+ feedbackSuccessEpic,
57
+ feedbackRegionEpic,
58
+ feedbackClickEpic
59
+ );
@@ -0,0 +1,154 @@
1
+ import {combineEpics, ofType} from "redux-observable";
2
+ import {debounceTime, delay, ignoreElements, map, switchMap, tap, withLatestFrom} from "rxjs/operators";
3
+ import {showFeedback, showResults} from "../actions/nyrisAppActions";
4
+ import {EpicConf} from "./types";
5
+ import feedbackEpics from "./feedback";
6
+ import searchEpics from "./search";
7
+ import {searchOffersForImage, searchOffersForCad, searchRegions} from "../actions/searchActions";
8
+ import {AppAction} from "../types";
9
+ import {selectFirstCenteredRegion} from "@nyris/nyris-api";
10
+
11
+
12
+
13
+ const historyEpic: EpicConf = (action$, state$, {history}) => action$.pipe(
14
+ ofType('SHOW_RESULTS', 'SHOW_START'),
15
+ withLatestFrom(state$),
16
+ tap(([action, state]) => {
17
+ let { type } = action;
18
+ console.log("action");
19
+ console.log(state.search.selectedFilters);
20
+ // action to clear all filters
21
+ if (type === 'SHOW_RESULTS' && history.location.pathname !== '/results') {
22
+ history.push('/results');
23
+ }
24
+ if (type === 'SHOW_START' && history.location.pathname !== '/') {
25
+
26
+ history.goBack();
27
+ }
28
+ }),
29
+ ignoreElements()
30
+ );
31
+
32
+ const onSearchSuccessShowResults: EpicConf = (action$) => action$.pipe(
33
+ ofType('SEARCH_REQUEST_SUCCEED'),
34
+ map(showResults)
35
+ );
36
+
37
+ const onSearchSuccessRedirectToSite: EpicConf = (action$, state$) => action$.pipe(
38
+ ofType('SEARCH_REQUEST_SUCCEED'),
39
+ withLatestFrom(state$),
40
+ tap(([action, {settings}]) => {
41
+ if (action.type !== 'SEARCH_REQUEST_SUCCEED' || !action.results || action.results.length !== 1) {
42
+ return;
43
+ }
44
+
45
+ const firstLink = action.results[0].l;
46
+ const instantRedirectPatterns = settings.instantRedirectPatterns;
47
+ if (!instantRedirectPatterns.find(r => new RegExp(r).test(firstLink))) {
48
+ return;
49
+ }
50
+ window.location.href = firstLink;
51
+ }),
52
+ ignoreElements()
53
+ );
54
+
55
+ const onSearchSuccessShowFeedbackDelayed: EpicConf = (action$) => action$.pipe(
56
+ ofType('SEARCH_REQUEST_SUCCEED'),
57
+ delay(3000),
58
+ map(showFeedback)
59
+ );
60
+
61
+
62
+ const startSearchOnImageLoaded: EpicConf = (action$, state$) => action$.pipe(
63
+ ofType('IMAGE_LOADED'),
64
+ withLatestFrom(state$),
65
+ switchMap(async ([action, {settings}]) : Promise<AppAction> => {
66
+ if (action.type !== 'IMAGE_LOADED') {
67
+ throw new Error(`Wrong action type ${action.type}`);
68
+ }
69
+
70
+ let { image } = action;
71
+
72
+ if (settings.regions) {
73
+ return searchRegions(image.canvas);
74
+ }
75
+ return searchOffersForImage(image.canvas);
76
+ })
77
+ );
78
+
79
+ const startSearchOnCadLoaded: EpicConf = (action$, state$) => action$.pipe(
80
+ ofType('CAD_LOADED'),
81
+ withLatestFrom(state$),
82
+ switchMap(async ([action, {settings}]) : Promise<AppAction> => {
83
+ if (action.type !== 'CAD_LOADED') {
84
+ throw new Error(`Wrong action type ${action.type}`);
85
+ }
86
+ let { file } = action;
87
+ return searchOffersForCad(file);
88
+ })
89
+ );
90
+
91
+ const startSearchOnRegionsSuccessful: EpicConf = (action$, state$) => action$.pipe(
92
+ ofType('REGION_REQUEST_SUCCEED'),
93
+ withLatestFrom(state$),
94
+ switchMap(async ([action, { search: { requestImage}}]) : Promise<AppAction> => {
95
+ if (action.type !== 'REGION_REQUEST_SUCCEED') {
96
+ throw new Error(`Wrong action type ${action.type}`);
97
+ }
98
+ if (!requestImage) {
99
+ throw new Error(`No requestImage`);
100
+ }
101
+ let { regions } = action;
102
+
103
+ let selection = selectFirstCenteredRegion(regions, 0.3, {x1: 0, x2: 1, y1: 0, y2: 1});
104
+ return searchOffersForImage(requestImage.canvas, selection);
105
+ })
106
+ );
107
+
108
+ const startSearchOnRegionsFailed: EpicConf = (action$, state$) => action$.pipe(
109
+ ofType('REGION_REQUEST_FAIL'),
110
+ withLatestFrom(state$),
111
+ switchMap(async ([action, { search: { requestImage}}]) : Promise<AppAction> => {
112
+ if (action.type !== 'REGION_REQUEST_FAIL') {
113
+ throw new Error(`Wrong action type ${action.type}`);
114
+ }
115
+ if (!requestImage) {
116
+ throw new Error(`No requestImage`);
117
+ }
118
+
119
+ return searchOffersForImage(requestImage.canvas);
120
+ })
121
+ );
122
+
123
+ const startSearchOnRegionChange: EpicConf = (action$, state$) => action$.pipe(
124
+ ofType('REGION_CHANGED'),
125
+ debounceTime(1200),
126
+ withLatestFrom(state$),
127
+ switchMap(async ([action, { search: { requestImage}}]) : Promise<AppAction> => {
128
+ if (action.type !== 'REGION_CHANGED') {
129
+ throw new Error(`Wrong action type ${action.type}`);
130
+ }
131
+ if (!requestImage) {
132
+ throw new Error(`No requestImage`);
133
+ }
134
+ let { normalizedRect } = action;
135
+ return searchOffersForImage(requestImage.canvas, normalizedRect);
136
+ })
137
+ );
138
+
139
+
140
+ const rootEpic = combineEpics(
141
+ searchEpics,
142
+ feedbackEpics,
143
+ historyEpic,
144
+ startSearchOnImageLoaded,
145
+ startSearchOnCadLoaded,
146
+ startSearchOnRegionsSuccessful,
147
+ startSearchOnRegionsFailed,
148
+ startSearchOnRegionChange,
149
+ onSearchSuccessShowResults,
150
+ onSearchSuccessShowFeedbackDelayed,
151
+ onSearchSuccessRedirectToSite
152
+ );
153
+
154
+ export default rootEpic;