Platform Email Settings (Admin): - Add GET/PUT/DELETE /admin/settings/email/* endpoints - Settings stored in admin_settings table override .env values - Support all providers: SMTP, SendGrid, Mailgun, Amazon SES - Edit mode UI with provider-specific configuration forms - Reset to .env defaults functionality - Test email to verify configuration Vendor Email Settings: - Add VendorEmailSettings model with one-to-one vendor relationship - Migration: v0a1b2c3d4e5_add_vendor_email_settings.py - Service: vendor_email_settings_service.py with tier validation - API endpoints: /vendor/email-settings/* (CRUD, status, verify) - Email tab in vendor settings page with full configuration - Warning banner until email is configured (like billing warnings) - Premium providers (SendGrid, Mailgun, SES) tier-gated to Business+ Email Service Updates: - get_platform_email_config(db) checks DB first, then .env - Configurable provider classes accept config dict - EmailService uses database-aware providers - Vendor emails use vendor's own SMTP (Wizamart doesn't pay) - "Powered by Wizamart" footer for Essential/Professional tiers - White-label (no footer) for Business/Enterprise tiers Other: - Add scripts/install.py for first-time platform setup - Add make install target - Update init-prod to include email template seeding 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
184 lines
8.2 KiB
HTML
184 lines
8.2 KiB
HTML
{# app/templates/shop/account/dashboard.html #}
|
|
{% extends "shop/base.html" %}
|
|
{% from 'shared/macros/modals.html' import confirm_modal %}
|
|
|
|
{% block title %}My Account - {{ vendor.name }}{% endblock %}
|
|
|
|
{% block alpine_data %}accountDashboard(){% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
|
<!-- Page Header -->
|
|
<div class="mb-8">
|
|
<h1 class="text-3xl font-bold text-gray-900 dark:text-white">My Account</h1>
|
|
<p class="mt-2 text-gray-600 dark:text-gray-400">Welcome back, {{ user.first_name }}!</p>
|
|
</div>
|
|
|
|
<!-- Dashboard Grid -->
|
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 mb-8">
|
|
|
|
<!-- Orders Card -->
|
|
<a href="{{ base_url }}shop/account/orders"
|
|
class="block bg-white dark:bg-gray-800 rounded-lg shadow hover:shadow-lg transition-shadow p-6 border border-gray-200 dark:border-gray-700">
|
|
<div class="flex items-center mb-4">
|
|
<div class="flex-shrink-0">
|
|
<span class="h-8 w-8 text-primary" style="color: var(--color-primary)" x-html="$icon('shopping-bag', 'h-8 w-8')"></span>
|
|
</div>
|
|
<div class="ml-4">
|
|
<h3 class="text-lg font-semibold text-gray-900 dark:text-white">Orders</h3>
|
|
<p class="text-sm text-gray-600 dark:text-gray-400">View order history</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<p class="text-2xl font-bold text-primary" style="color: var(--color-primary)">{{ user.total_orders }}</p>
|
|
<p class="text-sm text-gray-500 dark:text-gray-400">Total Orders</p>
|
|
</div>
|
|
</a>
|
|
|
|
<!-- Profile Card -->
|
|
<a href="{{ base_url }}shop/account/profile"
|
|
class="block bg-white dark:bg-gray-800 rounded-lg shadow hover:shadow-lg transition-shadow p-6 border border-gray-200 dark:border-gray-700">
|
|
<div class="flex items-center mb-4">
|
|
<div class="flex-shrink-0">
|
|
<span class="h-8 w-8 text-primary" style="color: var(--color-primary)" x-html="$icon('user', 'h-8 w-8')"></span>
|
|
</div>
|
|
<div class="ml-4">
|
|
<h3 class="text-lg font-semibold text-gray-900 dark:text-white">Profile</h3>
|
|
<p class="text-sm text-gray-600 dark:text-gray-400">Edit your information</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<p class="text-sm text-gray-700 dark:text-gray-300 truncate">{{ user.email }}</p>
|
|
</div>
|
|
</a>
|
|
|
|
<!-- Addresses Card -->
|
|
<a href="{{ base_url }}shop/account/addresses"
|
|
class="block bg-white dark:bg-gray-800 rounded-lg shadow hover:shadow-lg transition-shadow p-6 border border-gray-200 dark:border-gray-700">
|
|
<div class="flex items-center mb-4">
|
|
<div class="flex-shrink-0">
|
|
<span class="h-8 w-8 text-primary" style="color: var(--color-primary)" x-html="$icon('location-marker', 'h-8 w-8')"></span>
|
|
</div>
|
|
<div class="ml-4">
|
|
<h3 class="text-lg font-semibold text-gray-900 dark:text-white">Addresses</h3>
|
|
<p class="text-sm text-gray-600 dark:text-gray-400">Manage addresses</p>
|
|
</div>
|
|
</div>
|
|
</a>
|
|
|
|
<!-- Messages Card -->
|
|
<a href="{{ base_url }}shop/account/messages"
|
|
class="block bg-white dark:bg-gray-800 rounded-lg shadow hover:shadow-lg transition-shadow p-6 border border-gray-200 dark:border-gray-700"
|
|
x-data="{ unreadCount: 0 }"
|
|
x-init="fetch('/api/v1/shop/messages/unread-count').then(r => r.json()).then(d => unreadCount = d.unread_count).catch(() => {})">
|
|
<div class="flex items-center mb-4">
|
|
<div class="flex-shrink-0 relative">
|
|
<span class="h-8 w-8 text-primary" style="color: var(--color-primary)" x-html="$icon('chat-bubble-left', 'h-8 w-8')"></span>
|
|
<span x-show="unreadCount > 0"
|
|
class="absolute -top-1 -right-1 inline-flex items-center justify-center px-1.5 py-0.5 text-xs font-bold leading-none text-white bg-red-600 rounded-full"
|
|
x-text="unreadCount > 9 ? '9+' : unreadCount"></span>
|
|
</div>
|
|
<div class="ml-4">
|
|
<h3 class="text-lg font-semibold text-gray-900 dark:text-white">Messages</h3>
|
|
<p class="text-sm text-gray-600 dark:text-gray-400">Contact support</p>
|
|
</div>
|
|
</div>
|
|
<div x-show="unreadCount > 0">
|
|
<p class="text-sm text-primary font-medium" style="color: var(--color-primary)" x-text="unreadCount + ' unread message' + (unreadCount > 1 ? 's' : '')"></p>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
|
|
<!-- Account Summary -->
|
|
<div class="bg-white dark:bg-gray-800 rounded-lg shadow p-6 border border-gray-200 dark:border-gray-700">
|
|
<h3 class="text-xl font-semibold text-gray-900 dark:text-white mb-6">Account Summary</h3>
|
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
|
<div>
|
|
<p class="text-sm text-gray-600 dark:text-gray-400 mb-1">Customer Since</p>
|
|
<p class="text-lg font-semibold text-gray-900 dark:text-white">{{ user.created_at.strftime('%B %Y') }}</p>
|
|
</div>
|
|
<div>
|
|
<p class="text-sm text-gray-600 dark:text-gray-400 mb-1">Total Orders</p>
|
|
<p class="text-lg font-semibold text-gray-900 dark:text-white">{{ user.total_orders }}</p>
|
|
</div>
|
|
<div>
|
|
<p class="text-sm text-gray-600 dark:text-gray-400 mb-1">Customer Number</p>
|
|
<p class="text-lg font-semibold text-gray-900 dark:text-white">{{ user.customer_number }}</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Quick Actions -->
|
|
<div class="mt-8 flex justify-end">
|
|
<button @click="showLogoutModal = true"
|
|
class="px-6 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors">
|
|
Logout
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Logout Confirmation Modal -->
|
|
{{ confirm_modal(
|
|
id='logoutModal',
|
|
title='Logout Confirmation',
|
|
message="Are you sure you want to logout? You'll need to sign in again to access your account.",
|
|
confirm_action='confirmLogout()',
|
|
show_var='showLogoutModal',
|
|
confirm_text='Logout',
|
|
cancel_text='Cancel',
|
|
variant='danger'
|
|
) }}
|
|
{% endblock %}
|
|
|
|
{% block extra_scripts %}
|
|
<script>
|
|
function accountDashboard() {
|
|
return {
|
|
...shopLayoutData(),
|
|
showLogoutModal: false,
|
|
|
|
confirmLogout() {
|
|
// Close modal
|
|
this.showLogoutModal = false;
|
|
|
|
fetch('/api/v1/shop/auth/logout', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
}
|
|
})
|
|
.then(response => {
|
|
if (response.ok) {
|
|
// Clear localStorage token if any
|
|
localStorage.removeItem('customer_token');
|
|
|
|
// Show success message
|
|
this.showToast('Logged out successfully', 'success');
|
|
|
|
// Redirect to login page
|
|
setTimeout(() => {
|
|
window.location.href = '{{ base_url }}shop/account/login';
|
|
}, 500);
|
|
} else {
|
|
console.error('Logout failed with status:', response.status);
|
|
this.showToast('Logout failed', 'error');
|
|
// Still redirect on failure (cookie might be deleted)
|
|
setTimeout(() => {
|
|
window.location.href = '{{ base_url }}shop/account/login';
|
|
}, 1000);
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('Logout error:', error);
|
|
this.showToast('Logout failed', 'error');
|
|
// Redirect anyway
|
|
setTimeout(() => {
|
|
window.location.href = '{{ base_url }}shop/account/login';
|
|
}, 1000);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
{% endblock %}
|