mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #9285 from beganovich/switch-rff
Switching subscriptions RFF
This commit is contained in:
commit
7ab254a813
@ -44,7 +44,7 @@ class SubscriptionPlanSwitch extends Component
|
|||||||
/**
|
/**
|
||||||
* @var ClientContact
|
* @var ClientContact
|
||||||
*/
|
*/
|
||||||
public $contact;
|
public ClientContact $contact;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
@ -66,6 +66,7 @@ class SubscriptionPlanSwitch extends Component
|
|||||||
'invoice' => null,
|
'invoice' => null,
|
||||||
'company_gateway_id' => null,
|
'company_gateway_id' => null,
|
||||||
'payment_method_id' => null,
|
'payment_method_id' => null,
|
||||||
|
'show_rff' => false,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,6 +76,12 @@ class SubscriptionPlanSwitch extends Component
|
|||||||
|
|
||||||
public $company;
|
public $company;
|
||||||
|
|
||||||
|
public ?string $first_name;
|
||||||
|
|
||||||
|
public ?string $last_name;
|
||||||
|
|
||||||
|
public ?string $email;
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
MultiDB::setDb($this->company->db);
|
MultiDB::setDb($this->company->db);
|
||||||
@ -84,6 +91,31 @@ class SubscriptionPlanSwitch extends Component
|
|||||||
$this->methods = $this->contact->client->service()->getPaymentMethods($this->amount);
|
$this->methods = $this->contact->client->service()->getPaymentMethods($this->amount);
|
||||||
|
|
||||||
$this->hash = Str::uuid()->toString();
|
$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
|
public function handleBeforePaymentEvents(): void
|
||||||
|
@ -1,9 +1,47 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="grid grid-cols-12 gap-8 mt-8">
|
<div class="grid grid-cols-12 gap-8 mt-8">
|
||||||
<div class="col-span-12 md:col-span-5 md:col-start-4 px-4 py-5">
|
<div class="col-span-12 md:col-span-5 md:col-start-4 px-4 py-5">
|
||||||
<!-- Total price -->
|
@if($errors->any())
|
||||||
|
<div class="alert alert-failure mb-4">
|
||||||
|
@foreach($errors->all() as $error)
|
||||||
|
<p>{{ $error }}</p>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if($state['show_rff'])
|
||||||
|
<div class="mt-2">
|
||||||
|
@if(strlen(auth()->guard('contact')->user()->first_name) === 0)
|
||||||
|
<div class="col-span-6 sm:col-span-3">
|
||||||
|
<label for="first_name" class="input-label">{{ ctrans('texts.first_name') }}</label>
|
||||||
|
<input id="first_name" class="input w-full" wire:model="first_name" />
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
@if($amount > 0)
|
@if(strlen(auth()->guard('contact')->user()->last_name) === 0)
|
||||||
|
<div class="col-span-6 sm:col-span-3 mt-2">
|
||||||
|
<label for="last_name" class="input-label">{{ ctrans('texts.last_name') }}</label>
|
||||||
|
<input id="last_name" class="input w-full" wire:model="last_name" />
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if(strlen(auth()->guard('contact')->user()->email) === 0)
|
||||||
|
<div class="col-span-6 sm:col-span-3 mt-2">
|
||||||
|
<label for="email" class="input-label">{{ ctrans('texts.email') }}</label>
|
||||||
|
<input id="email" class="input w-full" wire:model="email" />
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div class="flex justify-center my-4">
|
||||||
|
<button wire:click="handleRff" class="button button-primary bg-primary">
|
||||||
|
{{ ctrans('texts.next_step') }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<!-- Total price -->
|
||||||
|
@if($amount > 0 && $state['show_rff'] == false)
|
||||||
|
|
||||||
<div class="relative mt-8">
|
<div class="relative mt-8">
|
||||||
<div class="absolute inset-0 flex items-center">
|
<div class="absolute inset-0 flex items-center">
|
||||||
@ -33,6 +71,9 @@
|
|||||||
<input type="hidden" name="action" value="payment">
|
<input type="hidden" name="action" value="payment">
|
||||||
<input type="hidden" name="company_gateway_id" value="{{ $state['company_gateway_id'] }}"/>
|
<input type="hidden" name="company_gateway_id" value="{{ $state['company_gateway_id'] }}"/>
|
||||||
<input type="hidden" name="payment_method_id" value="{{ $state['payment_method_id'] }}"/>
|
<input type="hidden" name="payment_method_id" value="{{ $state['payment_method_id'] }}"/>
|
||||||
|
<input type="hidden" name="contact_first_name" value="{{ $contact->first_name }}">
|
||||||
|
<input type="hidden" name="contact_last_name" value="{{ $contact->last_name }}">
|
||||||
|
<input type="hidden" name="contact_email" value="{{ $contact->email }}">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<!-- Payment methods -->
|
<!-- Payment methods -->
|
||||||
@ -62,7 +103,7 @@
|
|||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@elseif($amount <= 0)
|
@elseif($amount <= 0 && $state['show_rff'] == false)
|
||||||
|
|
||||||
<div class="relative flex justify-center text-sm leading-5">
|
<div class="relative flex justify-center text-sm leading-5">
|
||||||
<h1 class="text-2xl font-bold tracking-wide bg-gray-100 px-6 py-0">
|
<h1 class="text-2xl font-bold tracking-wide bg-gray-100 px-6 py-0">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user