Skip to content

Commit

Permalink
Merge pull request #140 from ymaheshwari1/#85zrhdn0f
Browse files Browse the repository at this point in the history
Removed: unwanted code related to search page(#85zrhdn0f)
  • Loading branch information
adityasharma7 authored Jan 6, 2023
2 parents 5148ad9 + 13453ab commit 5f07a0d
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 244 deletions.
49 changes: 0 additions & 49 deletions src/components/ProductListItem.vue

This file was deleted.

9 changes: 0 additions & 9 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
15 changes: 0 additions & 15 deletions src/services/ProductService.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/store/modules/product/ProductState.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export default interface ProductState {
cached: any;
products: {
list: any;
total: number;
}
}
41 changes: 0 additions & 41 deletions src/store/modules/product/actions.ts
Original file line number Diff line number Diff line change
@@ -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<ProductState, RootState> = {
Expand Down Expand Up @@ -39,43 +35,6 @@ const actions: ActionTree<ProductState, RootState> = {
// 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;
11 changes: 1 addition & 10 deletions src/store/modules/product/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ const getters: GetterTree<ProductState, RootState> = {
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;
6 changes: 1 addition & 5 deletions src/store/modules/product/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ import RootState from '../../RootState'
const productModule: Module<ProductState, RootState> = {
namespaced: true,
state: {
cached: {},
products: {
list: {},
total: 0
}
cached: {}
},
getters,
actions,
Expand Down
1 change: 0 additions & 1 deletion src/store/modules/product/mutation-types.ts
Original file line number Diff line number Diff line change
@@ -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'
4 changes: 0 additions & 4 deletions src/store/modules/product/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import ProductState from './ProductState'
import * as types from './mutation-types'

const mutations: MutationTree <ProductState> = {
[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) => {
Expand Down
106 changes: 0 additions & 106 deletions src/views/Search.vue

This file was deleted.

0 comments on commit 5f07a0d

Please sign in to comment.