create-brainerce-store 1.28.18 → 1.28.20
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.28.
|
|
34
|
+
version: "1.28.20",
|
|
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
|
@@ -9,7 +9,6 @@ import type {
|
|
|
9
9
|
} from 'brainerce';
|
|
10
10
|
import { getClient } from '@/lib/brainerce';
|
|
11
11
|
import { useCart } from '@/providers/store-provider';
|
|
12
|
-
import { useStoreInfo } from '@/providers/store-provider';
|
|
13
12
|
import { CartItem } from '@/components/cart/cart-item';
|
|
14
13
|
import { CartUpgradeBanner } from '@/components/cart/cart-upgrade-banner';
|
|
15
14
|
import { CartBundleOfferCard } from '@/components/cart/cart-bundle-offer';
|
|
@@ -24,55 +23,30 @@ import { useTranslations } from '@/lib/translations';
|
|
|
24
23
|
|
|
25
24
|
export default function CartPage() {
|
|
26
25
|
const { cart, cartLoading, refreshCart, itemCount } = useCart();
|
|
27
|
-
const { storeInfo } = useStoreInfo();
|
|
28
26
|
const t = useTranslations('cart');
|
|
29
27
|
const tc = useTranslations('common');
|
|
30
28
|
const [cartRecs, setCartRecs] = useState<CartRecommendationsResponse | null>(null);
|
|
31
29
|
const [upgrades, setUpgrades] = useState<CartUpgradesResponse | null>(null);
|
|
32
30
|
const [bundles, setBundles] = useState<CartBundlesResponse | null>(null);
|
|
33
31
|
|
|
34
|
-
// Load
|
|
32
|
+
// Load recommendations, upgrades, and bundles in a single request
|
|
35
33
|
useEffect(() => {
|
|
36
34
|
if (!cart?.id || cart.items.length === 0) {
|
|
37
35
|
setCartRecs(null);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const client = getClient();
|
|
41
|
-
client
|
|
42
|
-
.getCartRecommendations(cart.id, 4)
|
|
43
|
-
.then(setCartRecs)
|
|
44
|
-
.catch(() => {});
|
|
45
|
-
}, [cart?.id, cart?.items.length]);
|
|
46
|
-
|
|
47
|
-
// Load upgrade suggestions when cart changes
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
if (
|
|
50
|
-
!cart?.id ||
|
|
51
|
-
cart.items.length === 0 ||
|
|
52
|
-
storeInfo?.upsell?.cartUpgradeBannerEnabled === false
|
|
53
|
-
) {
|
|
54
36
|
setUpgrades(null);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const client = getClient();
|
|
58
|
-
client
|
|
59
|
-
.getCartUpgrades(cart.id)
|
|
60
|
-
.then(setUpgrades)
|
|
61
|
-
.catch(() => {});
|
|
62
|
-
}, [cart?.id, cart?.items.length, storeInfo?.upsell?.cartUpgradeBannerEnabled]);
|
|
63
|
-
|
|
64
|
-
// Load bundle offers when cart changes
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
if (!cart?.id || cart.items.length === 0 || storeInfo?.upsell?.cartBundleEnabled === false) {
|
|
67
37
|
setBundles(null);
|
|
68
38
|
return;
|
|
69
39
|
}
|
|
70
40
|
const client = getClient();
|
|
71
41
|
client
|
|
72
|
-
.
|
|
73
|
-
.then(
|
|
42
|
+
.getCart(cart.id, { include: ['recommendations', 'upgrades', 'bundles'] })
|
|
43
|
+
.then((enriched) => {
|
|
44
|
+
setCartRecs(enriched.recommendations ?? null);
|
|
45
|
+
setUpgrades(enriched.upgrades ?? null);
|
|
46
|
+
setBundles(enriched.bundles ?? null);
|
|
47
|
+
})
|
|
74
48
|
.catch(() => {});
|
|
75
|
-
}, [cart?.id, cart?.items.length
|
|
49
|
+
}, [cart?.id, cart?.items.length]);
|
|
76
50
|
|
|
77
51
|
if (cartLoading) {
|
|
78
52
|
return (
|