@managesome/eposmatic-toolkit 0.2.320 → 0.2.321
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -214,6 +214,34 @@ function buildOfferCashbackUpdate({ offer, orderDiscountDetails, categories, })
|
|
|
214
214
|
// === (for GIFT_CARDS and VOUCHER reward types — post-order) === //
|
|
215
215
|
// ================================><================================= //
|
|
216
216
|
function buildOfferRewardUpdate({ offer, orderDiscountDetails, }) {
|
|
217
|
+
const isGiftCardReward = offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.GIFT_CARDS;
|
|
218
|
+
const isVoucherReward = offer.reward_type === constants_1.OFFER_REWARD_TYPE_ENUM.VOUCHER;
|
|
219
|
+
// This helper is intentionally for deferred rewards only.
|
|
220
|
+
// It records redeemed-offer intent while leaving active discount/wallet state unchanged.
|
|
221
|
+
if (!isGiftCardReward && !isVoucherReward) {
|
|
222
|
+
return {
|
|
223
|
+
success: false,
|
|
224
|
+
discountDetails: null,
|
|
225
|
+
errorMessage: 'Offer reward helper supports only GIFT_CARDS and VOUCHER rewards.',
|
|
226
|
+
redeemedOfferId: null,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
if (isGiftCardReward && offer.reward_gift_cards == null) {
|
|
230
|
+
return {
|
|
231
|
+
success: false,
|
|
232
|
+
discountDetails: null,
|
|
233
|
+
errorMessage: 'Gift-card reward data is not available right now.',
|
|
234
|
+
redeemedOfferId: null,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
if (isVoucherReward && offer.reward_voucher == null) {
|
|
238
|
+
return {
|
|
239
|
+
success: false,
|
|
240
|
+
discountDetails: null,
|
|
241
|
+
errorMessage: 'Voucher reward data is not available right now.',
|
|
242
|
+
redeemedOfferId: null,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
217
245
|
const discountDetails = orderDiscountDetails ?? null;
|
|
218
246
|
return {
|
|
219
247
|
success: true,
|