feat: update payment status handling in profile view

Removed the 'paid' state and replaced its usage with 'currentYearIsPaid' state in profile view. This change improves the accuracy of payment status tracking. Also, added a line to refresh the 'currentPleb' object after creating a PaymentEvent and set 'qrCode' to null when the current year is paid.
This commit is contained in:
fsociety
2024-09-30 15:32:43 +02:00
parent 65fb920150
commit c47fc8792e

View File

@@ -29,7 +29,6 @@ state(['events' => []]);
state(['payments' => []]);
state(['invoice' => null]);
state(['qrCode' => null]);
state(['paid' => false]);
state(['amountToPay' => 1]);
state(['currentYearIsPaid' => false]);
state(['currentPubkey' => null]);
@@ -63,6 +62,7 @@ on([
}
if ($this->currentPleb->paymentEvents->count() < 1) {
$this->createPaymentEvent();
$this->currentPleb->refresh();
}
$this->loadEvents();
$this->searchPaymentEvent();
@@ -70,7 +70,7 @@ on([
]);
$listenForPayment = function () {
if (!$this->paid) {
if (!$this->currentYearIsPaid) {
$this->searchPaymentEvent();
}
};
@@ -127,10 +127,9 @@ $searchPaymentEvent = function () {
);
if ($this->currentYearIsPaid) {
$this->qrCode = null;
$this->currentPleb->paymentEvents->first()->update(['paid' => true]);
}
$this->paid = true;
}
};