diff --git a/app/Http/Livewire/SubscriptionPlanSwitch.php b/app/Http/Livewire/SubscriptionPlanSwitch.php index c1ea73efebfa..aac881662462 100644 --- a/app/Http/Livewire/SubscriptionPlanSwitch.php +++ b/app/Http/Livewire/SubscriptionPlanSwitch.php @@ -56,6 +56,7 @@ class SubscriptionPlanSwitch extends Component */ public $total; + public $hide_button = false; /** * @var array */ @@ -139,12 +140,20 @@ class SubscriptionPlanSwitch extends Component public function handlePaymentNotRequired() { - return $this->target->service()->createChangePlanCredit([ + $this->hide_button = true; + + $response = $this->target->service()->createChangePlanCredit([ 'recurring_invoice' => $this->recurring_invoice, 'subscription' => $this->subscription, 'target' => $this->target, 'hash' => $this->hash, ]); + + $this->hide_button = true; + + $this->dispatchBrowserEvent('redirectRoute', ['route' => $response]); + + // return redirect($response); } public function render() diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index 7f74fcb9be46..a79ccd9ab081 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -477,10 +477,14 @@ class SubscriptionService nlog($response); - if($credit) - return $this->handleRedirect('/client/credits/'.$credit->hashed_id); - else - return $this->handleRedirect('/client/credits'); + if($credit){ + // return $this->handleRedirect('/client/credits/'.$credit->hashed_id); + return '/client/credits/'.$credit->hashed_id; + } + else{ + // return $this->handleRedirect('/client/credits'); + return '/client/credits'; + } } diff --git a/resources/views/portal/ninja2020/components/livewire/subscription-plan-switch.blade.php b/resources/views/portal/ninja2020/components/livewire/subscription-plan-switch.blade.php index 7d53d6c5caf5..8d3c0301d58b 100644 --- a/resources/views/portal/ninja2020/components/livewire/subscription-plan-switch.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/subscription-plan-switch.blade.php @@ -1,3 +1,4 @@ +
@@ -62,6 +63,7 @@
@elseif($amount <= 0) +

{{ ctrans('texts.total') }}: {{ \App\Utils\Number::formatMoney($amount, $subscription->company) }} @@ -69,12 +71,20 @@

- -
@endif
+ + + \ No newline at end of file