@nyris/nyris-webapp 0.3.4 → 0.3.9

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 (206) hide show
  1. package/build/asset-manifest.json +18 -32
  2. package/build/index.html +1 -1
  3. package/build/{precache-manifest.9800bdc87f5a2c5d6d8a5d1a5287598f.js → precache-manifest.a97813497ab8d37548141e5e2618d0dc.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.0481043c.chunk.css +2 -0
  8. package/build/static/css/main.0481043c.chunk.css.map +1 -0
  9. package/build/static/js/2.6e13adbe.chunk.js +3 -0
  10. package/build/static/js/2.6e13adbe.chunk.js.LICENSE.txt +79 -0
  11. package/build/static/js/2.6e13adbe.chunk.js.map +1 -0
  12. package/build/static/js/main.f5da7aa4.chunk.js +2 -0
  13. package/build/static/js/main.f5da7aa4.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 +242 -17
  20. package/src/AppMD.tsx +320 -0
  21. package/src/actions/nyrisAppActions.ts +76 -0
  22. package/src/actions/searchActions.ts +217 -0
  23. package/src/components/ExampleImages.tsx +17 -32
  24. package/src/components/Feedback.tsx +48 -87
  25. package/src/components/FiltersList.tsx +67 -0
  26. package/src/components/Header.tsx +17 -32
  27. package/src/components/Result.tsx +113 -186
  28. package/src/components/Sidebar.tsx +42 -0
  29. package/src/defaults.ts +3 -4
  30. package/src/epics/feedback.ts +59 -0
  31. package/src/epics/index.ts +154 -0
  32. package/src/epics/search.ts +164 -0
  33. package/src/epics/types.ts +12 -0
  34. package/src/{common/assets/fonts → fonts}/roboto-bold-webfont.woff +0 -0
  35. package/src/{common/assets/fonts → fonts}/roboto-bold-webfont.woff2 +0 -0
  36. package/src/{common/assets/fonts → fonts}/roboto-italic-webfont.woff +0 -0
  37. package/src/{common/assets/fonts → fonts}/roboto-italic-webfont.woff2 +0 -0
  38. package/src/{common/assets/fonts → fonts}/roboto-regular-webfont.woff +0 -0
  39. package/src/{common/assets/fonts → fonts}/roboto-regular-webfont.woff2 +0 -0
  40. package/src/{common/assets/fonts → fonts}/robotocondensed-bold-webfont.woff +0 -0
  41. package/src/{common/assets/fonts → fonts}/robotocondensed-bold-webfont.woff2 +0 -0
  42. package/src/{common/assets/fonts → fonts}/robotocondensed-bolditalic-webfont.woff +0 -0
  43. package/src/{common/assets/fonts → fonts}/robotocondensed-bolditalic-webfont.woff2 +0 -0
  44. package/src/{common/assets/images → images}/fav/android-icon-192x192.png +0 -0
  45. package/src/{common/assets/images → images}/fav/apple-icon-114x114.png +0 -0
  46. package/src/{common/assets/images → images}/fav/apple-icon-120x120.png +0 -0
  47. package/src/{common/assets/images → images}/fav/apple-icon-144x144.png +0 -0
  48. package/src/{common/assets/images → images}/fav/apple-icon-152x152.png +0 -0
  49. package/src/{common/assets/images → images}/fav/apple-icon-180x180.png +0 -0
  50. package/src/{common/assets/images → images}/fav/apple-icon-57x57.png +0 -0
  51. package/src/{common/assets/images → images}/fav/apple-icon-60x60.png +0 -0
  52. package/src/{common/assets/images → images}/fav/apple-icon-72x72.png +0 -0
  53. package/src/{common/assets/images → images}/fav/apple-icon-76x76.png +0 -0
  54. package/src/{common/assets/images → images}/fav/browserconfig.xml +0 -0
  55. package/src/{common/assets/images → images}/fav/favicon-16x16.png +0 -0
  56. package/src/{common/assets/images → images}/fav/favicon-32x32.png +0 -0
  57. package/src/{common/assets/images → images}/fav/favicon-96x96.png +0 -0
  58. package/src/{common/assets/images → images}/fav/manifest.json +0 -0
  59. package/src/{common/assets/images → images}/ic_cam.png +0 -0
  60. package/src/{common/assets/images → images}/ic_cam.svg +0 -0
  61. package/src/{common/assets/images → images}/ic_cam_large.png +0 -0
  62. package/src/{common/assets/images → images}/ic_cam_large.svg +0 -0
  63. package/src/{common/assets/images → images}/ic_cam_large_noimage.png +0 -0
  64. package/src/{common/assets/images → images}/ic_close_feedback.png +0 -0
  65. package/src/{common/assets/images → images}/ic_close_feedback.svg +0 -0
  66. package/src/{common/assets/images → images}/ic_shopNow.png +0 -0
  67. package/src/{common/assets/images → images}/ic_shopNow.svg +0 -0
  68. package/src/{common/assets/images → images}/ic_shopNowLight.png +0 -0
  69. package/src/{common/assets/images → images}/ic_shopNowLight.svg +0 -0
  70. package/src/{common/assets/images → images}/nyris_logo.png +0 -0
  71. package/src/{common/assets/images → images}/rewe.svg +0 -0
  72. package/src/{common/assets/images → images}/sectionTransBack.png +0 -0
  73. package/src/{common/assets/images → images}/sectionTransBack.svg +0 -0
  74. package/src/{common/assets/images → images}/sectionTransTop.png +0 -0
  75. package/src/{common/assets/images → images}/sectionTransTop.svg +0 -0
  76. package/src/index.css +415 -572
  77. package/src/index.tsx +191 -39
  78. package/src/types.ts +3 -42
  79. package/tsconfig.json +8 -3
  80. package/build/js/settings.example.js +0 -31
  81. package/build/js/test.js +0 -56
  82. package/build/static/css/2.8285176a.chunk.css +0 -2
  83. package/build/static/css/2.8285176a.chunk.css.map +0 -1
  84. package/build/static/css/main.6676fe1f.chunk.css +0 -2
  85. package/build/static/css/main.6676fe1f.chunk.css.map +0 -1
  86. package/build/static/js/2.29ddd567.chunk.js +0 -3
  87. package/build/static/js/2.29ddd567.chunk.js.LICENSE.txt +0 -124
  88. package/build/static/js/2.29ddd567.chunk.js.map +0 -1
  89. package/build/static/js/main.c35ded37.chunk.js +0 -2
  90. package/build/static/js/main.c35ded37.chunk.js.map +0 -1
  91. package/build/static/media/Fill.37094b44.svg +0 -3
  92. package/build/static/media/Montserrat-Bold.5a052e98.otf +0 -0
  93. package/build/static/media/Montserrat-Light.21789e89.otf +0 -0
  94. package/build/static/media/Montserrat-Medium.a53e0373.otf +0 -0
  95. package/build/static/media/Montserrat-Regular.71cdc681.otf +0 -0
  96. package/build/static/media/Montserrat-SemiBold.f613d915.otf +0 -0
  97. package/build/static/media/Rectangle.4dd8b747.png +0 -0
  98. package/build/static/media/admin.9529c7f6.svg +0 -3
  99. package/build/static/media/bg-support-page.6ac55268.svg +0 -9
  100. package/build/static/media/book_mark.8e294c0b.svg +0 -3
  101. package/build/static/media/icon_dislike.94607ca6.svg +0 -3
  102. package/build/static/media/icon_like.a4fb1b18.svg +0 -3
  103. package/build/static/media/icon_modal_image.3068d0ea.svg +0 -21
  104. package/build/static/media/icon_search_image.c2c728c0.svg +0 -3
  105. package/build/static/media/nyris_logo.22d8f250.svg +0 -3
  106. package/build/static/media/reload_icon.4b579a74.svg +0 -3
  107. package/build/static/media/save_search.bebaeebf.svg +0 -3
  108. package/build/static/media/support.289c3a3c.svg +0 -3
  109. package/build/static/media/translate_icon.f0492297.svg +0 -3
  110. package/public/js/settings.example.js +0 -31
  111. package/public/js/test.js +0 -56
  112. package/src/Router.tsx +0 -97
  113. package/src/Store/Auth.ts +0 -44
  114. package/src/Store/Nyris.ts +0 -77
  115. package/src/Store/Search.ts +0 -270
  116. package/src/Store/Store.ts +0 -53
  117. package/src/Store/common.d.ts +0 -10
  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 -188
  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 -193
  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 -468
  200. package/src/services/Feedback.ts +0 -65
  201. package/src/services/findByImage.ts +0 -24
  202. package/src/services/findRegionsCustom.ts +0 -15
  203. package/src/services/image.ts +0 -107
  204. package/src/services/nyris.ts +0 -123
  205. package/src/services/session.ts +0 -20
  206. package/src/services/types.ts +0 -82
package/package.json CHANGED
@@ -1,16 +1,13 @@
1
1
  {
2
2
  "name": "@nyris/nyris-webapp",
3
- "version": "0.3.4",
3
+ "version": "0.3.9",
4
4
  "homepage": "./",
5
5
  "dependencies": {
6
- "@babel/runtime": "^7.17.2",
7
6
  "@material-ui/core": "^4.3.3",
8
- "@material-ui/data-grid": "^4.0.0-alpha.37",
9
7
  "@material-ui/icons": "^4.4.1",
10
8
  "@material-ui/lab": "^4.0.0-alpha.60",
11
- "@nyris/nyris-api": "^0.3.4",
12
- "@nyris/nyris-react-components": "^0.3.4",
13
- "@reduxjs/toolkit": "^1.6.1",
9
+ "@nyris/nyris-api": "^0.3.9",
10
+ "@nyris/nyris-react-components": "^0.2.6",
14
11
  "@types/blueimp-load-image": "^2.23.4",
15
12
  "@types/classnames": "^2.2.9",
16
13
  "@types/history": "^4.7.3",
@@ -19,37 +16,21 @@
19
16
  "@types/react": "16.9.2",
20
17
  "@types/react-dom": "16.9.0",
21
18
  "@types/react-redux": "^7.1.2",
22
- "@types/react-router-dom": "^5.1.8",
23
- "algoliasearch": "^4.12.2",
24
- "axios": "^0.26.1",
25
- "blueimp-load-image": "^2.24.0",
19
+ "blueimp-load-image": "^5.16.0",
26
20
  "classnames": "^2.2.6",
27
21
  "history": "^4.10.1",
28
- "js-cookie": "^3.0.1",
29
- "konva": "5.0.3",
30
- "lodash": "^4.17.21",
31
- "qs": "^6.10.3",
32
- "react": "^17.0.0",
22
+ "react": "^16.13.1",
33
23
  "react-dom": "^16.13.1",
34
24
  "react-dropzone": "^10.1.8",
35
- "react-hook-form": "^7.27.1",
36
- "react-instantsearch-dom": "^6.22.0",
37
- "react-instantsearch-hooks": "^6.22.0",
38
- "react-konva": "16.13.0-6",
39
25
  "react-move": "^6.0.0",
40
26
  "react-redux": "^7.1.1",
41
- "react-responsive-carousel": "^3.2.22",
42
- "react-router-dom": "^5.3.0",
43
27
  "react-scripts": "^3.4.1",
44
- "react-select": "^5.2.2",
45
- "react-table": "^7.7.0",
46
28
  "redux": "^4.0.4",
47
29
  "redux-observable": "^1.1.0",
48
- "redux-thunk": "^2.4.1",
49
30
  "rxjs": "^6.5.3",
50
31
  "source-map-explorer": "^2.0.1",
51
32
  "typeface-roboto": "0.0.75",
52
- "typescript": "^4.1.2"
33
+ "typescript": "3.6.2"
53
34
  },
54
35
  "scripts": {
55
36
  "analyze": "source-map-explorer 'build/static/js/*.js'",
@@ -77,12 +58,8 @@
77
58
  ]
78
59
  },
79
60
  "devDependencies": {
80
- "@types/js-cookie": "^3.0.1",
81
- "@types/lodash": "^4.14.178",
82
- "@types/react-instantsearch-dom": "^6.12.2",
83
61
  "mockserver": "^3.1.1",
84
62
  "react-styleguidist": "^11.0.5",
85
- "redux-devtools-extension": "^2.13.8",
86
- "sass": "^1.39.0"
63
+ "redux-devtools-extension": "^2.13.8"
87
64
  }
88
65
  }
package/src/App.css CHANGED
@@ -33,33 +33,77 @@
33
33
  }
34
34
 
35
35
  .predicted-categories {
36
- display: flex;
37
- flex-wrap: wrap;
38
- flex-direction: row;
39
- justify-content: center;
36
+ display: flex;
37
+ flex-wrap: wrap;
38
+ flex-direction: row;
39
+ justify-content: center;
40
40
  }
41
41
  .predicted-categories small {
42
- white-space: nowrap;
43
- padding-left: 0.4em;
44
- padding-right: 0.4em;
45
- font-size: 0.8em;
46
- border-radius: 5px;
47
- margin: 0.2em;
48
- background-color: #fff;
42
+ white-space: nowrap;
43
+ padding-left: 0.4em;
44
+ padding-right: 0.4em;
45
+ font-size: 0.8em;
46
+ border-radius: 5px;
47
+ margin: 0.2em;
48
+ background-color: #fff;
49
49
  }
50
-
51
- /* Css Common all page */
52
- .d-flex {
53
- display: flex !important;
50
+ .sidebar {
51
+ width: 240px;
52
+ color: white;
53
+ border: 1px solid rgba(246, 242, 242, 0.1);
54
+ margin: 0;
55
+ padding: 0;
56
+ width: 200px;
57
+ position: fixed;
58
+ height: 100%;
59
+ overflow: auto;
54
60
  }
55
- .justify-center {
61
+
62
+ .app {
63
+ font-family: sans-serif;
64
+ font-size: 18px;
65
+ display: flex;
66
+ align-items: left;
56
67
  justify-content: center;
68
+ flex-direction: column;
69
+ gap: 20px;
70
+ height: 100vh;
71
+ font-family: Cambria, Cochin, Georgia, Times, "Times New Roman", serif;
57
72
  }
58
- .flex-end {
59
- align-items: flex-end;
73
+ .filterlabel ,.topFilterlabel{
74
+ margin-top: 30px;
75
+ font-size: 25px;
76
+ margin-bottom: 10px;
77
+ color: white;
60
78
  }
61
- .flex-center {
62
- align-items: center;
79
+ .topFilterlabel {
80
+ border-bottom: 4px solid white;
81
+ }
82
+ .list-container {
83
+ display: flex;
84
+ flex-direction: column;
85
+ gap: 5px;
86
+ color: white;
87
+ font-size: 20px;
88
+ }
89
+ .checked-item,
90
+ .not-checked-item {
91
+ margin-left: 10px;
92
+ }
93
+ .checked-item {
94
+ text-decoration: line-through;
63
95
  }
96
+ .rowC {
97
+ display:flex; flex-direction:row;
98
+ }
99
+
100
+ .colC {
101
+ display: flex; flex-direction: row;
102
+ }
103
+ .MuiDrawer-paper {
104
+ width: drawerWidth;
105
+ box-sizing: 'border-box';
106
+ }
107
+
64
108
 
65
109
 
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom';
3
+ import App, { AppProps } from './App';
4
+ import AppMD from './AppMD';
5
+ import {defaultMdSettings, defaultSettings} from "./defaults";
6
+
7
+
8
+ const appProps: AppProps = {
9
+ search: {
10
+ results: [],
11
+ categoryPredictions: [],
12
+ filterOptions: [],
13
+ regions: [],
14
+ codes: [],
15
+ previewSelection: { x1: 0, x2: 1, y1: 0, y2: 1}
16
+ },
17
+ loading: false,
18
+ feedbackState: 'question',
19
+ handlers: {
20
+ onCameraClick: () => {},
21
+ onCaptureCanceled: () => {},
22
+ onCaptureComplete: () => {},
23
+ onCloseFeedback: () => {},
24
+ onExampleImageClick: () => {},
25
+ onFileDropped: () => {},
26
+ onImageClick: () => {},
27
+ onLinkClick: () => {},
28
+ onSelectFile: () => {},
29
+ onShowStart: () => {},
30
+ onSelectionChange: () => {},
31
+ onPositiveFeedback: () => {},
32
+ onNegativeFeedback: () => {},
33
+ },
34
+ showPart: 'start',
35
+ settings: { ...defaultSettings },
36
+ mdSettings: defaultMdSettings,
37
+ };
38
+
39
+ it('renders without crashing', () => {
40
+ const div = document.createElement('div');
41
+ ReactDOM.render(<App { ...appProps} />, div);
42
+ ReactDOM.unmountComponentAtNode(div);
43
+ });
44
+
45
+ it('renders material design version without crashing', () => {
46
+ const div = document.createElement('div');
47
+ ReactDOM.render(<AppMD { ...appProps} />, div);
48
+ ReactDOM.unmountComponentAtNode(div);
49
+ });
package/src/App.tsx CHANGED
@@ -1,19 +1,244 @@
1
- import "react-app-polyfill/ie11";
2
- import "react-app-polyfill/stable";
3
- import React from "react";
4
- import "typeface-roboto";
5
- import "index.css";
6
- import { useAppSelector } from "Store/Store";
7
- import LandingPageApp from "modules/LandingPage/index";
8
- import AppNewVersion from "modules/LandingPage/indexNewVersion";
9
- import {AppState} from "./types";
10
-
11
- function App(): JSX.Element {
12
- const { settings } = useAppSelector<AppState>((state: any) => state);
13
- const { themePage } = settings;
14
- let SelectedApp = themePage.searchSuite?.active ? AppNewVersion : LandingPageApp;
15
-
16
- return <SelectedApp />;
1
+ import React, { useEffect, useState } from "react";
2
+ import { useDispatch } from "react-redux";
3
+ import { Animate, NodeGroup } from "react-move";
4
+ import { useDropzone} from "react-dropzone";
5
+ import {
6
+ Box,
7
+ Snackbar
8
+ } from "@material-ui/core";
9
+ import { Alert } from "@material-ui/lab";
10
+ import classNames from "classnames";
11
+ import { loadFilters } from "./actions/searchActions";
12
+ import Result from "./components/Result";
13
+ import Sidebar from "./components/Sidebar";
14
+ import Header from "./components/Header";
15
+ import Feedback from "./components/Feedback";
16
+ import CategoryFilter from "./components/CategoryFilter";
17
+ import Codes from "./components/Codes";
18
+ import PredictedCategories from "./components/PredictedCategories";
19
+ import ExampleImages from "./components/ExampleImages";
20
+ import {makeFileHandler, Capture, Preview} from "@nyris/nyris-react-components";
21
+ import { RectCoords, cadExtensions, CategoryPrediction, Code, Region, Filter} from "@nyris/nyris-api";
22
+ import { AppSettings, CanvasWithId, MDSettings } from "./types";
23
+ import { NyrisAppPart, NyrisFeedbackState } from "./actions/nyrisAppActions";
24
+
25
+ export interface AppHandlers {
26
+ onExampleImageClick: (url: string) => void,
27
+ onImageClick: (position: number, url: string) => void,
28
+ onLinkClick: (position: number, url: string) => void,
29
+ onFileDropped: (file: File) => void,
30
+ onCaptureComplete: (image: HTMLCanvasElement) => void,
31
+ onCaptureCanceled: () => void,
32
+ onSelectFile: (f: File) => void,
33
+ onCameraClick: () => void,
34
+ onShowStart: () => void,
35
+ onSelectionChange: (r: RectCoords) => void,
36
+ onPositiveFeedback: () => void,
37
+ onNegativeFeedback: () => void,
38
+ onCloseFeedback: () => void
39
+ }
40
+ export interface AppProps {
41
+ search: {
42
+ results: any[],
43
+ requestId?: string,
44
+ duration?: number,
45
+ categoryPredictions: CategoryPrediction[],
46
+ codes: Code[],
47
+ filterOptions: string[],
48
+ errorMessage?: string,
49
+ regions: Region[],
50
+ previewSelection: RectCoords,
51
+ toastErrorMessage?: string,
52
+ filters: Filter[],
53
+ selectedFilters: Map<string,string[]>
54
+ },
55
+ previewImage?: CanvasWithId,
56
+ settings: AppSettings,
57
+ loading: boolean,
58
+ showPart: NyrisAppPart,
59
+ feedbackState: NyrisFeedbackState,
60
+ handlers: AppHandlers,
61
+ mdSettings: MDSettings
62
+ }
63
+
64
+ const Demo2: React.FC<AppProps> = ({
65
+ search: {results, regions, previewSelection, requestId, duration, errorMessage, filterOptions, categoryPredictions, codes, toastErrorMessage, filters, selectedFilters},
66
+ showPart, settings, handlers, loading, previewImage, feedbackState
67
+ }) => {
68
+
69
+ const {getRootProps, getInputProps, isDragActive} = useDropzone({onDrop: (fs: File[]) => handlers.onFileDropped(fs[0])});
70
+
71
+ const minPreviewHeight = 400;
72
+ const halfOfTheScreenHeight = Math.floor(window.innerHeight * 0.45);
73
+ const maxPreviewHeight = Math.max(minPreviewHeight, halfOfTheScreenHeight);
74
+ const [toastOpen, setToastOpen] = useState(false);
75
+ const dispatch = useDispatch();
76
+
77
+ const acceptTypes =[ 'image/*' ].concat( settings.cadSearch ? cadExtensions : [] ).join(',');
78
+
79
+
80
+ useEffect(() => {
81
+ if (toastErrorMessage !== '') {
82
+ setToastOpen(true);
83
+ }
84
+ }, [toastErrorMessage])
85
+
86
+ useEffect(() =>{
87
+ dispatch(loadFilters());
88
+ }, [showPart, dispatch])
89
+
90
+ return (
91
+ <React.Fragment>
92
+ <Header/>
93
+ <div className="wrapperBody">
94
+ <Sidebar filters={filters} selectedFilters={selectedFilters}/>
95
+
96
+ <div className="mainContent">
97
+ {showPart === 'camera' &&
98
+ <Capture onCaptureComplete={handlers.onCaptureComplete} onCaptureCanceled={handlers.onCaptureCanceled}
99
+ useAppText='Use default camera app'/>}
100
+
101
+
102
+ <div className={classNames('headSection', {hidden: showPart === 'results'})} id="headSection">
103
+ <div {...getRootProps({
104
+ onClick: e => {
105
+ e.stopPropagation();
106
+ }
107
+ })} className={classNames('wrapper', 'dragAndDropActionArea', {'fileIsHover': isDragActive})}>
108
+
109
+ <div className={classNames('contentWrap')}>
110
+ <Box display="flex" flexDirection="column" justifyContent="center" alignItems="center" minHeight="100vh">
111
+ <section className="uploadImage">
112
+ <input type="button" name="file" id="capture" className="inputfile" accept="image/*"
113
+ capture="environment" onClick={handlers.onCameraClick}/>
114
+ <input type="file" name="file" id="capture_file" className="inputfile" accept={acceptTypes}
115
+ capture="environment"/>
116
+ <input {...getInputProps()} type="file" name="file" id="select_file" className="inputfile"
117
+ accept={acceptTypes}
118
+ onChange={makeFileHandler(handlers.onSelectFile)}
119
+ />
120
+ <div className="onDesktop">
121
+ Drop an image
122
+ <div className="smallText">or</div>
123
+ </div>
124
+ <div className="onMobile camIcon">
125
+ <img src="./images/ic_cam_large.svg" alt="Camera"/>
126
+ </div>
127
+ <label htmlFor="capture" className="btn primary onMobile"
128
+ style={{marginBottom: '2em', width: '12em'}}>
129
+ <span className="onMobile">Take a picture</span>
130
+ </label>
131
+ <br/>
132
+ <label htmlFor="select_file" className="btn primary" style={{width: '12em'}}>
133
+ <span>Select a file</span>
134
+ </label>
135
+ <label htmlFor="capture" className="mobileUploadHandler onMobile"/>
136
+ </section>
137
+ <ExampleImages images={settings.exampleImages} onExampleImageClicked={handlers.onExampleImageClick}/>
138
+
139
+ </Box>
140
+ </div>
141
+ </div>
142
+
143
+ <div className="headerSeparatorTop"/>
144
+ <div className="headerSeparatorBack"/>
145
+ <div className={classNames('tryDifferent', {hidden: showPart !== 'results'})}
146
+ onClick={handlers.onShowStart}>
147
+ <div className="icIcon">
148
+ </div>
149
+ <div className="textDesc"> Try a different image</div>
150
+ <br style={{clear: 'both'}}/>
151
+ </div>
152
+ </div>
153
+
154
+ <section className={classNames({hideResults: showPart !== 'results'},'results', {resultsActive: showPart === 'results'}, (results.length === 1 ? 'singleProduct' : 'multipleProducts'))}>
155
+ {errorMessage &&
156
+ <div className="errorMsg">
157
+ {errorMessage}
158
+ <div style={{textAlign: 'center', fontSize: '0ß.7em', paddingTop: '0.8em'}}><span>Make sure to include the request ID when reporting a problem: {requestId}</span>
159
+ </div>
160
+ </div>
161
+ }
162
+ <Animate show={loading} start={{opacity: 0.0}} enter={{opacity: [1.0], timing: {duration: 300}}}
163
+ leave={{opacity: [0.0], timing: {duration: 300}}}>
164
+ {s =>
165
+ <div className="loadingOverlay" style={{...s}}>
166
+ <div className="loading"/>
167
+ </div>
168
+ }
169
+ </Animate>
170
+ {settings.preview && previewImage &&
171
+ <div className="preview">
172
+ <Preview key={previewImage.id}
173
+ maxWidth={document.body.clientWidth} maxHeight={maxPreviewHeight}
174
+ dotColor="#4C8F9F"
175
+ onSelectionChange={handlers.onSelectionChange} regions={regions}
176
+ selection={previewSelection} image={previewImage.canvas}/>
177
+ </div>
178
+ }
179
+ <div className="predicted-categories">
180
+ <PredictedCategories cs={categoryPredictions}/>
181
+ </div>
182
+ <div className="predicted-categories">
183
+ <Codes codes={codes}/>
184
+ </div>
185
+ <CategoryFilter cats={filterOptions}/>
186
+
187
+ <div className="wrapper">
188
+ <NodeGroup data={results}
189
+ keyAccessor={r => r.sku}
190
+ start={(r, i) => ({opacity: 0, translateX: -100})}
191
+ enter={(r, i) => ({
192
+ opacity: [1],
193
+ translateX: [0],
194
+ timing: {delay: i * 100, duration: 300}
195
+ })}
196
+ >
197
+ {rs => <>{rs.map(({key, data, state}) => <Result
198
+ key={key}
199
+ noImageUrl={settings.noImageUrl}
200
+ template={settings.resultTemplate}
201
+ onImageClick={handlers.onImageClick}
202
+ onLinkClick={handlers.onLinkClick}
203
+ result={data}
204
+ style={{opacity: state.opacity, transform: `translateX(${state.translateX}%)`}}/>)}</>}
205
+ </NodeGroup>
206
+
207
+ {results.length === 0 && showPart === 'results' && !loading && (
208
+
209
+ <div className="noResults">We did not find anything <span role="img"
210
+ aria-label="sad face">😕</span></div>
211
+ )}
212
+
213
+ <br style={{clear: 'both'}}/>
214
+
215
+ {duration && showPart === 'results' && (<div style={{textAlign: 'center', fontSize: '0.7em', paddingTop: '0.8em'}}>Search
216
+ took {duration.toFixed(2)} seconds</div>)}
217
+
218
+ {requestId && showPart === 'results' && <div style={{textAlign: 'center', fontSize: '0.7em', paddingTop: '0.8em'}}>Request
219
+ identifier {requestId}</div>}
220
+ </div>
221
+ </section>
222
+
223
+ <Snackbar open={toastOpen} autoHideDuration={3000} onClose={() => setToastOpen(false)}>
224
+ <Alert onClose={() => setToastOpen(false)} severity="error">
225
+ {toastErrorMessage}
226
+ </Alert>
227
+ </Snackbar>
228
+
229
+ </div>
230
+ </div>
231
+ <section className="footnote">
232
+ <div className="wrapper">
233
+ © 2017 - 2019 <a href="https://nyris.io">nyris GmbH</a> - All rights reserved - <a
234
+ href="https://nyris.io/imprint/">Imprint</a>
235
+ </div>
236
+ </section>
237
+ <Feedback feedbackState={feedbackState} onPositiveFeedback={handlers.onPositiveFeedback}
238
+ onNegativeFeedback={handlers.onNegativeFeedback} onClose={handlers.onCloseFeedback}/>
239
+
240
+ </React.Fragment>
241
+ );
17
242
  }
18
243
 
19
- export default App;
244
+ export default Demo2;