mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 12:54:31 -04:00
Refactor optional one-time products view and component
This commit is contained in:
parent
c2c939af76
commit
474a1908ba
@ -19,6 +19,13 @@ class OptionalOneTimeProducts extends Component
|
|||||||
{
|
{
|
||||||
public Subscription $subscription;
|
public Subscription $subscription;
|
||||||
|
|
||||||
|
public array $context;
|
||||||
|
|
||||||
|
public function quantity($id, $value): void
|
||||||
|
{
|
||||||
|
$this->dispatch('purchase.context', property: "bundle.optional_one_time_products.{$id}.quantity", value: $value);
|
||||||
|
}
|
||||||
|
|
||||||
public function render(): \Illuminate\View\View
|
public function render(): \Illuminate\View\View
|
||||||
{
|
{
|
||||||
return view('billing-portal.v3.cart.optional-one-time-products');
|
return view('billing-portal.v3.cart.optional-one-time-products');
|
||||||
|
@ -1,15 +1,20 @@
|
|||||||
<div class="space-y-10">
|
<div class="space-y-10">
|
||||||
@unless(empty($subscription->optional_recurring_product_ids))
|
@isset($context['bundle']['optional_one_time_products'])
|
||||||
@foreach($subscription->service()->optional_products() as $index => $product)
|
@foreach($context['bundle']['optional_one_time_products'] as $key => $entry)
|
||||||
|
|
||||||
|
@php
|
||||||
|
$product = $entry['product'];
|
||||||
|
@endphp
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class="flex items-start justify-between space-x-4">
|
<div class="flex items-start justify-between space-x-4">
|
||||||
<div class="flex flex-start">
|
<div class="flex flex-start">
|
||||||
@if(filter_var($product->product_image, FILTER_VALIDATE_URL))
|
@if(filter_var($product['product_image'], FILTER_VALIDATE_URL))
|
||||||
<div
|
<div
|
||||||
class="h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border border-gray-200 mr-2"
|
class="h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border border-gray-200 mr-2"
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
src="{{ $product->product_image }}"
|
src="{{ $product['product_image'] }}"
|
||||||
alt=""
|
alt=""
|
||||||
class="h-full w-full object-cover object-center border rounded-md"
|
class="h-full w-full object-cover object-center border rounded-md"
|
||||||
/>
|
/>
|
||||||
@ -17,24 +22,24 @@
|
|||||||
@endif
|
@endif
|
||||||
|
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<h2 class="text-lg font-medium">{{ $product->product_key }}</h2>
|
<h2 class="text-lg font-medium">{{ $product['product_key'] }}</h2>
|
||||||
<p class="block text-sm">{{ \App\Utils\Number::formatMoney($product->price, $subscription->company) }}</p>
|
<p class="block text-sm">{{ \App\Utils\Number::formatMoney($product['price'], $subscription['company']) }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-col-reverse space-y-3">
|
<div class="flex flex-col-reverse space-y-3">
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
@if(is_numeric($product->max_quantity))
|
@if($subscription->per_seat_enabled)
|
||||||
@if($subscription->use_inventory_management && $product->in_stock_quantity == 0)
|
@if($subscription->use_inventory_management && $product['in_stock_quantity'] == 0)
|
||||||
<p class="text-sm font-light text-red-500 text-right mr-2 mt-2">{{ ctrans('texts.out_of_stock') }}</p>
|
<p class="text-sm font-light text-red-500 text-right mr-2 mt-2">{{ ctrans('texts.out_of_stock') }}</p>
|
||||||
@else
|
@else
|
||||||
<p class="text-sm font-light text-gray-700 text-right mr-2 mt-2">{{ ctrans('texts.qty') }}</p>
|
<p class="text-sm font-light text-gray-700 text-right mr-2 mt-2">{{ ctrans('texts.qty') }}</p>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<select class="rounded-md border-gray-300 shadow-sm sm:text-sm" @if($subscription->use_inventory_management && $product->in_stock_quantity == 0) disabled @endif>
|
<select id="{{ $product['hashed_id'] }}" wire:change="quantity($event.target.id, $event.target.value)" class="rounded-md border-gray-300 shadow-sm sm:text-sm" @if($subscription->use_inventory_management && $product['in_stock_quantity'] == 0) disabled @endif>
|
||||||
<option value="0" selected="selected">0</option>
|
<option {{ $entry['quantity'] == '0' ? 'selected' : '' }} value="0" selected="selected">0</option>
|
||||||
@for ($i = 1; $i <= ($subscription->use_inventory_management ? min($product->in_stock_quantity, min(100,$product->max_quantity)) : min(100,$product->max_quantity)); $i++)
|
@for ($i = 1; $i <= ($subscription->use_inventory_management ? min($product['in_stock_quantity'], max(100,$product['max_quantity'])) : max(100,$product['max_quantity'])); $i++)
|
||||||
<option value="{{ $i }}">{{ $i }}</option>
|
<option {{ $entry['quantity'] == $i ? 'selected' : '' }} value="{{ $i }}">{{ $i }}</option>
|
||||||
@endfor
|
@endfor
|
||||||
</select>
|
</select>
|
||||||
@endif
|
@endif
|
||||||
@ -43,9 +48,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<article class="prose my-3 text-sm">
|
<article class="prose my-3 text-sm">
|
||||||
{!! $product->markdownNotes() !!}
|
{!! $product['notes'] !!}
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
@endunless
|
@endisset
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user