@caartzee/theme-sdk 0.0.0-stage → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +222 -2
- package/dist/bin/caartzee-theme.js +9223 -0
- package/dist/lib/index.js +11614 -0
- package/dist/types/src/auth/credentials-store.d.ts +18 -0
- package/dist/types/src/auth/index.d.ts +2 -0
- package/dist/types/src/auth/oauth-client.d.ts +39 -0
- package/dist/types/src/blocks/block-contract.d.ts +242 -0
- package/dist/types/src/candy/compatibility-matrix.d.ts +10 -0
- package/dist/types/src/candy/context-builder.d.ts +31 -0
- package/dist/types/src/candy/engine.d.ts +69 -0
- package/dist/types/src/candy/filters.d.ts +32 -0
- package/dist/types/src/candy/ide-support.d.ts +20 -0
- package/dist/types/src/candy/index.d.ts +9 -0
- package/dist/types/src/candy/schema-parser.d.ts +13 -0
- package/dist/types/src/candy/security.d.ts +54 -0
- package/dist/types/src/candy/tags.d.ts +11 -0
- package/dist/types/src/candy/types.d.ts +185 -0
- package/dist/types/src/cli/caartzee-cli.d.ts +9 -0
- package/dist/types/src/cli/candy-mcp.d.ts +2 -0
- package/dist/types/src/cli/candy-tool-server.d.ts +39 -0
- package/dist/types/src/cli/index.d.ts +1 -0
- package/dist/types/src/cli/mcp/component-tools.d.ts +2 -0
- package/dist/types/src/cli/mcp/docs-tools.d.ts +89 -0
- package/dist/types/src/cli/mcp/editor-tools.d.ts +22 -0
- package/dist/types/src/cli/mcp/resources-and-prompts.d.ts +2 -0
- package/dist/types/src/cli/mcp/testing-tools.d.ts +54 -0
- package/dist/types/src/cli/sdk-client.d.ts +12 -0
- package/dist/types/src/contracts/category-selection.d.ts +15 -0
- package/dist/types/src/contracts/commerce.d.ts +282 -0
- package/dist/types/src/contracts/footer-builder.d.ts +125 -0
- package/dist/types/src/contracts/hooks.d.ts +37 -0
- package/dist/types/src/contracts/manifest.d.ts +3127 -0
- package/dist/types/src/contracts/navigation.d.ts +39 -0
- package/dist/types/src/contracts/order-tracking.d.ts +40 -0
- package/dist/types/src/contracts/page.d.ts +262 -0
- package/dist/types/src/contracts/storefront-content.d.ts +60 -0
- package/dist/types/src/contracts/style-document.d.ts +2 -0
- package/dist/types/src/contracts/styles.d.ts +2002 -0
- package/dist/types/src/contracts/theme.d.ts +35 -0
- package/dist/types/src/dev-server/catalog-preview.d.ts +25 -0
- package/dist/types/src/dev-server/dev-server.d.ts +25 -0
- package/dist/types/src/dev-server/index.d.ts +1 -0
- package/dist/types/src/dev-server/local-commerce-runtime.d.ts +76 -0
- package/dist/types/src/dev-server/local-editor-server.d.ts +22 -0
- package/dist/types/src/dev-server/theme-preview.d.ts +8 -0
- package/dist/types/src/index.d.ts +27 -0
- package/dist/types/src/mock/index.d.ts +10 -0
- package/dist/types/src/mock/mock-categories.d.ts +2 -0
- package/dist/types/src/mock/mock-commerce.d.ts +55 -0
- package/dist/types/src/mock/mock-customer.d.ts +47 -0
- package/dist/types/src/mock/mock-hooks.d.ts +2 -0
- package/dist/types/src/mock/mock-products.d.ts +3 -0
- package/dist/types/src/rendering/commerce-pages.d.ts +16 -0
- package/dist/types/src/rendering/raw-html.d.ts +12 -0
- package/dist/types/src/rendering/section-wrapper.d.ts +30 -0
- package/dist/types/src/scaffold/candy-starter-assets.d.ts +2 -0
- package/dist/types/src/scaffold/commerce-generator.d.ts +3 -0
- package/dist/types/src/scaffold/index.d.ts +2 -0
- package/dist/types/src/scaffold/template-generator.d.ts +21 -0
- package/dist/types/src/sections/section-contract.d.ts +350 -0
- package/dist/types/src/settings/global-settings.d.ts +25 -0
- package/dist/types/src/templates/json-template.d.ts +991 -0
- package/dist/types/src/validation/package-validator.d.ts +53 -0
- package/dist/types/src/validation/rich-text.d.ts +24 -0
- package/package.json +29 -3
- package/templates/commerce/README.md +165 -0
- package/templates/commerce/assets/theme.css +1 -0
- package/templates/commerce/manifest.json +1 -0
- package/templates/commerce/src/blocks/index.ts +184 -0
- package/templates/commerce/src/config/settings-defaults.ts +25 -0
- package/templates/commerce/src/config/settings-schema.ts +102 -0
- package/templates/commerce/src/index.ts +90 -0
- package/templates/commerce/src/layouts/default.ts +275 -0
- package/templates/commerce/src/manifest.ts +976 -0
- package/templates/commerce/src/pages/account/components.ts +369 -0
- package/templates/commerce/src/pages/account/tabs.ts +792 -0
- package/templates/commerce/src/pages/account.ts +55 -0
- package/templates/commerce/src/pages/campaign.ts +423 -0
- package/templates/commerce/src/pages/cart.ts +261 -0
- package/templates/commerce/src/pages/category-detail.ts +124 -0
- package/templates/commerce/src/pages/category-list.ts +87 -0
- package/templates/commerce/src/pages/checkout.ts +712 -0
- package/templates/commerce/src/pages/commerce.ts +45 -0
- package/templates/commerce/src/pages/home.ts +160 -0
- package/templates/commerce/src/pages/index.ts +99 -0
- package/templates/commerce/src/pages/login.ts +204 -0
- package/templates/commerce/src/pages/order-success.ts +80 -0
- package/templates/commerce/src/pages/product-detail.ts +489 -0
- package/templates/commerce/src/pages/product-list.ts +125 -0
- package/templates/commerce/src/pages/search.ts +88 -0
- package/templates/commerce/src/pages/signup.ts +253 -0
- package/templates/commerce/src/pages/status.ts +7 -0
- package/templates/commerce/src/pages/theme-layout.ts +491 -0
- package/templates/commerce/src/pages/track-order.ts +196 -0
- package/templates/commerce/src/pages/wishlist.ts +83 -0
- package/templates/commerce/src/sections/about-story.ts +117 -0
- package/templates/commerce/src/sections/announcement-bar.ts +101 -0
- package/templates/commerce/src/sections/banner-grid.ts +319 -0
- package/templates/commerce/src/sections/campaign-banners.ts +158 -0
- package/templates/commerce/src/sections/category-slider.ts +144 -0
- package/templates/commerce/src/sections/content-builder.ts +123 -0
- package/templates/commerce/src/sections/content-controls.ts +45 -0
- package/templates/commerce/src/sections/custom-form.ts +59 -0
- package/templates/commerce/src/sections/faq-accordion.ts +123 -0
- package/templates/commerce/src/sections/footer.ts +728 -0
- package/templates/commerce/src/sections/header.ts +439 -0
- package/templates/commerce/src/sections/hero-slider.ts +492 -0
- package/templates/commerce/src/sections/hero.ts +137 -0
- package/templates/commerce/src/sections/index.ts +102 -0
- package/templates/commerce/src/sections/mobile-slider.ts +102 -0
- package/templates/commerce/src/sections/newsletter.ts +43 -0
- package/templates/commerce/src/sections/product-grid.ts +191 -0
- package/templates/commerce/src/sections/raw-html.ts +1 -0
- package/templates/commerce/src/sections/rich-text.ts +26 -0
- package/templates/commerce/src/sections/services-features.ts +211 -0
- package/templates/commerce/src/sections/testimonials.ts +194 -0
- package/templates/commerce/src/snippets/product-card.ts +178 -0
- package/templates/commerce/src/snippets/product-price.ts +46 -0
- package/templates/commerce/src/snippets/responsive-image.ts +29 -0
- package/templates/commerce/src/styles.ts +477 -0
- package/templates/commerce/src/templates/404.json +26 -0
- package/templates/commerce/src/templates/account.json +17 -0
- package/templates/commerce/src/templates/cart.json +17 -0
- package/templates/commerce/src/templates/category.json +16 -0
- package/templates/commerce/src/templates/checkout.json +15 -0
- package/templates/commerce/src/templates/collection.json +16 -0
- package/templates/commerce/src/templates/index.json +180 -0
- package/templates/commerce/src/templates/login.json +17 -0
- package/templates/commerce/src/templates/order-success.json +17 -0
- package/templates/commerce/src/templates/page.json +17 -0
- package/templates/commerce/src/templates/product.json +17 -0
- package/templates/commerce/src/templates/search.json +18 -0
- package/templates/commerce/src/templates/signup.json +17 -0
- package/templates/commerce/src/templates/track-order.json +17 -0
- package/templates/commerce/src/templates/wishlist.json +17 -0
- package/templates/commerce/src/templates.ts +510 -0
- package/templates/commerce/src/tokens.ts +22 -0
- package/templates/theme-candy-boilerplate/.editorconfig +14 -0
- package/templates/theme-candy-boilerplate/.gitattributes +1 -0
- package/templates/theme-candy-boilerplate/.vscode/extensions.json +7 -0
- package/templates/theme-candy-boilerplate/.vscode/settings.json +17 -0
- package/templates/theme-candy-boilerplate/assets/theme.css +78 -0
- package/templates/theme-candy-boilerplate/assets/theme.js +7 -0
- package/templates/theme-candy-boilerplate/candy.config.json +40 -0
- package/templates/theme-candy-boilerplate/index.ts +39 -0
- package/templates/theme-candy-boilerplate/layout/theme.candy +25 -0
- package/templates/theme-candy-boilerplate/locales/en.default.json +37 -0
- package/templates/theme-candy-boilerplate/manifest.json +123 -0
- package/templates/theme-candy-boilerplate/package.json +16 -0
- package/templates/theme-candy-boilerplate/schemas/settings_schema.json +36 -0
- package/templates/theme-candy-boilerplate/sections/featured-products.candy +89 -0
- package/templates/theme-candy-boilerplate/sections/footer.candy +50 -0
- package/templates/theme-candy-boilerplate/sections/header.candy +116 -0
- package/templates/theme-candy-boilerplate/sections/hero-banner.candy +135 -0
- package/templates/theme-candy-boilerplate/sections/image-with-text.candy +85 -0
- package/templates/theme-candy-boilerplate/snippets/price.candy +19 -0
- package/templates/theme-candy-boilerplate/snippets/product-card.candy +43 -0
- package/templates/theme-candy-boilerplate/templates/404.candy +12 -0
- package/templates/theme-candy-boilerplate/templates/cart.candy +51 -0
- package/templates/theme-candy-boilerplate/templates/collection.candy +51 -0
- package/templates/theme-candy-boilerplate/templates/index.candy +7 -0
- package/templates/theme-candy-boilerplate/templates/page.candy +10 -0
- package/templates/theme-candy-boilerplate/templates/product.candy +59 -0
- package/templates/theme-candy-boilerplate/templates/search.candy +40 -0
- package/templates/vscode-candy/LICENSE +21 -0
- package/templates/vscode-candy/README.md +22 -0
- package/templates/vscode-candy/extension.js +689 -0
- package/templates/vscode-candy/icons/candy-dark.svg +23 -0
- package/templates/vscode-candy/icons/candy-light.svg +23 -0
- package/templates/vscode-candy/icons/candy-logo.png +0 -0
- package/templates/vscode-candy/icons/candy-sweet-dark.svg +23 -0
- package/templates/vscode-candy/icons/candy-sweet-light.svg +23 -0
- package/templates/vscode-candy/language-configuration.json +47 -0
- package/templates/vscode-candy/package.json +118 -0
- package/templates/vscode-candy/schemas/candy-config.schema.json +56 -0
- package/templates/vscode-candy/schemas/candy-settings.schema.json +70 -0
- package/templates/vscode-candy/snippets/candy.code-snippets +270 -0
- package/templates/vscode-candy/syntaxes/candy.tmLanguage.json +296 -0
- package/templates/vscode-candy/vim/ftdetect/candy.vim +5 -0
|
@@ -0,0 +1,792 @@
|
|
|
1
|
+
import type { AccountPageData } from '@caartzee/theme-sdk';
|
|
2
|
+
import {
|
|
3
|
+
escapeHtml,
|
|
4
|
+
renderAccountPageHeader,
|
|
5
|
+
renderAccountCard,
|
|
6
|
+
renderAccountEmptyState,
|
|
7
|
+
resolveCustomerIdentity,
|
|
8
|
+
IconOrders,
|
|
9
|
+
IconAddresses,
|
|
10
|
+
IconShield,
|
|
11
|
+
IconPhone,
|
|
12
|
+
IconTrash,
|
|
13
|
+
IconDownloads,
|
|
14
|
+
IconChevronRight,
|
|
15
|
+
} from './components';
|
|
16
|
+
|
|
17
|
+
function getStatusBadge(status?: string): string {
|
|
18
|
+
const st = (status || 'processing').toLowerCase();
|
|
19
|
+
if (st.includes('deliver') || st.includes('complete') || st.includes('success')) {
|
|
20
|
+
return `
|
|
21
|
+
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold bg-emerald-50 dark:bg-emerald-950/40 text-emerald-700 dark:text-emerald-400 border border-emerald-200 dark:border-emerald-800">
|
|
22
|
+
${escapeHtml(status || 'Delivered')}
|
|
23
|
+
</span>
|
|
24
|
+
`;
|
|
25
|
+
}
|
|
26
|
+
if (st.includes('cancel') || st.includes('fail')) {
|
|
27
|
+
return `
|
|
28
|
+
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold bg-rose-50 dark:bg-rose-950/40 text-rose-700 dark:text-rose-400 border border-rose-200 dark:border-rose-800">
|
|
29
|
+
${escapeHtml(status || 'Cancelled')}
|
|
30
|
+
</span>
|
|
31
|
+
`;
|
|
32
|
+
}
|
|
33
|
+
if (st.includes('transit') || st.includes('ship')) {
|
|
34
|
+
return `
|
|
35
|
+
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold bg-indigo-50 dark:bg-indigo-950/40 text-indigo-700 dark:text-indigo-400 border border-indigo-200 dark:border-indigo-800">
|
|
36
|
+
${escapeHtml(status || 'In Transit')}
|
|
37
|
+
</span>
|
|
38
|
+
`;
|
|
39
|
+
}
|
|
40
|
+
return `
|
|
41
|
+
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold bg-amber-50 dark:bg-amber-950/40 text-amber-700 dark:text-amber-400 border border-amber-200 dark:border-amber-800">
|
|
42
|
+
${escapeHtml(status || 'Processing')}
|
|
43
|
+
</span>
|
|
44
|
+
`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function getPaymentBadge(status?: string): string {
|
|
48
|
+
if (!status) return '';
|
|
49
|
+
const st = status.toLowerCase();
|
|
50
|
+
if (st === 'success' || st === 'complete' || st === 'paid') {
|
|
51
|
+
return `
|
|
52
|
+
<span class="inline-flex items-center px-2 py-0.5 rounded-md text-[11px] font-bold uppercase tracking-wider bg-emerald-50 text-emerald-700 border border-emerald-200">
|
|
53
|
+
Paid
|
|
54
|
+
</span>
|
|
55
|
+
`;
|
|
56
|
+
}
|
|
57
|
+
return `
|
|
58
|
+
<span class="inline-flex items-center px-2 py-0.5 rounded-md text-[11px] font-bold uppercase tracking-wider bg-slate-100 text-slate-600 border border-slate-200">
|
|
59
|
+
${escapeHtml(status)}
|
|
60
|
+
</span>
|
|
61
|
+
`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function resolveOrderPrice(ord: any, currencyInfo?: any): string {
|
|
65
|
+
if (ord.formattedTotal) return ord.formattedTotal;
|
|
66
|
+
const num = Number(ord.total ?? ord.totalAmount ?? 0);
|
|
67
|
+
const sym = currencyInfo?.symbol || (currencyInfo?.currencySymbol) || '₹';
|
|
68
|
+
return `${sym}${num.toLocaleString('en-IN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ===========================================================================
|
|
72
|
+
// 1. Overview Tab (/account)
|
|
73
|
+
// ===========================================================================
|
|
74
|
+
|
|
75
|
+
export function renderOverviewTab(data: AccountPageData): string {
|
|
76
|
+
const { name } = resolveCustomerIdentity(data.customer);
|
|
77
|
+
const orders = Array.isArray(data.orders) ? data.orders : [];
|
|
78
|
+
const recentOrders = orders.slice(0, 4);
|
|
79
|
+
|
|
80
|
+
const header = renderAccountPageHeader({
|
|
81
|
+
title: `Welcome back, ${name}`,
|
|
82
|
+
description: 'From your account dashboard you can view your recent orders, manage your shipping addresses, and edit your profile details.',
|
|
83
|
+
actionHtml: `
|
|
84
|
+
<a href="/track-order" class="px-4 py-2 rounded-xl bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 hover:bg-slate-50 dark:hover:bg-slate-700/60 text-slate-700 dark:text-slate-200 text-xs font-semibold transition-all shadow-sm">
|
|
85
|
+
Track Order
|
|
86
|
+
</a>
|
|
87
|
+
`,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const addressCountLabel = Array.isArray(data.savedAddresses)
|
|
91
|
+
? `${data.savedAddresses.length} ${data.savedAddresses.length === 1 ? 'Address' : 'Addresses'}`
|
|
92
|
+
: 'Manage';
|
|
93
|
+
|
|
94
|
+
const totalOrdersCount = data.ordersError ? '—' : String(orders.length);
|
|
95
|
+
|
|
96
|
+
const summaryCards = `
|
|
97
|
+
<div class="grid grid-cols-1 sm:grid-cols-3 gap-4 sm:gap-6">
|
|
98
|
+
|
|
99
|
+
<!-- Card 1: Orders -->
|
|
100
|
+
<a
|
|
101
|
+
href="/account/orders"
|
|
102
|
+
class="group bg-white dark:bg-slate-900 rounded-3xl border border-slate-200/80 dark:border-slate-800 shadow-sm p-6 hover:border-indigo-300 dark:hover:border-indigo-700 hover:shadow-md transition-all flex flex-col justify-between"
|
|
103
|
+
>
|
|
104
|
+
<div>
|
|
105
|
+
<div class="w-10 h-10 rounded-xl bg-indigo-50 dark:bg-indigo-950/60 text-indigo-600 dark:text-indigo-400 flex items-center justify-center mb-4 group-hover:scale-105 transition-transform">
|
|
106
|
+
${IconOrders}
|
|
107
|
+
</div>
|
|
108
|
+
<span class="text-xs font-bold uppercase tracking-wider text-slate-400">Total Orders</span>
|
|
109
|
+
<div class="text-2xl font-black text-slate-900 dark:text-white mt-1">
|
|
110
|
+
${totalOrdersCount}
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
<div class="flex items-center justify-between text-xs font-semibold text-indigo-600 dark:text-indigo-400 pt-4 mt-4 border-t border-slate-100 dark:border-slate-800">
|
|
114
|
+
<span>View all orders</span>
|
|
115
|
+
${IconChevronRight}
|
|
116
|
+
</div>
|
|
117
|
+
</a>
|
|
118
|
+
|
|
119
|
+
<!-- Card 2: Saved Addresses -->
|
|
120
|
+
<a
|
|
121
|
+
href="/account/addresses"
|
|
122
|
+
class="group bg-white dark:bg-slate-900 rounded-3xl border border-slate-200/80 dark:border-slate-800 shadow-sm p-6 hover:border-indigo-300 dark:hover:border-indigo-700 hover:shadow-md transition-all flex flex-col justify-between"
|
|
123
|
+
>
|
|
124
|
+
<div>
|
|
125
|
+
<div class="w-10 h-10 rounded-xl bg-emerald-50 dark:bg-emerald-950/60 text-emerald-600 dark:text-emerald-400 flex items-center justify-center mb-4 group-hover:scale-105 transition-transform">
|
|
126
|
+
${IconAddresses}
|
|
127
|
+
</div>
|
|
128
|
+
<span class="text-xs font-bold uppercase tracking-wider text-slate-400">Saved Addresses</span>
|
|
129
|
+
<div class="text-2xl font-black text-slate-900 dark:text-white mt-1">
|
|
130
|
+
${escapeHtml(addressCountLabel)}
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
<div class="flex items-center justify-between text-xs font-semibold text-indigo-600 dark:text-indigo-400 pt-4 mt-4 border-t border-slate-100 dark:border-slate-800">
|
|
134
|
+
<span>Manage addresses</span>
|
|
135
|
+
${IconChevronRight}
|
|
136
|
+
</div>
|
|
137
|
+
</a>
|
|
138
|
+
|
|
139
|
+
<!-- Card 3: Profile & Security -->
|
|
140
|
+
<a
|
|
141
|
+
href="/account/profile"
|
|
142
|
+
class="group bg-white dark:bg-slate-900 rounded-3xl border border-slate-200/80 dark:border-slate-800 shadow-sm p-6 hover:border-indigo-300 dark:hover:border-indigo-700 hover:shadow-md transition-all flex flex-col justify-between"
|
|
143
|
+
>
|
|
144
|
+
<div>
|
|
145
|
+
<div class="w-10 h-10 rounded-xl bg-amber-50 dark:bg-amber-950/60 text-amber-600 dark:text-amber-400 flex items-center justify-center mb-4 group-hover:scale-105 transition-transform">
|
|
146
|
+
${IconShield}
|
|
147
|
+
</div>
|
|
148
|
+
<span class="text-xs font-bold uppercase tracking-wider text-slate-400">Security</span>
|
|
149
|
+
<div class="text-2xl font-black text-slate-900 dark:text-white mt-1">
|
|
150
|
+
Profile Settings
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
<div class="flex items-center justify-between text-xs font-semibold text-indigo-600 dark:text-indigo-400 pt-4 mt-4 border-t border-slate-100 dark:border-slate-800">
|
|
154
|
+
<span>Edit password & info</span>
|
|
155
|
+
${IconChevronRight}
|
|
156
|
+
</div>
|
|
157
|
+
</a>
|
|
158
|
+
|
|
159
|
+
</div>
|
|
160
|
+
`;
|
|
161
|
+
|
|
162
|
+
let recentOrdersContent = '';
|
|
163
|
+
if (recentOrders.length > 0) {
|
|
164
|
+
recentOrdersContent = `
|
|
165
|
+
<div class="overflow-x-auto">
|
|
166
|
+
<table class="w-full text-left text-sm">
|
|
167
|
+
<thead>
|
|
168
|
+
<tr class="border-b border-slate-100 dark:border-slate-800 text-xs font-bold uppercase tracking-wider text-slate-400">
|
|
169
|
+
<th class="py-3 px-4">Order #</th>
|
|
170
|
+
<th class="py-3 px-4">Date</th>
|
|
171
|
+
<th class="py-3 px-4">Status</th>
|
|
172
|
+
<th class="py-3 px-4">Total</th>
|
|
173
|
+
<th class="py-3 px-4 text-right">Action</th>
|
|
174
|
+
</tr>
|
|
175
|
+
</thead>
|
|
176
|
+
<tbody class="divide-y divide-slate-100 dark:divide-slate-800/60">
|
|
177
|
+
${recentOrders.map((ord: any) => {
|
|
178
|
+
const id = String(ord.orderNumber || ord.id || 'N/A');
|
|
179
|
+
const date = String(ord.createdAt || ord.created_at || ord.date || 'Recent');
|
|
180
|
+
const status = String(ord.status || 'Processing');
|
|
181
|
+
const total = resolveOrderPrice(ord, data.currencyInfo);
|
|
182
|
+
|
|
183
|
+
return `
|
|
184
|
+
<tr class="hover:bg-slate-50 dark:hover:bg-slate-800/40 transition-colors">
|
|
185
|
+
<td class="py-4 px-4 font-bold text-indigo-600 dark:text-indigo-400 font-mono">
|
|
186
|
+
#${escapeHtml(id)}
|
|
187
|
+
</td>
|
|
188
|
+
<td class="py-4 px-4 text-slate-600 dark:text-slate-300">
|
|
189
|
+
${escapeHtml(date)}
|
|
190
|
+
</td>
|
|
191
|
+
<td class="py-4 px-4">
|
|
192
|
+
${getStatusBadge(status)}
|
|
193
|
+
</td>
|
|
194
|
+
<td class="py-4 px-4 font-bold text-slate-900 dark:text-white">
|
|
195
|
+
${escapeHtml(total)}
|
|
196
|
+
</td>
|
|
197
|
+
<td class="py-4 px-4 text-right">
|
|
198
|
+
<a
|
|
199
|
+
href="/account/orders/${encodeURIComponent(String(ord.id || id))}"
|
|
200
|
+
class="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-xs font-semibold text-slate-700 dark:text-slate-200 bg-slate-100 dark:bg-slate-800 hover:bg-indigo-50 hover:text-indigo-600 dark:hover:bg-slate-700 transition-colors"
|
|
201
|
+
>
|
|
202
|
+
<span>View order</span>
|
|
203
|
+
${IconChevronRight}
|
|
204
|
+
</a>
|
|
205
|
+
</td>
|
|
206
|
+
</tr>
|
|
207
|
+
`;
|
|
208
|
+
}).join('')}
|
|
209
|
+
</tbody>
|
|
210
|
+
</table>
|
|
211
|
+
</div>
|
|
212
|
+
${orders.length > 4 ? `
|
|
213
|
+
<div class="pt-5 mt-4 border-t border-slate-100 dark:border-slate-800 text-center sm:text-right">
|
|
214
|
+
<a href="/account/orders" class="inline-flex items-center gap-1.5 text-xs font-bold text-indigo-600 dark:text-indigo-400 hover:text-indigo-700 transition-colors">
|
|
215
|
+
<span>View all ${orders.length} orders</span>
|
|
216
|
+
${IconChevronRight}
|
|
217
|
+
</a>
|
|
218
|
+
</div>
|
|
219
|
+
` : ''}
|
|
220
|
+
`;
|
|
221
|
+
} else if (data.ordersError) {
|
|
222
|
+
recentOrdersContent = renderAccountEmptyState({
|
|
223
|
+
title: 'Unable to load your orders',
|
|
224
|
+
description: data.ordersError || 'Unable to load your orders. Please try again.',
|
|
225
|
+
actionUrl: '/account',
|
|
226
|
+
actionLabel: 'Try Again',
|
|
227
|
+
});
|
|
228
|
+
} else {
|
|
229
|
+
recentOrdersContent = renderAccountEmptyState({
|
|
230
|
+
title: 'No orders placed yet',
|
|
231
|
+
description: 'Once you complete an order, your tracking details and receipts will appear here.',
|
|
232
|
+
actionUrl: '/products',
|
|
233
|
+
actionLabel: 'Browse Catalog',
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const recentOrdersCard = renderAccountCard({
|
|
238
|
+
title: 'Recent Orders',
|
|
239
|
+
description: 'Your latest purchases, shipment status, and Order History',
|
|
240
|
+
body: recentOrdersContent,
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
return header + summaryCards + recentOrdersCard;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// ===========================================================================
|
|
247
|
+
// 2. Orders Tab (/account/orders)
|
|
248
|
+
// ===========================================================================
|
|
249
|
+
|
|
250
|
+
export function renderOrdersTab(data: AccountPageData): string {
|
|
251
|
+
const orders = Array.isArray(data.orders) ? data.orders : [];
|
|
252
|
+
|
|
253
|
+
const header = renderAccountPageHeader({
|
|
254
|
+
title: 'My Orders',
|
|
255
|
+
description: 'View and track all your past purchases and ongoing orders.',
|
|
256
|
+
badge: data.ordersError ? 'Unavailable' : `${orders.length} ${orders.length === 1 ? 'order' : 'orders'}`,
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
let ordersContent = '';
|
|
260
|
+
if (orders.length > 0) {
|
|
261
|
+
ordersContent = `
|
|
262
|
+
<div class="overflow-x-auto">
|
|
263
|
+
<table class="w-full text-left text-sm">
|
|
264
|
+
<thead>
|
|
265
|
+
<tr class="border-b border-slate-100 dark:border-slate-800 text-xs font-bold uppercase tracking-wider text-slate-400">
|
|
266
|
+
<th class="py-3 px-4">Order #</th>
|
|
267
|
+
<th class="py-3 px-4">Date</th>
|
|
268
|
+
<th class="py-3 px-4">Status</th>
|
|
269
|
+
<th class="py-3 px-4">Payment</th>
|
|
270
|
+
<th class="py-3 px-4">Total</th>
|
|
271
|
+
<th class="py-3 px-4 text-right">Action</th>
|
|
272
|
+
</tr>
|
|
273
|
+
</thead>
|
|
274
|
+
<tbody class="divide-y divide-slate-100 dark:divide-slate-800/60">
|
|
275
|
+
${orders.map((ord: any) => {
|
|
276
|
+
const id = String(ord.orderNumber || ord.id || 'N/A');
|
|
277
|
+
const date = String(ord.createdAt || ord.created_at || ord.date || 'Recent');
|
|
278
|
+
const status = String(ord.status || 'Processing');
|
|
279
|
+
const paymentStatus = ord.paymentStatus || ord.payment_status || null;
|
|
280
|
+
const total = resolveOrderPrice(ord, data.currencyInfo);
|
|
281
|
+
|
|
282
|
+
return `
|
|
283
|
+
<tr class="hover:bg-slate-50 dark:hover:bg-slate-800/40 transition-colors">
|
|
284
|
+
<td class="py-4 px-4 font-bold text-indigo-600 dark:text-indigo-400 font-mono">
|
|
285
|
+
#${escapeHtml(id)}
|
|
286
|
+
</td>
|
|
287
|
+
<td class="py-4 px-4 text-slate-600 dark:text-slate-300">
|
|
288
|
+
${escapeHtml(date)}
|
|
289
|
+
</td>
|
|
290
|
+
<td class="py-4 px-4">
|
|
291
|
+
${getStatusBadge(status)}
|
|
292
|
+
</td>
|
|
293
|
+
<td class="py-4 px-4">
|
|
294
|
+
${getPaymentBadge(paymentStatus)}
|
|
295
|
+
</td>
|
|
296
|
+
<td class="py-4 px-4 font-bold text-slate-900 dark:text-white">
|
|
297
|
+
${escapeHtml(total)}
|
|
298
|
+
</td>
|
|
299
|
+
<td class="py-4 px-4 text-right">
|
|
300
|
+
<a
|
|
301
|
+
href="/account/orders/${encodeURIComponent(String(ord.id || id))}"
|
|
302
|
+
class="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-xs font-semibold text-slate-700 dark:text-slate-200 bg-slate-100 dark:bg-slate-800 hover:bg-indigo-50 hover:text-indigo-600 dark:hover:bg-slate-700 transition-colors"
|
|
303
|
+
>
|
|
304
|
+
<span>View order</span>
|
|
305
|
+
${IconChevronRight}
|
|
306
|
+
</a>
|
|
307
|
+
</td>
|
|
308
|
+
</tr>
|
|
309
|
+
`;
|
|
310
|
+
}).join('')}
|
|
311
|
+
</tbody>
|
|
312
|
+
</table>
|
|
313
|
+
</div>
|
|
314
|
+
`;
|
|
315
|
+
} else if (data.ordersError) {
|
|
316
|
+
ordersContent = renderAccountEmptyState({
|
|
317
|
+
title: 'Unable to load your orders',
|
|
318
|
+
description: data.ordersError || 'Unable to load your orders. Please try again.',
|
|
319
|
+
actionUrl: '/account/orders',
|
|
320
|
+
actionLabel: 'Try Again',
|
|
321
|
+
});
|
|
322
|
+
} else {
|
|
323
|
+
ordersContent = renderAccountEmptyState({
|
|
324
|
+
title: 'No orders placed yet',
|
|
325
|
+
description: 'Once you place an order, your tracking details and receipts will appear here.',
|
|
326
|
+
actionUrl: '/products',
|
|
327
|
+
actionLabel: 'Browse Catalog',
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const card = renderAccountCard({
|
|
332
|
+
title: 'Order History',
|
|
333
|
+
description: 'Complete purchase records and shipment status',
|
|
334
|
+
body: ordersContent,
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
return header + card;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// ===========================================================================
|
|
341
|
+
// 3. Profile Tab (/account/profile)
|
|
342
|
+
// ===========================================================================
|
|
343
|
+
|
|
344
|
+
export function renderProfileTab(data: AccountPageData): string {
|
|
345
|
+
const customer = data.customer || {};
|
|
346
|
+
|
|
347
|
+
const header = renderAccountPageHeader({
|
|
348
|
+
title: 'Profile Settings',
|
|
349
|
+
description: 'Manage your personal identity information and update your security password.',
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
const personalInfoBody = `
|
|
353
|
+
<form data-v2-action="profile" class="space-y-5">
|
|
354
|
+
<div class="grid grid-cols-1 sm:grid-cols-2 gap-5">
|
|
355
|
+
<div>
|
|
356
|
+
<label class="block text-xs font-bold uppercase tracking-wider text-slate-700 dark:text-slate-300 mb-1.5">
|
|
357
|
+
Full Name <span class="text-rose-500">*</span>
|
|
358
|
+
</label>
|
|
359
|
+
<input
|
|
360
|
+
name="name"
|
|
361
|
+
type="text"
|
|
362
|
+
required
|
|
363
|
+
maxlength="191"
|
|
364
|
+
value="${escapeHtml(customer?.name || '')}"
|
|
365
|
+
placeholder="John Doe"
|
|
366
|
+
class="w-full h-11 px-3.5 rounded-xl border border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 text-slate-900 dark:text-white placeholder-slate-400 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-500 transition-all"
|
|
367
|
+
>
|
|
368
|
+
</div>
|
|
369
|
+
|
|
370
|
+
<div>
|
|
371
|
+
<label class="block text-xs font-bold uppercase tracking-wider text-slate-700 dark:text-slate-300 mb-1.5">
|
|
372
|
+
Email Address <span class="text-rose-500">*</span>
|
|
373
|
+
</label>
|
|
374
|
+
<input
|
|
375
|
+
name="email"
|
|
376
|
+
type="email"
|
|
377
|
+
required
|
|
378
|
+
value="${escapeHtml(customer?.email || '')}"
|
|
379
|
+
placeholder="john@example.com"
|
|
380
|
+
class="w-full h-11 px-3.5 rounded-xl border border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 text-slate-900 dark:text-white placeholder-slate-400 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-500 transition-all"
|
|
381
|
+
>
|
|
382
|
+
</div>
|
|
383
|
+
</div>
|
|
384
|
+
|
|
385
|
+
${customer?.phone || customer?.mobile ? `
|
|
386
|
+
<div>
|
|
387
|
+
<label class="block text-xs font-bold uppercase tracking-wider text-slate-700 dark:text-slate-300 mb-1.5">
|
|
388
|
+
Phone Number
|
|
389
|
+
</label>
|
|
390
|
+
<input
|
|
391
|
+
name="phone"
|
|
392
|
+
type="tel"
|
|
393
|
+
value="${escapeHtml(customer?.phone || customer?.mobile || '')}"
|
|
394
|
+
class="w-full h-11 px-3.5 rounded-xl border border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 text-slate-900 dark:text-white placeholder-slate-400 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-500 transition-all"
|
|
395
|
+
>
|
|
396
|
+
</div>
|
|
397
|
+
` : ''}
|
|
398
|
+
|
|
399
|
+
<div class="flex items-center gap-4 pt-3 border-t border-slate-100 dark:border-slate-800">
|
|
400
|
+
<button
|
|
401
|
+
type="submit"
|
|
402
|
+
class="px-6 py-2.5 rounded-xl bg-indigo-600 hover:bg-indigo-700 text-white font-semibold text-sm shadow-md shadow-indigo-500/20 active:scale-95 transition-all cursor-pointer"
|
|
403
|
+
>
|
|
404
|
+
Save Changes
|
|
405
|
+
</button>
|
|
406
|
+
<p data-v2-feedback role="status" aria-live="polite" class="text-sm font-medium text-slate-600 dark:text-slate-400"></p>
|
|
407
|
+
</div>
|
|
408
|
+
</form>
|
|
409
|
+
`;
|
|
410
|
+
|
|
411
|
+
const passwordBody = `
|
|
412
|
+
<form data-v2-action="password" class="space-y-5">
|
|
413
|
+
<div class="grid grid-cols-1 sm:grid-cols-2 gap-5">
|
|
414
|
+
<div>
|
|
415
|
+
<label class="block text-xs font-bold uppercase tracking-wider text-slate-700 dark:text-slate-300 mb-1.5">
|
|
416
|
+
New Password <span class="text-rose-500">*</span>
|
|
417
|
+
</label>
|
|
418
|
+
<input
|
|
419
|
+
type="password"
|
|
420
|
+
name="password"
|
|
421
|
+
minlength="8"
|
|
422
|
+
required
|
|
423
|
+
autocomplete="new-password"
|
|
424
|
+
placeholder="At least 8 characters"
|
|
425
|
+
class="w-full h-11 px-3.5 rounded-xl border border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 text-slate-900 dark:text-white placeholder-slate-400 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-500 transition-all"
|
|
426
|
+
>
|
|
427
|
+
</div>
|
|
428
|
+
|
|
429
|
+
<div>
|
|
430
|
+
<label class="block text-xs font-bold uppercase tracking-wider text-slate-700 dark:text-slate-300 mb-1.5">
|
|
431
|
+
Confirm Password <span class="text-rose-500">*</span>
|
|
432
|
+
</label>
|
|
433
|
+
<input
|
|
434
|
+
type="password"
|
|
435
|
+
name="confirmation"
|
|
436
|
+
minlength="8"
|
|
437
|
+
required
|
|
438
|
+
autocomplete="new-password"
|
|
439
|
+
placeholder="Re-enter your password"
|
|
440
|
+
class="w-full h-11 px-3.5 rounded-xl border border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 text-slate-900 dark:text-white placeholder-slate-400 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-500 transition-all"
|
|
441
|
+
>
|
|
442
|
+
</div>
|
|
443
|
+
</div>
|
|
444
|
+
|
|
445
|
+
<div class="flex items-center gap-4 pt-3 border-t border-slate-100 dark:border-slate-800">
|
|
446
|
+
<button
|
|
447
|
+
type="submit"
|
|
448
|
+
class="px-6 py-2.5 rounded-xl bg-slate-900 hover:bg-slate-800 text-white dark:bg-slate-100 dark:text-slate-900 dark:hover:bg-white font-semibold text-sm shadow-sm active:scale-95 transition-all cursor-pointer"
|
|
449
|
+
>
|
|
450
|
+
Update Password
|
|
451
|
+
</button>
|
|
452
|
+
<p data-v2-feedback role="status" aria-live="polite" class="text-sm font-medium text-slate-600 dark:text-slate-400"></p>
|
|
453
|
+
</div>
|
|
454
|
+
</form>
|
|
455
|
+
`;
|
|
456
|
+
|
|
457
|
+
const personalCard = renderAccountCard({
|
|
458
|
+
title: 'Personal Information',
|
|
459
|
+
description: 'Update your name and contact details',
|
|
460
|
+
body: personalInfoBody,
|
|
461
|
+
classNames: 'mb-8',
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
const passwordCard = renderAccountCard({
|
|
465
|
+
title: 'Password & Security',
|
|
466
|
+
description: 'Ensure your account is protected with a secure password',
|
|
467
|
+
body: passwordBody,
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
return header + personalCard + passwordCard;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// ===========================================================================
|
|
474
|
+
// 4. Addresses Tab (/account/addresses)
|
|
475
|
+
// ===========================================================================
|
|
476
|
+
|
|
477
|
+
export function renderAddressesTab(data: AccountPageData): string {
|
|
478
|
+
const addresses = data.savedAddresses;
|
|
479
|
+
const countries = Array.isArray(data.countries) ? data.countries : [];
|
|
480
|
+
|
|
481
|
+
const header = renderAccountPageHeader({
|
|
482
|
+
title: 'My Addresses',
|
|
483
|
+
description: 'Manage your saved delivery addresses.',
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
let addressListHtml = '';
|
|
487
|
+
if (addresses === null) {
|
|
488
|
+
addressListHtml = `
|
|
489
|
+
<div class="p-4 rounded-2xl bg-amber-50 dark:bg-amber-950/40 border border-amber-200 dark:border-amber-800 text-amber-800 dark:text-amber-300 text-sm font-medium">
|
|
490
|
+
Addresses could not be loaded. Please try again.
|
|
491
|
+
</div>
|
|
492
|
+
`;
|
|
493
|
+
} else if (Array.isArray(addresses) && addresses.length > 0) {
|
|
494
|
+
addressListHtml = `
|
|
495
|
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
496
|
+
${addresses.map((a) => {
|
|
497
|
+
const countryName = a.country || countries.find((c) => c.id === a.countryId)?.name || '';
|
|
498
|
+
const addressLine = [a.address, a.city, a.state, countryName, a.postalCode]
|
|
499
|
+
.filter((v): v is string => Boolean(v && v.trim()))
|
|
500
|
+
.map(escapeHtml)
|
|
501
|
+
.join(', ');
|
|
502
|
+
|
|
503
|
+
return `
|
|
504
|
+
<div class="bg-slate-50 dark:bg-slate-800/60 rounded-2xl border ${a.isDefault ? 'border-emerald-300 dark:border-emerald-700 bg-emerald-50/20 dark:bg-emerald-950/20' : 'border-slate-200/80 dark:border-slate-700/80'} p-5 flex flex-col justify-between">
|
|
505
|
+
<div>
|
|
506
|
+
<div class="flex items-center justify-between pb-3 border-b border-slate-200/60 dark:border-slate-700/60 mb-3">
|
|
507
|
+
<span class="font-bold text-slate-900 dark:text-white text-sm">
|
|
508
|
+
${escapeHtml(a.name)}
|
|
509
|
+
</span>
|
|
510
|
+
${a.isDefault ? `
|
|
511
|
+
<span class="px-2.5 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wider bg-emerald-100 text-emerald-800 dark:bg-emerald-950/60 dark:text-emerald-300 border border-emerald-300 dark:border-emerald-700">
|
|
512
|
+
Default Address
|
|
513
|
+
</span>
|
|
514
|
+
` : `
|
|
515
|
+
<span class="px-2 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wider bg-slate-200/60 dark:bg-slate-700 text-slate-700 dark:text-slate-300">
|
|
516
|
+
Saved
|
|
517
|
+
</span>
|
|
518
|
+
`}
|
|
519
|
+
</div>
|
|
520
|
+
<p class="text-xs text-slate-600 dark:text-slate-300 leading-relaxed mb-3">
|
|
521
|
+
${addressLine}
|
|
522
|
+
</p>
|
|
523
|
+
${a.phone ? `
|
|
524
|
+
<p class="inline-flex items-center gap-1.5 text-xs text-slate-500 dark:text-slate-400">
|
|
525
|
+
${IconPhone}
|
|
526
|
+
<span>${escapeHtml(a.phone)}</span>
|
|
527
|
+
</p>
|
|
528
|
+
` : ''}
|
|
529
|
+
</div>
|
|
530
|
+
|
|
531
|
+
<div class="pt-4 mt-4 border-t border-slate-200/60 dark:border-slate-700/60 flex items-center justify-between gap-2">
|
|
532
|
+
<div>
|
|
533
|
+
${!a.isDefault ? `
|
|
534
|
+
<form data-v2-action="set-default-address" class="inline">
|
|
535
|
+
<input type="hidden" name="id" value="${escapeHtml(a.id)}">
|
|
536
|
+
<button
|
|
537
|
+
type="submit"
|
|
538
|
+
class="inline-flex items-center gap-1 px-3 py-1.5 rounded-xl text-xs font-semibold text-indigo-600 dark:text-indigo-400 hover:bg-indigo-50 dark:hover:bg-indigo-950/40 border border-indigo-200 dark:border-indigo-800 transition-colors cursor-pointer"
|
|
539
|
+
>
|
|
540
|
+
<span>Set as default</span>
|
|
541
|
+
</button>
|
|
542
|
+
<p data-v2-feedback role="status" aria-live="polite" class="text-xs text-slate-500 mt-1"></p>
|
|
543
|
+
</form>
|
|
544
|
+
` : '<span class="text-xs font-medium text-emerald-600 dark:text-emerald-400">Primary delivery address</span>'}
|
|
545
|
+
</div>
|
|
546
|
+
|
|
547
|
+
<form data-v2-action="delete-address" class="inline">
|
|
548
|
+
<input type="hidden" name="id" value="${escapeHtml(a.id)}">
|
|
549
|
+
<button
|
|
550
|
+
type="submit"
|
|
551
|
+
class="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-xs font-semibold text-rose-600 dark:text-rose-400 hover:bg-rose-50 dark:hover:bg-rose-950/40 border border-rose-200 dark:border-rose-900 transition-colors cursor-pointer"
|
|
552
|
+
>
|
|
553
|
+
${IconTrash}
|
|
554
|
+
<span>Delete</span>
|
|
555
|
+
</button>
|
|
556
|
+
<p data-v2-feedback role="status" aria-live="polite" class="text-xs text-slate-500 mt-1"></p>
|
|
557
|
+
</form>
|
|
558
|
+
</div>
|
|
559
|
+
</div>
|
|
560
|
+
`;
|
|
561
|
+
}).join('')}
|
|
562
|
+
</div>
|
|
563
|
+
`;
|
|
564
|
+
} else {
|
|
565
|
+
addressListHtml = renderAccountEmptyState({
|
|
566
|
+
title: 'No saved addresses',
|
|
567
|
+
description: 'You have not added any delivery addresses yet. Add your address below for faster checkout.',
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
const savedAddressesCard = renderAccountCard({
|
|
572
|
+
title: 'Saved Addresses',
|
|
573
|
+
description: 'Your saved shipping locations and default address',
|
|
574
|
+
body: addressListHtml,
|
|
575
|
+
classNames: 'mb-8',
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
const addAddressFormHtml = `
|
|
579
|
+
<form data-v2-action="address" class="space-y-4">
|
|
580
|
+
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
|
581
|
+
<div>
|
|
582
|
+
<label class="block text-xs font-bold uppercase tracking-wider text-slate-700 dark:text-slate-300 mb-1.5">
|
|
583
|
+
Full Name <span class="text-rose-500">*</span>
|
|
584
|
+
</label>
|
|
585
|
+
<input
|
|
586
|
+
name="name"
|
|
587
|
+
type="text"
|
|
588
|
+
required
|
|
589
|
+
maxlength="250"
|
|
590
|
+
placeholder="Recipient full name"
|
|
591
|
+
class="w-full h-11 px-3.5 rounded-xl border border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 text-slate-900 dark:text-white placeholder-slate-400 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-500 transition-all"
|
|
592
|
+
>
|
|
593
|
+
</div>
|
|
594
|
+
|
|
595
|
+
<div>
|
|
596
|
+
<label class="block text-xs font-bold uppercase tracking-wider text-slate-700 dark:text-slate-300 mb-1.5">
|
|
597
|
+
Phone Number <span class="text-rose-500">*</span>
|
|
598
|
+
</label>
|
|
599
|
+
<input
|
|
600
|
+
name="phone"
|
|
601
|
+
type="tel"
|
|
602
|
+
required
|
|
603
|
+
maxlength="250"
|
|
604
|
+
placeholder="Contact phone for delivery"
|
|
605
|
+
class="w-full h-11 px-3.5 rounded-xl border border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 text-slate-900 dark:text-white placeholder-slate-400 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-500 transition-all"
|
|
606
|
+
>
|
|
607
|
+
</div>
|
|
608
|
+
</div>
|
|
609
|
+
|
|
610
|
+
<div>
|
|
611
|
+
<label class="block text-xs font-bold uppercase tracking-wider text-slate-700 dark:text-slate-300 mb-1.5">
|
|
612
|
+
Flat, House No., Building, Street, Area <span class="text-rose-500">*</span>
|
|
613
|
+
</label>
|
|
614
|
+
<input
|
|
615
|
+
name="address"
|
|
616
|
+
type="text"
|
|
617
|
+
required
|
|
618
|
+
maxlength="250"
|
|
619
|
+
placeholder="e.g. Flat 402, Sai Residency, 12th Main Road, Indiranagar"
|
|
620
|
+
class="w-full h-11 px-3.5 rounded-xl border border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 text-slate-900 dark:text-white placeholder-slate-400 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-500 transition-all"
|
|
621
|
+
>
|
|
622
|
+
</div>
|
|
623
|
+
|
|
624
|
+
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
|
625
|
+
<div>
|
|
626
|
+
<label class="block text-xs font-bold uppercase tracking-wider text-slate-700 dark:text-slate-300 mb-1.5">
|
|
627
|
+
Country <span class="text-rose-500">*</span>
|
|
628
|
+
</label>
|
|
629
|
+
<select
|
|
630
|
+
name="country_id"
|
|
631
|
+
required
|
|
632
|
+
class="w-full h-11 px-3.5 rounded-xl border border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 text-slate-900 dark:text-white text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-500 transition-all cursor-pointer"
|
|
633
|
+
>
|
|
634
|
+
<option value="">Choose country</option>
|
|
635
|
+
${countries.map((c) => `<option value="${escapeHtml(c.id)}">${escapeHtml(c.name)}</option>`).join('')}
|
|
636
|
+
</select>
|
|
637
|
+
</div>
|
|
638
|
+
|
|
639
|
+
<div>
|
|
640
|
+
<label class="block text-xs font-bold uppercase tracking-wider text-slate-700 dark:text-slate-300 mb-1.5">
|
|
641
|
+
PIN Code <span class="text-rose-500">*</span>
|
|
642
|
+
</label>
|
|
643
|
+
<input
|
|
644
|
+
name="postal_code"
|
|
645
|
+
type="text"
|
|
646
|
+
required
|
|
647
|
+
pattern="[0-9]{6}"
|
|
648
|
+
maxlength="6"
|
|
649
|
+
inputmode="numeric"
|
|
650
|
+
oninput="this.value = this.value.replace(/[^0-9]/g, '').slice(0, 6);"
|
|
651
|
+
placeholder="e.g. 560038"
|
|
652
|
+
class="w-full h-11 px-3.5 rounded-xl border border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 text-slate-900 dark:text-white placeholder-slate-400 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-500 transition-all"
|
|
653
|
+
>
|
|
654
|
+
</div>
|
|
655
|
+
</div>
|
|
656
|
+
|
|
657
|
+
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
|
658
|
+
<div>
|
|
659
|
+
<label class="block text-xs font-bold uppercase tracking-wider text-slate-700 dark:text-slate-300 mb-1.5">
|
|
660
|
+
State <span class="text-rose-500">*</span>
|
|
661
|
+
</label>
|
|
662
|
+
<select
|
|
663
|
+
name="state_id"
|
|
664
|
+
required
|
|
665
|
+
class="w-full h-11 px-3.5 rounded-xl border border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 text-slate-900 dark:text-white text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-500 transition-all cursor-pointer"
|
|
666
|
+
>
|
|
667
|
+
<option value="">Choose country first</option>
|
|
668
|
+
</select>
|
|
669
|
+
</div>
|
|
670
|
+
|
|
671
|
+
<div>
|
|
672
|
+
<label class="block text-xs font-bold uppercase tracking-wider text-slate-700 dark:text-slate-300 mb-1.5">
|
|
673
|
+
City / Town <span class="text-rose-500">*</span>
|
|
674
|
+
</label>
|
|
675
|
+
<select
|
|
676
|
+
name="city"
|
|
677
|
+
required
|
|
678
|
+
class="w-full h-11 px-3.5 rounded-xl border border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 text-slate-900 dark:text-white text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-500 transition-all cursor-pointer"
|
|
679
|
+
>
|
|
680
|
+
<option value="">Select state first</option>
|
|
681
|
+
</select>
|
|
682
|
+
</div>
|
|
683
|
+
</div>
|
|
684
|
+
|
|
685
|
+
<div>
|
|
686
|
+
<label class="flex items-center gap-2.5 cursor-pointer mt-1 pt-1 select-none">
|
|
687
|
+
<input
|
|
688
|
+
type="checkbox"
|
|
689
|
+
name="is_default"
|
|
690
|
+
value="1"
|
|
691
|
+
class="w-4 h-4 rounded text-indigo-600 border-slate-300 focus:ring-indigo-500 cursor-pointer"
|
|
692
|
+
${!addresses || addresses.length === 0 ? 'checked' : ''}
|
|
693
|
+
>
|
|
694
|
+
<span class="text-xs font-medium text-slate-700 dark:text-slate-300">
|
|
695
|
+
Set as default delivery address
|
|
696
|
+
</span>
|
|
697
|
+
</label>
|
|
698
|
+
</div>
|
|
699
|
+
|
|
700
|
+
<div class="flex items-center gap-4 pt-3 border-t border-slate-100 dark:border-slate-800">
|
|
701
|
+
<button
|
|
702
|
+
type="submit"
|
|
703
|
+
class="px-6 py-2.5 rounded-xl bg-indigo-600 hover:bg-indigo-700 text-white font-semibold text-sm shadow-md shadow-indigo-500/20 active:scale-95 transition-all cursor-pointer"
|
|
704
|
+
>
|
|
705
|
+
Save Address
|
|
706
|
+
</button>
|
|
707
|
+
<p data-v2-feedback role="status" aria-live="polite" class="text-sm font-medium text-slate-600 dark:text-slate-400"></p>
|
|
708
|
+
</div>
|
|
709
|
+
</form>
|
|
710
|
+
`;
|
|
711
|
+
|
|
712
|
+
const addAddressCard = renderAccountCard({
|
|
713
|
+
title: 'Add New Address',
|
|
714
|
+
description: 'Enter your delivery address details below for future orders',
|
|
715
|
+
body: addAddressFormHtml,
|
|
716
|
+
});
|
|
717
|
+
|
|
718
|
+
return header + savedAddressesCard + addAddressCard;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
// ===========================================================================
|
|
722
|
+
// 5. Downloads Tab (/account/downloads)
|
|
723
|
+
// ===========================================================================
|
|
724
|
+
|
|
725
|
+
export function renderDownloadsTab(data: AccountPageData): string {
|
|
726
|
+
const downloads = data.downloads;
|
|
727
|
+
|
|
728
|
+
const header = renderAccountPageHeader({
|
|
729
|
+
title: 'My Downloads',
|
|
730
|
+
description: 'Access and download your digital purchases and license keys.',
|
|
731
|
+
});
|
|
732
|
+
|
|
733
|
+
let downloadsContent = '';
|
|
734
|
+
if (downloads === null) {
|
|
735
|
+
downloadsContent = `
|
|
736
|
+
<div class="p-4 rounded-2xl bg-amber-50 dark:bg-amber-950/40 border border-amber-200 dark:border-amber-800 text-amber-800 dark:text-amber-300 text-sm font-medium">
|
|
737
|
+
Downloads could not be loaded. Please try again.
|
|
738
|
+
</div>
|
|
739
|
+
`;
|
|
740
|
+
} else if (Array.isArray(downloads) && downloads.length > 0) {
|
|
741
|
+
downloadsContent = `
|
|
742
|
+
<div class="space-y-4">
|
|
743
|
+
${downloads.map((d) => `
|
|
744
|
+
<div class="bg-slate-50 dark:bg-slate-800/60 rounded-2xl border border-slate-200/80 dark:border-slate-700/80 p-5 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
|
|
745
|
+
<div class="flex items-center gap-4">
|
|
746
|
+
<div class="w-11 h-11 rounded-xl bg-indigo-50 dark:bg-indigo-950/60 text-indigo-600 dark:text-indigo-400 flex items-center justify-center shrink-0">
|
|
747
|
+
${IconDownloads}
|
|
748
|
+
</div>
|
|
749
|
+
<div>
|
|
750
|
+
<h3 class="text-sm font-bold text-slate-900 dark:text-white font-heading">
|
|
751
|
+
${escapeHtml(d.name)}
|
|
752
|
+
</h3>
|
|
753
|
+
<p class="text-xs text-slate-500 dark:text-slate-400 mt-0.5">
|
|
754
|
+
Order #${escapeHtml(d.orderId)}
|
|
755
|
+
</p>
|
|
756
|
+
</div>
|
|
757
|
+
</div>
|
|
758
|
+
|
|
759
|
+
<form data-v2-action="download" class="flex items-center gap-3">
|
|
760
|
+
<input type="hidden" name="order_id" value="${escapeHtml(d.orderId)}">
|
|
761
|
+
<input type="hidden" name="product_id" value="${escapeHtml(d.productId)}">
|
|
762
|
+
<button
|
|
763
|
+
type="submit"
|
|
764
|
+
class="inline-flex items-center gap-2 px-5 py-2 rounded-xl bg-indigo-600 hover:bg-indigo-700 text-white font-semibold text-xs shadow-md shadow-indigo-500/20 active:scale-95 transition-all cursor-pointer"
|
|
765
|
+
>
|
|
766
|
+
${IconDownloads}
|
|
767
|
+
<span>Download File</span>
|
|
768
|
+
</button>
|
|
769
|
+
<p data-v2-feedback role="status" aria-live="polite" class="text-xs text-slate-500"></p>
|
|
770
|
+
</form>
|
|
771
|
+
</div>
|
|
772
|
+
`).join('')}
|
|
773
|
+
</div>
|
|
774
|
+
`;
|
|
775
|
+
} else {
|
|
776
|
+
downloadsContent = renderAccountEmptyState({
|
|
777
|
+
icon: `<svg class="w-12 h-12 text-slate-300 dark:text-slate-700 mx-auto" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3"/></svg>`,
|
|
778
|
+
title: 'No purchased downloads',
|
|
779
|
+
description: 'Digital files and downloads linked to your purchases will be available here.',
|
|
780
|
+
actionUrl: '/digital-products',
|
|
781
|
+
actionLabel: 'Browse Digital Catalog',
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
const card = renderAccountCard({
|
|
786
|
+
title: 'Digital Products',
|
|
787
|
+
description: 'Licensed downloads and digital files',
|
|
788
|
+
body: downloadsContent,
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
return header + card;
|
|
792
|
+
}
|