create-brainerce-store 1.58.0 → 1.61.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/dist/index.js +7 -2
- package/messages/en.json +22 -0
- package/messages/he.json +22 -0
- package/package.json +2 -1
- package/templates/nextjs/base/.mcp.json +8 -0
- package/templates/nextjs/base/AGENTS.md.ejs +81 -65
- package/templates/nextjs/base/CLAUDE.md.ejs +92 -76
- package/templates/nextjs/base/src/app/api/auth/oauth-callback/route.ts +12 -4
- package/templates/nextjs/base/src/app/auth/callback/page.tsx +16 -1
- package/templates/nextjs/base/src/app/order-status/page.tsx +121 -0
- package/templates/nextjs/base/src/components/checkout/custom-fields-step.tsx +292 -258
- package/templates/nextjs/base/src/components/checkout/date-picker.tsx +309 -0
- package/templates/nextjs/base/src/components/checkout/datetime-picker.tsx +144 -0
- package/templates/nextjs/base/src/components/checkout/shipping-step.tsx +17 -1
- package/templates/nextjs/designs/atelier/messages-patch/en.json +7 -7
- package/templates/nextjs/designs/atelier/messages-patch/he.json +8 -8
- package/templates/nextjs/designs/atelier/ui/home/editorial-band.tsx +16 -14
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Suspense, useEffect, useState } from 'react';
|
|
4
|
+
import { useSearchParams } from 'next/navigation';
|
|
5
|
+
import { Link } from '@/core/lib/navigation';
|
|
6
|
+
import type { Order } from 'brainerce';
|
|
7
|
+
import { getClient } from '@/core/lib/brainerce';
|
|
8
|
+
import { LoadingSpinner } from '@/ui/shared/loading-spinner';
|
|
9
|
+
import { OrderHistory } from '@/components/account/order-history';
|
|
10
|
+
import { useTranslations } from '@/core/lib/translations';
|
|
11
|
+
|
|
12
|
+
// Read-only order lookup for links from transactional emails (order confirmation,
|
|
13
|
+
// shipped, refunded, etc). Unlike /order-confirmation, this page never calls
|
|
14
|
+
// handlePaymentSuccess() or touches cart state — it only fetches and displays,
|
|
15
|
+
// so it's safe to revisit at any time without side effects on an unrelated
|
|
16
|
+
// active cart. Works for guests too: the checkout id itself is the credential.
|
|
17
|
+
function OrderStatusContent() {
|
|
18
|
+
const searchParams = useSearchParams();
|
|
19
|
+
const checkoutId = searchParams.get('checkout_id');
|
|
20
|
+
|
|
21
|
+
const t = useTranslations('orderStatus');
|
|
22
|
+
const tc = useTranslations('common');
|
|
23
|
+
const [order, setOrder] = useState<Order | null>(null);
|
|
24
|
+
const [loading, setLoading] = useState(true);
|
|
25
|
+
const [error, setError] = useState<string | null>(null);
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (!checkoutId) {
|
|
29
|
+
setError(t('missingCheckoutInfo'));
|
|
30
|
+
setLoading(false);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let cancelled = false;
|
|
35
|
+
async function loadOrder() {
|
|
36
|
+
try {
|
|
37
|
+
const client = getClient();
|
|
38
|
+
const result = await client.getOrderByCheckout(checkoutId!);
|
|
39
|
+
if (!cancelled) setOrder(result);
|
|
40
|
+
} catch (err) {
|
|
41
|
+
if (!cancelled) {
|
|
42
|
+
const message = err instanceof Error ? err.message : t('notFound');
|
|
43
|
+
setError(message);
|
|
44
|
+
}
|
|
45
|
+
} finally {
|
|
46
|
+
if (!cancelled) setLoading(false);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
loadOrder();
|
|
51
|
+
return () => {
|
|
52
|
+
cancelled = true;
|
|
53
|
+
};
|
|
54
|
+
}, [checkoutId, t]);
|
|
55
|
+
|
|
56
|
+
if (loading) {
|
|
57
|
+
return (
|
|
58
|
+
<div className="flex min-h-[60vh] flex-col items-center justify-center">
|
|
59
|
+
<LoadingSpinner size="lg" />
|
|
60
|
+
<p className="text-muted-foreground mt-4">{t('loading')}</p>
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (error || !order) {
|
|
66
|
+
return (
|
|
67
|
+
<div className="mx-auto max-w-2xl px-4 py-16 text-center sm:px-6 lg:px-8">
|
|
68
|
+
<svg
|
|
69
|
+
className="text-destructive mx-auto mb-4 h-16 w-16"
|
|
70
|
+
fill="none"
|
|
71
|
+
viewBox="0 0 24 24"
|
|
72
|
+
stroke="currentColor"
|
|
73
|
+
>
|
|
74
|
+
<path
|
|
75
|
+
strokeLinecap="round"
|
|
76
|
+
strokeLinejoin="round"
|
|
77
|
+
strokeWidth={1.5}
|
|
78
|
+
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.834-2.694-.834-3.464 0L3.34 16.5c-.77.833.192 2.5 1.732 2.5z"
|
|
79
|
+
/>
|
|
80
|
+
</svg>
|
|
81
|
+
<h1 className="text-foreground text-2xl font-bold">{t('errorTitle')}</h1>
|
|
82
|
+
<p className="text-muted-foreground mt-2">{error || t('notFound')}</p>
|
|
83
|
+
<Link
|
|
84
|
+
href="/"
|
|
85
|
+
className="bg-primary text-primary-foreground mt-6 inline-flex items-center rounded px-6 py-3 font-medium transition-opacity hover:opacity-90"
|
|
86
|
+
>
|
|
87
|
+
{t('returnHome')}
|
|
88
|
+
</Link>
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<div className="mx-auto max-w-3xl px-4 py-8 sm:px-6 lg:px-8">
|
|
95
|
+
<h1 className="text-foreground mb-6 text-2xl font-bold">{t('pageTitle')}</h1>
|
|
96
|
+
<OrderHistory orders={[order]} />
|
|
97
|
+
<div className="mt-8 flex items-center justify-center">
|
|
98
|
+
<Link
|
|
99
|
+
href="/products"
|
|
100
|
+
className="bg-primary text-primary-foreground inline-flex items-center rounded px-6 py-3 font-medium transition-opacity hover:opacity-90"
|
|
101
|
+
>
|
|
102
|
+
{tc('continueShopping')}
|
|
103
|
+
</Link>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export default function OrderStatusPage() {
|
|
110
|
+
return (
|
|
111
|
+
<Suspense
|
|
112
|
+
fallback={
|
|
113
|
+
<div className="flex min-h-[60vh] items-center justify-center">
|
|
114
|
+
<LoadingSpinner size="lg" />
|
|
115
|
+
</div>
|
|
116
|
+
}
|
|
117
|
+
>
|
|
118
|
+
<OrderStatusContent />
|
|
119
|
+
</Suspense>
|
|
120
|
+
);
|
|
121
|
+
}
|