This commit is contained in:
Benjamin Beganović 2021-03-29 15:50:36 +02:00
parent c4ff24132e
commit 05cbd30bef
2 changed files with 26 additions and 6 deletions

View File

@ -139,6 +139,16 @@ class BillingPortalPurchase extends Component
*/ */
public $request_data; public $request_data;
/**
* @var string
*/
public $price;
public function mount()
{
$this->price = $this->subscription->service()->price();
}
/** /**
* Handle user authentication * Handle user authentication
* *
@ -331,6 +341,13 @@ class BillingPortalPurchase extends Component
return 0; return 0;
} }
public function handleCoupon()
{
if ($this->coupon == $this->subscription->promo_code) {
$this->price = $this->subscription->promo_price;
}
}
public function render() public function render()
{ {
if ($this->contact instanceof ClientContact) { if ($this->contact instanceof ClientContact) {

View File

@ -71,7 +71,7 @@
<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-50 px-6 py-0"> <h1 class="text-2xl font-bold tracking-wide bg-gray-50 px-6 py-0">
{{ ctrans('texts.total') }}: {{ $subscription->service()->price() }} {{ ctrans('texts.total') }}: {{ $price }}
</h1> </h1>
</div> </div>
</div> </div>
@ -184,12 +184,15 @@
</div> </div>
</div> </div>
<div class="flex items-center mt-4"> <form wire:submit.prevent="handleCoupon" class="flex items-center mt-4">
@csrf
<label class="w-full mr-2"> <label class="w-full mr-2">
<input type="text" wire:model.lazy="coupon" class="input w-full m-0"/> <input type="text" wire:model.lazy="coupon" class="input w-full m-0"/>
<small class="block text-gray-900 mt-2">{{ ctrans('texts.billing_coupon_notice') }}</small>
</label> </label>
</div>
<button class="button button-primary bg-primary">Apply</button>
</form>
@endif @endif
</div> </div>
</div> </div>