@nyris/nyris-webapp 0.3.5 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/build/asset-manifest.json +18 -32
  2. package/build/index.html +1 -1
  3. package/build/{precache-manifest.bbb31f2ce7710d7eb3175b1b48241d24.js → precache-manifest.bffed513ca17d8ac16af1cc3aaa7d908.js} +13 -89
  4. package/build/service-worker.js +1 -1
  5. package/build/static/css/2.43a1c8b7.chunk.css +2 -0
  6. package/build/static/css/2.43a1c8b7.chunk.css.map +1 -0
  7. package/build/static/css/main.2a76dc8a.chunk.css +2 -0
  8. package/build/static/css/main.2a76dc8a.chunk.css.map +1 -0
  9. package/build/static/js/2.4e9a4ce1.chunk.js +3 -0
  10. package/build/static/js/2.4e9a4ce1.chunk.js.LICENSE.txt +79 -0
  11. package/build/static/js/2.4e9a4ce1.chunk.js.map +1 -0
  12. package/build/static/js/main.ec93aa4d.chunk.js +2 -0
  13. package/build/static/js/main.ec93aa4d.chunk.js.map +1 -0
  14. package/build/static/js/{runtime-main.b418ff16.js → runtime-main.f5553a9b.js} +1 -1
  15. package/build/static/js/{runtime-main.b418ff16.js.map → runtime-main.f5553a9b.js.map} +1 -1
  16. package/package.json +7 -30
  17. package/src/App.css +64 -20
  18. package/src/App.test.tsx +49 -0
  19. package/src/App.tsx +253 -15
  20. package/src/AppMD.tsx +320 -0
  21. package/src/Demo2.tsx +220 -0
  22. package/src/actions/nyrisAppActions.ts +76 -0
  23. package/src/actions/searchActions.ts +218 -0
  24. package/src/components/ExampleImages.tsx +17 -32
  25. package/src/components/Feedback.tsx +48 -87
  26. package/src/components/FiltersList.tsx +69 -0
  27. package/src/components/Header.tsx +17 -32
  28. package/src/components/Result.tsx +113 -186
  29. package/src/components/Sidebar.tsx +40 -0
  30. package/src/defaults.ts +3 -4
  31. package/src/epics/feedback.ts +59 -0
  32. package/src/epics/index.ts +154 -0
  33. package/src/epics/search.ts +203 -0
  34. package/src/epics/types.ts +12 -0
  35. package/src/{common/assets/fonts → fonts}/roboto-bold-webfont.woff +0 -0
  36. package/src/{common/assets/fonts → fonts}/roboto-bold-webfont.woff2 +0 -0
  37. package/src/{common/assets/fonts → fonts}/roboto-italic-webfont.woff +0 -0
  38. package/src/{common/assets/fonts → fonts}/roboto-italic-webfont.woff2 +0 -0
  39. package/src/{common/assets/fonts → fonts}/roboto-regular-webfont.woff +0 -0
  40. package/src/{common/assets/fonts → fonts}/roboto-regular-webfont.woff2 +0 -0
  41. package/src/{common/assets/fonts → fonts}/robotocondensed-bold-webfont.woff +0 -0
  42. package/src/{common/assets/fonts → fonts}/robotocondensed-bold-webfont.woff2 +0 -0
  43. package/src/{common/assets/fonts → fonts}/robotocondensed-bolditalic-webfont.woff +0 -0
  44. package/src/{common/assets/fonts → fonts}/robotocondensed-bolditalic-webfont.woff2 +0 -0
  45. package/src/{common/assets/images → images}/fav/android-icon-192x192.png +0 -0
  46. package/src/{common/assets/images → images}/fav/apple-icon-114x114.png +0 -0
  47. package/src/{common/assets/images → images}/fav/apple-icon-120x120.png +0 -0
  48. package/src/{common/assets/images → images}/fav/apple-icon-144x144.png +0 -0
  49. package/src/{common/assets/images → images}/fav/apple-icon-152x152.png +0 -0
  50. package/src/{common/assets/images → images}/fav/apple-icon-180x180.png +0 -0
  51. package/src/{common/assets/images → images}/fav/apple-icon-57x57.png +0 -0
  52. package/src/{common/assets/images → images}/fav/apple-icon-60x60.png +0 -0
  53. package/src/{common/assets/images → images}/fav/apple-icon-72x72.png +0 -0
  54. package/src/{common/assets/images → images}/fav/apple-icon-76x76.png +0 -0
  55. package/src/{common/assets/images → images}/fav/browserconfig.xml +0 -0
  56. package/src/{common/assets/images → images}/fav/favicon-16x16.png +0 -0
  57. package/src/{common/assets/images → images}/fav/favicon-32x32.png +0 -0
  58. package/src/{common/assets/images → images}/fav/favicon-96x96.png +0 -0
  59. package/src/{common/assets/images → images}/fav/manifest.json +0 -0
  60. package/src/{common/assets/images → images}/ic_cam.png +0 -0
  61. package/src/{common/assets/images → images}/ic_cam.svg +0 -0
  62. package/src/{common/assets/images → images}/ic_cam_large.png +0 -0
  63. package/src/{common/assets/images → images}/ic_cam_large.svg +0 -0
  64. package/src/{common/assets/images → images}/ic_cam_large_noimage.png +0 -0
  65. package/src/{common/assets/images → images}/ic_close_feedback.png +0 -0
  66. package/src/{common/assets/images → images}/ic_close_feedback.svg +0 -0
  67. package/src/{common/assets/images → images}/ic_shopNow.png +0 -0
  68. package/src/{common/assets/images → images}/ic_shopNow.svg +0 -0
  69. package/src/{common/assets/images → images}/ic_shopNowLight.png +0 -0
  70. package/src/{common/assets/images → images}/ic_shopNowLight.svg +0 -0
  71. package/src/{common/assets/images → images}/nyris_logo.png +0 -0
  72. package/src/{common/assets/images → images}/rewe.svg +0 -0
  73. package/src/{common/assets/images → images}/sectionTransBack.png +0 -0
  74. package/src/{common/assets/images → images}/sectionTransBack.svg +0 -0
  75. package/src/{common/assets/images → images}/sectionTransTop.png +0 -0
  76. package/src/{common/assets/images → images}/sectionTransTop.svg +0 -0
  77. package/src/index.css +416 -573
  78. package/src/index.tsx +189 -39
  79. package/src/types.ts +7 -51
  80. package/tsconfig.json +8 -3
  81. package/build/js/settings.example.js +0 -31
  82. package/build/js/test.js +0 -56
  83. package/build/static/css/2.8285176a.chunk.css +0 -2
  84. package/build/static/css/2.8285176a.chunk.css.map +0 -1
  85. package/build/static/css/main.6676fe1f.chunk.css +0 -2
  86. package/build/static/css/main.6676fe1f.chunk.css.map +0 -1
  87. package/build/static/js/2.4a55bc61.chunk.js +0 -3
  88. package/build/static/js/2.4a55bc61.chunk.js.LICENSE.txt +0 -124
  89. package/build/static/js/2.4a55bc61.chunk.js.map +0 -1
  90. package/build/static/js/main.2660f94a.chunk.js +0 -2
  91. package/build/static/js/main.2660f94a.chunk.js.map +0 -1
  92. package/build/static/media/Fill.37094b44.svg +0 -3
  93. package/build/static/media/Montserrat-Bold.5a052e98.otf +0 -0
  94. package/build/static/media/Montserrat-Light.21789e89.otf +0 -0
  95. package/build/static/media/Montserrat-Medium.a53e0373.otf +0 -0
  96. package/build/static/media/Montserrat-Regular.71cdc681.otf +0 -0
  97. package/build/static/media/Montserrat-SemiBold.f613d915.otf +0 -0
  98. package/build/static/media/Rectangle.4dd8b747.png +0 -0
  99. package/build/static/media/admin.9529c7f6.svg +0 -3
  100. package/build/static/media/bg-support-page.6ac55268.svg +0 -9
  101. package/build/static/media/book_mark.8e294c0b.svg +0 -3
  102. package/build/static/media/icon_dislike.94607ca6.svg +0 -3
  103. package/build/static/media/icon_like.a4fb1b18.svg +0 -3
  104. package/build/static/media/icon_modal_image.3068d0ea.svg +0 -21
  105. package/build/static/media/icon_search_image.c2c728c0.svg +0 -3
  106. package/build/static/media/nyris_logo.22d8f250.svg +0 -3
  107. package/build/static/media/reload_icon.4b579a74.svg +0 -3
  108. package/build/static/media/save_search.bebaeebf.svg +0 -3
  109. package/build/static/media/support.289c3a3c.svg +0 -3
  110. package/build/static/media/translate_icon.f0492297.svg +0 -3
  111. package/public/js/settings.example.js +0 -31
  112. package/public/js/test.js +0 -56
  113. package/src/Router.tsx +0 -97
  114. package/src/Store/Auth.ts +0 -44
  115. package/src/Store/Nyris.ts +0 -77
  116. package/src/Store/Search.ts +0 -243
  117. package/src/Store/Store.ts +0 -53
  118. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Bold.otf +0 -0
  119. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Light.otf +0 -0
  120. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Medium.otf +0 -0
  121. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Regular.otf +0 -0
  122. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-SemiBold.otf +0 -0
  123. package/src/common/assets/icons/Fill.png +0 -0
  124. package/src/common/assets/icons/Fill.svg +0 -3
  125. package/src/common/assets/icons/Icon_wechat.png +0 -0
  126. package/src/common/assets/icons/Icon_whatsapp.png +0 -0
  127. package/src/common/assets/icons/admin.png +0 -0
  128. package/src/common/assets/icons/admin.svg +0 -3
  129. package/src/common/assets/icons/book_mark.png +0 -0
  130. package/src/common/assets/icons/book_mark.svg +0 -3
  131. package/src/common/assets/icons/icon_barcode.png +0 -0
  132. package/src/common/assets/icons/icon_camera.png +0 -0
  133. package/src/common/assets/icons/icon_dislike.svg +0 -3
  134. package/src/common/assets/icons/icon_disslike.png +0 -0
  135. package/src/common/assets/icons/icon_email.png +0 -0
  136. package/src/common/assets/icons/icon_like.png +0 -0
  137. package/src/common/assets/icons/icon_like.svg +0 -3
  138. package/src/common/assets/icons/icon_modal_image.png +0 -0
  139. package/src/common/assets/icons/icon_modal_image.svg +0 -21
  140. package/src/common/assets/icons/icon_picture.png +0 -0
  141. package/src/common/assets/icons/icon_search_image.png +0 -0
  142. package/src/common/assets/icons/icon_search_image.svg +0 -3
  143. package/src/common/assets/icons/nyris_logo.svg +0 -3
  144. package/src/common/assets/icons/reload_icon.png +0 -0
  145. package/src/common/assets/icons/reload_icon.svg +0 -3
  146. package/src/common/assets/icons/save_search.png +0 -0
  147. package/src/common/assets/icons/save_search.svg +0 -3
  148. package/src/common/assets/icons/setting_search_icon.png +0 -0
  149. package/src/common/assets/icons/support.png +0 -0
  150. package/src/common/assets/icons/support.svg +0 -3
  151. package/src/common/assets/icons/translate_icon.png +0 -0
  152. package/src/common/assets/icons/translate_icon.svg +0 -3
  153. package/src/common/assets/icons/view_off.png +0 -0
  154. package/src/common/assets/images/Rectangle.png +0 -0
  155. package/src/common/assets/images/bg-support-page.svg +0 -9
  156. package/src/common/assets/images/image_test.png +0 -0
  157. package/src/components/CustomHits/index.tsx +0 -57
  158. package/src/components/DetailItem.tsx +0 -175
  159. package/src/components/DragDropFile.tsx +0 -192
  160. package/src/components/FilterComponent.tsx +0 -33
  161. package/src/components/Footer.tsx +0 -29
  162. package/src/components/FooterMD.tsx +0 -54
  163. package/src/components/FooterNewVersion.tsx +0 -12
  164. package/src/components/FooterResult.tsx +0 -47
  165. package/src/components/HeaderMd.tsx +0 -38
  166. package/src/components/HeaderNewVersion.tsx +0 -92
  167. package/src/components/Layout.tsx +0 -46
  168. package/src/components/LoadingScreen/index.tsx +0 -29
  169. package/src/components/Navigation.tsx +0 -34
  170. package/src/components/Panigation/Pagination.tsx +0 -140
  171. package/src/components/Panigation/cx.js +0 -3
  172. package/src/components/Panigation/isModifierClick.js +0 -10
  173. package/src/components/Saved/AllItem.tsx +0 -32
  174. package/src/components/Saved/Category.tsx +0 -16
  175. package/src/components/carousel/DefaultCarousel.tsx +0 -48
  176. package/src/components/common.d.ts +0 -9
  177. package/src/components/common.scss +0 -54
  178. package/src/components/default-select.tsx +0 -44
  179. package/src/components/hitItem/hits.tsx +0 -50
  180. package/src/components/hitItem/infinitiHits.tsx +0 -33
  181. package/src/components/input/inputSearch.tsx +0 -77
  182. package/src/components/modal/DefaultModal.tsx +0 -28
  183. package/src/components/results/ItemResult.tsx +0 -155
  184. package/src/components/search/ListSearch.tsx +0 -209
  185. package/src/modules/LandingPage/App.tsx +0 -318
  186. package/src/modules/LandingPage/AppMD.tsx +0 -399
  187. package/src/modules/LandingPage/common.scss +0 -1304
  188. package/src/modules/LandingPage/index.tsx +0 -169
  189. package/src/modules/LandingPage/indexNewVersion.tsx +0 -110
  190. package/src/modules/LandingPage/propsType.ts +0 -43
  191. package/src/page/Auth/login.tsx +0 -7
  192. package/src/page/Exception/404.tsx +0 -11
  193. package/src/page/History/index.tsx +0 -76
  194. package/src/page/Profile/index.tsx +0 -87
  195. package/src/page/Saved/MockData.ts +0 -223
  196. package/src/page/Saved/index.tsx +0 -166
  197. package/src/page/Support/index.tsx +0 -160
  198. package/src/page/result/MockData.ts +0 -36
  199. package/src/page/result/index.tsx +0 -418
  200. package/src/services/Feedback.ts +0 -64
  201. package/src/services/image.ts +0 -40
  202. package/src/services/session.ts +0 -17
  203. package/src/services/types.ts +0 -50
@@ -1,418 +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 ItemResult from "components/results/ItemResult";
14
- import { useAppDispatch, useAppSelector } from "Store/Store";
15
- import { debounce } from "lodash";
16
- import KeyboardArrowRightOutlinedIcon from "@material-ui/icons/KeyboardArrowRightOutlined";
17
- import KeyboardArrowLeftOutlinedIcon from "@material-ui/icons/KeyboardArrowLeftOutlined";
18
- import FooterResult from "components/FooterResult";
19
- import DefaultModal from "components/modal/DefaultModal";
20
- import CloseOutlinedIcon from "@material-ui/icons/CloseOutlined";
21
- import DetailItem from "components/DetailItem";
22
- import FileCopyOutlinedIcon from "@material-ui/icons/FileCopyOutlined";
23
- import { RectCoords } from "@nyris/nyris-api";
24
- import {
25
- setSearchResults,
26
- loadingActionResults,
27
- selectionChanged,
28
- updateResultChangePosition, setRegions, setSelectedRegion,
29
- } from "Store/Search";
30
- import { showFeedback, showResults } from "Store/Nyris";
31
- import algoliasearch from "algoliasearch/lite";
32
- import {
33
- InstantSearch,
34
- Hits,
35
- Pagination,
36
- Configure,
37
- } from "react-instantsearch-dom";
38
- import CustomSearchBox from "components/input/inputSearch";
39
- import {feedbackClickEpic, feedbackSuccessEpic, feedbackTextSearchEpic} from "services/Feedback";
40
- import {
41
- createImage, findByImage, findRegions,
42
- } from "services/image";
43
- import LoadingScreenCustom from "components/LoadingScreen";
44
- import { Preview } from "@nyris/nyris-react-components";
45
- import {AlgoliaResult, AlgoliaSettings} from "../../types";
46
-
47
- interface Props {}
48
-
49
- const defaultSelection = {x1: 0.1, x2: 0.9, y1: 0.1, y2: 0.9};
50
- function ResultComponent(props: Props) {
51
- const dispatch = useAppDispatch();
52
- const stateGlobal = useAppSelector((state) => state);
53
- const [showColLeft, setToggleShowColLeft] = useState<boolean>(false);
54
- const [showImageCanvas, setShowImageCanvas] = useState<boolean>(true);
55
- const [isOpenModalImage, setOpenModalImage] = useState<boolean>(false);
56
- const [numberResult, setNumberResult] = useState<number>(0);
57
- const [isOpenModalShare, setOpenModalShare] = useState<boolean>(false);
58
- const { search, settings } = stateGlobal;
59
- const { results, requestImage, regions, selectedRegion } = search;
60
- const { valueTextSearch } = search;
61
- const [dataResult, setDataResult] = useState<any[]>([]);
62
- const [dataImageModal, setDataImageModal] = useState<any>();
63
- const [searchStateInput, setSearchStateInput] = useState<any>({});
64
- const [isLoading, setLoading] = useState<any>(false);
65
- const { apiKey, appId, indexName } = settings.algolia as AlgoliaSettings;
66
- const searchClient = algoliasearch(appId, apiKey);
67
- const index = searchClient.initIndex(indexName);
68
-
69
- useEffect(() => {
70
- if (!valueTextSearch) {
71
- return;
72
- }
73
- setSearchStateInput(valueTextSearch);
74
- }, [valueTextSearch]);
75
-
76
- useEffect(() => {
77
- if (results?.length === 0) {
78
- setDataResult([]);
79
- return;
80
- }
81
- setDataResult(results);
82
- }, [results]);
83
-
84
- useEffect(() => {
85
- if (!showColLeft) {
86
- return setShowImageCanvas(true);
87
- }
88
- return setShowImageCanvas(false);
89
- }, [showColLeft]);
90
-
91
- // TODO: hanlder modal:
92
- const handlerToggleModal = (item: any) => {
93
- setDataImageModal(item);
94
- return setOpenModalImage(true);
95
- };
96
-
97
- const onNextItem = () => {
98
- if (numberResult === results.length) {
99
- return;
100
- }
101
- setNumberResult(numberResult + 1);
102
- };
103
-
104
- const onPrevItem = () => {
105
- if (numberResult === 0) {
106
- return;
107
- }
108
- setNumberResult(numberResult - 1);
109
- };
110
-
111
- // TODO: rectCoords
112
-
113
- const debounceRectCoords = (value: any) => handlerRectCoords(value);
114
-
115
- const handlerRectCoords = debounce((value: any) => {
116
- dispatch(selectionChanged(value));
117
- setLoading(true);
118
- return findItemsInSelection(value);
119
- }, 500);
120
-
121
- // TODO: Search offers for image:
122
- const findItemsInSelection = (r: RectCoords) => {
123
- if (!requestImage) {
124
- return;
125
- }
126
- const { canvas }: any = requestImage;
127
- findByImage(canvas, stateGlobal.settings, r).then((res) => {
128
- const payload = {
129
- ...res,
130
- };
131
- dispatch(updateResultChangePosition(payload));
132
- setLoading(false);
133
- return dispatch(showFeedback());
134
- });
135
- };
136
-
137
- // TODO: Search text
138
- const searchTextByApiAndFilter = async (searchState: any) => {
139
- try {
140
- if (searchState?.query !== "") {
141
- const data = await index.search<AlgoliaResult>(searchState.query, {});
142
- const productIds = data.hits.map((hit) => hit.sku);
143
- await feedbackTextSearchEpic(stateGlobal, data.query, data.page, productIds);
144
- }
145
- } catch (error) {
146
- console.log("searchTextByApi", error);
147
- return;
148
- }
149
- };
150
-
151
- const sendFeedBackAction = async (type: string) =>
152
- feedbackSuccessEpic(stateGlobal, type === "like");
153
-
154
- // Search image with url or file
155
- const getUrlToCanvasFile = async (url: string, position?: number) => {
156
- dispatch(showResults());
157
- dispatch(loadingActionResults());
158
- let image = await createImage(url);
159
- if (position) {
160
- feedbackClickEpic(stateGlobal, position);
161
- return;
162
- }
163
- let searchRegion : RectCoords | undefined = undefined;
164
- if (settings.regions) {
165
- let res = await findRegions(image, settings);
166
- searchRegion = res.selectedRegion;
167
- dispatch(setRegions(res.regions));
168
- dispatch(setSelectedRegion(searchRegion));
169
- }
170
-
171
- findByImage(image, settings, searchRegion).then((res ) => {
172
- dispatch(setSearchResults(res));
173
- setLoading(false);
174
- return dispatch(showFeedback());
175
- });
176
- };
177
-
178
- // Todo: item result.
179
- const Hit = (hit: any) => {
180
- return (
181
- <ItemResult
182
- dataItem={hit?.hit}
183
- handlerToggleModal={() => {
184
- handlerToggleModal(hit?.hit);
185
- }}
186
- handlerToggleModalShare={() => setOpenModalShare(true)}
187
- indexItem={hit.__position}
188
- isHover={false}
189
- onSearchImage={(url: any) => {
190
- setSearchStateInput({});
191
- getUrlToCanvasFile(url);
192
- setLoading(true);
193
- }}
194
- handlerFeedback={(value: string) => {
195
- sendFeedBackAction(value);
196
- }}
197
- />
198
- );
199
- };
200
-
201
- const nonEmptyFilter: any[] = !requestImage
202
- ? []
203
- : ["sku:DOES_NOT_EXIST<score=1>"];
204
- const filterSkus: any = search?.results
205
- ? search?.results.slice().reverse().map(
206
- (f: any, i: number) => `sku:'${f.sku}'<score=${i}>`
207
- )
208
- : "";
209
- const filtersString = [...nonEmptyFilter, ...filterSkus].join(" OR ");
210
- return (
211
- <Box className={`wrap-main-result loading`}>
212
- <>
213
- {isLoading && (
214
- <Box className="box-wrap-loading">
215
- <Box className="loadingSpinCT">
216
- <Box className="box-content-spin"></Box>
217
- </Box>
218
- </Box>
219
- )}
220
- <InstantSearch
221
- indexName={indexName}
222
- searchClient={searchClient}
223
- searchState={searchStateInput}
224
- onSearchStateChange={(state) => {
225
- setSearchStateInput(state);
226
- searchTextByApiAndFilter(state);
227
- }}
228
- >
229
- <Configure filters={filtersString}></Configure>
230
- <Box className="box-wrap-result-component">
231
- <div className="box-search">
232
- <Box>
233
- <CustomSearchBox />
234
- </Box>
235
- {/* <Box className="box-filter">
236
- <FilterComponent />
237
- </Box> */}
238
- </div>
239
- <Box className="box-result">
240
- <>
241
- {settings.preview && requestImage && (
242
- <Box className={`col-left ${showColLeft && "toggle"}`}>
243
- <Box className="box-preview">
244
- <Button
245
- className="button-toggle"
246
- onClick={() => {
247
- setTimeout(() => {
248
- setToggleShowColLeft(!showColLeft);
249
- }, 500);
250
- }}
251
- >
252
- {showColLeft ? (
253
- <KeyboardArrowRightOutlinedIcon />
254
- ) : (
255
- <KeyboardArrowLeftOutlinedIcon />
256
- )}
257
- </Button>
258
- {requestImage && showImageCanvas && (
259
- <Box className="preview-item">
260
- <Preview
261
- key={requestImage?.id}
262
- onSelectionChange={(r: RectCoords) => {
263
- debounceRectCoords(r);
264
- return;
265
- }}
266
- image={requestImage?.canvas}
267
- selection={selectedRegion|| defaultSelection}
268
- regions={regions}
269
- maxWidth={400}
270
- maxHeight={500}
271
- dotColor="#FBD914"
272
- />
273
- </Box>
274
- )}
275
- </Box>
276
- <Box className="box-title_col-left">
277
- <Typography style={{ fontSize: 11, color: "#fff" }}>
278
- Adjust the selection frame for better results.
279
- </Typography>
280
- </Box>
281
- </Box>
282
- )}
283
-
284
- <Box
285
- className={`col-right ${
286
- settings.preview && "ml-auto mr-auto"
287
- }`}
288
- >
289
- <Box
290
- className={`box-item-result ${
291
- requestImage && showImageCanvas
292
- ? "mr-auto"
293
- : "ml-auto mr-auto"
294
- }`}
295
- >
296
- <LoadingScreenCustom>
297
- <Hits hitComponent={Hit} />
298
- </LoadingScreenCustom>
299
- </Box>
300
- </Box>
301
- </>
302
- </Box>
303
- <Box>
304
- <Box className="box-panigation">
305
- <Pagination />
306
- </Box>
307
- <Box className="box-notify">
308
- <FooterResult search={search} />
309
- </Box>
310
- </Box>
311
-
312
- {/* TODO: Component modal image */}
313
- <DefaultModal
314
- openModal={isOpenModalImage}
315
- handleClose={(e: any) => {
316
- setOpenModalImage(false);
317
- }}
318
- >
319
- <DetailItem
320
- handlerCloseModal={() => {
321
- setOpenModalImage(false);
322
- }}
323
- onPrevItem={onPrevItem}
324
- onNextItem={onNextItem}
325
- dataItem={dataImageModal}
326
- results={dataResult}
327
- onHandlerModalShare={() => setOpenModalShare(true)}
328
- onSearchImage={(url: string) => {
329
- setLoading(true);
330
- getUrlToCanvasFile(url);
331
- }}
332
- />
333
- </DefaultModal>
334
-
335
- {/* TODO: Component modal share */}
336
- <DefaultModal
337
- openModal={isOpenModalShare}
338
- handleClose={() => setOpenModalShare(false)}
339
- >
340
- <Box className="box-modal-default box-modal-share">
341
- <Box
342
- className="ml-auto"
343
- style={{ width: "fit-content", marginRight: 5 }}
344
- >
345
- <Button
346
- style={{ padding: 0 }}
347
- onClick={() => setOpenModalShare(false)}
348
- >
349
- <CloseOutlinedIcon
350
- style={{ fontSize: 12, color: "#55566B" }}
351
- />
352
- </Button>
353
- </Box>
354
- <Box className="box-content-box-share">
355
- <Typography className="text-f12 text-gray text-bold">
356
- Share
357
- </Typography>
358
- <Paper component="form" className="box-input">
359
- <InputBase
360
- className="text-f9 text-gray"
361
- style={{ width: "100%" }}
362
- value={"https://www.go..."}
363
- />
364
- <IconButton
365
- color="secondary"
366
- aria-label="directions"
367
- style={{ padding: 0 }}
368
- >
369
- <FileCopyOutlinedIcon style={{ fontSize: 8 }} />
370
- </IconButton>
371
- </Paper>
372
-
373
- <Box mt={1} className="box-media-share">
374
- <Button style={{ padding: 0 }}>
375
- <Box display={"flex"} alignItems={"center"}>
376
- <img src={IconEmail} alt="icon_email" />
377
- <Typography
378
- className="text-f8 fw-500"
379
- style={{ color: "#2B2C46", marginLeft: 5 }}
380
- >
381
- Share with e-Mail
382
- </Typography>
383
- </Box>
384
- </Button>
385
- <Button style={{ padding: 0 }}>
386
- <Box display={"flex"} alignItems={"center"}>
387
- <img src={IconWhatsApp} alt="icon_email" />
388
- <Typography
389
- className="text-f8 fw-500"
390
- style={{ color: "#2B2C46", marginLeft: 5 }}
391
- >
392
- Share with WhatsApp
393
- </Typography>
394
- </Box>
395
- </Button>
396
- <Button style={{ padding: 0 }}>
397
- <Box display={"flex"} alignItems={"center"}>
398
- <img src={IconWeChat} alt="icon_email" />
399
- <Typography
400
- className="text-f8 fw-500"
401
- style={{ color: "#2B2C46", marginLeft: 5 }}
402
- >
403
- Share with WeChat
404
- </Typography>
405
- </Box>
406
- </Button>
407
- </Box>
408
- </Box>
409
- </Box>
410
- </DefaultModal>
411
- </Box>
412
- </InstantSearch>
413
- </>
414
- </Box>
415
- );
416
- }
417
-
418
- export default ResultComponent;
@@ -1,64 +0,0 @@
1
- import NyrisAPI, {FeedbackEventPayload, NyrisAPISettings, RectCoords} from "@nyris/nyris-api";
2
- import {RootState} from "../Store/Store";
3
-
4
- export const feedbackSuccessEpic = async (state: RootState, success: boolean) => {
5
- const { search, settings } = state;
6
- return await sendFeedbackByApi(settings, search.sessionId, search.requestId, {
7
- event: 'feedback',
8
- data: { success }
9
- });
10
- };
11
-
12
- export const feedbackClickEpic = async (state: RootState, position: number) => {
13
- const { search, settings } = state;
14
- return await sendFeedbackByApi(settings, search.sessionId, search.requestId, {
15
- event: "click",
16
- data: { positions: [position] },
17
- });
18
- };
19
-
20
- export const feedbackTextSearchEpic = async (state: RootState, query: string, page: number, productIds: string[]) => {
21
- try {
22
- const { search, settings } = state;
23
- const eventData = {
24
- query,
25
- page,
26
- product_ids: productIds,
27
- };
28
- const textSearchEvent = { event: "text-search", data: eventData };
29
- // @ts-ignore
30
- return await sendFeedbackByApi(settings, search.sessionId, search.requestId, textSearchEvent);
31
- } catch (error) {
32
- console.log("error feedbackTextSearchEpic", error);
33
- }
34
- };
35
-
36
- export const feedbackRegionEpic = async (state: RootState, region: RectCoords) => {
37
- const {settings, search} = state;
38
- const {sessionId, requestId } = search;
39
- const { x1, x2, y1, y2 } = region;
40
- const payload : FeedbackEventPayload = {
41
- event: "region",
42
- data: { rect: { x: x1, y: y1, w: x2 - x1, h: y2 - y1 } }
43
- };
44
- return await sendFeedbackByApi(settings, sessionId, requestId, payload);
45
- };
46
-
47
- export const sendFeedbackByApi = async (
48
- settings: NyrisAPISettings,
49
- sessionId: string | undefined,
50
- requestId: string | undefined,
51
- payload: FeedbackEventPayload
52
- ) => {
53
- const api = new NyrisAPI(settings);
54
- if (sessionId && requestId) {
55
- try {
56
- const dataByApi = await api
57
- .sendFeedback(sessionId, requestId, payload)
58
- .then((res) => {});
59
- console.log("dataByApi", dataByApi);
60
- } catch (error) {
61
- console.log("error sendFeedbackByApi321", error);
62
- }
63
- }
64
- };
@@ -1,40 +0,0 @@
1
- import {
2
- NyrisAPISettings,
3
- RectCoords,
4
- selectFirstCenteredRegion,
5
- urlOrBlobToCanvas
6
- } from "@nyris/nyris-api";
7
- import NyrisAPI from "@nyris/nyris-api";
8
- import {isEqual} from "lodash";
9
-
10
- export const defaultRect = {x1: 0, x2: 1, y1: 0, y2: 1};
11
-
12
- export const createImage = async (fileOrUrl: File|string|HTMLCanvasElement) => {
13
- const image = fileOrUrl instanceof HTMLCanvasElement ? fileOrUrl : await urlOrBlobToCanvas(fileOrUrl);
14
- return image;
15
- }
16
-
17
- export const findRegions = async (image: HTMLCanvasElement, settings: NyrisAPISettings) => {
18
- const nyrisApi = new NyrisAPI(settings);
19
- let regions = await nyrisApi.findRegions(image);
20
-
21
- const selectedRegion = selectFirstCenteredRegion(regions, 0.3, defaultRect);
22
- return {
23
- selectedRegion: isEqual(selectedRegion, defaultRect) ? undefined : selectedRegion,
24
- regions
25
- }
26
- };
27
-
28
- export const findByImage = (image: HTMLCanvasElement, settings: NyrisAPISettings, region?: RectCoords) => {
29
- const nyrisApi = new NyrisAPI(settings);
30
- let options = {};
31
- if (region) {
32
- options = { cropRect: region };
33
- }
34
- return nyrisApi.findByImage(image, options);
35
- };
36
-
37
- export const findByCadFile = (file: File, settings: NyrisAPISettings) => {
38
- const nyrisApi = new NyrisAPI(settings);
39
- return nyrisApi.findByCad(file, {});
40
- };
@@ -1,17 +0,0 @@
1
- import axios from "axios";
2
- import {NyrisAPISettings} from "@nyris/nyris-api";
3
-
4
- const httpClient = axios.create();
5
-
6
- export const createSessionByApi = async (settings: NyrisAPISettings) => {
7
- const { apiKey, baseUrl} = settings;
8
- let headers = {
9
- "X-Api-Key": apiKey,
10
- };
11
- let response = await httpClient.request({
12
- method: "POST",
13
- url: `${baseUrl}/find/v1/session`,
14
- headers,
15
- });
16
- return response.data.session;
17
- };
@@ -1,50 +0,0 @@
1
- // import {SearchAction, SearchState} from "./actions/searchActions";
2
- // import {NyrisAction, NyrisAppState} from "./actions/nyrisAppActions";
3
-
4
-
5
- import {MDSettings} from "../types";
6
-
7
- export interface SearchServiceSettings {
8
- xOptions: boolean | string,
9
- customSearchRequest?: ((file: Blob, client: any) => Promise<any>),
10
- responseHook?: ((response: any) => any),
11
- apiKey: string,
12
- imageMatchingUrl?: string,
13
- imageMatchingUrlBySku?: string,
14
- imageMatchingSubmitManualUrl?: string,
15
- regionProposalUrl?: string,
16
- responseFormat?: string,
17
- feedbackUrl?: string,
18
- exampleImages: string[],
19
- resultTemplate?: string,
20
- noImageUrl?: string,
21
- materialDesign?: MDSettings,
22
- preview: boolean,
23
- regions: boolean,
24
- jpegQuality: number,
25
- maxWidth: number,
26
- maxHeight: number,
27
- useRecommendations: boolean
28
- }
29
-
30
- export interface Crop {
31
- x: number,
32
- y: number,
33
- w: number,
34
- h: number
35
- }
36
-
37
- export interface WH {
38
- w: number,
39
- h: number
40
- }
41
-
42
- export interface Result {
43
- position: number,
44
- sku?: string,
45
- title?: string,
46
- l?: string,
47
- img?: { url?: string },
48
- // There can be also any other data
49
- [x: string]: any
50
- }