${function(){
const { prerequisite_type, prerequisite_value, discount_type, obtain_product } = data[0].campaign?.reward.discount_code_activity || data[0].benefit?.reward.discount_code_activity || {};
if (discount_type === 'buy_x_get_y') {
let x_content = '';
let y_content = '';
const x = prerequisite_value;
const {obtain_value, obtain_type} = obtain_product;
if (prerequisite_type === 'quantity') {
x_content = `Purchase the following items for a total of ${x} items`;
} else if (prerequisite_type === 'subtotal') {
x_content = `Purchase the following items for a total of
`;
}
if (obtain_type === 'free') {
y_content = `Get for free`;
} else if (obtain_type === 'percentage') {
y_content = `${obtain_value}% OFF on the purchase of the following items`;
} else if (obtain_type === 'fixed_amount') {
y_content = `The following items are discounted by
each`;
}
return `
`;
}
if (prerequisite_type === 'none') {
return `No threshold`;
}
if (prerequisite_type === 'quantity') {
return `The order is available when it contains at least ${parseInt(prerequisite_value)} items`;
}
if (prerequisite_type === 'subtotal') {
return `Available when the order amount exceeds
`;
}
}()}