@nyris/nyris-webapp 0.3.23 → 0.3.25

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 (117) hide show
  1. package/README.md +1 -1
  2. package/build/asset-manifest.json +12 -18
  3. package/build/index.html +1 -1
  4. package/build/{precache-manifest.550e76235499efc131a68c80392f6bfc.js → precache-manifest.3eed67031bd288eaf7ff98cd02aef6d7.js} +11 -35
  5. package/build/service-worker.js +1 -1
  6. package/build/static/css/main.0d30f026.chunk.css +2 -0
  7. package/build/static/css/main.0d30f026.chunk.css.map +1 -0
  8. package/build/static/js/2.ad8c5320.chunk.js +3 -0
  9. package/build/static/js/{2.f0507df9.chunk.js.LICENSE.txt → 2.ad8c5320.chunk.js.LICENSE.txt} +0 -15
  10. package/build/static/js/2.ad8c5320.chunk.js.map +1 -0
  11. package/build/static/js/main.7c54ad4d.chunk.js +3 -0
  12. package/build/static/js/main.7c54ad4d.chunk.js.map +1 -0
  13. package/package.json +5 -3
  14. package/src/App.tsx +24 -15
  15. package/src/Router.tsx +6 -41
  16. package/src/Store/Store.ts +14 -23
  17. package/src/Store/{Auth.ts → auth/Auth.ts} +6 -17
  18. package/src/Store/auth/types.ts +11 -0
  19. package/src/Store/constants.ts +21 -0
  20. package/src/Store/nyris/Nyris.ts +67 -0
  21. package/src/Store/nyris/types.ts +11 -0
  22. package/src/Store/{Search.ts → search/Search.ts} +3 -63
  23. package/src/Store/search/search.initialState.ts +28 -0
  24. package/src/Store/search/types.ts +34 -0
  25. package/src/components/DetailItem.tsx +29 -25
  26. package/src/components/DragDropFile.tsx +8 -3
  27. package/src/components/Feedback.tsx +11 -14
  28. package/src/components/FooterMobile.tsx +3 -51
  29. package/src/components/FooterResult.tsx +1 -1
  30. package/src/components/Header.tsx +29 -30
  31. package/src/components/HeaderMobile.tsx +14 -21
  32. package/src/components/Layout.tsx +11 -27
  33. package/src/components/PanelResult/index.tsx +1 -1
  34. package/src/components/{LoadingScreen → ProductList}/index.tsx +3 -3
  35. package/src/components/appMobile.scss +2 -21
  36. package/src/components/carousel/ImagePreviewCarousel.tsx +2 -1
  37. package/src/components/clear-refinements/clear-refinements.tsx +1 -1
  38. package/src/components/common.scss +2 -0
  39. package/src/components/drawer/cameraCustom.tsx +7 -14
  40. package/src/components/input/inputSearch.tsx +9 -8
  41. package/src/components/pre-filter/{desktop/index.tsx → index.tsx} +5 -5
  42. package/src/components/results/ItemResult.tsx +40 -34
  43. package/src/constants.ts +12 -0
  44. package/src/hooks/useVisualSearch.tsx +2 -2
  45. package/src/i18n.ts +10 -0
  46. package/src/index.css +13 -0
  47. package/src/index.tsx +0 -20
  48. package/src/{modules/LandingPage/indexNewVersion.tsx → page/landingPage/AppMD.tsx} +2 -4
  49. package/src/{modules/LandingPage → page/landingPage}/AppMobile.tsx +4 -5
  50. package/src/{modules/LandingPage → page/landingPage}/common.scss +2 -8
  51. package/src/page/result/index.tsx +8 -10
  52. package/src/services/Feedback.ts +48 -71
  53. package/src/services/{filter.tsx → filter.ts} +1 -1
  54. package/src/services/types.ts +30 -39
  55. package/src/translations.ts +22 -0
  56. package/src/types.ts +13 -66
  57. package/build/js/test.js +0 -84
  58. package/build/static/css/main.c956b74c.chunk.css +0 -2
  59. package/build/static/css/main.c956b74c.chunk.css.map +0 -1
  60. package/build/static/js/2.f0507df9.chunk.js +0 -3
  61. package/build/static/js/2.f0507df9.chunk.js.map +0 -1
  62. package/build/static/js/main.247c7b7e.chunk.js +0 -3
  63. package/build/static/js/main.247c7b7e.chunk.js.map +0 -1
  64. package/build/static/media/Rectangle.4dd8b747.png +0 -0
  65. package/build/static/media/icon_company.2b2a0a61.svg +0 -3
  66. package/build/static/media/icon_email.132d632b.svg +0 -3
  67. package/build/static/media/icon_phone.09335da9.svg +0 -3
  68. package/build/static/media/icon_textArea.f6d78b61.svg +0 -3
  69. package/build/static/media/icon_users.2013c76e.svg +0 -3
  70. package/public/js/test.js +0 -84
  71. package/src/App.css +0 -65
  72. package/src/Store/Nyris.ts +0 -77
  73. package/src/components/AppContainer.tsx +0 -126
  74. package/src/components/CategoryFilter.tsx +0 -17
  75. package/src/components/Codes.tsx +0 -20
  76. package/src/components/CustomHits/index.tsx +0 -47
  77. package/src/components/Footer.tsx +0 -96
  78. package/src/components/FooterMD.tsx +0 -54
  79. package/src/components/FooterNewVersion.tsx +0 -12
  80. package/src/components/HeaderMd.tsx +0 -38
  81. package/src/components/HeaderNewVersion.tsx +0 -112
  82. package/src/components/Navigation.tsx +0 -34
  83. package/src/components/PredictedCategories.tsx +0 -14
  84. package/src/components/Refine.tsx +0 -28
  85. package/src/components/RelevantSort.tsx +0 -12
  86. package/src/components/Result.tsx +0 -210
  87. package/src/components/Saved/AllItem.tsx +0 -32
  88. package/src/components/Saved/Category.tsx +0 -16
  89. package/src/components/auto-complete/basic.tsx +0 -153
  90. package/src/components/autocomplete/plugins/popular-searches/popular-searches.css +0 -3
  91. package/src/components/autocomplete/plugins/popular-searches/popular-searches.tsx +0 -75
  92. package/src/components/button/clear-fillter.tsx +0 -30
  93. package/src/components/camera/screenshot.tsx +0 -33
  94. package/src/components/count/count.tsx +0 -20
  95. package/src/components/hitItem/hits.tsx +0 -50
  96. package/src/components/hitItem/infinitiHits.tsx +0 -33
  97. package/src/components/icon/icon.tsx +0 -13
  98. package/src/components/icon_textArea.svg +0 -3
  99. package/src/components/refinement-list/index.tsx +0 -42
  100. package/src/components/results/pagination.tsx +0 -34
  101. package/src/components/search/ListSearch.tsx +0 -209
  102. package/src/defaults.ts +0 -37
  103. package/src/modules/LandingPage/App.tsx +0 -318
  104. package/src/modules/LandingPage/AppMD.tsx +0 -399
  105. package/src/modules/LandingPage/index.tsx +0 -186
  106. package/src/modules/LandingPage/propsType.ts +0 -43
  107. package/src/page/Auth/login.tsx +0 -7
  108. package/src/page/Exception/404.tsx +0 -11
  109. package/src/page/History/index.tsx +0 -76
  110. package/src/page/Profile/index.tsx +0 -140
  111. package/src/page/ResultMobile/index.tsx +0 -12
  112. package/src/page/Saved/MockData.ts +0 -223
  113. package/src/page/Saved/index.tsx +0 -166
  114. package/src/page/Support/MockData.ts +0 -45
  115. package/src/page/Support/index.tsx +0 -492
  116. package/src/page/result/MockData.ts +0 -50
  117. /package/build/static/js/{main.247c7b7e.chunk.js.LICENSE.txt → main.7c54ad4d.chunk.js.LICENSE.txt} +0 -0
@@ -1,112 +0,0 @@
1
- import { Box, Grid } from '@material-ui/core';
2
- import React from 'react';
3
- import { NavLink } from 'react-router-dom';
4
- import './common.scss';
5
- import { useAppDispatch, useAppSelector } from 'Store/Store';
6
- import { reset } from 'Store/Search';
7
-
8
- function HeaderNewVersion(): JSX.Element {
9
- const dispatch = useAppDispatch();
10
- const { settings } = useAppSelector(state => state);
11
-
12
- // const handleCheckMatchLink = (match: any, location: any) => {
13
- // let active = false;
14
- // if (match?.url === location.pathname) {
15
- // active = true;
16
- // }
17
-
18
- // return active;
19
- // };
20
-
21
- return (
22
- <Box className="box-content" display={'flex'}>
23
- <NavLink
24
- to="/"
25
- style={{ lineHeight: 0, paddingLeft: '10px' }}
26
- onClick={() => {
27
- dispatch(reset(''));
28
- }}
29
- >
30
- {/* <section id="branding" style={{ height: 32 }} /> */}
31
- <img
32
- src={settings.themePage.searchSuite?.appBarLogoUrl}
33
- alt={settings.themePage.searchSuite?.appBarLogoUrlAlt}
34
- style={{
35
- aspectRatio: 1,
36
- width: settings.themePage.searchSuite?.logoWidth,
37
- height: settings.themePage.searchSuite?.logoHeight,
38
- }}
39
- />
40
- </NavLink>
41
- <Grid container className="nav-menu">
42
- {/* <Grid item className="item-nav">
43
- <NavLink
44
- activeClassName="active"
45
- isActive={(match, location) =>
46
- handleCheckMatchLink(match, location)
47
- }
48
- to={"/search-history"}
49
- className="nav-link p-0 menu-children rounded-0"
50
- >
51
- <span className="d-none d-sm-block ms-4 px-2 py-1 border-bottom-1">
52
- Search history
53
- <img width={10} height={10} src={`${IconReLoad}`} alt=""/>
54
- </span>
55
- </NavLink>
56
- </Grid>
57
- <Grid item className="item-nav">
58
- <NavLink
59
- activeClassName="active"
60
- isActive={(match, location) =>
61
- handleCheckMatchLink(match, location)
62
- }
63
- to={"/saved"}
64
- className="nav-link p-0 menu-children rounded-0"
65
- >
66
- <span className="d-none d-sm-block ms-4 px-2 py-1 border-bottom-1">
67
- Saved
68
- <img width={10} height={10} src={`${IconSave}`} alt=""/>
69
- </span>
70
- </NavLink>
71
- </Grid>
72
- */}
73
-
74
- {/*hidden_as_required
75
- <Grid item className="item-nav">
76
- <NavLink
77
- activeClassName="active"
78
- isActive={(match, location) =>
79
- handleCheckMatchLink(match, location)
80
- }
81
- to={'/support'}
82
- className="nav-link p-0 menu-children rounded-0"
83
- >
84
- <span className="d-none d-sm-block ms-4 px-2 py-1 border-bottom-1">
85
- Support
86
- <img width={20} height={20} src={`${IconSupport}`} alt="" />
87
- </span>
88
- </NavLink>
89
- </Grid>
90
-
91
-
92
- <Grid item className="item-nav">
93
- <NavLink
94
- activeClassName="active"
95
- isActive={(match, location) =>
96
- handleCheckMatchLink(match, location)
97
- }
98
- to={'/account'}
99
- className="nav-link p-0 menu-children rounded-0"
100
- >
101
- <span className="d-none d-sm-block ms-4 px-2 py-1 border-bottom-1">
102
- My Account
103
- <img width={20} height={20} src={`${IconAdmin}`} alt="" />
104
- </span>
105
- </NavLink>
106
- </Grid>*/}
107
- </Grid>
108
- </Box>
109
- );
110
- }
111
-
112
- export default HeaderNewVersion;
@@ -1,34 +0,0 @@
1
- import React from "react";
2
- import { NavLink } from "react-router-dom";
3
- // import * as H from "history";
4
-
5
- function Navigation(): JSX.Element {
6
- // const handleCheckMatchLink = (match: any, location: H.Location) => {
7
- // if (match?.url === location?.pathname) {
8
- // return true;
9
- // }
10
- // return false;
11
- // };
12
-
13
- return (
14
- <ul className="d-flex align-center">
15
- <li>
16
- <NavLink
17
- activeClassName="active"
18
- // isActive={(match, location: H.Location) => {
19
- // return handleCheckMatchLink(match, location);
20
- // }}
21
- isActive={() => false}
22
- to={"/search-history"}
23
- className="nav-link p-0 menu-children rounded-0"
24
- >
25
- <span className="d-none d-sm-block ms-4 px-2 py-1 border-bottom-1">
26
- Search history
27
- </span>
28
- </NavLink>
29
- </li>
30
- </ul>
31
- );
32
- }
33
-
34
- export default Navigation;
@@ -1,14 +0,0 @@
1
- import React from 'react';
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
-
13
-
14
- export default PredictedCategories;
@@ -1,28 +0,0 @@
1
- import { useQuery } from 'hooks/useQuery';
2
- import { isEmpty } from 'lodash';
3
- import React, { memo, useEffect } from 'react';
4
- import { connectSearchBox } from 'react-instantsearch-dom';
5
- import { useAppDispatch, useAppSelector } from 'Store/Store';
6
-
7
- const RefineComponent = (props: any) => {
8
- const { refine } = props;
9
- const stateGlobal = useAppSelector(state => state);
10
- const { search } = stateGlobal;
11
- const { textSearchInputMobile } = search;
12
- const dispatch = useAppDispatch();
13
- const query = useQuery();
14
-
15
- useEffect(() => {
16
- const searchQuery = query.get('query') || '';
17
- refine(searchQuery);
18
- // not an ideal solution: fixes text search not working from landing page
19
- setTimeout(() => {
20
- refine(searchQuery);
21
- }, 100);
22
- }, [query, dispatch]);
23
-
24
- return <></>;
25
- };
26
-
27
- const Refine = connectSearchBox<any>(memo(RefineComponent));
28
- export default Refine;
@@ -1,12 +0,0 @@
1
- import React from "react";
2
- import { connectRelevantSort } from "react-instantsearch-dom";
3
-
4
- function RelevantSortComponent({ isRelevantSorted, refine }: any) {
5
- return (
6
- <button onClick={() => refine(isRelevantSorted ? 0 : undefined)}>
7
- Show {isRelevantSorted ? "all" : "relevant"} results
8
- </button>
9
- );
10
- }
11
-
12
- export const RelevantSort = connectRelevantSort(RelevantSortComponent);
@@ -1,210 +0,0 @@
1
- import React from "react";
2
- import { OfferNyrisResult as ResultData } from "@nyris/nyris-api";
3
-
4
- // TODO this needs refactoring: Make it one block with parameters for first line, second line, image url ..
5
-
6
- interface Options {
7
- result: any;
8
- noImageUrl: string;
9
- onImageClick: (e: React.MouseEvent) => void;
10
- onLinkClick: (e: React.MouseEvent) => void;
11
- }
12
-
13
- const renderPrice = (result: ResultData) =>
14
- result.p ? "" + (result.p.vi / 100).toFixed(2) + " " + result.p.c : "";
15
-
16
- const renderDefault = ({
17
- result,
18
- noImageUrl,
19
- onImageClick,
20
- onLinkClick,
21
- }: Options) => {
22
- return (
23
- <>
24
- <a
25
- href={result.l}
26
- className="imageLink"
27
- title="Click the image so see similar products"
28
- onClick={onImageClick}
29
- onAuxClick={onLinkClick}
30
- >
31
- <div className="prdctImg">
32
- <div className="imgWrap">
33
- <img
34
- src={(result.img && result.img.url + "?r=512x512") || noImageUrl}
35
- alt={result.title}
36
- />
37
- </div>
38
- </div>
39
- </a>
40
- <div className="prdctDetailsWrap">
41
- <div>
42
- <div className="prdctTitle">{result.title}</div>
43
- <div className="prdctMeta">
44
- <span className="prdctPrice">{renderPrice(result)}</span>
45
- </div>
46
- <a
47
- onClick={onLinkClick}
48
- onAuxClick={onLinkClick}
49
- className="prdctShopLink"
50
- href={result.l}
51
- target="_blank"
52
- rel="noopener noreferrer"
53
- >
54
- Buy Now
55
- </a>
56
- </div>
57
- </div>
58
- </>
59
- );
60
- };
61
-
62
- const renderSnr = ({
63
- result,
64
- noImageUrl,
65
- onImageClick,
66
- onLinkClick,
67
- }: Options) => (
68
- <>
69
- <a
70
- href={result.l}
71
- className="imageLink"
72
- onClick={onImageClick}
73
- onAuxClick={onLinkClick}
74
- >
75
- <div className="prdctImg">
76
- <div className="imgWrap">
77
- <img
78
- src={(result.img && result.img.url + "?r=512x512") || noImageUrl}
79
- alt={result.title}
80
- />
81
- </div>
82
- </div>
83
- </a>
84
- <div className="prdctDetailsWrap">
85
- <div>
86
- <div className="prdctTitle">{result.sku}</div>
87
- <div
88
- className="prdctMeta"
89
- style={{ height: "5em", whiteSpace: "normal" }}
90
- >
91
- {result.title}
92
- </div>
93
- <a
94
- style={{ backgroundImage: "none", paddingLeft: "10px" }}
95
- className="prdctShopLink"
96
- href={result.l}
97
- target="_blank"
98
- rel="noopener noreferrer"
99
- onClick={onLinkClick}
100
- onAuxClick={onLinkClick}
101
- >
102
- Info
103
- </a>
104
- </div>
105
- </div>
106
- </>
107
- );
108
-
109
- const renderSnrMultilink = (
110
- { result, noImageUrl, onImageClick }: Options,
111
- onLinkClick: (url: string) => void
112
- ) => (
113
- <>
114
- <a
115
- href={result.l}
116
- className="imageLink"
117
- onClick={onImageClick}
118
- onAuxClick={onImageClick}
119
- >
120
- <div className="prdctImg">
121
- <div className="imgWrap">
122
- <img
123
- src={(result.img && result.img.url + "?r=512x512") || noImageUrl}
124
- alt={result.title}
125
- />
126
- </div>
127
- </div>
128
- </a>
129
- <div className="prdctDetailsWrap">
130
- <div>
131
- <div className="prdctTitle">{result.sku}</div>
132
- <div
133
- className="prdctMeta"
134
- style={{ height: "5em", whiteSpace: "normal" }}
135
- >
136
- {result.title}
137
- </div>
138
- {result.l.map((l: { text: string; href: string }) => (
139
- <a
140
- style={{ backgroundImage: "none", paddingLeft: "10px" }}
141
- className="prdctShopLink"
142
- href={l.href}
143
- onClick={() => onLinkClick(l.href)}
144
- onAuxClick={() => onLinkClick(l.href)}
145
- target="_blank"
146
- key={l.href}
147
- rel="noopener noreferrer"
148
- >
149
- {l.text}
150
- </a>
151
- ))}
152
- </div>
153
- </div>
154
- </>
155
- );
156
-
157
- export interface ResultProps {
158
- result: any;
159
- style: any;
160
- template?: string;
161
- onImageClick: (pos: number, url: string) => void;
162
- onLinkClick: (pos: number, url: string) => void;
163
- noImageUrl?: string;
164
- }
165
-
166
- const Result: React.FC<ResultProps> = ({
167
- result,
168
- style,
169
- template,
170
- onImageClick,
171
- onLinkClick,
172
- noImageUrl,
173
- }) => {
174
- let options: Options = {
175
- onImageClick: (e: React.MouseEvent) => {
176
- e.preventDefault();
177
- onImageClick(result.position, result.img.url);
178
- },
179
- onLinkClick: (e: React.MouseEvent) => {
180
- e.preventDefault();
181
- onLinkClick(result.position, result.l);
182
- },
183
- noImageUrl: noImageUrl || "images/ic_cam_large_noimage.png",
184
- result,
185
- };
186
-
187
- let resultInner = null;
188
- switch (template) {
189
- case "snr":
190
- resultInner = renderSnr(options);
191
- break;
192
- case "snr-multilink":
193
- resultInner = renderSnrMultilink(options, (url) =>
194
- onLinkClick(result.position, url)
195
- );
196
- break;
197
- case "default":
198
- default:
199
- resultInner = renderDefault(options);
200
- break;
201
- }
202
-
203
- return (
204
- <div className="prdctItem" style={{ ...style }}>
205
- {resultInner}
206
- </div>
207
- );
208
- };
209
-
210
- export default Result;
@@ -1,32 +0,0 @@
1
- import { Grid } from "@material-ui/core";
2
- import ItemResult from "components/results/ItemResult";
3
- import React from "react";
4
-
5
- interface Props {
6
- dataItem: any[];
7
- isHover?: boolean
8
- }
9
-
10
- function AllItem(props: Props) {
11
- const { dataItem } = props;
12
-
13
- return (
14
- <Grid container spacing={2}>
15
- {dataItem &&
16
- dataItem.map((item: any, index: any) => {
17
- return (
18
- <Grid item sm={3} key={index}>
19
- <ItemResult
20
- dataItem={item}
21
- isHover={true}
22
- // handlerToggleModal={handlerToggleModal}
23
- // handlerToggleModalShare={() => setOpenModalShare(true)}
24
- />
25
- </Grid>
26
- );
27
- })}
28
- </Grid>
29
- );
30
- }
31
-
32
- export default AllItem;
@@ -1,16 +0,0 @@
1
- import { Grid } from "@material-ui/core";
2
- import React from "react";
3
-
4
- interface Props {
5
- nameCategory?: string;
6
- }
7
-
8
- function CategoryItemSaved(props: Props) {
9
- return (
10
- <Grid container>
11
- <Grid item xs={4}></Grid>
12
- </Grid>
13
- );
14
- }
15
-
16
- export default CategoryItemSaved;
@@ -1,153 +0,0 @@
1
- import { autocomplete } from '@algolia/autocomplete-js';
2
- import algoliasearch from 'algoliasearch/lite';
3
- import { popularSearchesPluginCreator } from 'components/autocomplete/plugins/popular-searches/popular-searches';
4
- import { debounce } from 'lodash';
5
- import React, {
6
- createElement,
7
- Fragment,
8
- useCallback,
9
- useEffect,
10
- useMemo,
11
- useRef,
12
- useState,
13
- } from 'react';
14
- import { render } from 'react-dom';
15
- import { connectSearchBox } from 'react-instantsearch-dom';
16
- import { useHistory } from 'react-router-dom';
17
- import { onResetRequestImage, updateValueTextSearchMobile } from 'Store/Search';
18
- import { useAppDispatch, useAppSelector } from 'Store/Store';
19
- import { AlgoliaSettings, AppState } from 'types';
20
- interface Props {
21
- containerRefInputMobile?: any;
22
- isiImageThumbSearchInput?: boolean;
23
- isResetImage?: boolean;
24
- imageThumbSearchInput?: any;
25
- }
26
-
27
- function AutocompleteBasicComponent(props: Props) {
28
- const {
29
- containerRefInputMobile,
30
- refine,
31
- isResetImage,
32
- imageThumbSearchInput,
33
- }: any = props;
34
- const [refBoxFilter, setRefBoxFilter] = useState<any>(null);
35
- const { settings, search } = useAppSelector<AppState>((state: any) => state);
36
- const { apiKey, appId, indexName } = settings.algolia as AlgoliaSettings;
37
- const searchClient = algoliasearch(appId, apiKey);
38
- const history = useHistory();
39
- const dispatch = useAppDispatch();
40
- const { textSearchInputMobile } = search;
41
- const panelContainerRef = useRef<HTMLDivElement>(null);
42
- const [refPanelContainer, setRefPanelContainer] = useState<any>(null);
43
-
44
- useEffect(() => {
45
- if (isResetImage) {
46
- dispatch(onResetRequestImage(''));
47
- setTimeout(() => {
48
- refine(textSearchInputMobile);
49
- }, 300);
50
- return;
51
- }
52
- }, [isResetImage, dispatch, refine, textSearchInputMobile]);
53
-
54
- useEffect(() => {
55
- if (imageThumbSearchInput !== '') {
56
- dispatch(updateValueTextSearchMobile(''));
57
- }
58
- }, [imageThumbSearchInput, dispatch]);
59
-
60
- useEffect(() => {
61
- setRefPanelContainer(panelContainerRef);
62
- }, [panelContainerRef]);
63
-
64
- useEffect(() => {
65
- setRefBoxFilter(containerRefInputMobile);
66
- }, [containerRefInputMobile]);
67
-
68
- const plugins = useMemo(
69
- () => [
70
- popularSearchesPluginCreator({
71
- searchClient,
72
- onSelect({ item }: any) {
73
- dispatch(updateValueTextSearchMobile(item?.keyword));
74
- refine(`${item?.keyword}`);
75
- if (history.location.pathname !== '/result') {
76
- history.push('/result');
77
- }
78
- },
79
- indexName,
80
- handerCloseModal() {
81
- setRefPanelContainer(<div></div>);
82
- },
83
- }),
84
- ],
85
- // eslint-disable-next-line react-hooks/exhaustive-deps
86
- [searchClient],
87
- );
88
-
89
- useEffect(() => {
90
- if (!refBoxFilter?.current || !refPanelContainer.current) {
91
- return;
92
- }
93
- const autocompleteInstance = autocomplete({
94
- container: refBoxFilter.current,
95
- panelContainer: refPanelContainer.current,
96
- panelPlacement: 'full-width',
97
- renderer: { createElement, Fragment, render: () => {} },
98
- initialState: {
99
- query: textSearchInputMobile,
100
- },
101
- translations: {
102
- detachedCancelButtonText: `‹`,
103
- submitButtonTitle: 's',
104
- },
105
- placeholder: textSearchInputMobile ? textSearchInputMobile : 'Search',
106
- plugins,
107
- openOnFocus: true,
108
- onSubmit,
109
- render({ sections, components }, root) {
110
- render(
111
- <Fragment>
112
- <div className="aa-PanelLayout aa-Panel--scollable ">
113
- {sections}
114
- </div>
115
- </Fragment>,
116
- root,
117
- );
118
- },
119
-
120
- ...props,
121
- });
122
- return () => {
123
- // Waiting for an 'unsubscribe' method on Autocomplete plugin API
124
- plugins.forEach((plugin: any) => {
125
- if (typeof plugin.unsubscribe === 'function') {
126
- plugin.unsubscribe();
127
- }
128
- });
129
-
130
- autocompleteInstance?.destroy();
131
- };
132
- // eslint-disable-next-line react-hooks/exhaustive-deps
133
- }, [plugins, refBoxFilter, refPanelContainer, textSearchInputMobile]);
134
-
135
- const onSubmit = ({ state }: any) => {
136
- debounceSearch(state?.query);
137
- dispatch(updateValueTextSearchMobile(state?.query));
138
- if (history.location.pathname !== '/result') {
139
- history.push('/result');
140
- }
141
- };
142
- const debounceSearch = useCallback(
143
- debounce((nextValue: any) => refine(nextValue), 200),
144
- [],
145
- );
146
-
147
- return <div className="panel-container-custom" ref={panelContainerRef} />;
148
- }
149
-
150
- const AutocompleteBasicMobileComponent = connectSearchBox<any>(
151
- AutocompleteBasicComponent,
152
- );
153
- export default AutocompleteBasicMobileComponent;
@@ -1,3 +0,0 @@
1
- .aa-ItemContentTitle {
2
- @apply overflow-visible;
3
- }
@@ -1,75 +0,0 @@
1
- import React from 'react';
2
- import type { OnSelectParams } from '@algolia/autocomplete-core';
3
- import { createQuerySuggestionsPlugin } from '@algolia/autocomplete-plugin-query-suggestions';
4
- import type { AutocompleteQuerySuggestionsHit } from '@algolia/autocomplete-plugin-query-suggestions/dist/esm/types';
5
- import type { SearchClient } from 'algoliasearch/lite';
6
-
7
- type PopularSearchesPluginCreatorParams = {
8
- searchClient: SearchClient;
9
- onSelect?: (params: OnSelectParams<AutocompleteQuerySuggestionsHit>) => void;
10
- indexName?: any;
11
- handerCloseModal?: any;
12
- };
13
-
14
- export function popularSearchesPluginCreator({
15
- searchClient,
16
- onSelect: customOnSelect,
17
- indexName,
18
- handerCloseModal,
19
- }: PopularSearchesPluginCreatorParams) {
20
- return createQuerySuggestionsPlugin({
21
- searchClient,
22
- indexName: indexName,
23
- categoryAttribute: ['brand', 'keyword_0', 'custom_category'],
24
- getSearchParams({ state }) {
25
- return { hitsPerPage: 5 };
26
- },
27
- transformSource({ source, onTapAhead }) {
28
- return {
29
- ...source,
30
- onSelect(params) {
31
- if (typeof customOnSelect === 'function') {
32
- customOnSelect(params);
33
- }
34
- },
35
- templates: {
36
- /* header() {
37
- return (
38
- <div>
39
- <span className="aa-SourceHeaderTitle">Suggested searches</span>
40
- </div>
41
- );
42
- },*/
43
- item({ item }: any) {
44
- return (
45
- <div className="aa-ItemWrapper d-flex">
46
- {/*<div className="aa-ItemContent">
47
- <div className="aa-ItemContentBody">
48
- <div className="aa-ItemContentTitle">
49
- <Typography>{item.keyword}</Typography>
50
- </div>
51
- </div>
52
- </div>*/}
53
- {/* <div className="aa-ItemActions">
54
- <button
55
- type="button"
56
- className="aa-ItemActionButton"
57
- title={`Fill query with "${item.title}"`}
58
- onClick={event => {
59
- event.preventDefault();
60
- event.stopPropagation();
61
- onTapAhead(item);
62
- }}
63
- ></button>
64
- </div>*/}
65
- </div>
66
- );
67
- },
68
- noResults() {
69
- return 'No products for this query.';
70
- },
71
- },
72
- };
73
- },
74
- });
75
- }