@@ -120,8 +120,8 @@ import {
120
120
SfOverlay ,
121
121
SfBadge ,
122
122
SfHeader
123
- } from " @storefront-ui/vue" ;
124
- import { useUiState } from " ~/composables" ;
123
+ } from ' @storefront-ui/vue' ;
124
+ import { useUiState } from ' ~/composables' ;
125
125
import {
126
126
useCart ,
127
127
useWishlist ,
@@ -130,16 +130,16 @@ import {
130
130
categoryGetters ,
131
131
useCategory ,
132
132
useFacet
133
- } from " @vue-storefront/odoo" ;
134
- import { clickOutside } from " @storefront-ui/vue/src/utilities/directives/click-outside/click-outside-directive.js" ;
135
- import { computed , ref , watch } from " @nuxtjs/composition-api" ;
136
- import { onSSR } from " @vue-storefront/core" ;
137
- import { useUiHelpers } from " ~/composables" ;
138
- import LocaleSelector from " ./LocaleSelector" ;
139
- import SearchResults from " ~/components/SearchResults" ;
133
+ } from ' @vue-storefront/odoo' ;
134
+ import { clickOutside } from ' @storefront-ui/vue/src/utilities/directives/click-outside/click-outside-directive.js' ;
135
+ import { computed , ref , watch } from ' @nuxtjs/composition-api' ;
136
+ import { onSSR } from ' @vue-storefront/core' ;
137
+ import { useUiHelpers } from ' ~/composables' ;
138
+ import LocaleSelector from ' ./LocaleSelector' ;
139
+ import SearchResults from ' ~/components/SearchResults' ;
140
140
141
- import debounce from " lodash.debounce" ;
142
- import { mapMobileObserver } from " @storefront-ui/vue/src/utilities/mobile-observer.js" ;
141
+ import debounce from ' lodash.debounce' ;
142
+ import { mapMobileObserver } from ' @storefront-ui/vue/src/utilities/mobile-observer.js' ;
143
143
export default {
144
144
components: {
145
145
SfHeader,
@@ -160,20 +160,15 @@ export default {
160
160
const isSearchOpen = ref (false );
161
161
162
162
const { changeSearchTerm } = useUiHelpers ();
163
- const {
164
- toggleCartSidebar ,
165
- toggleWishlistSidebar ,
166
- toggleLoginModal
167
- } = useUiState ();
163
+ const { toggleCartSidebar , toggleWishlistSidebar , toggleLoginModal } =
164
+ useUiState ();
168
165
169
166
const { load: loadUser , isAuthenticated } = useUser ();
170
167
const { load: loadCart , cart } = useCart ();
171
168
const { load: loadWishlist , wishlist } = useWishlist ();
172
- const { search: searchProductApi , result } = useFacet (" AppHeader:Search" );
173
- const {
174
- categories: topCategories ,
175
- search: searchTopCategoryApi
176
- } = useCategory (" AppHeader:TopCategories" );
169
+ const { search: searchProductApi , result } = useFacet (' AppHeader:Search' );
170
+ const { categories: topCategories , search: searchTopCategoryApi } =
171
+ useCategory (' AppHeader:TopCategories' );
177
172
178
173
const isMobile = computed (() => mapMobileObserver ().isMobile .get ());
179
174
@@ -182,7 +177,7 @@ export default {
182
177
return count ? count .toString () : null ;
183
178
});
184
179
const accountIcon = computed (() =>
185
- isAuthenticated .value ? " profile_fill" : " profile"
180
+ isAuthenticated .value ? ' profile_fill' : ' profile'
186
181
);
187
182
188
183
const removeSearchResults = () => {
@@ -191,46 +186,50 @@ export default {
191
186
192
187
const closeSearch = () => {
193
188
if (! isSearchOpen .value ) return ;
194
- term .value = " " ;
189
+ term .value = ' ' ;
195
190
isSearchOpen .value = false ;
196
191
};
197
192
198
- const handleSearch = debounce (async paramValue => {
193
+ const handleSearch = debounce (async ( paramValue ) => {
199
194
if (! paramValue .target ) {
200
195
term .value = paramValue;
201
196
} else {
202
197
term .value = paramValue .target .value ;
203
198
}
204
199
if (term .value .length < 2 ) return ;
205
200
206
- await searchProductApi ({ search: term .value , pageSize: 12 });
201
+ await searchProductApi ({
202
+ search: term .value ,
203
+ pageSize: 12 ,
204
+ fetchCategory: true
205
+ });
207
206
208
207
formatedResult .value = {
209
208
products: result? .value ? .data ? .products ,
210
209
categories: result? .value ? .data ? .categories
211
- .filter (category => category .childs === null )
212
- .map (category => categoryGetters .getTree (category))
210
+ .filter (( category ) => category .childs === null )
211
+ .map (( category ) => categoryGetters .getTree (category))
213
212
};
214
213
}, 100 );
215
214
const closeOrFocusSearchBar = () => {
216
215
if (isMobile .value ) {
217
216
return closeSearch ();
218
217
}
219
- term .value = " " ;
218
+ term .value = ' ' ;
220
219
return searchBarRef .value .$el .children [0 ].focus ();
221
220
};
222
221
// TODO: https://github.com/DivanteLtd/vue-storefront/issues/4927
223
222
const handleAccountClick = async () => {
224
223
if (isAuthenticated .value ) {
225
- return root .$router .push (" /my-account" );
224
+ return root .$router .push (' /my-account' );
226
225
}
227
226
228
227
toggleLoginModal ();
229
228
};
230
229
231
230
const filteredTopCategories = computed (() =>
232
231
topCategories .value .filter (
233
- cat => cat .name === " WOMEN" || cat .name === " MEN"
232
+ ( cat ) => cat .name === ' WOMEN' || cat .name === ' MEN'
234
233
)
235
234
);
236
235
0 commit comments