mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-06-23 16:05:24 +00:00
fix onchange for course discount code
This commit is contained in:
parent
8e68214972
commit
77337b8019
@ -37,7 +37,7 @@ const CoursePaymentButton = ({ lnAddress, amount, onSuccess, onError, courseId }
|
|||||||
if (invoice) {
|
if (invoice) {
|
||||||
intervalId = setInterval(async () => {
|
intervalId = setInterval(async () => {
|
||||||
const paid = await invoice.verifyPayment();
|
const paid = await invoice.verifyPayment();
|
||||||
|
|
||||||
if (paid && invoice.preimage) {
|
if (paid && invoice.preimage) {
|
||||||
clearInterval(intervalId);
|
clearInterval(intervalId);
|
||||||
// handle success
|
// handle success
|
||||||
@ -47,7 +47,7 @@ const CoursePaymentButton = ({ lnAddress, amount, onSuccess, onError, courseId }
|
|||||||
} else {
|
} else {
|
||||||
console.error('no invoice');
|
console.error('no invoice');
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
if (intervalId) {
|
if (intervalId) {
|
||||||
clearInterval(intervalId);
|
clearInterval(intervalId);
|
||||||
@ -117,7 +117,7 @@ const CoursePaymentButton = ({ lnAddress, amount, onSuccess, onError, courseId }
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
{!showDiscountInput ? (
|
{!showDiscountInput ? (
|
||||||
<button
|
<button
|
||||||
onClick={() => setShowDiscountInput(true)}
|
onClick={() => setShowDiscountInput(true)}
|
||||||
className="text-sm text-blue-500 hover:text-blue-700 underline self-start flex items-center gap-1"
|
className="text-sm text-blue-500 hover:text-blue-700 underline self-start flex items-center gap-1"
|
||||||
>
|
>
|
||||||
@ -128,13 +128,16 @@ const CoursePaymentButton = ({ lnAddress, amount, onSuccess, onError, courseId }
|
|||||||
<div className="flex flex-col gap-2 w-full">
|
<div className="flex flex-col gap-2 w-full">
|
||||||
<div className="flex gap-2 items-center">
|
<div className="flex gap-2 items-center">
|
||||||
<div className="relative flex-1">
|
<div className="relative flex-1">
|
||||||
<InputText
|
<InputText
|
||||||
value={discountCode}
|
value={discountCode}
|
||||||
onChange={(e) => handleDiscountCode(e.target.value)}
|
onChange={(e) => {
|
||||||
|
setDiscountCode(e.target.value);
|
||||||
|
setDiscountApplied(e.target.value === DISCOUNT_CODE);
|
||||||
|
}}
|
||||||
placeholder="Enter discount code"
|
placeholder="Enter discount code"
|
||||||
className="text-sm w-full p-2"
|
className="text-sm w-full p-2"
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setShowDiscountInput(false);
|
setShowDiscountInput(false);
|
||||||
setDiscountCode('');
|
setDiscountCode('');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user