Skip to content

Commit

Permalink
LYNX-759: Refactoring; bugfixing;
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4de committed Feb 13, 2025
1 parent 52775cc commit e0bb70e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion blocks/targeted-block/condition-matcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function conditionsMatched(activeRules, blockConfig) {
(segment) => segment.name,
);
const activeGroup = activeRules.customerGroup?.name;
const activeCartRules = activeRules.cart?.rules?.map(
const activeCartRules = activeRules.cart?.map(
(rule) => rule.name,
);
const activePriceRules = activeRules.catalogPriceRules?.rules?.map(
Expand Down
10 changes: 5 additions & 5 deletions blocks/targeted-block/graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const getCustomerGroups = async () => {
method: 'GET',
},
);
return response.data;
return response.data?.customerGroup;
} catch (error) {
console.error('Could not retrieve customer groups', error);
}
Expand All @@ -38,7 +38,7 @@ const getCustomerSegments = async () => {
method: 'GET',
},
);
return response.data;
return response.data?.customer?.segments || [];
} catch (error) {
console.error('Could not retrieve customer segments', error);
}
Expand All @@ -62,9 +62,9 @@ const getCartRules = async (cartId) => {
variables: { cartId },
},
);
return response.data;
return response.data?.cart?.rules || [];
} catch (error) {
console.error('Could not retrieve customer segments', error);
console.error('Could not retrieve customer cart rules', error);
}
return [];
};
Expand Down Expand Up @@ -96,7 +96,7 @@ const getCatalogPriceRules = async (sku) => {
);
return response.data?.products?.items[0];
} catch (error) {
console.error(`Could not retrieve catalog rules for ${sku}`, error);
console.error(`Could not retrieve catalog price rules for ${sku}`, error);
}
return [];
};
Expand Down
4 changes: 1 addition & 3 deletions blocks/targeted-block/targeted-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ const updateTargetedBlocksVisibility = async () => {
const activeRules = {
customerSegments: await getCustomerSegments(),
customerGroup: await getCustomerGroups(),
cart: {
rules: [],
},
cart: [],
catalogPriceRules: [],
};

Expand Down

0 comments on commit e0bb70e

Please sign in to comment.