The TPL-008 rule was only in the single-file validation path, not in the full project validation. Added it to _validate_templates(). Fixed invalid block names: - customers.html: page_scripts → extra_scripts - notifications.html: page_scripts → extra_scripts - test-vendors-users-migration.html: scripts → extra_scripts - test-auth-flow.html: scripts → extra_scripts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
246 lines
11 KiB
HTML
246 lines
11 KiB
HTML
{# app/templates/admin/customers.html #}
|
|
{% extends "admin/base.html" %}
|
|
{% from 'shared/macros/headers.html' import page_header %}
|
|
{% from 'shared/macros/alerts.html' import loading_state, error_state %}
|
|
{% from 'shared/macros/tables.html' import table_wrapper, table_header %}
|
|
{% from 'shared/macros/pagination.html' import pagination_full %}
|
|
|
|
{% block title %}Customers{% endblock %}
|
|
|
|
{% block alpine_data %}adminCustomers(){% endblock %}
|
|
|
|
{% block content %}
|
|
{{ page_header('Customer Management') }}
|
|
|
|
{{ loading_state('Loading customers...') }}
|
|
|
|
{{ error_state('Error loading customers') }}
|
|
|
|
<!-- Stats Cards -->
|
|
<div x-show="!loading" class="grid gap-6 mb-8 md:grid-cols-2 xl:grid-cols-4">
|
|
<!-- Card: Total Customers -->
|
|
<div class="flex items-center p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
|
<div class="p-3 mr-4 text-blue-500 bg-blue-100 rounded-full dark:text-blue-100 dark:bg-blue-500">
|
|
<span x-html="$icon('user-group', 'w-5 h-5')"></span>
|
|
</div>
|
|
<div>
|
|
<p class="mb-2 text-sm font-medium text-gray-600 dark:text-gray-400">
|
|
Total Customers
|
|
</p>
|
|
<p class="text-lg font-semibold text-gray-700 dark:text-gray-200" x-text="stats.total || 0">
|
|
0
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Card: Active Customers -->
|
|
<div class="flex items-center p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
|
<div class="p-3 mr-4 text-green-500 bg-green-100 rounded-full dark:text-green-100 dark:bg-green-500">
|
|
<span x-html="$icon('user-check', 'w-5 h-5')"></span>
|
|
</div>
|
|
<div>
|
|
<p class="mb-2 text-sm font-medium text-gray-600 dark:text-gray-400">
|
|
Active
|
|
</p>
|
|
<p class="text-lg font-semibold text-gray-700 dark:text-gray-200" x-text="stats.active || 0">
|
|
0
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Card: With Orders -->
|
|
<div class="flex items-center p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
|
<div class="p-3 mr-4 text-purple-500 bg-purple-100 rounded-full dark:text-purple-100 dark:bg-purple-500">
|
|
<span x-html="$icon('shopping-bag', 'w-5 h-5')"></span>
|
|
</div>
|
|
<div>
|
|
<p class="mb-2 text-sm font-medium text-gray-600 dark:text-gray-400">
|
|
With Orders
|
|
</p>
|
|
<p class="text-lg font-semibold text-gray-700 dark:text-gray-200" x-text="stats.with_orders || 0">
|
|
0
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Card: Total Spent -->
|
|
<div class="flex items-center p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
|
<div class="p-3 mr-4 text-orange-500 bg-orange-100 rounded-full dark:text-orange-100 dark:bg-orange-500">
|
|
<span x-html="$icon('currency-euro', 'w-5 h-5')"></span>
|
|
</div>
|
|
<div>
|
|
<p class="mb-2 text-sm font-medium text-gray-600 dark:text-gray-400">
|
|
Total Revenue
|
|
</p>
|
|
<p class="text-lg font-semibold text-gray-700 dark:text-gray-200" x-text="formatCurrency(stats.total_spent || 0)">
|
|
0
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Search and Filters -->
|
|
<div x-show="!loading" class="mb-6 px-4 py-3 bg-white rounded-lg shadow-md dark:bg-gray-800">
|
|
<div class="flex flex-col md:flex-row md:items-center md:justify-between gap-4">
|
|
<!-- Search Bar -->
|
|
<div class="flex-1 max-w-md">
|
|
<div class="relative">
|
|
<input
|
|
type="text"
|
|
x-model="filters.search"
|
|
@input.debounce.300ms="resetAndLoad()"
|
|
placeholder="Search by name, email, or customer number..."
|
|
class="w-full pl-10 pr-4 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:bg-gray-700 dark:text-gray-300"
|
|
>
|
|
<div class="absolute inset-y-0 left-0 flex items-center pl-3">
|
|
<span x-html="$icon('search', 'w-5 h-5 text-gray-400')"></span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Status Filter -->
|
|
<div class="flex items-center gap-4">
|
|
<select
|
|
x-model="filters.is_active"
|
|
@change="resetAndLoad()"
|
|
class="px-4 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none dark:bg-gray-700 dark:text-gray-300"
|
|
>
|
|
<option value="">All Status</option>
|
|
<option value="true">Active</option>
|
|
<option value="false">Inactive</option>
|
|
</select>
|
|
|
|
<select
|
|
x-model="filters.vendor_id"
|
|
@change="resetAndLoad()"
|
|
class="px-4 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none dark:bg-gray-700 dark:text-gray-300"
|
|
>
|
|
<option value="">All Vendors</option>
|
|
<template x-for="vendor in vendors" :key="vendor.id">
|
|
<option :value="vendor.id" x-text="vendor.name"></option>
|
|
</template>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Customers Table -->
|
|
<div x-show="!loading" class="w-full overflow-hidden rounded-lg shadow-xs">
|
|
<div class="w-full overflow-x-auto">
|
|
<table class="w-full whitespace-no-wrap">
|
|
<thead>
|
|
<tr class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800">
|
|
<th class="px-4 py-3">Customer</th>
|
|
<th class="px-4 py-3">Vendor</th>
|
|
<th class="px-4 py-3">Customer #</th>
|
|
<th class="px-4 py-3">Orders</th>
|
|
<th class="px-4 py-3">Total Spent</th>
|
|
<th class="px-4 py-3">Status</th>
|
|
<th class="px-4 py-3">Joined</th>
|
|
<th class="px-4 py-3">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800">
|
|
<!-- Loading state -->
|
|
<template x-if="loadingCustomers && customers.length === 0">
|
|
<tr>
|
|
<td colspan="8" class="px-4 py-8 text-center text-gray-500 dark:text-gray-400">
|
|
<span x-html="$icon('spinner', 'w-6 h-6 mx-auto mb-2')"></span>
|
|
<p>Loading customers...</p>
|
|
</td>
|
|
</tr>
|
|
</template>
|
|
|
|
<!-- Empty state -->
|
|
<template x-if="!loadingCustomers && customers.length === 0">
|
|
<tr>
|
|
<td colspan="8" class="px-4 py-8 text-center text-gray-500 dark:text-gray-400">
|
|
<span x-html="$icon('user-group', 'w-12 h-12 mx-auto mb-2 text-gray-300')"></span>
|
|
<p class="font-medium">No customers found</p>
|
|
<p class="text-sm mt-1">Try adjusting your search or filters</p>
|
|
</td>
|
|
</tr>
|
|
</template>
|
|
|
|
<!-- Customer rows -->
|
|
<template x-for="customer in customers" :key="customer.id">
|
|
<tr class="text-gray-700 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-700">
|
|
<!-- Customer -->
|
|
<td class="px-4 py-3">
|
|
<div class="flex items-center text-sm">
|
|
<div class="relative hidden w-8 h-8 mr-3 rounded-full md:block bg-gray-200 dark:bg-gray-700 flex items-center justify-center">
|
|
<span x-html="$icon('user', 'w-4 h-4 text-gray-500')"></span>
|
|
</div>
|
|
<div>
|
|
<p class="font-semibold" x-text="customer.first_name && customer.last_name ? customer.first_name + ' ' + customer.last_name : customer.email"></p>
|
|
<p class="text-xs text-gray-600 dark:text-gray-400" x-text="customer.email"></p>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
|
|
<!-- Vendor -->
|
|
<td class="px-4 py-3 text-sm">
|
|
<span x-text="customer.vendor_code || customer.vendor_name || '-'"></span>
|
|
</td>
|
|
|
|
<!-- Customer Number -->
|
|
<td class="px-4 py-3 text-sm">
|
|
<span class="font-mono text-xs" x-text="customer.customer_number"></span>
|
|
</td>
|
|
|
|
<!-- Orders -->
|
|
<td class="px-4 py-3 text-sm">
|
|
<span x-text="customer.total_orders || 0"></span>
|
|
</td>
|
|
|
|
<!-- Total Spent -->
|
|
<td class="px-4 py-3 text-sm">
|
|
<span x-text="formatCurrency(customer.total_spent || 0)"></span>
|
|
</td>
|
|
|
|
<!-- Status -->
|
|
<td class="px-4 py-3 text-xs">
|
|
<span
|
|
class="px-2 py-1 font-semibold leading-tight rounded-full"
|
|
:class="customer.is_active
|
|
? 'text-green-700 bg-green-100 dark:bg-green-700 dark:text-green-100'
|
|
: 'text-red-700 bg-red-100 dark:bg-red-700 dark:text-red-100'"
|
|
x-text="customer.is_active ? 'Active' : 'Inactive'"
|
|
></span>
|
|
</td>
|
|
|
|
<!-- Joined -->
|
|
<td class="px-4 py-3 text-sm">
|
|
<span x-text="formatDate(customer.created_at)"></span>
|
|
</td>
|
|
|
|
<!-- Actions -->
|
|
<td class="px-4 py-3">
|
|
<div class="flex items-center space-x-2 text-sm">
|
|
<button
|
|
@click="toggleStatus(customer)"
|
|
class="px-2 py-1 text-xs font-medium leading-5 rounded-lg"
|
|
:class="customer.is_active
|
|
? 'text-red-600 hover:bg-red-100 dark:text-red-400 dark:hover:bg-red-700/50'
|
|
: 'text-green-600 hover:bg-green-100 dark:text-green-400 dark:hover:bg-green-700/50'"
|
|
:title="customer.is_active ? 'Deactivate' : 'Activate'"
|
|
>
|
|
<span x-html="customer.is_active ? $icon('x-circle', 'w-4 h-4') : $icon('check-circle', 'w-4 h-4')"></span>
|
|
</button>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</template>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- Numbered Pagination -->
|
|
{{ pagination_full(load_fn="loadCustomers()", item_label="customers") }}
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block extra_scripts %}
|
|
<script src="{{ url_for('static', path='admin/js/customers.js') }}"></script>
|
|
{% endblock %}
|