feat: Phase 2 - page CRUD, subscriber management, user management
This commit is contained in:
@@ -5,8 +5,106 @@
|
||||
@section('mobile_title', __('Pages'))
|
||||
|
||||
@section('content')
|
||||
<div class="mx-auto max-w-6xl">
|
||||
<h1 class="text-2xl font-semibold text-slate-900">{{ __('Pre-registration pages') }}</h1>
|
||||
<p class="mt-2 text-sm text-slate-600">{{ __('Page list and CRUD will be added in the next step.') }}</p>
|
||||
<div class="mx-auto max-w-7xl">
|
||||
<div class="mb-8 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div>
|
||||
<h1 class="text-2xl font-semibold text-slate-900">{{ __('Pre-registration pages') }}</h1>
|
||||
<p class="mt-1 text-sm text-slate-600">{{ __('Manage landing pages and subscriber lists.') }}</p>
|
||||
</div>
|
||||
@can('create', \App\Models\PreregistrationPage::class)
|
||||
<a href="{{ route('admin.pages.create') }}"
|
||||
class="inline-flex items-center justify-center rounded-lg bg-indigo-600 px-4 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500">
|
||||
{{ __('New page') }}
|
||||
</a>
|
||||
@endcan
|
||||
</div>
|
||||
|
||||
<div class="overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full divide-y divide-slate-200 text-left text-sm">
|
||||
<thead class="bg-slate-50">
|
||||
<tr>
|
||||
@if (auth()->user()->isSuperadmin())
|
||||
<th scope="col" class="px-4 py-3 font-semibold text-slate-700">{{ __('Owner') }}</th>
|
||||
@endif
|
||||
<th scope="col" class="px-4 py-3 font-semibold text-slate-700">{{ __('Title') }}</th>
|
||||
<th scope="col" class="px-4 py-3 font-semibold text-slate-700">{{ __('Status') }}</th>
|
||||
<th scope="col" class="px-4 py-3 font-semibold text-slate-700">{{ __('Start') }}</th>
|
||||
<th scope="col" class="px-4 py-3 font-semibold text-slate-700">{{ __('End') }}</th>
|
||||
<th scope="col" class="px-4 py-3 font-semibold text-slate-700">{{ __('Subscribers') }}</th>
|
||||
<th scope="col" class="px-4 py-3 text-right font-semibold text-slate-700">{{ __('Actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-100">
|
||||
@forelse ($pages as $page)
|
||||
@php
|
||||
$publicUrl = route('public.page', ['slug' => $page->slug]);
|
||||
$key = $page->statusKey();
|
||||
$statusClasses = match ($key) {
|
||||
'before_start' => 'bg-slate-100 text-slate-800',
|
||||
'active' => 'bg-emerald-100 text-emerald-800',
|
||||
'expired' => 'bg-rose-100 text-rose-800',
|
||||
default => 'bg-slate-100 text-slate-800',
|
||||
};
|
||||
$statusLabel = match ($key) {
|
||||
'before_start' => __('Before start'),
|
||||
'active' => __('Active'),
|
||||
'expired' => __('Expired'),
|
||||
default => $key,
|
||||
};
|
||||
@endphp
|
||||
<tr class="hover:bg-slate-50/80">
|
||||
@if (auth()->user()->isSuperadmin())
|
||||
<td class="whitespace-nowrap px-4 py-3 text-slate-600">{{ $page->user?->email ?? '—' }}</td>
|
||||
@endif
|
||||
<td class="px-4 py-3 font-medium text-slate-900">{{ $page->title }}</td>
|
||||
<td class="whitespace-nowrap px-4 py-3">
|
||||
<span class="inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium {{ $statusClasses }}">{{ $statusLabel }}</span>
|
||||
</td>
|
||||
<td class="whitespace-nowrap px-4 py-3 text-slate-600">{{ $page->start_date->timezone(config('app.timezone'))->format('Y-m-d H:i') }}</td>
|
||||
<td class="whitespace-nowrap px-4 py-3 text-slate-600">{{ $page->end_date->timezone(config('app.timezone'))->format('Y-m-d H:i') }}</td>
|
||||
<td class="whitespace-nowrap px-4 py-3 tabular-nums text-slate-600">{{ number_format($page->subscribers_count) }}</td>
|
||||
<td class="whitespace-nowrap px-4 py-3 text-right">
|
||||
<div class="flex flex-wrap items-center justify-end gap-2">
|
||||
@can('update', $page)
|
||||
<a href="{{ route('admin.pages.edit', $page) }}" class="text-indigo-600 hover:text-indigo-500">{{ __('Edit') }}</a>
|
||||
@endcan
|
||||
@can('view', $page)
|
||||
<a href="{{ route('admin.pages.subscribers.index', $page) }}" class="text-indigo-600 hover:text-indigo-500">{{ __('Subscribers') }}</a>
|
||||
@endcan
|
||||
<button
|
||||
type="button"
|
||||
x-data="{ copied: false }"
|
||||
x-on:click="navigator.clipboard.writeText({{ json_encode($publicUrl) }}); copied = true; setTimeout(() => copied = false, 2000)"
|
||||
class="text-sm text-slate-600 hover:text-slate-900"
|
||||
>
|
||||
<span x-show="!copied">{{ __('Copy URL') }}</span>
|
||||
<span x-show="copied" x-cloak class="text-emerald-600">{{ __('Copied!') }}</span>
|
||||
</button>
|
||||
@can('delete', $page)
|
||||
<form action="{{ route('admin.pages.destroy', $page) }}" method="post" class="inline"
|
||||
onsubmit="return confirm(@js(__('Delete this page and all subscribers? This cannot be undone.')));">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="text-red-600 hover:text-red-500">{{ __('Delete') }}</button>
|
||||
</form>
|
||||
@endcan
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="{{ auth()->user()->isSuperadmin() ? 7 : 6 }}" class="px-4 py-12 text-center text-slate-500">
|
||||
{{ __('No pages yet.') }}
|
||||
@can('create', \App\Models\PreregistrationPage::class)
|
||||
<a href="{{ route('admin.pages.create') }}" class="font-medium text-indigo-600 hover:text-indigo-500">{{ __('Create one') }}</a>
|
||||
@endcan
|
||||
</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user