Improvements fo reactivity

This commit is contained in:
David Bomba 2024-07-02 15:06:45 +10:00
parent 6f5a08f87d
commit aa5695ac45
3 changed files with 30 additions and 21 deletions

View File

@ -25,23 +25,23 @@ class PaymentMethod extends Component
public $methods = [];
public $isLoading = false;
public $isLoading = true;
// public function placeholder()
// {
// return <<<'HTML'
// <div class="flex items-center justify-center min-h-screen">
// <svg class="animate-spin h-10 w-10 text-gray-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
// <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
// <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
// </svg>
// </div>
// HTML;
// }
public function placeholder()
{
return <<<'HTML'
<div class="flex items-center justify-center min-h-screen">
<svg class="animate-spin h-10 w-10 text-gray-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
</div>
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()

View File

@ -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);
}

View File

@ -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()