@nyris/nyris-webapp 0.2.6 → 0.3.3

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 (200) hide show
  1. package/build/asset-manifest.json +32 -18
  2. package/build/index.html +1 -1
  3. package/build/js/test.js +56 -0
  4. package/build/{precache-manifest.aa7c9d32340f77d86c9a3347b54ba2a5.js → precache-manifest.01ce682577e62add75aa397b2a944b75.js} +89 -13
  5. package/build/service-worker.js +1 -1
  6. package/build/static/css/2.8285176a.chunk.css +2 -0
  7. package/build/static/css/2.8285176a.chunk.css.map +1 -0
  8. package/build/static/css/main.6676fe1f.chunk.css +2 -0
  9. package/build/static/css/main.6676fe1f.chunk.css.map +1 -0
  10. package/build/static/js/2.d1562c08.chunk.js +3 -0
  11. package/build/static/js/2.d1562c08.chunk.js.LICENSE.txt +133 -0
  12. package/build/static/js/2.d1562c08.chunk.js.map +1 -0
  13. package/build/static/js/main.5c08aba4.chunk.js +2 -0
  14. package/build/static/js/main.5c08aba4.chunk.js.map +1 -0
  15. package/build/static/js/{runtime-main.f5553a9b.js → runtime-main.b418ff16.js} +1 -1
  16. package/build/static/js/{runtime-main.f5553a9b.js.map → runtime-main.b418ff16.js.map} +1 -1
  17. package/build/static/media/Fill.37094b44.svg +3 -0
  18. package/build/static/media/Montserrat-Bold.5a052e98.otf +0 -0
  19. package/build/static/media/Montserrat-Light.21789e89.otf +0 -0
  20. package/build/static/media/Montserrat-Medium.a53e0373.otf +0 -0
  21. package/build/static/media/Montserrat-Regular.71cdc681.otf +0 -0
  22. package/build/static/media/Montserrat-SemiBold.f613d915.otf +0 -0
  23. package/build/static/media/Rectangle.4dd8b747.png +0 -0
  24. package/build/static/media/admin.9529c7f6.svg +3 -0
  25. package/build/static/media/bg-support-page.6ac55268.svg +9 -0
  26. package/build/static/media/book_mark.8e294c0b.svg +3 -0
  27. package/build/static/media/icon_dislike.94607ca6.svg +3 -0
  28. package/build/static/media/icon_like.a4fb1b18.svg +3 -0
  29. package/build/static/media/icon_modal_image.3068d0ea.svg +21 -0
  30. package/build/static/media/icon_search_image.c2c728c0.svg +3 -0
  31. package/build/static/media/nyris_logo.22d8f250.svg +3 -0
  32. package/build/static/media/reload_icon.4b579a74.svg +3 -0
  33. package/build/static/media/save_search.bebaeebf.svg +3 -0
  34. package/build/static/media/support.289c3a3c.svg +3 -0
  35. package/build/static/media/translate_icon.f0492297.svg +3 -0
  36. package/package.json +30 -6
  37. package/public/js/test.js +56 -0
  38. package/src/App.css +27 -11
  39. package/src/App.tsx +19 -235
  40. package/src/Router.tsx +97 -0
  41. package/src/Store/Auth.ts +44 -0
  42. package/src/Store/Nyris.ts +77 -0
  43. package/src/Store/Search.ts +269 -0
  44. package/src/Store/Store.ts +46 -0
  45. package/src/Store/common.d.ts +10 -0
  46. package/src/{epics → Store/epics}/feedback.ts +0 -0
  47. package/src/{epics → Store/epics}/types.ts +1 -1
  48. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Bold.otf +0 -0
  49. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Light.otf +0 -0
  50. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Medium.otf +0 -0
  51. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Regular.otf +0 -0
  52. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-SemiBold.otf +0 -0
  53. package/src/{fonts → common/assets/fonts}/roboto-bold-webfont.woff +0 -0
  54. package/src/{fonts → common/assets/fonts}/roboto-bold-webfont.woff2 +0 -0
  55. package/src/{fonts → common/assets/fonts}/roboto-italic-webfont.woff +0 -0
  56. package/src/{fonts → common/assets/fonts}/roboto-italic-webfont.woff2 +0 -0
  57. package/src/{fonts → common/assets/fonts}/roboto-regular-webfont.woff +0 -0
  58. package/src/{fonts → common/assets/fonts}/roboto-regular-webfont.woff2 +0 -0
  59. package/src/{fonts → common/assets/fonts}/robotocondensed-bold-webfont.woff +0 -0
  60. package/src/{fonts → common/assets/fonts}/robotocondensed-bold-webfont.woff2 +0 -0
  61. package/src/{fonts → common/assets/fonts}/robotocondensed-bolditalic-webfont.woff +0 -0
  62. package/src/{fonts → common/assets/fonts}/robotocondensed-bolditalic-webfont.woff2 +0 -0
  63. package/src/common/assets/icons/Fill.png +0 -0
  64. package/src/common/assets/icons/Fill.svg +3 -0
  65. package/src/common/assets/icons/Icon_wechat.png +0 -0
  66. package/src/common/assets/icons/Icon_whatsapp.png +0 -0
  67. package/src/common/assets/icons/admin.png +0 -0
  68. package/src/common/assets/icons/admin.svg +3 -0
  69. package/src/common/assets/icons/book_mark.png +0 -0
  70. package/src/common/assets/icons/book_mark.svg +3 -0
  71. package/src/common/assets/icons/icon_barcode.png +0 -0
  72. package/src/common/assets/icons/icon_camera.png +0 -0
  73. package/src/common/assets/icons/icon_dislike.svg +3 -0
  74. package/src/common/assets/icons/icon_disslike.png +0 -0
  75. package/src/common/assets/icons/icon_email.png +0 -0
  76. package/src/common/assets/icons/icon_like.png +0 -0
  77. package/src/common/assets/icons/icon_like.svg +3 -0
  78. package/src/common/assets/icons/icon_modal_image.png +0 -0
  79. package/src/common/assets/icons/icon_modal_image.svg +21 -0
  80. package/src/common/assets/icons/icon_picture.png +0 -0
  81. package/src/common/assets/icons/icon_search_image.png +0 -0
  82. package/src/common/assets/icons/icon_search_image.svg +3 -0
  83. package/src/common/assets/icons/nyris_logo.svg +3 -0
  84. package/src/common/assets/icons/reload_icon.png +0 -0
  85. package/src/common/assets/icons/reload_icon.svg +3 -0
  86. package/src/common/assets/icons/save_search.png +0 -0
  87. package/src/common/assets/icons/save_search.svg +3 -0
  88. package/src/common/assets/icons/setting_search_icon.png +0 -0
  89. package/src/common/assets/icons/support.png +0 -0
  90. package/src/common/assets/icons/support.svg +3 -0
  91. package/src/common/assets/icons/translate_icon.png +0 -0
  92. package/src/common/assets/icons/translate_icon.svg +3 -0
  93. package/src/common/assets/icons/view_off.png +0 -0
  94. package/src/common/assets/images/Rectangle.png +0 -0
  95. package/src/common/assets/images/bg-support-page.svg +9 -0
  96. package/src/{images → common/assets/images}/fav/android-icon-192x192.png +0 -0
  97. package/src/{images → common/assets/images}/fav/apple-icon-114x114.png +0 -0
  98. package/src/{images → common/assets/images}/fav/apple-icon-120x120.png +0 -0
  99. package/src/{images → common/assets/images}/fav/apple-icon-144x144.png +0 -0
  100. package/src/{images → common/assets/images}/fav/apple-icon-152x152.png +0 -0
  101. package/src/{images → common/assets/images}/fav/apple-icon-180x180.png +0 -0
  102. package/src/{images → common/assets/images}/fav/apple-icon-57x57.png +0 -0
  103. package/src/{images → common/assets/images}/fav/apple-icon-60x60.png +0 -0
  104. package/src/{images → common/assets/images}/fav/apple-icon-72x72.png +0 -0
  105. package/src/{images → common/assets/images}/fav/apple-icon-76x76.png +0 -0
  106. package/src/{images → common/assets/images}/fav/browserconfig.xml +0 -0
  107. package/src/{images → common/assets/images}/fav/favicon-16x16.png +0 -0
  108. package/src/{images → common/assets/images}/fav/favicon-32x32.png +0 -0
  109. package/src/{images → common/assets/images}/fav/favicon-96x96.png +0 -0
  110. package/src/{images → common/assets/images}/fav/manifest.json +0 -0
  111. package/src/{images → common/assets/images}/ic_cam.png +0 -0
  112. package/src/{images → common/assets/images}/ic_cam.svg +0 -0
  113. package/src/{images → common/assets/images}/ic_cam_large.png +0 -0
  114. package/src/{images → common/assets/images}/ic_cam_large.svg +0 -0
  115. package/src/{images → common/assets/images}/ic_cam_large_noimage.png +0 -0
  116. package/src/{images → common/assets/images}/ic_close_feedback.png +0 -0
  117. package/src/{images → common/assets/images}/ic_close_feedback.svg +0 -0
  118. package/src/{images → common/assets/images}/ic_shopNow.png +0 -0
  119. package/src/{images → common/assets/images}/ic_shopNow.svg +0 -0
  120. package/src/{images → common/assets/images}/ic_shopNowLight.png +0 -0
  121. package/src/{images → common/assets/images}/ic_shopNowLight.svg +0 -0
  122. package/src/common/assets/images/image_test.png +0 -0
  123. package/src/{images → common/assets/images}/nyris_logo.png +0 -0
  124. package/src/{images → common/assets/images}/rewe.svg +0 -0
  125. package/src/{images → common/assets/images}/sectionTransBack.png +0 -0
  126. package/src/{images → common/assets/images}/sectionTransBack.svg +0 -0
  127. package/src/{images → common/assets/images}/sectionTransTop.png +0 -0
  128. package/src/{images → common/assets/images}/sectionTransTop.svg +0 -0
  129. package/src/components/CustomHits/index.tsx +57 -0
  130. package/src/components/DetailItem.tsx +175 -0
  131. package/src/components/DragDropFile.tsx +188 -0
  132. package/src/components/ExampleImages.tsx +32 -17
  133. package/src/components/Feedback.tsx +87 -48
  134. package/src/components/FilterComponent.tsx +33 -0
  135. package/src/components/Footer.tsx +29 -0
  136. package/src/components/FooterMD.tsx +54 -0
  137. package/src/components/FooterNewVersion.tsx +12 -0
  138. package/src/components/FooterResult.tsx +47 -0
  139. package/src/components/Header.tsx +35 -0
  140. package/src/components/HeaderMd.tsx +39 -0
  141. package/src/components/HeaderNewVersion.tsx +92 -0
  142. package/src/components/Layout.tsx +46 -0
  143. package/src/components/LoadingScreen/index.tsx +29 -0
  144. package/src/components/Navigation.tsx +34 -0
  145. package/src/components/Panigation/Pagination.tsx +140 -0
  146. package/src/components/Panigation/cx.js +3 -0
  147. package/src/components/Panigation/isModifierClick.js +10 -0
  148. package/src/components/Result.tsx +186 -113
  149. package/src/components/Saved/AllItem.tsx +32 -0
  150. package/src/components/Saved/Category.tsx +16 -0
  151. package/src/components/carousel/DefaultCarousel.tsx +48 -0
  152. package/src/components/common.d.ts +9 -0
  153. package/src/components/common.scss +54 -0
  154. package/src/components/default-select.tsx +44 -0
  155. package/src/components/hitItem/hits.tsx +50 -0
  156. package/src/components/hitItem/infinitiHits.tsx +33 -0
  157. package/src/components/input/inputSearch.tsx +77 -0
  158. package/src/components/modal/DefaultModal.tsx +28 -0
  159. package/src/components/preview/preview.tsx +433 -0
  160. package/src/components/results/ItemResult.tsx +155 -0
  161. package/src/components/search/ListSearch.tsx +209 -0
  162. package/src/defaults.ts +4 -3
  163. package/src/index.css +577 -306
  164. package/src/index.tsx +39 -187
  165. package/src/modules/LandingPage/common.scss +1304 -0
  166. package/src/modules/LandingPage/indexApp.tsx +492 -0
  167. package/src/modules/LandingPage/indexAppMD.tsx +501 -0
  168. package/src/modules/LandingPage/indexNewVersion.tsx +117 -0
  169. package/src/page/Auth/login.tsx +7 -0
  170. package/src/page/Exception/404.tsx +11 -0
  171. package/src/page/History/index.tsx +76 -0
  172. package/src/page/Profile/index.tsx +87 -0
  173. package/src/page/Saved/MockData.ts +223 -0
  174. package/src/page/Saved/index.tsx +166 -0
  175. package/src/page/Support/index.tsx +160 -0
  176. package/src/page/result/MockData.ts +36 -0
  177. package/src/page/result/index.tsx +473 -0
  178. package/src/services/Feedback.ts +65 -0
  179. package/src/services/findByImage.ts +24 -0
  180. package/src/services/findRegionsCustom.ts +212 -0
  181. package/src/services/image.ts +110 -0
  182. package/src/services/nyris.ts +123 -0
  183. package/src/services/session.ts +20 -0
  184. package/src/services/types.ts +96 -0
  185. package/src/types.ts +43 -3
  186. package/tsconfig.json +3 -8
  187. package/build/static/css/2.43a1c8b7.chunk.css +0 -2
  188. package/build/static/css/2.43a1c8b7.chunk.css.map +0 -1
  189. package/build/static/css/main.f6ed5f12.chunk.css +0 -2
  190. package/build/static/css/main.f6ed5f12.chunk.css.map +0 -1
  191. package/build/static/js/2.a591d52a.chunk.js +0 -3
  192. package/build/static/js/2.a591d52a.chunk.js.LICENSE.txt +0 -79
  193. package/build/static/js/2.a591d52a.chunk.js.map +0 -1
  194. package/build/static/js/main.5a3dcfb4.chunk.js +0 -2
  195. package/build/static/js/main.5a3dcfb4.chunk.js.map +0 -1
  196. package/src/AppMD.tsx +0 -320
  197. package/src/actions/nyrisAppActions.ts +0 -76
  198. package/src/actions/searchActions.ts +0 -143
  199. package/src/epics/index.ts +0 -149
  200. package/src/epics/search.ts +0 -114
@@ -0,0 +1,501 @@
1
+ import { useDropzone } from "react-dropzone";
2
+ import {
3
+ makeStyles,
4
+ Button,
5
+ Card,
6
+ CardActions,
7
+ CardContent,
8
+ CardMedia,
9
+ CircularProgress,
10
+ Container,
11
+ CssBaseline,
12
+ Fab,
13
+ Grid,
14
+ Hidden,
15
+ Typography,
16
+ } from "@material-ui/core";
17
+ import { PhotoCamera, ArrowBack, Image } from "@material-ui/icons";
18
+ import Icon from "@material-ui/core/Icon";
19
+ import React, { useCallback, useEffect, useState } from "react";
20
+ import { NodeGroup } from "react-move";
21
+ import classNames from "classnames";
22
+ import { Capture } from "@nyris/nyris-react-components";
23
+ import { useAppDispatch, useAppSelector } from "Store/Store";
24
+ import {
25
+ RectCoords,
26
+ cadExtensions,
27
+ isCadFile,
28
+ isImageFile,
29
+ ImageSearchOptions,
30
+ } from "@nyris/nyris-api";
31
+ import NyrisAPI from "@nyris/nyris-api";
32
+ import {
33
+ loadCadFileLoad,
34
+ loadFile,
35
+ loadFileSelectRegion,
36
+ loadingActionRegions,
37
+ loadingActionResults,
38
+ searchFileImageNonRegion,
39
+ // selectionChanged,
40
+ } from "Store/Search";
41
+ import { showCamera, showFeedback, showResults, showStart } from "Store/Nyris";
42
+ import _, { debounce, isEmpty } from "lodash";
43
+ import { serviceImage, serviceImageNonRegion } from "services/image";
44
+ import { findByImage } from "services/findByImage";
45
+ import { feedbackRegionEpic } from "services/Feedback";
46
+ import { MDSettings } from "../../types";
47
+ import Preview from "components/preview/preview";
48
+
49
+ const useStyles = makeStyles((theme) => ({
50
+ icon: {
51
+ marginRight: theme.spacing(2),
52
+ },
53
+ heroContent: {
54
+ backgroundColor: theme.palette.background.paper,
55
+ padding: theme.spacing(8, 0, 6),
56
+ transition: "all 300ms",
57
+ overflow: "hidden",
58
+ height: 500,
59
+ },
60
+ heroContentClosed: {
61
+ height: 0,
62
+ padding: 0,
63
+ },
64
+ heroButtons: {
65
+ marginTop: theme.spacing(4),
66
+ },
67
+ cardGrid: {
68
+ paddingTop: theme.spacing(8),
69
+ paddingBottom: theme.spacing(8),
70
+ minHeight: 600,
71
+ overflow: "hidden",
72
+ transition: "all 300ms",
73
+ },
74
+ cardGridCollapsed: {
75
+ height: 0,
76
+ opacity: 0,
77
+ minHeight: 0,
78
+ paddingTop: 0,
79
+ paddingBottom: 0,
80
+ },
81
+ card: {
82
+ height: "100%",
83
+ display: "flex",
84
+ flexDirection: "column",
85
+ },
86
+ cardMedia: {
87
+ paddingTop: "56.25%", // 16:9
88
+ backgroundSize: "contain",
89
+ },
90
+ cardContent: {
91
+ flexGrow: 1,
92
+ paddingBottom: 0,
93
+ },
94
+ footer: {
95
+ backgroundColor: theme.palette.background.paper,
96
+ padding: theme.spacing(6),
97
+ },
98
+ withElipsis: {
99
+ textOverflow: "ellipsis",
100
+ overflow: "hidden",
101
+ whiteSpace: "nowrap",
102
+ },
103
+ loading: {
104
+ margin: theme.spacing(2),
105
+ },
106
+ fabContainer: {
107
+ position: "fixed",
108
+ bottom: theme.spacing(2),
109
+ },
110
+ fab: {
111
+ marginLeft: theme.spacing(2),
112
+ },
113
+ }));
114
+
115
+ const makeFileHandler = (action: any) => (e: any) => {
116
+ let file = (e.dataTransfer && e.dataTransfer.files[0]) || e.target.files[0];
117
+ if (e.target && e.target.value) {
118
+ e.target.value = "";
119
+ }
120
+
121
+ if (file) {
122
+ action(file);
123
+ }
124
+ };
125
+
126
+ const LandingPageAppMD: React.FC<any> = () => {
127
+ const dispatch = useAppDispatch();
128
+ const classes = useStyles();
129
+ const [rectCoords, setRectCoords] = useState<any>();
130
+ const searchState = useAppSelector((state) => state);
131
+ const { settings, search, nyris } = searchState;
132
+ const { showPart } = nyris;
133
+ const {
134
+ requestImage,
135
+ regions,
136
+ selectedRegion,
137
+ fetchingRegions,
138
+ fetchingResults,
139
+ results,
140
+ requestId,
141
+ } = search;
142
+ const { themePage }: any = settings;
143
+ useEffect(() => {
144
+ if (isEmpty(rectCoords)) {
145
+ return;
146
+ }
147
+ onSearchOffersForImage(rectCoords);
148
+ // eslint-disable-next-line react-hooks/exhaustive-deps
149
+ }, [rectCoords]);
150
+
151
+ const loading = fetchingRegions || fetchingResults;
152
+
153
+ const mdSettings: any = themePage.materialDesign as MDSettings;
154
+
155
+ const { getRootProps, getInputProps, isDragActive } = useDropzone({
156
+ onDrop: (fs: File[]) => dispatch(loadFile(fs[0])),
157
+ });
158
+
159
+ // const minPreviewHeight = 400;
160
+ // const halfOfTheScreenHeight = Math.floor(window.innerHeight * 0.45);
161
+ // const maxPreviewHeight = Math.max(minPreviewHeight, halfOfTheScreenHeight);
162
+ const acceptTypes = ["image/*"]
163
+ .concat(settings.cadSearch ? cadExtensions : [])
164
+ .join(",");
165
+
166
+ const isCheckImageFile = async (file: any) => {
167
+ dispatch(showResults(""));
168
+ dispatch(loadingActionResults(""));
169
+ dispatch(showFeedback(""));
170
+ if (isImageFile(file) || typeof file === "string") {
171
+ if (settings.regions) {
172
+ serviceImage(file, searchState).then((res) => {
173
+ dispatch(loadFile(res));
174
+ return dispatch(showFeedback(""));
175
+ });
176
+ } else {
177
+ serviceImageNonRegion(file, searchState, rectCoords).then((res) => {
178
+ dispatch(searchFileImageNonRegion(res));
179
+ });
180
+ }
181
+ // return serviceImage(file, settings).then((res) => {
182
+ // return dispatch(loadFile(res));
183
+ // });
184
+ }
185
+ if (isCadFile(file)) {
186
+ return dispatch(loadCadFileLoad(file));
187
+ }
188
+ };
189
+
190
+ const feedbackClickEpic = async (position: any, _url: string) => {
191
+ try {
192
+ const api = new NyrisAPI(settings);
193
+ const sessionId = search.sessionId || search.requestId;
194
+ if (sessionId && requestId) {
195
+ await api.sendFeedback(sessionId, requestId, {
196
+ event: "click",
197
+ data: { positions: [position] },
198
+ });
199
+ }
200
+ } catch (error) {
201
+ console.log("err feedbackClickEpic", error);
202
+ }
203
+ };
204
+
205
+ const handlerRectCoords = debounce((value) => {
206
+ setRectCoords(value);
207
+ }, 1200);
208
+
209
+ const debounceRectCoords = useCallback(
210
+ (value) => handlerRectCoords(value),
211
+ // eslint-disable-next-line react-hooks/exhaustive-deps
212
+ []
213
+ );
214
+ const onSearchOffersForImage = (r: RectCoords) => {
215
+ const { canvas }: any = requestImage;
216
+ let options: ImageSearchOptions = {
217
+ cropRect: r,
218
+ };
219
+ feedbackRegionEpic(searchState, r);
220
+ dispatch(loadingActionRegions(""));
221
+ return findByImage(canvas, options, settings).then((res) => {
222
+ dispatch(loadFileSelectRegion(res));
223
+ return dispatch(showFeedback(""));
224
+ });
225
+ };
226
+
227
+ return (
228
+ <React.Fragment>
229
+ {!_.isEmpty(mdSettings?.resultLinkIcon) && (
230
+ <link
231
+ rel="stylesheet"
232
+ href="https://fonts.googleapis.com/icon?family=Material+Icons"
233
+ />
234
+ )}
235
+ <CssBaseline />
236
+ {showPart === "camera" && (
237
+ <Capture
238
+ onCaptureComplete={(image: HTMLCanvasElement) =>
239
+ isCheckImageFile(image)
240
+ }
241
+ onCaptureCanceled={() => dispatch(showStart)}
242
+ useAppText="Use default camera app"
243
+ />
244
+ )}
245
+ <main>
246
+ <div
247
+ className={classNames(
248
+ classes.heroContent,
249
+ showPart === "results" ? classes.heroContentClosed : null
250
+ )}
251
+ >
252
+ <Container maxWidth="md">
253
+ <div>
254
+ <Hidden mdUp>
255
+ <div style={{ textAlign: "center" }}>
256
+ <PhotoCamera style={{ fontSize: "20em", color: "#cccccc" }} />
257
+ </div>
258
+ <div style={{ textAlign: "center" }}>
259
+ <Button
260
+ variant={"contained"}
261
+ color={"primary"}
262
+ onClick={() => {
263
+ return dispatch(showCamera);
264
+ }}
265
+ >
266
+ Take a picture
267
+ </Button>
268
+ </div>
269
+ <div style={{ textAlign: "center" }}>
270
+ <Typography>or</Typography>
271
+ </div>
272
+ <div style={{ textAlign: "center" }}>
273
+ <input
274
+ accept={acceptTypes}
275
+ id="raised-button-file"
276
+ type="file"
277
+ onChange={makeFileHandler((e: any) => isCheckImageFile(e))}
278
+ style={{
279
+ width: ".1px",
280
+ height: ".1px",
281
+ overflow: "hidden",
282
+ opacity: 0,
283
+ }}
284
+ />
285
+ <label htmlFor="raised-button-file">
286
+ <Button
287
+ variant={"contained"}
288
+ color={"primary"}
289
+ component="span"
290
+ >
291
+ Select a file
292
+ </Button>
293
+ </label>
294
+ </div>
295
+ </Hidden>
296
+ <Hidden smDown>
297
+ <div
298
+ style={{
299
+ borderStyle: "dashed",
300
+ borderWidth: 5,
301
+ borderColor: isDragActive ? "#ccc" : "#eee",
302
+ borderRadius: 10,
303
+ padding: 10,
304
+ paddingBottom: 30,
305
+ }}
306
+ {...getRootProps({
307
+ onClick: (e) => {
308
+ e.stopPropagation();
309
+ },
310
+ })}
311
+ >
312
+ <div style={{ textAlign: "center" }}>
313
+ <Image style={{ fontSize: "20em", color: "#cccccc" }} />
314
+ </div>
315
+ <div style={{ textAlign: "center" }}>
316
+ <Typography variant="body2">DROP AN IMAGE</Typography>
317
+ </div>
318
+ <div style={{ textAlign: "center" }}>
319
+ <Typography variant="subtitle2">or</Typography>
320
+ </div>
321
+ <div style={{ textAlign: "center" }}>
322
+ <input
323
+ accept={acceptTypes}
324
+ id="raised-button-file"
325
+ type="file"
326
+ {...getInputProps()}
327
+ onChange={makeFileHandler((e: any) => {
328
+ return isCheckImageFile(e);
329
+ })}
330
+ style={{
331
+ width: ".1px",
332
+ height: ".1px",
333
+ overflow: "hidden",
334
+ opacity: 0,
335
+ }}
336
+ />
337
+ <label htmlFor="raised-button-file">
338
+ <Button
339
+ variant={"contained"}
340
+ color={"primary"}
341
+ component="span"
342
+ >
343
+ Select an image
344
+ </Button>
345
+ </label>
346
+ </div>
347
+ </div>
348
+ </Hidden>
349
+ </div>
350
+ </Container>
351
+ </div>
352
+ <Container
353
+ className={classNames(
354
+ classes.cardGrid,
355
+ showPart !== "results" && classes.cardGridCollapsed
356
+ )}
357
+ maxWidth="md"
358
+ >
359
+ {requestImage && (
360
+ <Card style={{ marginBottom: "4em" }} raised={true}>
361
+ <Preview
362
+ key={requestImage?.id}
363
+ onSelectionChange={(r: RectCoords) => {
364
+ debounceRectCoords(r);
365
+ return;
366
+ }}
367
+ image={requestImage?.canvas}
368
+ initialRegion={
369
+ !selectedRegion
370
+ ? regions[0]
371
+ ? regions[0]
372
+ : { x1: 0, x2: 1, y1: 0, y2: 1 }
373
+ : selectedRegion
374
+ }
375
+ regions={regions}
376
+ maxWidth={400}
377
+ maxHeight={500}
378
+ dotColor="#FBD914"
379
+ />
380
+ </Card>
381
+ )}
382
+
383
+ {loading && (
384
+ <div style={{ textAlign: "center" }}>
385
+ <CircularProgress className={classes.loading} />
386
+ </div>
387
+ )}
388
+
389
+ <Grid container spacing={4}>
390
+ <NodeGroup
391
+ data={results}
392
+ keyAccessor={(r) => r.position + r.sku}
393
+ start={(r, i) => ({ opacity: 0, translateX: -100 })}
394
+ enter={(r, i) => ({
395
+ opacity: [1],
396
+ translateX: [0],
397
+ timing: { delay: i * 100, duration: 300 },
398
+ })}
399
+ >
400
+ {(rs) => (
401
+ <>
402
+ {rs.map(({ key, data: result, state }) => (
403
+ <Grid item key={key} xs={12} sm={4} md={3}>
404
+ <Card
405
+ className={classes.card}
406
+ style={{
407
+ opacity: state.opacity,
408
+ position: "relative",
409
+ transform: `translateX(${state.translateX}%)`,
410
+ }}
411
+ >
412
+ <CardMedia
413
+ className={classes.cardMedia}
414
+ image={
415
+ (result.img && result.img.url) ||
416
+ settings.noImageUrl
417
+ }
418
+ title={result.title}
419
+ />
420
+ <CardContent className={classes.cardContent}>
421
+ <Typography
422
+ gutterBottom
423
+ variant="subtitle2"
424
+ component="h5"
425
+ className={classes.withElipsis}
426
+ >
427
+ {result[mdSettings.resultFirstRowProperty]}
428
+ </Typography>
429
+ <Typography
430
+ variant="body2"
431
+ className={classes.withElipsis}
432
+ >
433
+ {result[mdSettings.resultSecondRowProperty]}
434
+ </Typography>
435
+ </CardContent>
436
+ {result.l && (
437
+ <CardActions>
438
+ <Button
439
+ variant="outlined"
440
+ style={{ marginLeft: "auto" }}
441
+ size="small"
442
+ color="primary"
443
+ onClick={
444
+ () => {
445
+ return feedbackClickEpic(
446
+ result.position,
447
+ result.l
448
+ );
449
+ }
450
+ // handlers.onLinkClick(result.position, result.l)
451
+ }
452
+ onAuxClick={() => {
453
+ return feedbackClickEpic(
454
+ result.position,
455
+ result.l
456
+ );
457
+ }}
458
+ >
459
+ {mdSettings.resultLinkIcon && (
460
+ <React.Fragment>
461
+ <Icon>{mdSettings.resultLinkIcon}</Icon>{" "}
462
+ </React.Fragment>
463
+ )}
464
+ {mdSettings.resultLinkText}
465
+ </Button>
466
+ </CardActions>
467
+ )}
468
+ </Card>
469
+ </Grid>
470
+ ))}
471
+ </>
472
+ )}
473
+ </NodeGroup>
474
+ </Grid>
475
+
476
+ {results.length === 0 && showPart === "results" && !loading && (
477
+ <Typography variant="h3" align="center">
478
+ We did not find anything
479
+ </Typography>
480
+ )}
481
+ </Container>
482
+ {showPart !== "start" && (
483
+ <Container maxWidth="lg">
484
+ <div className={classes.fabContainer}>
485
+ <Fab
486
+ aria-label="back"
487
+ className={classes.fab}
488
+ color="primary"
489
+ onClick={() => dispatch(showStart(""))}
490
+ >
491
+ <ArrowBack />
492
+ </Fab>
493
+ </div>
494
+ </Container>
495
+ )}
496
+ </main>
497
+ </React.Fragment>
498
+ );
499
+ };
500
+
501
+ export default LandingPageAppMD;
@@ -0,0 +1,117 @@
1
+ import { Box, Typography } from "@material-ui/core";
2
+ import React, { useState, useEffect } from "react";
3
+ import "./common.scss";
4
+ import TranslateIcon from "common/assets/icons/translate_icon.svg";
5
+ import DragDropFile from "components/DragDropFile";
6
+ import { cadExtensions } from "@nyris/nyris-api";
7
+ import { useAppDispatch, useAppSelector } from "Store/Store";
8
+ import { changeValueTextSearch, setUpdateSession } from "Store/Search";
9
+ import { useHistory } from "react-router-dom";
10
+ import {
11
+ Configure,
12
+ InstantSearch,
13
+ connectInfiniteHits,
14
+ } from "react-instantsearch-dom";
15
+ import algoliasearch from "algoliasearch/lite";
16
+ import CustomSearchBox from "components/input/inputSearch";
17
+ import NyrisAPICT from "services/findRegionsCustom";
18
+
19
+ interface Props {}
20
+
21
+ function AppNewVersion(props: Props) {
22
+ const dispatch = useAppDispatch();
23
+ const history = useHistory();
24
+ const searchState = useAppSelector((state) => state);
25
+ const { settings, search }: any = searchState;
26
+ const [searchStateInput, setSearchStateInput] = useState<any>({});
27
+ const [isLoading, setLoading] = useState<boolean>(false);
28
+ const nyrisApi = new NyrisAPICT(settings);
29
+ const { apiKeyAlgolia, appIdAlgolia, indexNameAlgolia } = settings;
30
+ const searchClient = algoliasearch(appIdAlgolia, apiKeyAlgolia);
31
+ searchClient.initIndex(indexNameAlgolia);
32
+
33
+ useEffect(() => {
34
+ const createSession = async () => {
35
+ try {
36
+ await nyrisApi.createSession().then((res: any) => {
37
+ const payload: any = {
38
+ sessionId: res.data.session,
39
+ requestId: res.data.id,
40
+ };
41
+ dispatch(setUpdateSession(payload));
42
+ });
43
+ } catch (error) {}
44
+ };
45
+
46
+ createSession();
47
+ // eslint-disable-next-line react-hooks/exhaustive-deps
48
+ }, []);
49
+
50
+ const acceptTypes = ["image/*"]
51
+ .concat(settings.cadSearch ? cadExtensions : [])
52
+ .join(",");
53
+
54
+ const InfiniteHits = ({ hits }: any) => {
55
+ return <div></div>;
56
+ };
57
+
58
+ const onChangeLoading = (value: boolean) => {
59
+ setLoading(value);
60
+ };
61
+
62
+ const CustomInfiniteHits = connectInfiniteHits(InfiniteHits);
63
+
64
+ const nonEmptyFilter: any[] = !search?.requestImage
65
+ ? []
66
+ : ["sku:DOES_NOT_EXIST<score=1>"];
67
+ const filterSkus: any = search?.results
68
+ ? search?.results.map(
69
+ (f: any) => `sku:'${f.sku}'<score=${Math.round(100 * f.score)}>`
70
+ )
71
+ : "";
72
+ const filtersString = [...nonEmptyFilter, ...filterSkus].join(" OR ");
73
+
74
+ return (
75
+ <Box className={`box-content-main ${isLoading ? "loading" : ""}`}>
76
+ <InstantSearch
77
+ indexName={indexNameAlgolia}
78
+ searchClient={searchClient}
79
+ searchState={searchStateInput}
80
+ onSearchStateChange={(state: any) => {
81
+ setSearchStateInput(state);
82
+ dispatch(changeValueTextSearch(state));
83
+ history.push("/result");
84
+ }}
85
+ >
86
+ <Box className="box-content_top">
87
+ <div className="box-logo">
88
+ <img src={TranslateIcon} width={32} height={27} alt="logo_icon" />
89
+ </div>
90
+ <div className="box-input">
91
+ <div className="wrap-input-search">
92
+ <Configure filters={filtersString}></Configure>
93
+ <div style={{ display: "none" }}>
94
+ <CustomInfiniteHits />
95
+ </div>
96
+ <CustomSearchBox />
97
+ </div>
98
+ </div>
99
+ <div className="box-bottom">
100
+ <Typography className="text-bottom">
101
+ Search by any name, category, SKU or keyword.
102
+ </Typography>
103
+ </div>
104
+ </Box>
105
+ <Box className="box-content_bottom">
106
+ <DragDropFile
107
+ acceptTypes={acceptTypes}
108
+ isLoading={isLoading}
109
+ onChangeLoading={onChangeLoading}
110
+ />
111
+ </Box>
112
+ </InstantSearch>
113
+ </Box>
114
+ );
115
+ }
116
+
117
+ export default AppNewVersion;
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+
3
+ function Login(): JSX.Element {
4
+ return <div>page login</div>;
5
+ }
6
+
7
+ export default Login;
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+
3
+ interface Props {}
4
+
5
+ function NotFound(props: Props): JSX.Element {
6
+ const {} = props;
7
+
8
+ return <div>NotFound</div>;
9
+ }
10
+
11
+ export default NotFound;