@@ -253,7 +253,11 @@ export default defineComponent({
selectedVariants: {} as any,
cusotmerLoyaltyOptions : JSON.parse(process.env?.VUE_APP_CUST_LOYALTY_OPTIONS),
cusotmerLoyalty: '',
- hasPromisedDate: true
+ hasPromisedDate: true,
+ filters:{
+ color: [] as any,
+ size: [] as any
+ } as any
}
},
computed: {
@@ -264,10 +268,36 @@ export default defineComponent({
isJobPending: 'job/isJobPending',
jobTotal: 'job/getTotal',
userProfile: 'user/getUserProfile',
- selectedBrand: 'user/getSelectedBrand'
- })
+ selectedBrand: 'user/getSelectedBrand',
+ }),
+ filteredProducts () {
+ const filteredProducts = JSON.parse(JSON.stringify(this.current));
+ if(this.filters.size.length || this.filters.color.length){
+ filteredProducts.list.items = this.current.list.items.map((item: any)=>{
+ const product = this.getProduct(item.groupValue);
+ const hasSize = this.filters.size.some((sizeFeature: any) => {
+ return product.productFeatures.includes("Size/" + sizeFeature)
+ })
+ const hasColor = this.filters.color.some((colorFeature: any) => {
+ return product.productFeatures.includes("Color/" + colorFeature)
+ })
+ if (hasSize || hasColor) return item;
+ else return null
+ }).filter((product: any) => product);
+ }
+ return filteredProducts;
+ }
},
methods: {
+ filter (featureValue: any, type: any) {
+ if (this.filters[type].includes(featureValue)) {
+ const index = this.filters[type].indexOf(featureValue);
+ this.filters[type].splice(index,1);
+ }
+ else {
+ this.filters[type].push(featureValue);
+ }
+ },
async getVariantProducts() {
const payload = {
groupByField: 'productId',