diff --git a/app/Livewire/SubscriptionPlanSwitch.php b/app/Livewire/SubscriptionPlanSwitch.php index a4518efe84..df39bade41 100644 --- a/app/Livewire/SubscriptionPlanSwitch.php +++ b/app/Livewire/SubscriptionPlanSwitch.php @@ -44,7 +44,7 @@ class SubscriptionPlanSwitch extends Component /** * @var ClientContact */ - public $contact; + public ClientContact $contact; /** * @var array @@ -66,6 +66,7 @@ class SubscriptionPlanSwitch extends Component 'invoice' => null, 'company_gateway_id' => null, 'payment_method_id' => null, + 'show_rff' => false, ]; /** @@ -75,6 +76,12 @@ class SubscriptionPlanSwitch extends Component public $company; + public ?string $first_name; + + public ?string $last_name; + + public ?string $email; + public function mount() { MultiDB::setDb($this->company->db); @@ -84,6 +91,31 @@ class SubscriptionPlanSwitch extends Component $this->methods = $this->contact->client->service()->getPaymentMethods($this->amount); $this->hash = Str::uuid()->toString(); + + $this->state['show_rff'] = auth()->guard('contact')->user()->showRff(); + + $this->first_name = $this->contact->first_name; + + $this->last_name = $this->contact->last_name; + + $this->email = $this->contact->email; + } + + public function handleRff() + { + $this->validate([ + 'first_name' => ['required'], + 'last_name' => ['required'], + 'email' => ['required', 'email'], + ]); + + $this->contact->update([ + 'first_name' => $this->first_name, + 'last_name' => $this->last_name, + 'email' => $this->email, + ]); + + $this->state['show_rff'] = false; } public function handleBeforePaymentEvents(): void 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 c1be68fc70..91520780ad 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,9 +1,47 @@
- + @if($errors->any()) +
+ @foreach($errors->all() as $error) +

{{ $error }}

+ @endforeach +
+ @endif + + @if($state['show_rff']) +
+ @if(strlen(auth()->guard('contact')->user()->first_name) === 0) +
+ + +
+ @endif - @if($amount > 0) + @if(strlen(auth()->guard('contact')->user()->last_name) === 0) +
+ + +
+ @endif + + @if(strlen(auth()->guard('contact')->user()->email) === 0) +
+ + +
+ @endif + +
+ +
+
+ @endif + + + @if($amount > 0 && $state['show_rff'] == false)
@@ -33,6 +71,9 @@ + + + @@ -62,7 +103,7 @@ @endif
- @elseif($amount <= 0) + @elseif($amount <= 0 && $state['show_rff'] == false)