From aa5695ac45938161274afe5db4a8feebbf2b9ee8 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 2 Jul 2024 15:06:45 +1000 Subject: [PATCH] Improvements fo reactivity --- app/Livewire/Flow2/PaymentMethod.php | 34 +++++++++++++-------------- app/Livewire/Flow2/ProcessPayment.php | 6 ++++- app/Livewire/InvoicePay.php | 11 ++++++--- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/app/Livewire/Flow2/PaymentMethod.php b/app/Livewire/Flow2/PaymentMethod.php index 5af240929066..e8c812f6f976 100644 --- a/app/Livewire/Flow2/PaymentMethod.php +++ b/app/Livewire/Flow2/PaymentMethod.php @@ -25,23 +25,23 @@ class PaymentMethod extends Component public $methods = []; - public $isLoading = false; + public $isLoading = true; - // public function placeholder() - // { - // return <<<'HTML' - //
- // - // - // - // - //
- // HTML; - // } + public function placeholder() + { + return <<<'HTML' +
+ + + + +
+ HTML; + } public function mount() { - // $this->isLoading = true; + $this->invoice = $this->context['invoice']; $this->variables = $this->context['variables']; @@ -49,13 +49,13 @@ class PaymentMethod extends Component $this->methods = $this->invoice->client->service()->getPaymentMethods($this->invoice->balance); - // $this->isLoading = false; - // $this->dispatch('loadingCompleted'); - if(count($this->methods) == 1) { $this->dispatch('singlePaymentMethodFound', company_gateway_id: $this->methods[0]['company_gateway_id'], gateway_type_id: $this->methods[0]['gateway_type_id'], amount: $this->invoice->balance); } - + else { + $this->isLoading = false; + $this->dispatch('loadingCompleted'); + } } public function render() diff --git a/app/Livewire/Flow2/ProcessPayment.php b/app/Livewire/Flow2/ProcessPayment.php index fe2375464968..b9f91a5fc6ef 100644 --- a/app/Livewire/Flow2/ProcessPayment.php +++ b/app/Livewire/Flow2/ProcessPayment.php @@ -33,7 +33,10 @@ class ProcessPayment extends Component public function mount() { - + + nlog($this->isLoading); + + nlog("inside Process Payment"); MultiDB::setDb($this->context['invoice']->company->db); $invitation = InvoiceInvitation::find($this->context['invitation_id']); @@ -114,6 +117,7 @@ class ProcessPayment extends Component public function boot() { + nlog($this->isLoading); } diff --git a/app/Livewire/InvoicePay.php b/app/Livewire/InvoicePay.php index 336859bfaacc..4d0539bddc59 100644 --- a/app/Livewire/InvoicePay.php +++ b/app/Livewire/InvoicePay.php @@ -88,7 +88,10 @@ class InvoicePay extends Component #[On('payment-method-selected')] public function paymentMethodSelected($company_gateway_id, $gateway_type_id, $amount) { + nlog("payment method selected inside InvoicePay"); + $this->payment_method_accepted = true; + $this->context['company_gateway_id'] = $company_gateway_id; $this->context['gateway_type_id'] = $gateway_type_id; $this->context['amount'] = $amount; @@ -98,8 +101,7 @@ class InvoicePay extends Component $this->context['invitation_id'] = $this->invitation_id; // $this->invite = \App\Models\InvoiceInvitation::withTrashed()->find($this->invitation_id)->withoutRelations(); - $this->payment_method_accepted =true; - + $this->component(); } @@ -119,13 +121,16 @@ class InvoicePay extends Component return PaymentMethod::class; // if($this->ready) + + nlog("computed"); + return ProcessPayment::class; } #[Computed()] public function componentUniqueId(): string { - return "purchase-".md5(time()); + return "purchase-".md5(microtime()); } public function mount()