create-brainerce-store 1.12.3 → 1.12.4
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
CHANGED
|
@@ -31,7 +31,7 @@ var require_package = __commonJS({
|
|
|
31
31
|
"package.json"(exports2, module2) {
|
|
32
32
|
module2.exports = {
|
|
33
33
|
name: "create-brainerce-store",
|
|
34
|
-
version: "1.12.
|
|
34
|
+
version: "1.12.4",
|
|
35
35
|
description: "Scaffold a production-ready e-commerce storefront connected to Brainerce",
|
|
36
36
|
bin: {
|
|
37
37
|
"create-brainerce-store": "dist/index.js"
|
package/package.json
CHANGED
|
@@ -119,7 +119,9 @@ function OrderConfirmationContent() {
|
|
|
119
119
|
|
|
120
120
|
<p className="text-muted-foreground mt-2">{t('confirmationEmail')}</p>
|
|
121
121
|
|
|
122
|
-
{result.status.orderId &&
|
|
122
|
+
{result.status.orderId && (
|
|
123
|
+
<ConfirmationDownloads orderId={result.status.orderId} checkoutId={checkoutId!} />
|
|
124
|
+
)}
|
|
123
125
|
|
|
124
126
|
<div className="mt-8 flex flex-col items-center justify-center gap-3 sm:flex-row">
|
|
125
127
|
<Link
|
|
@@ -180,26 +182,35 @@ function OrderConfirmationContent() {
|
|
|
180
182
|
);
|
|
181
183
|
}
|
|
182
184
|
|
|
183
|
-
function ConfirmationDownloads({ orderId }: { orderId: string }) {
|
|
185
|
+
function ConfirmationDownloads({ orderId, checkoutId }: { orderId: string; checkoutId: string }) {
|
|
184
186
|
const t = useTranslations('orderConfirmation');
|
|
185
187
|
const [downloads, setDownloads] = useState<OrderDownloadLink[] | null>(null);
|
|
186
188
|
|
|
187
189
|
useEffect(() => {
|
|
188
190
|
let cancelled = false;
|
|
189
191
|
async function fetchDownloads() {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
192
|
+
const client = getClient();
|
|
193
|
+
// Retry a few times — the worker may still be writing downloadMeta
|
|
194
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
195
|
+
try {
|
|
196
|
+
const links = await client.getOrderDownloads(orderId, { checkoutId });
|
|
197
|
+
if (!cancelled && links.length > 0) {
|
|
198
|
+
setDownloads(links);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
} catch {
|
|
202
|
+
// Not all orders have downloads
|
|
203
|
+
}
|
|
204
|
+
if (attempt < 2 && !cancelled) {
|
|
205
|
+
await new Promise((r) => setTimeout(r, 1500));
|
|
206
|
+
}
|
|
196
207
|
}
|
|
197
208
|
}
|
|
198
209
|
fetchDownloads();
|
|
199
210
|
return () => {
|
|
200
211
|
cancelled = true;
|
|
201
212
|
};
|
|
202
|
-
}, [orderId]);
|
|
213
|
+
}, [orderId, checkoutId]);
|
|
203
214
|
|
|
204
215
|
if (!downloads || downloads.length === 0) return null;
|
|
205
216
|
|