@nyris/nyris-webapp 0.2.5 → 0.3.2

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 (199) hide show
  1. package/build/asset-manifest.json +32 -18
  2. package/build/index.html +1 -1
  3. package/build/js/test.js +62 -0
  4. package/build/{precache-manifest.497998bf0df450969bab5608621be10a.js → precache-manifest.8f85a4fff2063a7498a608ec69549bb1.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.efc0ab83.chunk.js +3 -0
  11. package/build/static/js/2.efc0ab83.chunk.js.LICENSE.txt +133 -0
  12. package/build/static/js/2.efc0ab83.chunk.js.map +1 -0
  13. package/build/static/js/main.3bfed050.chunk.js +2 -0
  14. package/build/static/js/main.3bfed050.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 +62 -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/DetailItem.tsx +175 -0
  130. package/src/components/DragDropFile.tsx +188 -0
  131. package/src/components/ExampleImages.tsx +32 -17
  132. package/src/components/Feedback.tsx +87 -48
  133. package/src/components/FilterComponent.tsx +33 -0
  134. package/src/components/Footer.tsx +29 -0
  135. package/src/components/FooterMD.tsx +54 -0
  136. package/src/components/FooterNewVersion.tsx +12 -0
  137. package/src/components/FooterResult.tsx +47 -0
  138. package/src/components/Header.tsx +35 -0
  139. package/src/components/HeaderMd.tsx +39 -0
  140. package/src/components/HeaderNewVersion.tsx +92 -0
  141. package/src/components/Layout.tsx +46 -0
  142. package/src/components/LoadingScreen/index.tsx +29 -0
  143. package/src/components/Navigation.tsx +34 -0
  144. package/src/components/Panigation/Pagination.tsx +140 -0
  145. package/src/components/Panigation/cx.js +3 -0
  146. package/src/components/Panigation/isModifierClick.js +10 -0
  147. package/src/components/Result.tsx +186 -113
  148. package/src/components/Saved/AllItem.tsx +32 -0
  149. package/src/components/Saved/Category.tsx +16 -0
  150. package/src/components/carousel/DefaultCarousel.tsx +48 -0
  151. package/src/components/common.d.ts +9 -0
  152. package/src/components/common.scss +54 -0
  153. package/src/components/default-select.tsx +44 -0
  154. package/src/components/hitItem/hits.tsx +50 -0
  155. package/src/components/hitItem/infinitiHits.tsx +33 -0
  156. package/src/components/input/inputSearch.tsx +77 -0
  157. package/src/components/modal/DefaultModal.tsx +28 -0
  158. package/src/components/preview/preview.tsx +433 -0
  159. package/src/components/results/ItemResult.tsx +155 -0
  160. package/src/components/search/ListSearch.tsx +209 -0
  161. package/src/defaults.ts +4 -3
  162. package/src/index.css +577 -306
  163. package/src/index.tsx +39 -187
  164. package/src/modules/LandingPage/common.scss +1304 -0
  165. package/src/modules/LandingPage/indexApp.tsx +474 -0
  166. package/src/modules/LandingPage/indexAppMD.tsx +494 -0
  167. package/src/modules/LandingPage/indexNewVersion.tsx +117 -0
  168. package/src/page/Auth/login.tsx +7 -0
  169. package/src/page/Exception/404.tsx +11 -0
  170. package/src/page/History/index.tsx +76 -0
  171. package/src/page/Profile/index.tsx +87 -0
  172. package/src/page/Saved/MockData.ts +223 -0
  173. package/src/page/Saved/index.tsx +166 -0
  174. package/src/page/Support/index.tsx +160 -0
  175. package/src/page/result/MockData.ts +36 -0
  176. package/src/page/result/index.tsx +473 -0
  177. package/src/services/Feedback.ts +65 -0
  178. package/src/services/findByImage.ts +24 -0
  179. package/src/services/findRegionsCustom.ts +212 -0
  180. package/src/services/image.ts +110 -0
  181. package/src/services/nyris.ts +123 -0
  182. package/src/services/session.ts +20 -0
  183. package/src/services/types.ts +96 -0
  184. package/src/types.ts +43 -3
  185. package/tsconfig.json +3 -8
  186. package/build/static/css/2.43a1c8b7.chunk.css +0 -2
  187. package/build/static/css/2.43a1c8b7.chunk.css.map +0 -1
  188. package/build/static/css/main.f6ed5f12.chunk.css +0 -2
  189. package/build/static/css/main.f6ed5f12.chunk.css.map +0 -1
  190. package/build/static/js/2.a591d52a.chunk.js +0 -3
  191. package/build/static/js/2.a591d52a.chunk.js.LICENSE.txt +0 -79
  192. package/build/static/js/2.a591d52a.chunk.js.map +0 -1
  193. package/build/static/js/main.28bb3581.chunk.js +0 -2
  194. package/build/static/js/main.28bb3581.chunk.js.map +0 -1
  195. package/src/AppMD.tsx +0 -320
  196. package/src/actions/nyrisAppActions.ts +0 -76
  197. package/src/actions/searchActions.ts +0 -143
  198. package/src/epics/index.ts +0 -149
  199. package/src/epics/search.ts +0 -114
@@ -0,0 +1,494 @@
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, Preview } 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
+
48
+ const useStyles = makeStyles((theme) => ({
49
+ icon: {
50
+ marginRight: theme.spacing(2),
51
+ },
52
+ heroContent: {
53
+ backgroundColor: theme.palette.background.paper,
54
+ padding: theme.spacing(8, 0, 6),
55
+ transition: "all 300ms",
56
+ overflow: "hidden",
57
+ height: 500,
58
+ },
59
+ heroContentClosed: {
60
+ height: 0,
61
+ padding: 0,
62
+ },
63
+ heroButtons: {
64
+ marginTop: theme.spacing(4),
65
+ },
66
+ cardGrid: {
67
+ paddingTop: theme.spacing(8),
68
+ paddingBottom: theme.spacing(8),
69
+ minHeight: 600,
70
+ overflow: "hidden",
71
+ transition: "all 300ms",
72
+ },
73
+ cardGridCollapsed: {
74
+ height: 0,
75
+ opacity: 0,
76
+ minHeight: 0,
77
+ paddingTop: 0,
78
+ paddingBottom: 0,
79
+ },
80
+ card: {
81
+ height: "100%",
82
+ display: "flex",
83
+ flexDirection: "column",
84
+ },
85
+ cardMedia: {
86
+ paddingTop: "56.25%", // 16:9
87
+ backgroundSize: "contain",
88
+ },
89
+ cardContent: {
90
+ flexGrow: 1,
91
+ paddingBottom: 0,
92
+ },
93
+ footer: {
94
+ backgroundColor: theme.palette.background.paper,
95
+ padding: theme.spacing(6),
96
+ },
97
+ withElipsis: {
98
+ textOverflow: "ellipsis",
99
+ overflow: "hidden",
100
+ whiteSpace: "nowrap",
101
+ },
102
+ loading: {
103
+ margin: theme.spacing(2),
104
+ },
105
+ fabContainer: {
106
+ position: "fixed",
107
+ bottom: theme.spacing(2),
108
+ },
109
+ fab: {
110
+ marginLeft: theme.spacing(2),
111
+ },
112
+ }));
113
+
114
+ const makeFileHandler = (action: any) => (e: any) => {
115
+ let file = (e.dataTransfer && e.dataTransfer.files[0]) || e.target.files[0];
116
+ if (e.target && e.target.value) {
117
+ e.target.value = "";
118
+ }
119
+
120
+ if (file) {
121
+ action(file);
122
+ }
123
+ };
124
+
125
+ const LandingPageAppMD: React.FC<any> = () => {
126
+ const dispatch = useAppDispatch();
127
+ const classes = useStyles();
128
+ const [rectCoords, setRectCoords] = useState<any>();
129
+ const searchState = useAppSelector((state) => state);
130
+ const { settings, search, nyris } = searchState;
131
+ const { showPart } = nyris;
132
+ const {
133
+ requestImage,
134
+ regions,
135
+ selectedRegion,
136
+ fetchingRegions,
137
+ fetchingResults,
138
+ results,
139
+ requestId,
140
+ } = search;
141
+ const { themePage }: any = settings;
142
+ useEffect(() => {
143
+ if (isEmpty(rectCoords)) {
144
+ return;
145
+ }
146
+ onSearchOffersForImage(rectCoords);
147
+ // eslint-disable-next-line react-hooks/exhaustive-deps
148
+ }, [rectCoords]);
149
+
150
+ const loading = fetchingRegions || fetchingResults;
151
+
152
+ const mdSettings: any = themePage.materialDesign as MDSettings;
153
+
154
+ const { getRootProps, getInputProps, isDragActive } = useDropzone({
155
+ onDrop: (fs: File[]) => dispatch(loadFile(fs[0])),
156
+ });
157
+
158
+ const minPreviewHeight = 400;
159
+ const halfOfTheScreenHeight = Math.floor(window.innerHeight * 0.45);
160
+ const maxPreviewHeight = Math.max(minPreviewHeight, halfOfTheScreenHeight);
161
+ const acceptTypes = ["image/*"]
162
+ .concat(settings.cadSearch ? cadExtensions : [])
163
+ .join(",");
164
+
165
+ const isCheckImageFile = async (file: any) => {
166
+ dispatch(showResults(""));
167
+ dispatch(loadingActionResults(""));
168
+ dispatch(showFeedback(""));
169
+ if (isImageFile(file) || typeof file === "string") {
170
+ if (settings.regions) {
171
+ serviceImage(file, searchState).then((res) => {
172
+ dispatch(loadFile(res));
173
+ return dispatch(showFeedback(""));
174
+ });
175
+ } else {
176
+ serviceImageNonRegion(file, searchState, rectCoords).then((res) => {
177
+ dispatch(searchFileImageNonRegion(res));
178
+ });
179
+ }
180
+ // return serviceImage(file, settings).then((res) => {
181
+ // return dispatch(loadFile(res));
182
+ // });
183
+ }
184
+ if (isCadFile(file)) {
185
+ return dispatch(loadCadFileLoad(file));
186
+ }
187
+ };
188
+
189
+ const feedbackClickEpic = async (position: any, _url: string) => {
190
+ try {
191
+ const api = new NyrisAPI(settings);
192
+ const sessionId = search.sessionId || search.requestId;
193
+ if (sessionId && requestId) {
194
+ await api.sendFeedback(sessionId, requestId, {
195
+ event: "click",
196
+ data: { positions: [position] },
197
+ });
198
+ }
199
+ } catch (error) {
200
+ console.log("err feedbackClickEpic", error);
201
+ }
202
+ };
203
+
204
+ const handlerRectCoords = debounce((value) => {
205
+ setRectCoords(value);
206
+ }, 1200);
207
+
208
+ const debounceRectCoords = useCallback(
209
+ (value) => handlerRectCoords(value),
210
+ // eslint-disable-next-line react-hooks/exhaustive-deps
211
+ []
212
+ );
213
+ const onSearchOffersForImage = (r: RectCoords) => {
214
+ const { canvas }: any = requestImage;
215
+ let options: ImageSearchOptions = {
216
+ cropRect: r,
217
+ };
218
+ feedbackRegionEpic(searchState, r);
219
+ dispatch(loadingActionRegions(""));
220
+ return findByImage(canvas, options, settings).then((res) => {
221
+ dispatch(loadFileSelectRegion(res));
222
+ return dispatch(showFeedback(""));
223
+ });
224
+ };
225
+
226
+ return (
227
+ <React.Fragment>
228
+ {!_.isEmpty(mdSettings?.resultLinkIcon) && (
229
+ <link
230
+ rel="stylesheet"
231
+ href="https://fonts.googleapis.com/icon?family=Material+Icons"
232
+ />
233
+ )}
234
+ <CssBaseline />
235
+ {showPart === "camera" && (
236
+ <Capture
237
+ onCaptureComplete={(image: HTMLCanvasElement) =>
238
+ isCheckImageFile(image)
239
+ }
240
+ onCaptureCanceled={() => dispatch(showStart)}
241
+ useAppText="Use default camera app"
242
+ />
243
+ )}
244
+ <main>
245
+ <div
246
+ className={classNames(
247
+ classes.heroContent,
248
+ showPart === "results" ? classes.heroContentClosed : null
249
+ )}
250
+ >
251
+ <Container maxWidth="md">
252
+ <div>
253
+ <Hidden mdUp>
254
+ <div style={{ textAlign: "center" }}>
255
+ <PhotoCamera style={{ fontSize: "20em", color: "#cccccc" }} />
256
+ </div>
257
+ <div style={{ textAlign: "center" }}>
258
+ <Button
259
+ variant={"contained"}
260
+ color={"primary"}
261
+ onClick={() => {
262
+ return dispatch(showCamera);
263
+ }}
264
+ >
265
+ Take a picture
266
+ </Button>
267
+ </div>
268
+ <div style={{ textAlign: "center" }}>
269
+ <Typography>or</Typography>
270
+ </div>
271
+ <div style={{ textAlign: "center" }}>
272
+ <input
273
+ accept={acceptTypes}
274
+ id="raised-button-file"
275
+ type="file"
276
+ onChange={makeFileHandler((e: any) => isCheckImageFile(e))}
277
+ style={{
278
+ width: ".1px",
279
+ height: ".1px",
280
+ overflow: "hidden",
281
+ opacity: 0,
282
+ }}
283
+ />
284
+ <label htmlFor="raised-button-file">
285
+ <Button
286
+ variant={"contained"}
287
+ color={"primary"}
288
+ component="span"
289
+ >
290
+ Select a file
291
+ </Button>
292
+ </label>
293
+ </div>
294
+ </Hidden>
295
+ <Hidden smDown>
296
+ <div
297
+ style={{
298
+ borderStyle: "dashed",
299
+ borderWidth: 5,
300
+ borderColor: isDragActive ? "#ccc" : "#eee",
301
+ borderRadius: 10,
302
+ padding: 10,
303
+ paddingBottom: 30,
304
+ }}
305
+ {...getRootProps({
306
+ onClick: (e) => {
307
+ e.stopPropagation();
308
+ },
309
+ })}
310
+ >
311
+ <div style={{ textAlign: "center" }}>
312
+ <Image style={{ fontSize: "20em", color: "#cccccc" }} />
313
+ </div>
314
+ <div style={{ textAlign: "center" }}>
315
+ <Typography variant="body2">DROP AN IMAGE</Typography>
316
+ </div>
317
+ <div style={{ textAlign: "center" }}>
318
+ <Typography variant="subtitle2">or</Typography>
319
+ </div>
320
+ <div style={{ textAlign: "center" }}>
321
+ <input
322
+ accept={acceptTypes}
323
+ id="raised-button-file"
324
+ type="file"
325
+ {...getInputProps()}
326
+ onChange={makeFileHandler((e: any) => {
327
+ return isCheckImageFile(e);
328
+ })}
329
+ style={{
330
+ width: ".1px",
331
+ height: ".1px",
332
+ overflow: "hidden",
333
+ opacity: 0,
334
+ }}
335
+ />
336
+ <label htmlFor="raised-button-file">
337
+ <Button
338
+ variant={"contained"}
339
+ color={"primary"}
340
+ component="span"
341
+ >
342
+ Select an image
343
+ </Button>
344
+ </label>
345
+ </div>
346
+ </div>
347
+ </Hidden>
348
+ </div>
349
+ </Container>
350
+ </div>
351
+ <Container
352
+ className={classNames(
353
+ classes.cardGrid,
354
+ showPart !== "results" && classes.cardGridCollapsed
355
+ )}
356
+ maxWidth="md"
357
+ >
358
+ {requestImage && (
359
+ <Card style={{ marginBottom: "4em" }} raised={true}>
360
+ <Preview
361
+ key={requestImage.id}
362
+ maxWidth={document.body.clientWidth}
363
+ maxHeight={maxPreviewHeight}
364
+ dotColor={mdSettings.primaryColor}
365
+ onSelectionChange={(r: RectCoords) => {
366
+ dispatch(selectionChanged(r));
367
+ return debounceRectCoords(r);
368
+ }}
369
+ regions={regions}
370
+ selection={selectedRegion}
371
+ image={requestImage.canvas}
372
+ />
373
+ </Card>
374
+ )}
375
+
376
+ {loading && (
377
+ <div style={{ textAlign: "center" }}>
378
+ <CircularProgress className={classes.loading} />
379
+ </div>
380
+ )}
381
+
382
+ <Grid container spacing={4}>
383
+ <NodeGroup
384
+ data={results}
385
+ keyAccessor={(r) => r.position + r.sku}
386
+ start={(r, i) => ({ opacity: 0, translateX: -100 })}
387
+ enter={(r, i) => ({
388
+ opacity: [1],
389
+ translateX: [0],
390
+ timing: { delay: i * 100, duration: 300 },
391
+ })}
392
+ >
393
+ {(rs) => (
394
+ <>
395
+ {rs.map(({ key, data: result, state }) => (
396
+ <Grid item key={key} xs={12} sm={4} md={3}>
397
+ <Card
398
+ className={classes.card}
399
+ style={{
400
+ opacity: state.opacity,
401
+ position: "relative",
402
+ transform: `translateX(${state.translateX}%)`,
403
+ }}
404
+ >
405
+ <CardMedia
406
+ className={classes.cardMedia}
407
+ image={
408
+ (result.img && result.img.url) ||
409
+ settings.noImageUrl
410
+ }
411
+ title={result.title}
412
+ />
413
+ <CardContent className={classes.cardContent}>
414
+ <Typography
415
+ gutterBottom
416
+ variant="subtitle2"
417
+ component="h5"
418
+ className={classes.withElipsis}
419
+ >
420
+ {result[mdSettings.resultFirstRowProperty]}
421
+ </Typography>
422
+ <Typography
423
+ variant="body2"
424
+ className={classes.withElipsis}
425
+ >
426
+ {result[mdSettings.resultSecondRowProperty]}
427
+ </Typography>
428
+ </CardContent>
429
+ {result.l && (
430
+ <CardActions>
431
+ <Button
432
+ variant="outlined"
433
+ style={{ marginLeft: "auto" }}
434
+ size="small"
435
+ color="primary"
436
+ onClick={
437
+ () => {
438
+ return feedbackClickEpic(
439
+ result.position,
440
+ result.l
441
+ );
442
+ }
443
+ // handlers.onLinkClick(result.position, result.l)
444
+ }
445
+ onAuxClick={() => {
446
+ return feedbackClickEpic(
447
+ result.position,
448
+ result.l
449
+ );
450
+ }}
451
+ >
452
+ {mdSettings.resultLinkIcon && (
453
+ <React.Fragment>
454
+ <Icon>{mdSettings.resultLinkIcon}</Icon>{" "}
455
+ </React.Fragment>
456
+ )}
457
+ {mdSettings.resultLinkText}
458
+ </Button>
459
+ </CardActions>
460
+ )}
461
+ </Card>
462
+ </Grid>
463
+ ))}
464
+ </>
465
+ )}
466
+ </NodeGroup>
467
+ </Grid>
468
+
469
+ {results.length === 0 && showPart === "results" && !loading && (
470
+ <Typography variant="h3" align="center">
471
+ We did not find anything
472
+ </Typography>
473
+ )}
474
+ </Container>
475
+ {showPart !== "start" && (
476
+ <Container maxWidth="lg">
477
+ <div className={classes.fabContainer}>
478
+ <Fab
479
+ aria-label="back"
480
+ className={classes.fab}
481
+ color="primary"
482
+ onClick={() => dispatch(showStart(""))}
483
+ >
484
+ <ArrowBack />
485
+ </Fab>
486
+ </div>
487
+ </Container>
488
+ )}
489
+ </main>
490
+ </React.Fragment>
491
+ );
492
+ };
493
+
494
+ 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;
@@ -0,0 +1,76 @@
1
+ import { Box, Button, Typography } from "@material-ui/core";
2
+ import React from "react";
3
+ import ListSearch from "components/search/ListSearch";
4
+
5
+ interface Option {
6
+ readonly label: string;
7
+ readonly value: string;
8
+ }
9
+
10
+ function SearchHistory(): JSX.Element {
11
+ return (
12
+ <Box className="wrap-main-search-history">
13
+ <Box className="box-main-top">
14
+ <Box className="box-input">
15
+ {/* <InputSearch
16
+ inputValueInputSearch={inputValueInputSearch}
17
+ handleChange={handleChangeInputSearch}
18
+ handleKeyDown={handleKeyDown}
19
+ handleInputChange={handleInputChange}
20
+ valueInputSearch={valueInputSearch}
21
+ styleControl={{
22
+ width: 640,
23
+ background: "#FFFFFF",
24
+ boxShadow: "0px 0px 6.66667px rgba(0, 0, 0, 0.2)",
25
+ borderRadius: 21,
26
+ minHeight: 42,
27
+ display: "flex",
28
+ alignItems: "center",
29
+ paddingLeft: "16px",
30
+ }}
31
+ placeholder={"Search"}
32
+ customComponent={{
33
+ DropdownIndicator: () => {
34
+ return (
35
+ <Box mr={1}>
36
+ <button
37
+ className="btn-input-search"
38
+ onClick={() => {
39
+ console.log("321");
40
+ }}
41
+ >
42
+ <img src={IconSetting} alt="icon_search" />
43
+ </button>
44
+ </Box>
45
+ );
46
+ },
47
+ }}
48
+ /> */}
49
+ </Box>
50
+ </Box>
51
+
52
+ <Box className="box-main-bottom">
53
+ <Box className="col-left">
54
+ <ul className="box-time">
55
+ <li>
56
+ <Button>
57
+ <Typography className="text-f9 active">2021</Typography>
58
+ </Button>
59
+ </li>
60
+ <li>
61
+ <Button>
62
+ <Typography className="text-f9">2020</Typography>
63
+ </Button>
64
+ </li>
65
+ </ul>
66
+ </Box>
67
+ <Box className="col-right">
68
+ <ListSearch />
69
+ <ListSearch />
70
+ </Box>
71
+ </Box>
72
+ </Box>
73
+ );
74
+ }
75
+
76
+ export default SearchHistory;