@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
@@ -1,468 +0,0 @@
1
- import {
2
- Box,
3
- Button,
4
- IconButton,
5
- InputBase,
6
- Paper,
7
- Typography,
8
- } from "@material-ui/core";
9
- import React, { useEffect, useState } from "react";
10
- import IconWhatsApp from "common/assets/icons/Icon_whatsapp.png";
11
- import IconEmail from "common/assets/icons/icon_email.png";
12
- import IconWeChat from "common/assets/icons/Icon_wechat.png";
13
- // import FilterComponent from "components/FilterComponent";
14
- // import {
15
- // dataFieldFive,
16
- // dataFieldFour,
17
- // dataFieldOne,
18
- // dataFieldSix,
19
- // dataFieldThree,
20
- // dataFieldTow,
21
- // } from "./MockData";
22
- import ItemResult from "components/results/ItemResult";
23
- import { useAppDispatch, useAppSelector } from "Store/Store";
24
- import { debounce } from "lodash";
25
- import KeyboardArrowRightOutlinedIcon from "@material-ui/icons/KeyboardArrowRightOutlined";
26
- import KeyboardArrowLeftOutlinedIcon from "@material-ui/icons/KeyboardArrowLeftOutlined";
27
- import FooterResult from "components/FooterResult";
28
- import DefaultModal from "components/modal/DefaultModal";
29
- import CloseOutlinedIcon from "@material-ui/icons/CloseOutlined";
30
- import DetailItem from "components/DetailItem";
31
- import FileCopyOutlinedIcon from "@material-ui/icons/FileCopyOutlined";
32
- import { RectCoords } from "@nyris/nyris-api";
33
- import {
34
- setSearchResults,
35
- loadingActionResults,
36
- searchFileImageNonRegion,
37
- selectionChanged,
38
- updateResultChangePosition,
39
- } from "Store/Search";
40
- import { showFeedback, showResults } from "Store/Nyris";
41
- import algoliasearch from "algoliasearch/lite";
42
- import {
43
- InstantSearch,
44
- Hits,
45
- Pagination,
46
- Configure,
47
- } from "react-instantsearch-dom";
48
- import CustomSearchBox from "components/input/inputSearch";
49
- import { feedbackClickEpic } from "services/Feedback";
50
- import {
51
- searchImageByPosition,
52
- serviceImage,
53
- serviceImageNonRegion,
54
- } from "services/image";
55
- import NyrisAPI from "@nyris/nyris-api";
56
- import LoadingScreenCustom from "components/LoadingScreen";
57
- import { Preview } from "@nyris/nyris-react-components";
58
-
59
- interface Props {}
60
-
61
- function ResultComponent(props: Props) {
62
- const dispatch = useAppDispatch();
63
- const StateGlobal = useAppSelector((state) => state);
64
- const [showColLeft, setToggleShowColLeft] = useState<boolean>(false);
65
- const [showImageCanvas, setShowImageCanvas] = useState<boolean>(true);
66
- const [isOpenModalImage, setOpenModalImage] = useState<boolean>(false);
67
- const [numberResult, setNumberResult] = useState<number>(0);
68
- const [isOpenModalShare, setOpenModalShare] = useState<boolean>(false);
69
- const { search, settings }: any = StateGlobal;
70
- const { results, requestImage, regions, selectedRegion }: any = search;
71
- const { valueTextSearch } = search;
72
- const [dataResult, setDataResult] = useState<any[]>([]);
73
- const [dataImageModal, setDataImageModal] = useState<any>();
74
- const [searchStateInput, setSearchStateInput] = useState<any>({});
75
- const apiNyris = new NyrisAPI(settings);
76
- const [isLoading, setLoading] = useState<any>(false);
77
- const { apiKeyAlgolia, appIdAlgolia, indexNameAlgolia } = settings;
78
- const searchClient = algoliasearch(appIdAlgolia, apiKeyAlgolia);
79
- const index = searchClient.initIndex(indexNameAlgolia);
80
-
81
- useEffect(() => {
82
- if (!valueTextSearch) {
83
- return;
84
- }
85
- setSearchStateInput(valueTextSearch);
86
- }, [valueTextSearch]);
87
-
88
- useEffect(() => {
89
- if (results?.length === 0) {
90
- setDataResult([]);
91
- return;
92
- }
93
- setDataResult(results);
94
- }, [results]);
95
-
96
- useEffect(() => {
97
- if (!showColLeft) {
98
- return setShowImageCanvas(true);
99
- }
100
- return setShowImageCanvas(false);
101
- }, [showColLeft]);
102
-
103
- // TODO: hanlder modal:
104
- const handlerToggleModal = (item: any) => {
105
- setDataImageModal(item);
106
- return setOpenModalImage(true);
107
- };
108
-
109
- const onNextItem = () => {
110
- if (numberResult === results.length) {
111
- return;
112
- }
113
- setNumberResult(numberResult + 1);
114
- };
115
-
116
- const onPrevItem = () => {
117
- if (numberResult === 0) {
118
- return;
119
- }
120
- setNumberResult(numberResult - 1);
121
- };
122
-
123
- // TODO: rectCoords
124
-
125
- const debounceRectCoords = (value: any) => handlerRectCoords(value);
126
-
127
- const handlerRectCoords = debounce((value: any) => {
128
- dispatch(selectionChanged(value));
129
- setLoading(true);
130
- return onSearchOffersForImage(value);
131
- }, 500);
132
-
133
- // TODO: Search offers for image:
134
- const onSearchOffersForImage = (r: RectCoords) => {
135
- if (!requestImage) {
136
- return;
137
- }
138
- const { canvas }: any = requestImage;
139
- if (settings.regions) {
140
- searchImageByPosition(canvas, StateGlobal, r).then((res: any) => {
141
- const payload = {
142
- ...res,
143
- requestImage: requestImage,
144
- };
145
- dispatch(updateResultChangePosition(payload));
146
- setLoading(false);
147
- return dispatch(showFeedback());
148
- });
149
- } else {
150
- serviceImageNonRegion(canvas, StateGlobal, null).then((res: any) => {
151
- const payload = {
152
- ...res,
153
- requestImage: requestImage,
154
- };
155
- dispatch(updateResultChangePosition(payload));
156
- return dispatch(showFeedback());
157
- });
158
- }
159
- };
160
-
161
- // TODO: Search text
162
- const searchTextByApiAndFilter = async (searchState: any) => {
163
- try {
164
- if (searchState?.query !== "") {
165
- const data = await index.search(searchState.query, {});
166
- const productIds = data.hits.map((hit: any) => hit.sku);
167
- const eventData = {
168
- query: data.query,
169
- page: data.page,
170
- product_ids: productIds,
171
- };
172
- const textSearchEvent: any = { event: "text-search", data: eventData };
173
- await apiNyris.sendFeedback(
174
- search?.sessionId,
175
- search?.requestId,
176
- textSearchEvent
177
- );
178
- }
179
- } catch (error: any) {
180
- console.log("searchTextByApi", error);
181
- return;
182
- }
183
- };
184
-
185
- // TODO: Handler like dislike
186
- const sendFeedBackAction = async (type: string) => {
187
- try {
188
- const action = type === "like" ? true : false;
189
- const payload: any = {
190
- event: "feedback",
191
- data: {
192
- success: action,
193
- },
194
- };
195
- await apiNyris.sendFeedback(
196
- search?.sessionId,
197
- search?.requestId,
198
- payload
199
- );
200
- } catch (error) {}
201
- };
202
-
203
- // Search image with url or file
204
- const getUrlToCanvasFile = (url: string, position?: number) => {
205
- dispatch(showResults());
206
- dispatch(loadingActionResults());
207
- if (position) {
208
- feedbackClickEpic(StateGlobal, position);
209
- return;
210
- }
211
- if (settings.regions) {
212
- serviceImage(url, settings).then((res ) => {
213
- console.log("res", res)
214
- dispatch(setSearchResults(res));
215
- setLoading(false);
216
- return dispatch(showFeedback());
217
- });
218
-
219
- return;
220
- } else {
221
- serviceImageNonRegion(url, StateGlobal, undefined).then((res) => {
222
- dispatch(searchFileImageNonRegion(res));
223
- });
224
- return;
225
- }
226
- };
227
-
228
- // Todo: item result.
229
- const Hit = (hit: any) => {
230
- return (
231
- <ItemResult
232
- dataItem={hit?.hit}
233
- handlerToggleModal={() => {
234
- handlerToggleModal(hit?.hit);
235
- }}
236
- handlerToggleModalShare={() => setOpenModalShare(true)}
237
- indexItem={hit.__position}
238
- isHover={false}
239
- onSearchImage={(url: any) => {
240
- setSearchStateInput({});
241
- getUrlToCanvasFile(url);
242
- setLoading(true);
243
- }}
244
- handlerFeedback={(value: string) => {
245
- sendFeedBackAction(value);
246
- }}
247
- />
248
- );
249
- };
250
-
251
- const nonEmptyFilter: any[] = !search?.requestImage
252
- ? []
253
- : ["sku:DOES_NOT_EXIST<score=1>"];
254
- const filterSkus: any = search?.results
255
- ? search?.results.map(
256
- (f: any) => `sku:'${f.sku}'<score=${Math.round(100 * f.score)}>`
257
- )
258
- : "";
259
- const filtersString = [...nonEmptyFilter, ...filterSkus].join(" OR ");
260
- return (
261
- <Box className={`wrap-main-result loading`}>
262
- <>
263
- {isLoading && (
264
- <Box className="box-wrap-loading">
265
- <Box className="loadingSpinCT">
266
- <Box className="box-content-spin"></Box>
267
- </Box>
268
- </Box>
269
- )}
270
- <InstantSearch
271
- indexName={indexNameAlgolia}
272
- searchClient={searchClient}
273
- searchState={searchStateInput}
274
- onSearchStateChange={(state: any) => {
275
- setSearchStateInput(state);
276
- searchTextByApiAndFilter(state);
277
- }}
278
- >
279
- <Configure filters={filtersString}></Configure>
280
- <Box className="box-wrap-result-component">
281
- <div className="box-search">
282
- <Box>
283
- <CustomSearchBox />
284
- </Box>
285
- {/* <Box className="box-filter">
286
- <FilterComponent />
287
- </Box> */}
288
- </div>
289
- <Box className="box-result">
290
- <>
291
- {settings.preview && requestImage && (
292
- <Box className={`col-left ${showColLeft && "toggle"}`}>
293
- <Box className="box-preview">
294
- <Button
295
- className="button-toggle"
296
- onClick={() => {
297
- setTimeout(() => {
298
- setToggleShowColLeft(!showColLeft);
299
- }, 500);
300
- }}
301
- >
302
- {showColLeft ? (
303
- <KeyboardArrowRightOutlinedIcon />
304
- ) : (
305
- <KeyboardArrowLeftOutlinedIcon />
306
- )}
307
- </Button>
308
- {requestImage && showImageCanvas && (
309
- <Box className="preview-item">
310
- <Preview
311
- key={requestImage?.id}
312
- onSelectionChange={(r: RectCoords) => {
313
- debounceRectCoords(r);
314
- return;
315
- }}
316
- image={requestImage?.canvas}
317
- selection={selectedRegion}
318
- regions={regions}
319
- maxWidth={400}
320
- maxHeight={500}
321
- dotColor="#FBD914"
322
- />
323
- </Box>
324
- )}
325
- </Box>
326
- <Box className="box-title_col-left">
327
- <Typography style={{ fontSize: 11, color: "#fff" }}>
328
- Adjust the selection frame for better results.
329
- </Typography>
330
- </Box>
331
- </Box>
332
- )}
333
-
334
- <Box
335
- className={`col-right ${
336
- settings.preview && "ml-auto mr-auto"
337
- }`}
338
- >
339
- <Box
340
- className={`box-item-result ${
341
- requestImage && showImageCanvas
342
- ? "mr-auto"
343
- : "ml-auto mr-auto"
344
- }`}
345
- >
346
- <LoadingScreenCustom>
347
- <Hits hitComponent={Hit} />
348
- </LoadingScreenCustom>
349
- </Box>
350
- </Box>
351
- </>
352
- </Box>
353
- <Box>
354
- <Box className="box-panigation">
355
- <Pagination />
356
- </Box>
357
- <Box className="box-notify">
358
- <FooterResult search={search} />
359
- </Box>
360
- </Box>
361
-
362
- {/* TODO: Component modal image */}
363
- <DefaultModal
364
- openModal={isOpenModalImage}
365
- handleClose={(e: any) => {
366
- setOpenModalImage(false);
367
- }}
368
- >
369
- <DetailItem
370
- handlerCloseModal={() => {
371
- setOpenModalImage(false);
372
- }}
373
- onPrevItem={onPrevItem}
374
- onNextItem={onNextItem}
375
- dataItem={dataImageModal}
376
- results={dataResult}
377
- onHandlerModalShare={() => setOpenModalShare(true)}
378
- onSearchImage={(url: string) => {
379
- setLoading(true);
380
- getUrlToCanvasFile(url);
381
- }}
382
- />
383
- </DefaultModal>
384
-
385
- {/* TODO: Component modal share */}
386
- <DefaultModal
387
- openModal={isOpenModalShare}
388
- handleClose={() => setOpenModalShare(false)}
389
- >
390
- <Box className="box-modal-default box-modal-share">
391
- <Box
392
- className="ml-auto"
393
- style={{ width: "fit-content", marginRight: 5 }}
394
- >
395
- <Button
396
- style={{ padding: 0 }}
397
- onClick={() => setOpenModalShare(false)}
398
- >
399
- <CloseOutlinedIcon
400
- style={{ fontSize: 12, color: "#55566B" }}
401
- />
402
- </Button>
403
- </Box>
404
- <Box className="box-content-box-share">
405
- <Typography className="text-f12 text-gray text-bold">
406
- Share
407
- </Typography>
408
- <Paper component="form" className="box-input">
409
- <InputBase
410
- className="text-f9 text-gray"
411
- style={{ width: "100%" }}
412
- value={"https://www.go..."}
413
- />
414
- <IconButton
415
- color="secondary"
416
- aria-label="directions"
417
- style={{ padding: 0 }}
418
- >
419
- <FileCopyOutlinedIcon style={{ fontSize: 8 }} />
420
- </IconButton>
421
- </Paper>
422
-
423
- <Box mt={1} className="box-media-share">
424
- <Button style={{ padding: 0 }}>
425
- <Box display={"flex"} alignItems={"center"}>
426
- <img src={IconEmail} alt="icon_email" />
427
- <Typography
428
- className="text-f8 fw-500"
429
- style={{ color: "#2B2C46", marginLeft: 5 }}
430
- >
431
- Share with e-Mail
432
- </Typography>
433
- </Box>
434
- </Button>
435
- <Button style={{ padding: 0 }}>
436
- <Box display={"flex"} alignItems={"center"}>
437
- <img src={IconWhatsApp} alt="icon_email" />
438
- <Typography
439
- className="text-f8 fw-500"
440
- style={{ color: "#2B2C46", marginLeft: 5 }}
441
- >
442
- Share with WhatsApp
443
- </Typography>
444
- </Box>
445
- </Button>
446
- <Button style={{ padding: 0 }}>
447
- <Box display={"flex"} alignItems={"center"}>
448
- <img src={IconWeChat} alt="icon_email" />
449
- <Typography
450
- className="text-f8 fw-500"
451
- style={{ color: "#2B2C46", marginLeft: 5 }}
452
- >
453
- Share with WeChat
454
- </Typography>
455
- </Box>
456
- </Button>
457
- </Box>
458
- </Box>
459
- </Box>
460
- </DefaultModal>
461
- </Box>
462
- </InstantSearch>
463
- </>
464
- </Box>
465
- );
466
- }
467
-
468
- export default ResultComponent;
@@ -1,65 +0,0 @@
1
- import NyrisAPI from "@nyris/nyris-api";
2
-
3
- export const feedbackSuccessEpic = async (state: any, success: boolean) => {
4
- const { search, settings } = state;
5
- try {
6
- const api = new NyrisAPI(settings);
7
- const sessionId = search.sessionId || search.requestId;
8
- return await api.sendFeedback(sessionId, search.requestId, {
9
- event: "feedback",
10
- data: { success },
11
- });
12
- } catch (error) {
13
- console.log("error feedbackSuccessEpic", error);
14
- }
15
- };
16
-
17
- export const feedbackClickEpic = async (state: any, position: number) => {
18
- try {
19
- const { search, settings } = state;
20
- const api = new NyrisAPI(settings);
21
- const sessionId = search.sessionId || search.requestId;
22
- if (sessionId && state.search.requestId) {
23
- await api.sendFeedback(sessionId, state.search.requestId, {
24
- event: "click",
25
- data: { positions: [position] },
26
- });
27
- }
28
- } catch (error) {
29
- console.log("error feedbackClickEpic", feedbackClickEpic);
30
- }
31
- };
32
-
33
- export const feedbackRegionEpic = async (state: any, region: any) => {
34
- try {
35
- const { search, settings } = state;
36
- const api = new NyrisAPI(settings);
37
- const sessionId = search.sessionId || search.requestId;
38
- const { x1, x2, y1, y2 } = region;
39
- if (sessionId && search.requestId) {
40
- await api.sendFeedback(sessionId, search.requestId, {
41
- event: "region",
42
- data: { rect: { x: x1, y: y1, w: x2 - x1, h: y2 - y1 } },
43
- });
44
- }
45
- } catch (error) {
46
- console.log("error feedbackRegionEpic", error);
47
- }
48
- };
49
-
50
- export const sendFeedbackByApi = async (
51
- settings: any,
52
- sessionId: any,
53
- requestId: any,
54
- payload: any
55
- ) => {
56
- const api = new NyrisAPI(settings);
57
- try {
58
- const dataByApi = await api
59
- .sendFeedback(sessionId, requestId, payload)
60
- .then((res) => {});
61
- console.log("dataByApi", dataByApi);
62
- } catch (error) {
63
- console.log("error sendFeedbackByApi321", error);
64
- }
65
- };
@@ -1,24 +0,0 @@
1
- import NyrisAPI from "@nyris/nyris-api";
2
-
3
- export const findByImage = async (image: any, options: any, settings: any) => {
4
-
5
- try {
6
- const api = new NyrisAPI(settings);
7
- const {
8
- results,
9
- duration,
10
- requestId,
11
- categoryPredictions,
12
- codes,
13
- } = await api.findByImage(image, options);
14
- return {
15
- results,
16
- duration,
17
- requestId,
18
- categoryPredictions,
19
- codes,
20
- };
21
- } catch (error) {
22
- console.log("error findByImage", error);
23
- }
24
- };
@@ -1,15 +0,0 @@
1
- import {
2
- ImageSearchOptions,
3
- Region,
4
- Result,
5
- SearchServiceSettings,
6
- } from "./types";
7
- // import {canvasToJpgBlob, getElementSize, getThumbSizeArea, toCanvas} from "./nyris";
8
- import axios, { AxiosInstance } from "axios";
9
- import {
10
- canvasToJpgBlob,
11
- getElementSize,
12
- getThumbSizeArea,
13
- toCanvas,
14
- } from "./nyris";
15
-
@@ -1,107 +0,0 @@
1
- import {ImageSearchOptions, NyrisAPISettings, selectFirstCenteredRegion, urlOrBlobToCanvas} from "@nyris/nyris-api";
2
- import NyrisAPI from "@nyris/nyris-api";
3
- import { fileOrBlobToCanvas, rectToCrop } from "./nyris";
4
-
5
- export const serviceImage = async (file: any, settings: NyrisAPISettings) => {
6
- try {
7
- const nyrisApi = new NyrisAPI(settings);
8
- const randomId = Math.random().toString();
9
-
10
- const image = await fileOrBlobToCanvas(file);
11
- const imageFileCanvas = { canvas: image, id: randomId };
12
-
13
- const regions = await nyrisApi.findRegions(image);
14
- const searchRegion = selectFirstCenteredRegion(regions, 0.3, {x1: 0, x2: 1, y1: 0, y2: 1});
15
-
16
- let options : ImageSearchOptions = {
17
- ...settings,
18
- cropRect: searchRegion
19
- };
20
-
21
- const { results, requestId, duration, categoryPredictions, codes } =
22
- await nyrisApi.findByImage(image, options);
23
- const payload = {
24
- results,
25
- requestId,
26
- categoryPredictions,
27
- codes,
28
- duration,
29
- regions,
30
- requestImage: imageFileCanvas,
31
- selectedRegion: searchRegion
32
- };
33
-
34
- return payload;
35
- } catch (error) {
36
- console.log("error serviceImage", error);
37
- return;
38
- }
39
- };
40
-
41
- export const serviceImageNonRegion = async (
42
- file: any,
43
- stateStore: any,
44
- rectCoords: any
45
- ) => {
46
- const { settings } = stateStore;
47
- const api = new NyrisAPI(settings);
48
- const image = await urlOrBlobToCanvas(file);
49
- const randomId = Math.random().toString();
50
- const imageFileCanvas = { canvas: image, id: randomId };
51
- let options: ImageSearchOptions = {
52
- cropRect: rectCoords,
53
- };
54
- try {
55
- const { results, duration, requestId, categoryPredictions, codes } =
56
- await api.findByImage(image, options);
57
- return {
58
- results,
59
- requestId,
60
- duration,
61
- categoryPredictions,
62
- codes,
63
- requestImage: imageFileCanvas,
64
- };
65
- } catch (e) {
66
- console.warn("search failed serviceImageNonRegion", e);
67
- }
68
- };
69
-
70
- export const searchImageByPosition = async (
71
- image: HTMLCanvasElement,
72
- stateStore: any,
73
- region?: any
74
- ) => {
75
- try {
76
- const { settings } = stateStore;
77
-
78
- let options = settings;
79
- const nyrisApi = new NyrisAPI(settings);
80
- if (region) {
81
- let { x1, x2, y1, y2 } = region;
82
- let crop = rectToCrop({
83
- x1: x1 * image.width,
84
- x2: x2 * image.width,
85
- y1: y1 * image.height,
86
- y2: y2 * image.height,
87
- });
88
- options = {
89
- ...options,
90
- crop,
91
- };
92
- }
93
- const { results, duration, requestId, categoryPredictions, codes } =
94
- await nyrisApi.findByImage(image, options);
95
- const payload = {
96
- results,
97
- requestId,
98
- categoryPredictions,
99
- codes,
100
- duration,
101
- regions: region,
102
- };
103
- return payload;
104
- } catch (error: any) {
105
- console.log("error searchImageByPosition", error);
106
- }
107
- };