Clean up test again, it seems to work

This commit is contained in:
austinkelsay 2024-11-26 15:44:12 -06:00
parent 9e8e355ae8
commit 93d0dc9b31
No known key found for this signature in database
GPG Key ID: 44CB4EC6D9F2FA02

View File

@ -104,6 +104,16 @@ const CoursePaymentButton = ({ lnAddress, amount, onSuccess, onError, courseId }
setDialogVisible(false);
};
const handleDiscountCode = (value) => {
setDiscountCode(value);
if (value.toLowerCase() === DISCOUNT_CODE.toLowerCase()) {
setDiscountApplied(true);
showToast('success', 'Discount Applied', `${calculateDiscount(amount).savedPercentage}% discount applied!`);
} else if (value && value.toLowerCase() !== DISCOUNT_CODE.toLowerCase()) {
setDiscountApplied(false);
}
};
return (
<div className="flex flex-col gap-2">
{!showDiscountInput ? (
@ -120,10 +130,7 @@ const CoursePaymentButton = ({ lnAddress, amount, onSuccess, onError, courseId }
<div className="relative flex-1">
<InputText
value={discountCode}
onChange={(e) => {
setDiscountCode(e.target.value);
setDiscountApplied(e.target.value === DISCOUNT_CODE);
}}
onChange={(e) => handleDiscountCode(e.target.value)}
placeholder="Enter discount code"
className="text-sm w-full p-2"
/>