diff --git a/app/Livewire/BillingPortal/RFF.php b/app/Livewire/BillingPortal/RFF.php index facd64b24ed7..5c63d314a943 100644 --- a/app/Livewire/BillingPortal/RFF.php +++ b/app/Livewire/BillingPortal/RFF.php @@ -12,54 +12,32 @@ namespace App\Livewire\BillingPortal; -use App\Models\ClientContact; +use App\Models\CompanyGateway; +use Illuminate\Support\Facades\Cache; +use Livewire\Attributes\On; use Livewire\Component; class RFF extends Component { public array $context; - public ClientContact $contact; - - public ?string $contact_first_name; - public ?string $contact_last_name; - public ?string $contact_email; - - public function handleRff() + #[On('passed-required-fields-check')] + public function continue(): void { - $validated = $this->validate([ - 'contact_first_name' => ['required'], - 'contact_last_name' => ['required'], - // 'contact_email' => ['sometimes', 'email'], - ]); - - $this->contact = auth()->guard('contact')->user(); - $this->contact->first_name = $validated['contact_first_name']; - $this->contact->last_name = $validated['contact_last_name']; - $this->contact->save(); - - $this->contact_first_name = $this->contact->first_name; - $this->contact_last_name = $this->contact->last_name; - $this->contact_email = $this->contact->email; - - $this->dispatch('purchase.context', property: 'contact.first_name', value: $this->contact->first_name); - $this->dispatch('purchase.context', property: 'contact.last_name', value: $this->contact->last_name); - $this->dispatch('purchase.next'); } - - public function mount() - { - /** @var \App\Models\ClientContact $contact */ - $contact = auth()->guard('contact')->user(); - - if ($contact->showRff() === false) { - $this->dispatch('purchase.next'); - } - } public function render() { - return view('billing-portal.v3.rff'); + $gateway = CompanyGateway::findOrFail($this->context['form']['company_gateway_id']); + $countries = Cache::get('countries'); + + return view('billing-portal.v3.rff', [ + 'gateway' => $gateway->driver( + auth()->guard('contact')->user()->client + ), + 'countries' => $countries, + 'company' => $gateway->company, + ]); } } diff --git a/resources/views/billing-portal/v3/rff.blade.php b/resources/views/billing-portal/v3/rff.blade.php index eb4260cfbc45..6c999e1fcaf5 100644 --- a/resources/views/billing-portal/v3/rff.blade.php +++ b/resources/views/billing-portal/v3/rff.blade.php @@ -9,34 +9,14 @@ @endif -
- @csrf - - @if(strlen(auth()->guard('contact')->user()->first_name) === 0) -
- - -
- @endif - - @if(strlen(auth()->guard('contact')->user()->last_name) === 0) - - @endif - - @if(strlen(auth()->guard('contact')->user()->email) === 0) - - @endif - - -
- \ No newline at end of file +
+ @livewire('required-client-info', [ + 'fields' => method_exists($gateway, 'getClientRequiredFields') ? $gateway->getClientRequiredFields() : [], + 'contact' => auth()->guard('contact')->user(), + 'countries' => $countries, + 'company' => $company, + 'company_gateway_id' => $gateway->company_gateway ? $gateway->company_gateway->id : $gateway->id, + 'form_only' => true + ]) +
+