From 91003a89d1806535e099425f435f28baac49060a Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Fri, 6 Jan 2023 11:16:28 +0530 Subject: [PATCH 1/3] Removed: unwanted code for search page(#85zrhdn0f) --- src/store/modules/product/ProductState.ts | 4 - src/store/modules/product/actions.ts | 37 ------- src/store/modules/product/getters.ts | 11 +- src/store/modules/product/index.ts | 6 +- src/store/modules/product/mutation-types.ts | 1 - src/store/modules/product/mutations.ts | 4 - src/views/Search.vue | 106 -------------------- 7 files changed, 2 insertions(+), 167 deletions(-) delete mode 100644 src/views/Search.vue diff --git a/src/store/modules/product/ProductState.ts b/src/store/modules/product/ProductState.ts index 741a4488..740608b5 100644 --- a/src/store/modules/product/ProductState.ts +++ b/src/store/modules/product/ProductState.ts @@ -1,7 +1,3 @@ export default interface ProductState { cached: any; - products: { - list: any; - total: number; - } } \ No newline at end of file diff --git a/src/store/modules/product/actions.ts b/src/store/modules/product/actions.ts index 6a04e7f9..7e7d93c1 100644 --- a/src/store/modules/product/actions.ts +++ b/src/store/modules/product/actions.ts @@ -39,43 +39,6 @@ const actions: ActionTree = { // TODO Handle specific error return resp; }, - - // Find Product - async findProduct ({ commit, state }, payload) { - - // Show loader only when new query and not the infinite scroll - if (payload.viewIndex === 0) emitter.emit("presentLoader"); - - let resp; - - try { - resp = await ProductService.fetchProducts({ - // used sku as we are currently only using sku to search for the product - "filters": ['sku: ' + payload.queryString], - "viewSize": payload.viewSize, - "viewIndex": payload.viewIndex - }) - - // resp.data.response.numFound tells the number of items in the response - if (resp.status === 200 && resp.data.response.numFound > 0 && !hasError(resp)) { - let products = resp.data.response.docs; - const totalProductsCount = resp.data.response.numFound; - - if (payload.viewIndex && payload.viewIndex > 0) products = state.products.list.concat(products) - commit(types.PRODUCT_SEARCH_UPDATED, { products: products, totalProductsCount: totalProductsCount }) - } else { - //showing error whenever getting no products in the response or having any other error - showToast(translate("Product not found")); - } - // Remove added loader only when new query and not the infinite scroll - if (payload.viewIndex === 0) emitter.emit("dismissLoader"); - } catch(error){ - console.error(error) - showToast(translate("Something went wrong")); - } - // TODO Handle specific error - return resp; - }, } export default actions; diff --git a/src/store/modules/product/getters.ts b/src/store/modules/product/getters.ts index d0b50a36..fc9604c7 100644 --- a/src/store/modules/product/getters.ts +++ b/src/store/modules/product/getters.ts @@ -6,15 +6,6 @@ const getters: GetterTree = { getProduct: (state) => (productId: string) => { // Returning empty object so that it doesn't breaks the UI return state.cached[productId] ? state.cached[productId] : {}; - }, - getSearchProducts(state) { - return state.products.list; - }, - isScrollable(state) { - return ( - state.products.list.length > 0 && - state.products.list.length < state.products.total - ); - }, + } }; export default getters; \ No newline at end of file diff --git a/src/store/modules/product/index.ts b/src/store/modules/product/index.ts index 628ce332..4d67f460 100644 --- a/src/store/modules/product/index.ts +++ b/src/store/modules/product/index.ts @@ -8,11 +8,7 @@ import RootState from '../../RootState' const productModule: Module = { namespaced: true, state: { - cached: {}, - products: { - list: {}, - total: 0 - } + cached: {} }, getters, actions, diff --git a/src/store/modules/product/mutation-types.ts b/src/store/modules/product/mutation-types.ts index 734c80c6..efcf3edd 100644 --- a/src/store/modules/product/mutation-types.ts +++ b/src/store/modules/product/mutation-types.ts @@ -1,3 +1,2 @@ export const SN_PRODUCT = 'product' -export const PRODUCT_SEARCH_UPDATED = SN_PRODUCT + '/SEARCH_UPDATED' export const PRODUCT_ADD_TO_CACHED_MULTIPLE = SN_PRODUCT + '/ADD_TO_CACHED_MULTIPLE' diff --git a/src/store/modules/product/mutations.ts b/src/store/modules/product/mutations.ts index 9e79c6a5..e533dc7a 100644 --- a/src/store/modules/product/mutations.ts +++ b/src/store/modules/product/mutations.ts @@ -3,10 +3,6 @@ import ProductState from './ProductState' import * as types from './mutation-types' const mutations: MutationTree = { - [types.PRODUCT_SEARCH_UPDATED] (state, payload) { - state.products.list = payload.products; - state.products.total = payload.totalProductsCount; - }, [types.PRODUCT_ADD_TO_CACHED_MULTIPLE] (state, payload) { if (payload.products) { payload.products.forEach((product: any) => { diff --git a/src/views/Search.vue b/src/views/Search.vue deleted file mode 100644 index 899ec96e..00000000 --- a/src/views/Search.vue +++ /dev/null @@ -1,106 +0,0 @@ - - - \ No newline at end of file From 1d45e6f0dbf47d03e1e10b435049db52265d0810 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Fri, 6 Jan 2023 11:22:46 +0530 Subject: [PATCH 2/3] Removed: unwanted imports and product services(#85zrhdn0f) --- src/services/ProductService.ts | 15 --------------- src/store/modules/product/actions.ts | 4 ---- 2 files changed, 19 deletions(-) delete mode 100644 src/services/ProductService.ts diff --git a/src/services/ProductService.ts b/src/services/ProductService.ts deleted file mode 100644 index 48848dd3..00000000 --- a/src/services/ProductService.ts +++ /dev/null @@ -1,15 +0,0 @@ -import api from '@/api'; - -const fetchProducts = async (query: any): Promise => { - return api({ - // TODO: We can replace this with any API - url: "searchProducts", - method: "post", - data: query, - cache: true - }); -} - -export const ProductService = { - fetchProducts -} \ No newline at end of file diff --git a/src/store/modules/product/actions.ts b/src/store/modules/product/actions.ts index 7e7d93c1..74938648 100644 --- a/src/store/modules/product/actions.ts +++ b/src/store/modules/product/actions.ts @@ -1,11 +1,7 @@ -import { ProductService } from "@/services/ProductService"; import { ActionTree } from 'vuex' import RootState from '@/store/RootState' import ProductState from './ProductState' import * as types from './mutation-types' -import { hasError, showToast } from '@/utils' -import { translate } from '@/i18n' -import emitter from '@/event-bus' import { fetchProducts, isError } from "@/adapter"; const actions: ActionTree = { From 13453ab327f03adccefc9f74fa840a4f095431eb Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Fri, 6 Jan 2023 11:42:32 +0530 Subject: [PATCH 3/3] Removed: ProductListItem component and the filter to get product feature(#85zrhdn0f) --- src/components/ProductListItem.vue | 49 ------------------------------ src/main.ts | 9 ------ 2 files changed, 58 deletions(-) delete mode 100644 src/components/ProductListItem.vue diff --git a/src/components/ProductListItem.vue b/src/components/ProductListItem.vue deleted file mode 100644 index e312f8f5..00000000 --- a/src/components/ProductListItem.vue +++ /dev/null @@ -1,49 +0,0 @@ - - - \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index cc3c421c..8a70521d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -50,15 +50,6 @@ app.config.globalProperties.$filters = { const userProfile = store.getters['user/getUserProfile']; // TODO Fix this setDefault should set the default timezone instead of getting it everytiem and setting the tz return DateTime.utc(value, inFormat).setZone(userProfile.userTimeZone).toFormat(outFormat ? outFormat : 'MM-DD-YYYY') - }, - getFeature(featureHierarchy: any, featureKey: string) { - let featureValue = '' - if (featureHierarchy) { - const feature = featureHierarchy.find((featureItem: any) => featureItem.startsWith(featureKey)) - const featureSplit = feature ? feature.split('/') : []; - featureValue = featureSplit[2] ? featureSplit[2] : ''; - } - return featureValue; } }