@nyris/nyris-webapp 0.3.5 → 0.3.12
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.
- package/build/asset-manifest.json +18 -32
- package/build/index.html +1 -1
- package/build/{precache-manifest.bbb31f2ce7710d7eb3175b1b48241d24.js → precache-manifest.1b00dd5c15aa0815244681503d6fa9da.js} +13 -89
- package/build/service-worker.js +1 -1
- package/build/static/css/2.43a1c8b7.chunk.css +2 -0
- package/build/static/css/2.43a1c8b7.chunk.css.map +1 -0
- package/build/static/css/main.0c9239ba.chunk.css +2 -0
- package/build/static/css/main.0c9239ba.chunk.css.map +1 -0
- package/build/static/js/2.520bb6d6.chunk.js +3 -0
- package/build/static/js/2.520bb6d6.chunk.js.LICENSE.txt +79 -0
- package/build/static/js/2.520bb6d6.chunk.js.map +1 -0
- package/build/static/js/main.ef6a9744.chunk.js +2 -0
- package/build/static/js/main.ef6a9744.chunk.js.map +1 -0
- package/build/static/js/{runtime-main.b418ff16.js → runtime-main.f5553a9b.js} +1 -1
- package/build/static/js/{runtime-main.b418ff16.js.map → runtime-main.f5553a9b.js.map} +1 -1
- package/package.json +7 -30
- package/src/App.css +64 -20
- package/src/App.test.tsx +49 -0
- package/src/App.tsx +386 -15
- package/src/AppMD.tsx +320 -0
- package/src/actions/nyrisAppActions.ts +80 -0
- package/src/actions/searchActions.ts +323 -0
- package/src/components/CategoryFilter.tsx +16 -13
- package/src/components/Codes.tsx +20 -16
- package/src/components/ExampleImages.tsx +10 -15
- package/src/components/Feedback.tsx +12 -21
- package/src/components/FiltersList.tsx +122 -0
- package/src/components/Header.tsx +26 -29
- package/src/components/PredictedCategories.tsx +15 -12
- package/src/components/SelectedFiltersSummary.tsx +85 -0
- package/src/components/Sidebar.tsx +52 -0
- package/src/defaults.ts +3 -4
- package/src/epics/feedback.ts +59 -0
- package/src/epics/index.ts +223 -0
- package/src/epics/search.ts +239 -0
- package/src/epics/types.ts +12 -0
- package/src/{common/assets/fonts → fonts}/roboto-bold-webfont.woff +0 -0
- package/src/{common/assets/fonts → fonts}/roboto-bold-webfont.woff2 +0 -0
- package/src/{common/assets/fonts → fonts}/roboto-italic-webfont.woff +0 -0
- package/src/{common/assets/fonts → fonts}/roboto-italic-webfont.woff2 +0 -0
- package/src/{common/assets/fonts → fonts}/roboto-regular-webfont.woff +0 -0
- package/src/{common/assets/fonts → fonts}/roboto-regular-webfont.woff2 +0 -0
- package/src/{common/assets/fonts → fonts}/robotocondensed-bold-webfont.woff +0 -0
- package/src/{common/assets/fonts → fonts}/robotocondensed-bold-webfont.woff2 +0 -0
- package/src/{common/assets/fonts → fonts}/robotocondensed-bolditalic-webfont.woff +0 -0
- package/src/{common/assets/fonts → fonts}/robotocondensed-bolditalic-webfont.woff2 +0 -0
- package/src/{common/assets/images → images}/fav/android-icon-192x192.png +0 -0
- package/src/{common/assets/images → images}/fav/apple-icon-114x114.png +0 -0
- package/src/{common/assets/images → images}/fav/apple-icon-120x120.png +0 -0
- package/src/{common/assets/images → images}/fav/apple-icon-144x144.png +0 -0
- package/src/{common/assets/images → images}/fav/apple-icon-152x152.png +0 -0
- package/src/{common/assets/images → images}/fav/apple-icon-180x180.png +0 -0
- package/src/{common/assets/images → images}/fav/apple-icon-57x57.png +0 -0
- package/src/{common/assets/images → images}/fav/apple-icon-60x60.png +0 -0
- package/src/{common/assets/images → images}/fav/apple-icon-72x72.png +0 -0
- package/src/{common/assets/images → images}/fav/apple-icon-76x76.png +0 -0
- package/src/{common/assets/images → images}/fav/browserconfig.xml +0 -0
- package/src/{common/assets/images → images}/fav/favicon-16x16.png +0 -0
- package/src/{common/assets/images → images}/fav/favicon-32x32.png +0 -0
- package/src/{common/assets/images → images}/fav/favicon-96x96.png +0 -0
- package/src/{common/assets/images → images}/fav/manifest.json +0 -0
- package/src/{common/assets/images → images}/ic_cam.png +0 -0
- package/src/{common/assets/images → images}/ic_cam.svg +0 -0
- package/src/{common/assets/images → images}/ic_cam_large.png +0 -0
- package/src/{common/assets/images → images}/ic_cam_large.svg +0 -0
- package/src/{common/assets/images → images}/ic_cam_large_noimage.png +0 -0
- package/src/{common/assets/images → images}/ic_close_feedback.png +0 -0
- package/src/{common/assets/images → images}/ic_close_feedback.svg +0 -0
- package/src/{common/assets/images → images}/ic_shopNow.png +0 -0
- package/src/{common/assets/images → images}/ic_shopNow.svg +0 -0
- package/src/{common/assets/images → images}/ic_shopNowLight.png +0 -0
- package/src/{common/assets/images → images}/ic_shopNowLight.svg +0 -0
- package/src/{common/assets/images → images}/nyris_logo.png +0 -0
- package/src/{common/assets/images → images}/rewe.svg +0 -0
- package/src/{common/assets/images → images}/sectionTransBack.png +0 -0
- package/src/{common/assets/images → images}/sectionTransBack.svg +0 -0
- package/src/{common/assets/images → images}/sectionTransTop.png +0 -0
- package/src/{common/assets/images → images}/sectionTransTop.svg +0 -0
- package/src/index.css +502 -570
- package/src/index.tsx +170 -16
- package/src/types.ts +7 -51
- package/src/utils.ts +5 -0
- package/tsconfig.json +8 -3
- package/build/js/settings.example.js +0 -31
- package/build/js/test.js +0 -56
- package/build/static/css/2.8285176a.chunk.css +0 -2
- package/build/static/css/2.8285176a.chunk.css.map +0 -1
- package/build/static/css/main.6676fe1f.chunk.css +0 -2
- package/build/static/css/main.6676fe1f.chunk.css.map +0 -1
- package/build/static/js/2.4a55bc61.chunk.js +0 -3
- package/build/static/js/2.4a55bc61.chunk.js.LICENSE.txt +0 -124
- package/build/static/js/2.4a55bc61.chunk.js.map +0 -1
- package/build/static/js/main.2660f94a.chunk.js +0 -2
- package/build/static/js/main.2660f94a.chunk.js.map +0 -1
- package/build/static/media/Fill.37094b44.svg +0 -3
- package/build/static/media/Montserrat-Bold.5a052e98.otf +0 -0
- package/build/static/media/Montserrat-Light.21789e89.otf +0 -0
- package/build/static/media/Montserrat-Medium.a53e0373.otf +0 -0
- package/build/static/media/Montserrat-Regular.71cdc681.otf +0 -0
- package/build/static/media/Montserrat-SemiBold.f613d915.otf +0 -0
- package/build/static/media/Rectangle.4dd8b747.png +0 -0
- package/build/static/media/admin.9529c7f6.svg +0 -3
- package/build/static/media/bg-support-page.6ac55268.svg +0 -9
- package/build/static/media/book_mark.8e294c0b.svg +0 -3
- package/build/static/media/icon_dislike.94607ca6.svg +0 -3
- package/build/static/media/icon_like.a4fb1b18.svg +0 -3
- package/build/static/media/icon_modal_image.3068d0ea.svg +0 -21
- package/build/static/media/icon_search_image.c2c728c0.svg +0 -3
- package/build/static/media/nyris_logo.22d8f250.svg +0 -3
- package/build/static/media/reload_icon.4b579a74.svg +0 -3
- package/build/static/media/save_search.bebaeebf.svg +0 -3
- package/build/static/media/support.289c3a3c.svg +0 -3
- package/build/static/media/translate_icon.f0492297.svg +0 -3
- package/public/js/settings.example.js +0 -31
- package/public/js/test.js +0 -56
- package/src/Router.tsx +0 -97
- package/src/Store/Auth.ts +0 -44
- package/src/Store/Nyris.ts +0 -77
- package/src/Store/Search.ts +0 -243
- package/src/Store/Store.ts +0 -53
- package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Bold.otf +0 -0
- package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Light.otf +0 -0
- package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Medium.otf +0 -0
- package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Regular.otf +0 -0
- package/src/common/assets/fonts/Montserrat_OTF/Montserrat-SemiBold.otf +0 -0
- package/src/common/assets/icons/Fill.png +0 -0
- package/src/common/assets/icons/Fill.svg +0 -3
- package/src/common/assets/icons/Icon_wechat.png +0 -0
- package/src/common/assets/icons/Icon_whatsapp.png +0 -0
- package/src/common/assets/icons/admin.png +0 -0
- package/src/common/assets/icons/admin.svg +0 -3
- package/src/common/assets/icons/book_mark.png +0 -0
- package/src/common/assets/icons/book_mark.svg +0 -3
- package/src/common/assets/icons/icon_barcode.png +0 -0
- package/src/common/assets/icons/icon_camera.png +0 -0
- package/src/common/assets/icons/icon_dislike.svg +0 -3
- package/src/common/assets/icons/icon_disslike.png +0 -0
- package/src/common/assets/icons/icon_email.png +0 -0
- package/src/common/assets/icons/icon_like.png +0 -0
- package/src/common/assets/icons/icon_like.svg +0 -3
- package/src/common/assets/icons/icon_modal_image.png +0 -0
- package/src/common/assets/icons/icon_modal_image.svg +0 -21
- package/src/common/assets/icons/icon_picture.png +0 -0
- package/src/common/assets/icons/icon_search_image.png +0 -0
- package/src/common/assets/icons/icon_search_image.svg +0 -3
- package/src/common/assets/icons/nyris_logo.svg +0 -3
- package/src/common/assets/icons/reload_icon.png +0 -0
- package/src/common/assets/icons/reload_icon.svg +0 -3
- package/src/common/assets/icons/save_search.png +0 -0
- package/src/common/assets/icons/save_search.svg +0 -3
- package/src/common/assets/icons/setting_search_icon.png +0 -0
- package/src/common/assets/icons/support.png +0 -0
- package/src/common/assets/icons/support.svg +0 -3
- package/src/common/assets/icons/translate_icon.png +0 -0
- package/src/common/assets/icons/translate_icon.svg +0 -3
- package/src/common/assets/icons/view_off.png +0 -0
- package/src/common/assets/images/Rectangle.png +0 -0
- package/src/common/assets/images/bg-support-page.svg +0 -9
- package/src/common/assets/images/image_test.png +0 -0
- package/src/components/CustomHits/index.tsx +0 -57
- package/src/components/DetailItem.tsx +0 -175
- package/src/components/DragDropFile.tsx +0 -192
- package/src/components/FilterComponent.tsx +0 -33
- package/src/components/Footer.tsx +0 -29
- package/src/components/FooterMD.tsx +0 -54
- package/src/components/FooterNewVersion.tsx +0 -12
- package/src/components/FooterResult.tsx +0 -47
- package/src/components/HeaderMd.tsx +0 -38
- package/src/components/HeaderNewVersion.tsx +0 -92
- package/src/components/Layout.tsx +0 -46
- package/src/components/LoadingScreen/index.tsx +0 -29
- package/src/components/Navigation.tsx +0 -34
- package/src/components/Panigation/Pagination.tsx +0 -140
- package/src/components/Panigation/cx.js +0 -3
- package/src/components/Panigation/isModifierClick.js +0 -10
- package/src/components/Saved/AllItem.tsx +0 -32
- package/src/components/Saved/Category.tsx +0 -16
- package/src/components/carousel/DefaultCarousel.tsx +0 -48
- package/src/components/common.d.ts +0 -9
- package/src/components/common.scss +0 -54
- package/src/components/default-select.tsx +0 -44
- package/src/components/hitItem/hits.tsx +0 -50
- package/src/components/hitItem/infinitiHits.tsx +0 -33
- package/src/components/input/inputSearch.tsx +0 -77
- package/src/components/modal/DefaultModal.tsx +0 -28
- package/src/components/results/ItemResult.tsx +0 -155
- package/src/components/search/ListSearch.tsx +0 -209
- package/src/modules/LandingPage/App.tsx +0 -318
- package/src/modules/LandingPage/AppMD.tsx +0 -399
- package/src/modules/LandingPage/common.scss +0 -1304
- package/src/modules/LandingPage/index.tsx +0 -169
- package/src/modules/LandingPage/indexNewVersion.tsx +0 -110
- package/src/modules/LandingPage/propsType.ts +0 -43
- package/src/page/Auth/login.tsx +0 -7
- package/src/page/Exception/404.tsx +0 -11
- package/src/page/History/index.tsx +0 -76
- package/src/page/Profile/index.tsx +0 -87
- package/src/page/Saved/MockData.ts +0 -223
- package/src/page/Saved/index.tsx +0 -166
- package/src/page/Support/index.tsx +0 -160
- package/src/page/result/MockData.ts +0 -36
- package/src/page/result/index.tsx +0 -418
- package/src/services/Feedback.ts +0 -64
- package/src/services/image.ts +0 -40
- package/src/services/session.ts +0 -17
- package/src/services/types.ts +0 -50
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
|
|
3
|
-
const PredictedCategories = ({cs}: {cs: {name: string, score: number}[]}) =>
|
|
4
|
-
<>
|
|
5
|
-
{cs.map((c) =>
|
|
6
|
-
<small key={c.name}>
|
|
7
|
-
{c.name === "" ? "No category" : c.name.split(" > ").slice(-1)[0]}:
|
|
8
|
-
{(c.score * 100).toFixed(0)}%
|
|
9
|
-
</small>)}
|
|
10
|
-
</>
|
|
11
|
-
;
|
|
12
|
-
|
|
1
|
+
import React from "react";
|
|
13
2
|
|
|
3
|
+
const PredictedCategories = ({
|
|
4
|
+
cs,
|
|
5
|
+
}: {
|
|
6
|
+
cs: { name: string; score: number }[];
|
|
7
|
+
}) => (
|
|
8
|
+
<>
|
|
9
|
+
{cs.map((c) => (
|
|
10
|
+
<small key={c.name}>
|
|
11
|
+
{c.name === "" ? "No category" : c.name.split(" > ").slice(-1)[0]}:
|
|
12
|
+
{(c.score * 100).toFixed(0)}%
|
|
13
|
+
</small>
|
|
14
|
+
))}
|
|
15
|
+
</>
|
|
16
|
+
);
|
|
14
17
|
export default PredictedCategories;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BsX } from "react-icons/bs";
|
|
3
|
+
import { connect, ConnectedProps, useDispatch } from "react-redux";
|
|
4
|
+
import { AppState } from "../types";
|
|
5
|
+
import { capitalizeFirstLetter } from "../utils";
|
|
6
|
+
import {
|
|
7
|
+
removeFromSelectedFilters,
|
|
8
|
+
clearAllSelectedFilters,
|
|
9
|
+
filterChanged,
|
|
10
|
+
} from "../actions/searchActions";
|
|
11
|
+
|
|
12
|
+
const SelectedFiltersSummary: React.FC<selectedFiltersSummaryProps> = ({
|
|
13
|
+
search,
|
|
14
|
+
}) => {
|
|
15
|
+
const dispatch = useDispatch();
|
|
16
|
+
const handleRemoveFilterButtonClick = (key: string, value: string) => {
|
|
17
|
+
dispatch(removeFromSelectedFilters(key, value));
|
|
18
|
+
dispatch(filterChanged());
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const clearAllSelectedFiltersFromList = () => {
|
|
22
|
+
dispatch(clearAllSelectedFilters());
|
|
23
|
+
dispatch(filterChanged());
|
|
24
|
+
};
|
|
25
|
+
const selectedValues = ([] as string[]).concat.apply(
|
|
26
|
+
[],
|
|
27
|
+
Array.from(search.selectedFilters.values())
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<div className="wrap-box-refinements">
|
|
32
|
+
<ul>
|
|
33
|
+
{Array.from(search.selectedFilters.keys()).map(
|
|
34
|
+
(filterKey) =>
|
|
35
|
+
search.selectedFilters.get(filterKey) &&
|
|
36
|
+
search.selectedFilters.get(filterKey)!.map((val) => {
|
|
37
|
+
return (
|
|
38
|
+
<li>
|
|
39
|
+
<button
|
|
40
|
+
onClick={() =>
|
|
41
|
+
handleRemoveFilterButtonClick(filterKey, val)
|
|
42
|
+
}
|
|
43
|
+
>
|
|
44
|
+
<span className="summary-label">
|
|
45
|
+
<div className="summary-label-key-text">
|
|
46
|
+
{capitalizeFirstLetter(val)}
|
|
47
|
+
<BsX />
|
|
48
|
+
</div>
|
|
49
|
+
</span>
|
|
50
|
+
</button>
|
|
51
|
+
</li>
|
|
52
|
+
);
|
|
53
|
+
})
|
|
54
|
+
)}
|
|
55
|
+
<li>
|
|
56
|
+
<button
|
|
57
|
+
className={
|
|
58
|
+
search.selectedFilters &&
|
|
59
|
+
search.selectedFilters.size > 0 &&
|
|
60
|
+
selectedValues &&
|
|
61
|
+
selectedValues.length > 0
|
|
62
|
+
? "clear-all-filters "
|
|
63
|
+
: "clear-all-filters-hidden"
|
|
64
|
+
}
|
|
65
|
+
onClick={() => clearAllSelectedFiltersFromList()}
|
|
66
|
+
>
|
|
67
|
+
{" "}
|
|
68
|
+
Clear All{" "}
|
|
69
|
+
</button>
|
|
70
|
+
</li>
|
|
71
|
+
</ul>
|
|
72
|
+
</div>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const mapStateToProps = (state: AppState) => ({
|
|
77
|
+
showPart: state.nyrisDesign.showPart,
|
|
78
|
+
search: {
|
|
79
|
+
filters: state.search.filters,
|
|
80
|
+
selectedFilters: state.search.selectedFilters,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
const connector = connect(mapStateToProps);
|
|
84
|
+
type selectedFiltersSummaryProps = ConnectedProps<typeof connector>;
|
|
85
|
+
export default connect(mapStateToProps)(SelectedFiltersSummary);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { RiMenuLine } from "react-icons/ri";
|
|
3
|
+
import { Filter } from "../../../nyris-api/index";
|
|
4
|
+
import FiltersList from "./FiltersList";
|
|
5
|
+
|
|
6
|
+
interface SidebarProps {
|
|
7
|
+
filters: Filter[];
|
|
8
|
+
selectedFilters: Map<string, string[]>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const Sidebar: React.FC<SidebarProps> = ({ filters, selectedFilters }) => {
|
|
12
|
+
console.log(filters);
|
|
13
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
14
|
+
const handleToggler = () => {
|
|
15
|
+
if (isExpanded) {
|
|
16
|
+
setIsExpanded(false);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
setIsExpanded(true);
|
|
20
|
+
};
|
|
21
|
+
return (
|
|
22
|
+
<div className={isExpanded ? "sidebar" : "Sidebar collapsed"}>
|
|
23
|
+
<div
|
|
24
|
+
className={
|
|
25
|
+
isExpanded ? "sidebarContent" : "sidebarContent overflowHidden"
|
|
26
|
+
}
|
|
27
|
+
>
|
|
28
|
+
<div className="sidebarHeader">
|
|
29
|
+
<RiMenuLine className="sidebar-icon" onClick={handleToggler} />
|
|
30
|
+
{/* <h1 className={isExpanded ? "sidebar-logo" : "sidebar-logo collapsedHide"}> Filters </h1>
|
|
31
|
+
*/}
|
|
32
|
+
</div>
|
|
33
|
+
<div
|
|
34
|
+
className={
|
|
35
|
+
isExpanded ? "Sidebar-items" : "Sidebar-items collapsedHide"
|
|
36
|
+
}
|
|
37
|
+
>
|
|
38
|
+
{filters &&
|
|
39
|
+
filters.map((x) => {
|
|
40
|
+
let selectedValues = x.key
|
|
41
|
+
? selectedFilters.get(x.key)
|
|
42
|
+
: undefined;
|
|
43
|
+
return <FiltersList filter={x} selectedValues={selectedValues} />;
|
|
44
|
+
})}
|
|
45
|
+
{/* <FiltersList2/> */}
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default Sidebar;
|
package/src/defaults.ts
CHANGED
|
@@ -17,10 +17,7 @@ export const defaultSettings : AppSettings = {
|
|
|
17
17
|
'^https?://(www.)?vimeo.com/',
|
|
18
18
|
'^https?://(www.)?dailymotion.com/',
|
|
19
19
|
'^https?://(www.)?dai.ly/'
|
|
20
|
-
]
|
|
21
|
-
themePage: {
|
|
22
|
-
default: { active: true }
|
|
23
|
-
}
|
|
20
|
+
]
|
|
24
21
|
};
|
|
25
22
|
|
|
26
23
|
export const defaultMdSettings = {
|
|
@@ -30,8 +27,10 @@ export const defaultMdSettings = {
|
|
|
30
27
|
appBarTitle: '',
|
|
31
28
|
primaryColor: '#e2001a',
|
|
32
29
|
secondaryColor: '#777777',
|
|
30
|
+
|
|
33
31
|
resultFirstRowProperty: 'title',
|
|
34
32
|
resultSecondRowProperty: 'sku',
|
|
35
33
|
resultLinkText: 'Info',
|
|
34
|
+
|
|
36
35
|
customFontFamily: 'Helvetica',
|
|
37
36
|
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {combineEpics, ofType} from "redux-observable";
|
|
2
|
+
import {debounceTime, ignoreElements, tap, withLatestFrom} from "rxjs/operators";
|
|
3
|
+
import {EpicConf} from "./types";
|
|
4
|
+
|
|
5
|
+
const feedbackSuccessEpic: EpicConf = (action$, state$, {api}) => action$.pipe(
|
|
6
|
+
ofType('FEEDBACK_SUBMIT_POSITIVE', "FEEDBACK_SUBMIT_NEGATIVE"),
|
|
7
|
+
withLatestFrom(state$),
|
|
8
|
+
tap(async ([{type}, state]) => {
|
|
9
|
+
const success = type === 'FEEDBACK_SUBMIT_POSITIVE';
|
|
10
|
+
const sessionId = state.search.sessionId || state.search.requestId;
|
|
11
|
+
if (sessionId && state.search.requestId) {
|
|
12
|
+
await api.sendFeedback(sessionId, state.search.requestId, {
|
|
13
|
+
event: 'feedback', data: {success}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}),
|
|
17
|
+
ignoreElements()
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const feedbackRegionEpic: EpicConf = (action$, state$, {api}) => action$.pipe(
|
|
21
|
+
ofType('REGION_CHANGED'),
|
|
22
|
+
debounceTime(1200),
|
|
23
|
+
withLatestFrom(state$),
|
|
24
|
+
tap(async ([action, state]) => {
|
|
25
|
+
if (action.type === 'REGION_CHANGED') {
|
|
26
|
+
let {normalizedRect: {x1, x2, y1, y2}} = action;
|
|
27
|
+
const sessionId = state.search.sessionId || state.search.requestId;
|
|
28
|
+
if (sessionId && state.search.requestId) {
|
|
29
|
+
await api.sendFeedback(sessionId, state.search.requestId, {
|
|
30
|
+
event: 'region', data: {rect: {x: x1, y: y1, w: x2 - x1, h: y2 - y1}}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}),
|
|
35
|
+
ignoreElements()
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const feedbackClickEpic: EpicConf = (action$, state$, {api}) => action$.pipe(
|
|
39
|
+
ofType('RESULT_LINK_CLICKED', 'RESULT_IMAGE_CLICKED'),
|
|
40
|
+
withLatestFrom(state$),
|
|
41
|
+
tap(async ([action, state]) => {
|
|
42
|
+
if (action.type === 'RESULT_LINK_CLICKED' || action.type === 'RESULT_IMAGE_CLICKED') {
|
|
43
|
+
let {position} = action;
|
|
44
|
+
const sessionId = state.search.sessionId || state.search.requestId;
|
|
45
|
+
if (sessionId && state.search.requestId) {
|
|
46
|
+
await api.sendFeedback(sessionId, state.search.requestId, {
|
|
47
|
+
event: 'click', data: {positions: [position]}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}),
|
|
52
|
+
ignoreElements()
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
export default combineEpics(
|
|
56
|
+
feedbackSuccessEpic,
|
|
57
|
+
feedbackRegionEpic,
|
|
58
|
+
feedbackClickEpic
|
|
59
|
+
);
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { combineEpics, ofType } from "redux-observable";
|
|
2
|
+
import {
|
|
3
|
+
debounceTime,
|
|
4
|
+
delay,
|
|
5
|
+
ignoreElements,
|
|
6
|
+
map,
|
|
7
|
+
switchMap,
|
|
8
|
+
tap,
|
|
9
|
+
withLatestFrom,
|
|
10
|
+
} from "rxjs/operators";
|
|
11
|
+
import { showFeedback, showResults } from "../actions/nyrisAppActions";
|
|
12
|
+
import { EpicConf } from "./types";
|
|
13
|
+
import feedbackEpics from "./feedback";
|
|
14
|
+
import searchEpics from "./search";
|
|
15
|
+
import {
|
|
16
|
+
searchOffersForImage,
|
|
17
|
+
searchOffersForCad,
|
|
18
|
+
searchRegions,
|
|
19
|
+
} from "../actions/searchActions";
|
|
20
|
+
import { AppAction } from "../types";
|
|
21
|
+
import { selectFirstCenteredRegion } from "@nyris/nyris-api";
|
|
22
|
+
|
|
23
|
+
const historyEpic: EpicConf = (action$, state$, { history }) =>
|
|
24
|
+
action$.pipe(
|
|
25
|
+
ofType("SHOW_RESULTS", "SHOW_START"),
|
|
26
|
+
withLatestFrom(state$),
|
|
27
|
+
tap(([action, state]) => {
|
|
28
|
+
let { type } = action;
|
|
29
|
+
console.log("action");
|
|
30
|
+
console.log(state.search.selectedFilters);
|
|
31
|
+
// action to clear all filters
|
|
32
|
+
if (type === "SHOW_RESULTS" && history.location.pathname !== "/results") {
|
|
33
|
+
history.push("/results");
|
|
34
|
+
}
|
|
35
|
+
if (type === "SHOW_START" && history.location.pathname !== "/") {
|
|
36
|
+
history.goBack();
|
|
37
|
+
}
|
|
38
|
+
}),
|
|
39
|
+
ignoreElements()
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const onSearchSuccessShowResults: EpicConf = (action$) =>
|
|
43
|
+
action$.pipe(ofType("SEARCH_REQUEST_SUCCEED"), map(showResults));
|
|
44
|
+
|
|
45
|
+
const onSearchSuccessRedirectToSite: EpicConf = (action$, state$) =>
|
|
46
|
+
action$.pipe(
|
|
47
|
+
ofType("SEARCH_REQUEST_SUCCEED"),
|
|
48
|
+
withLatestFrom(state$),
|
|
49
|
+
tap(([action, { settings }]) => {
|
|
50
|
+
if (
|
|
51
|
+
action.type !== "SEARCH_REQUEST_SUCCEED" ||
|
|
52
|
+
!action.results ||
|
|
53
|
+
action.results.length !== 1
|
|
54
|
+
) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const firstLink = action.results[0].l;
|
|
59
|
+
const instantRedirectPatterns = settings.instantRedirectPatterns;
|
|
60
|
+
if (!instantRedirectPatterns.find((r) => new RegExp(r).test(firstLink))) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
window.location.href = firstLink;
|
|
64
|
+
}),
|
|
65
|
+
ignoreElements()
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const onSearchSuccessShowFeedbackDelayed: EpicConf = (action$) =>
|
|
69
|
+
action$.pipe(
|
|
70
|
+
ofType("SEARCH_REQUEST_SUCCEED"),
|
|
71
|
+
delay(3000),
|
|
72
|
+
map(showFeedback)
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const startSearchOnImageLoaded: EpicConf = (action$, state$) =>
|
|
76
|
+
action$.pipe(
|
|
77
|
+
ofType("IMAGE_LOADED"),
|
|
78
|
+
withLatestFrom(state$),
|
|
79
|
+
switchMap(async ([action, { settings }]): Promise<AppAction> => {
|
|
80
|
+
if (action.type !== "IMAGE_LOADED") {
|
|
81
|
+
throw new Error(`Wrong action type ${action.type}`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
let { image } = action;
|
|
85
|
+
|
|
86
|
+
if (settings.regions) {
|
|
87
|
+
return searchRegions(image.canvas);
|
|
88
|
+
}
|
|
89
|
+
return searchOffersForImage(image.canvas);
|
|
90
|
+
})
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const startSearchOnCadLoaded: EpicConf = (action$, state$) =>
|
|
94
|
+
action$.pipe(
|
|
95
|
+
ofType("CAD_LOADED"),
|
|
96
|
+
withLatestFrom(state$),
|
|
97
|
+
switchMap(async ([action, { settings }]): Promise<AppAction> => {
|
|
98
|
+
if (action.type !== "CAD_LOADED") {
|
|
99
|
+
throw new Error(`Wrong action type ${action.type}`);
|
|
100
|
+
}
|
|
101
|
+
let { file } = action;
|
|
102
|
+
return searchOffersForCad(file);
|
|
103
|
+
})
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
const startSearchOnRegionsSuccessful: EpicConf = (action$, state$) =>
|
|
107
|
+
action$.pipe(
|
|
108
|
+
ofType("REGION_REQUEST_SUCCEED"),
|
|
109
|
+
withLatestFrom(state$),
|
|
110
|
+
switchMap(
|
|
111
|
+
async ([
|
|
112
|
+
action,
|
|
113
|
+
{
|
|
114
|
+
search: { requestImage },
|
|
115
|
+
},
|
|
116
|
+
]): Promise<AppAction> => {
|
|
117
|
+
if (action.type !== "REGION_REQUEST_SUCCEED") {
|
|
118
|
+
throw new Error(`Wrong action type ${action.type}`);
|
|
119
|
+
}
|
|
120
|
+
if (!requestImage) {
|
|
121
|
+
throw new Error(`No requestImage`);
|
|
122
|
+
}
|
|
123
|
+
let { regions } = action;
|
|
124
|
+
|
|
125
|
+
let selection = selectFirstCenteredRegion(regions, 0.3, {
|
|
126
|
+
x1: 0,
|
|
127
|
+
x2: 1,
|
|
128
|
+
y1: 0,
|
|
129
|
+
y2: 1,
|
|
130
|
+
});
|
|
131
|
+
return searchOffersForImage(requestImage.canvas, selection);
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
const startSearchOnRegionsFailed: EpicConf = (action$, state$) =>
|
|
137
|
+
action$.pipe(
|
|
138
|
+
ofType("REGION_REQUEST_FAIL"),
|
|
139
|
+
withLatestFrom(state$),
|
|
140
|
+
switchMap(
|
|
141
|
+
async ([
|
|
142
|
+
action,
|
|
143
|
+
{
|
|
144
|
+
search: { requestImage },
|
|
145
|
+
},
|
|
146
|
+
]): Promise<AppAction> => {
|
|
147
|
+
if (action.type !== "REGION_REQUEST_FAIL") {
|
|
148
|
+
throw new Error(`Wrong action type ${action.type}`);
|
|
149
|
+
}
|
|
150
|
+
if (!requestImage) {
|
|
151
|
+
throw new Error(`No requestImage`);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return searchOffersForImage(requestImage.canvas);
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
const startSearchOnRegionChange: EpicConf = (action$, state$) =>
|
|
160
|
+
action$.pipe(
|
|
161
|
+
ofType("REGION_CHANGED"),
|
|
162
|
+
debounceTime(1200),
|
|
163
|
+
withLatestFrom(state$),
|
|
164
|
+
switchMap(
|
|
165
|
+
async ([
|
|
166
|
+
action,
|
|
167
|
+
{
|
|
168
|
+
search: { requestImage },
|
|
169
|
+
},
|
|
170
|
+
]): Promise<AppAction> => {
|
|
171
|
+
if (action.type !== "REGION_CHANGED") {
|
|
172
|
+
throw new Error(`Wrong action type ${action.type}`);
|
|
173
|
+
}
|
|
174
|
+
if (!requestImage) {
|
|
175
|
+
throw new Error(`No requestImage`);
|
|
176
|
+
}
|
|
177
|
+
let { normalizedRect } = action;
|
|
178
|
+
return searchOffersForImage(requestImage.canvas, normalizedRect);
|
|
179
|
+
}
|
|
180
|
+
)
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
const startSearchOnFilterChange: EpicConf = (action$, state$) =>
|
|
184
|
+
action$.pipe(
|
|
185
|
+
ofType("FILTER_CHANGED"),
|
|
186
|
+
withLatestFrom(state$),
|
|
187
|
+
switchMap(
|
|
188
|
+
async ([
|
|
189
|
+
action,
|
|
190
|
+
{
|
|
191
|
+
search: { requestImage },
|
|
192
|
+
},
|
|
193
|
+
]): Promise<AppAction> => {
|
|
194
|
+
if (action.type !== "FILTER_CHANGED") {
|
|
195
|
+
throw new Error(`Wrong action type ${action.type}`);
|
|
196
|
+
}
|
|
197
|
+
if (requestImage) {
|
|
198
|
+
return searchOffersForImage(requestImage.canvas);
|
|
199
|
+
} else {
|
|
200
|
+
return { type: "FILTER_CHANGED_FAIL" };
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
)
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
//const startSearchOnClearingAllFilters:
|
|
207
|
+
|
|
208
|
+
const rootEpic = combineEpics(
|
|
209
|
+
searchEpics,
|
|
210
|
+
feedbackEpics,
|
|
211
|
+
historyEpic,
|
|
212
|
+
startSearchOnImageLoaded,
|
|
213
|
+
startSearchOnCadLoaded,
|
|
214
|
+
startSearchOnRegionsSuccessful,
|
|
215
|
+
startSearchOnRegionsFailed,
|
|
216
|
+
startSearchOnRegionChange,
|
|
217
|
+
onSearchSuccessShowResults,
|
|
218
|
+
onSearchSuccessShowFeedbackDelayed,
|
|
219
|
+
onSearchSuccessRedirectToSite,
|
|
220
|
+
startSearchOnFilterChange
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
export default rootEpic;
|