@extends('backend.layouts.app') @section('title', __('Gift Card Templates')) @section('content') @php $statusMap = [ 'active' => ['label' => __('Active'), 'cls' => 'success'], 'draft' => ['label' => __('Draft'), 'cls' => 'warning'], 'inactive' => ['label' => __('Inactive'), 'cls' => 'secondary'], ]; @endphp {{-- Wrapper for the whole template-manager page. The admin layout doesn't ship Alpine.js, so this view uses vanilla jQuery + the CoreUI Modal API (same toolkit as the rest of the admin) for the edit flow. The trailing inline script registers click listeners, drives the live preview, and swaps swatch / chip active classes. --}}
{{-- Page header — matches All Gift Cards screen for visual parity. --}}
{{ __('Catalog') }}

{{ __('Gift Card Templates') }}

{{ __('Manage the designs available to users when creating a gift card.') }}

@can('gift-card-list') {{ __('All Gift Cards') }} @endcan @can('gift-card-template-manage') @endcan
{{-- KPI strip --}}
{{ __('Total templates') }}
{{ number_format($stats['total']) }}
{{ __('Active') }}
{{ number_format($stats['active']) }}
{{ __('Drafts') }}
{{ number_format($stats['drafts']) }}
{{ __('Cards sent this month') }}
{{ number_format($stats['sent_mtd']) }}
{{-- Table — full width. The editor is a Bootstrap modal that lives outside the row so it doesn't reserve column space while it's hidden. --}}
{{-- Toolbar --}}
@can('gift-card-template-manage') @endcan @forelse($templates as $t) @php $meta = $statusMap[$t->status] ?? ['label' => $t->status, 'cls' => 'secondary']; /* * Pre-compute the edit payload here. Inlining it as * @json($t->only([...])) inside @click breaks Blade's * @json compiler — it splits the expression on commas * (because @json supports a second flags arg) and * truncates the array at the first inner comma. */ $editPayload = $t->only([ 'id', 'name', 'category', 'preset_key', 'background_color', 'text_color', 'ribbon_text', 'default_amount', 'status', 'sort_order', ]); @endphp @can('gift-card-template-manage') @endcan @empty @endforelse @can('gift-card-template-manage') @endcan
{{ __('Reorder') }}{{ __('Design') }} {{ __('Name') }} {{ __('Category') }} {{ __('Status') }} {{ __('Used') }} {{ __('Actions') }}
{{ $t->name }} #GC-{{ str_pad($t->id, 3, '0', STR_PAD_LEFT) }}
{{ $t->category }} {{ $meta['label'] }}
{{ number_format($t->used_count) }} {{ __('cards') }}
@can('gift-card-template-manage') {{-- Use the project-wide delete handler defined in public/general/js/helpers.js — it listens for clicks on .delete, reads data-url, points the global #delete-form-modal at it and pops #delete_modal. Matches blog/role/page admin. --}} {{ __('Delete') }} @else {{ __('Read-only') }} @endcan
{{ __('Drag rows by the grip icon to reorder gift card templates.') }}
@if($templates->hasPages())
{{ $templates->links() }}
@endif
{{-- /.row table-only --}} {{-- Edit / Create template modal. Lives outside the .row so it never reserves layout space while hidden — Bootstrap's .modal style handles that with display:none. Opens whenever Alpine `editing` becomes non-null (see the x-effect handler below). --}}
{{-- /.gift-card-template-manager wrapper --}} @push('styles') @endpush @push('scripts') @endpush @endsection