From 0a9eeaed62bc00b0d217d0b817c256d94555524f Mon Sep 17 00:00:00 2001 From: Ahmad-AbuOsbeh Date: Wed, 30 Aug 2023 03:47:07 +0300 Subject: [PATCH] allow zero cost to redeem per item --- control/content/controllers/content.reward.controller.js | 6 +++--- control/content/templates/reward.html | 4 ++-- widget/controllers/widget.item.controller.js | 2 +- widget/controllers/widget.redeem.controller.js | 2 +- widget/controllers/widget.success.controller.js | 2 +- widget/templates/Item_Details.html | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/control/content/controllers/content.reward.controller.js b/control/content/controllers/content.reward.controller.js index 47b3eea..d412fa3 100644 --- a/control/content/controllers/content.reward.controller.js +++ b/control/content/controllers/content.reward.controller.js @@ -158,7 +158,7 @@ if(!ContentReward.item.title || ContentReward.item.title.length == 0) { ContentReward.validations.title = true; } - if ((!ContentReward.item.pointsToRedeem || ContentReward.item.pointsToRedeem.length == 0) && + if (((!ContentReward.item.pointsToRedeem && ContentReward.item.pointsToRedeem !== 0) || ContentReward.item.pointsToRedeem.length == 0) && (!ContentReward.item.pointsPerItem || ContentReward.item.pointsPerItem.length == 0) ){ ContentReward.validations.points = true; } @@ -166,7 +166,7 @@ // "Hack" for overcoming pointsToRedeem validation if the item can only be bought but not redeemed if(ContentReward.item.pointsPerItem && ContentReward.item.pointsPerItem.length > 0 && - (!ContentReward.item.pointsToRedeem || ContentReward.item.pointsToRedeem.length === 0 || ContentReward.item.pointsToRedeem === '38762499627')) { + ((!ContentReward.item.pointsToRedeem && ContentReward.item.pointsToRedeem !== 0) || ContentReward.item.pointsToRedeem.length === 0 || ContentReward.item.pointsToRedeem === '38762499627')) { ContentReward.item.pointsToRedeem = '38762499627' } ContentReward.addReward(JSON.parse(angular.toJson(ContentReward.item))); @@ -253,7 +253,7 @@ /*validate the required fields whether its there or not */ ContentReward.isValidReward = function (reward) { if (reward) - return (reward.title && reward.pointsToRedeem); + return (reward.title && (reward.pointsToRedeem || reward.pointsToRedeem === 0)); }; /*This method is used to get the rewards details*/ diff --git a/control/content/templates/reward.html b/control/content/templates/reward.html index c53b01c..66f9cf9 100644 --- a/control/content/templates/reward.html +++ b/control/content/templates/reward.html @@ -37,7 +37,7 @@

Item Details

If this field is blank, then “Points per Item” cannot be blank. If this field has a value greater than zero, then this item will show up as a reward to redeem on the Loyalty feature’s main screen
- +
@@ -73,7 +73,7 @@

Item Details

Save diff --git a/widget/controllers/widget.item.controller.js b/widget/controllers/widget.item.controller.js index b0190b5..7de9f17 100644 --- a/widget/controllers/widget.item.controller.js +++ b/widget/controllers/widget.item.controller.js @@ -244,7 +244,7 @@ if (item && item.description) { WidgetItem.reward.description = item.description; } - if (item && item.pointsToRedeem) { + if (item && (item.pointsToRedeem || item.pointsToRedeem === 0)) { WidgetItem.reward.pointsToRedeem = item.pointsToRedeem; } }); diff --git a/widget/controllers/widget.redeem.controller.js b/widget/controllers/widget.redeem.controller.js index a344501..5f7c9ad 100644 --- a/widget/controllers/widget.redeem.controller.js +++ b/widget/controllers/widget.redeem.controller.js @@ -99,7 +99,7 @@ if (item && item.description) { WidgetRedeem.reward.description = item.description; } - if (item && item.pointsToRedeem) { + if (item && (item.pointsToRedeem || item.pointsToRedeem === 0)) { WidgetRedeem.reward.pointsToRedeem = item.pointsToRedeem; } }); diff --git a/widget/controllers/widget.success.controller.js b/widget/controllers/widget.success.controller.js index 9327d6b..85ffc91 100644 --- a/widget/controllers/widget.success.controller.js +++ b/widget/controllers/widget.success.controller.js @@ -76,7 +76,7 @@ if (item && item.description) { WidgetSuccess.reward.description = item.description; } - if (item && item.pointsToRedeem) { + if (item && (item.pointsToRedeem || item.pointsToRedeem === 0)) { WidgetSuccess.reward.pointsToRedeem = item.pointsToRedeem; } }); diff --git a/widget/templates/Item_Details.html b/widget/templates/Item_Details.html index f20d3c3..92b2934 100644 --- a/widget/templates/Item_Details.html +++ b/widget/templates/Item_Details.html @@ -11,7 +11,7 @@

{{WidgetItem.reward.title}}

-