CluPilotCloud/resources/views/livewire/admin/plans.blade.php

94 lines
6.1 KiB
PHP

<div class="space-y-5">
<div class="animate-rise">
<h1 class="text-2xl font-semibold tracking-tight text-ink">{{ __('plans.title') }}</h1>
<p class="mt-1 text-sm text-muted">{{ __('plans.subtitle') }}</p>
</div>
<div class="grid grid-cols-1 gap-5 lg:grid-cols-[1fr_320px] lg:items-start">
{{-- Plan lines --}}
<div class="overflow-hidden rounded-xl border border-line bg-surface shadow-xs animate-rise [animation-delay:60ms]">
@if ($families->isEmpty())
<p class="p-8 text-center text-sm text-muted">{{ __('plans.empty') }}</p>
@else
<div class="overflow-x-auto">
<table class="w-full text-sm">
<thead>
<tr class="border-b border-line bg-surface-2 text-left text-xs uppercase tracking-wide text-faint">
<th class="px-4 py-3 font-semibold">{{ __('plans.plan') }}</th>
<th class="px-4 py-3 font-semibold">{{ __('plans.tier') }}</th>
<th class="px-4 py-3 font-semibold">{{ __('plans.live_version') }}</th>
<th class="px-4 py-3 font-semibold">{{ __('plans.status') }}</th>
<th class="px-4 py-3 text-right font-semibold">{{ __('plans.actions') }}</th>
</tr>
</thead>
<tbody>
@foreach ($families as $family)
<tr wire:key="plan-{{ $family['uuid'] }}" class="border-b border-line last:border-0">
<td class="px-4 py-3">
<span class="font-semibold text-ink">{{ $family['name'] }}</span>
<span class="ml-1.5 font-mono text-xs text-faint">{{ $family['key'] }}</span>
@if ($family['drafts'] > 0)
<span class="ml-2 rounded-pill border border-line-strong bg-surface-2 px-2 py-0.5 text-xs text-muted">
{{ trans_choice('plans.drafts', $family['drafts'], ['count' => $family['drafts']]) }}
</span>
@endif
</td>
<td class="px-4 py-3 font-mono text-xs text-muted">{{ $family['tier'] }}</td>
<td class="px-4 py-3 text-body">
@if ($family['live'])
v{{ $family['live']->version }}
@if ($family['next'])
<span class="block text-xs text-faint">
{{ __('plans.next_from', ['version' => $family['next']->version, 'date' => $family['next']->available_from->isoFormat('L')]) }}
</span>
@endif
@else
<span class="text-faint">{{ __('plans.no_live_version') }}</span>
@endif
</td>
<td class="px-4 py-3">
@php $selling = in_array($family['key'], $sellable, true); @endphp
<button type="button" wire:click="toggleSales('{{ $family['uuid'] }}')"
class="inline-flex items-center gap-1.5 rounded-pill border px-2.5 py-0.5 text-xs font-medium transition
{{ $selling ? 'border-success-border bg-success-bg text-success' : 'border-line-strong bg-surface-2 text-muted' }}">
<span class="size-1.5 rounded-pill bg-current" aria-hidden="true"></span>
{{ $selling ? __('plans.on_sale') : ($family['sales_enabled'] ? __('plans.nothing_available') : __('plans.withdrawn_badge')) }}
</button>
</td>
<td class="px-4 py-3 text-right">
<a href="{{ route('admin.plans.versions', $family['uuid']) }}" wire:navigate>
<x-ui.button variant="secondary" size="sm">
{{ __('plans.manage_versions', ['count' => $family['versions_count']]) }}
</x-ui.button>
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
</div>
{{-- New plan line --}}
<div class="rounded-xl border border-line bg-surface p-5 shadow-xs animate-rise [animation-delay:120ms]">
<h2 class="text-base font-semibold text-ink">{{ __('plans.new_title') }}</h2>
<p class="mt-1 text-sm text-muted">{{ __('plans.new_body') }}</p>
<form wire:submit="save" class="mt-4 space-y-4">
<x-ui.input name="key" :label="__('plans.key')" :hint="__('plans.key_hint')"
wire:model="key" autocomplete="off" />
<x-ui.input name="name" :label="__('plans.name')" wire:model="name" autocomplete="off" />
<x-ui.input name="tier" type="number" min="0" max="255"
:label="__('plans.tier')" :hint="__('plans.tier_hint')" wire:model="tier" />
<x-ui.button type="submit" class="w-full" wire:loading.attr="disabled">
{{ __('plans.create') }}
</x-ui.button>
</form>
</div>
</div>
</div>