mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Make RFF proxy for RequiredClientInfo
This commit is contained in:
parent
938ffbe66b
commit
6346e7a92f
@ -12,54 +12,32 @@
|
|||||||
|
|
||||||
namespace App\Livewire\BillingPortal;
|
namespace App\Livewire\BillingPortal;
|
||||||
|
|
||||||
use App\Models\ClientContact;
|
use App\Models\CompanyGateway;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Livewire\Attributes\On;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class RFF extends Component
|
class RFF extends Component
|
||||||
{
|
{
|
||||||
public array $context;
|
public array $context;
|
||||||
|
|
||||||
public ClientContact $contact;
|
#[On('passed-required-fields-check')]
|
||||||
|
public function continue(): void
|
||||||
public ?string $contact_first_name;
|
|
||||||
public ?string $contact_last_name;
|
|
||||||
public ?string $contact_email;
|
|
||||||
|
|
||||||
public function handleRff()
|
|
||||||
{
|
{
|
||||||
$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');
|
$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()
|
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,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,34 +9,14 @@
|
|||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<form wire:submit="handleRff">
|
<div>
|
||||||
@csrf
|
@livewire('required-client-info', [
|
||||||
|
'fields' => method_exists($gateway, 'getClientRequiredFields') ? $gateway->getClientRequiredFields() : [],
|
||||||
@if(strlen(auth()->guard('contact')->user()->first_name) === 0)
|
'contact' => auth()->guard('contact')->user(),
|
||||||
<div class="col-auto mt-3">
|
'countries' => $countries,
|
||||||
<label for="first_name" class="input-label">{{ ctrans('texts.first_name') }}</label>
|
'company' => $company,
|
||||||
<input id="first_name" class="input w-full" wire:model="contact_first_name" />
|
'company_gateway_id' => $gateway->company_gateway ? $gateway->company_gateway->id : $gateway->id,
|
||||||
|
'form_only' => true
|
||||||
|
])
|
||||||
</div>
|
</div>
|
||||||
@endif
|
|
||||||
|
|
||||||
@if(strlen(auth()->guard('contact')->user()->last_name) === 0)
|
|
||||||
<div class="col-auto mt-3 @if(auth()->guard('contact')->user()->last_name) !== 0) hidden @endif">
|
|
||||||
<label for="last_name" class="input-label">{{ ctrans('texts.last_name') }}</label>
|
|
||||||
<input id="last_name" class="input w-full" wire:model="contact_last_name" />
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
@if(strlen(auth()->guard('contact')->user()->email) === 0)
|
|
||||||
<div class="col-auto mt-3 @if(auth()->guard('contact')->user()->email) !== 0) hidden @endif">
|
|
||||||
<label for="email" class="input-label">{{ ctrans('texts.email') }}</label>
|
|
||||||
<input id="email" class="input w-full" wire:model="contact_email" />
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
<button
|
|
||||||
type="submit"
|
|
||||||
class="button button-block bg-primary text-white mt-4">
|
|
||||||
{{ ctrans('texts.next') }}
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
Loading…
x
Reference in New Issue
Block a user