@nuvler/cli 0.5.16 → 0.5.18
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/api/theme-context.js +2 -0
- package/dist/api/theme-context.js.map +1 -1
- package/dist/commands/theme/create.js +1 -1
- package/dist/nuvler.js +24 -1
- package/dist/nuvler.js.map +1 -1
- package/dist/templates/nuvler-atelier/package.json +2 -2
- package/dist/templates/nuvler-default/README.md +4 -4
- package/dist/templates/nuvler-default/nuvler.theme.json +1 -1
- package/dist/templates/nuvler-default/package.json +2 -2
- package/dist/templates/nuvler-default/src/catalog-filters.tsx +169 -0
- package/dist/templates/nuvler-default/src/contact-form.tsx +172 -0
- package/dist/templates/nuvler-default/src/home-data.ts +30 -0
- package/dist/templates/nuvler-default/src/home.tsx +2 -196
- package/dist/templates/nuvler-default/src/interaction-colors.ts +49 -0
- package/dist/templates/nuvler-default/src/kit-composition.ts +15 -0
- package/dist/templates/nuvler-default/src/kit-group-selector.tsx +230 -0
- package/dist/templates/nuvler-default/src/kit-selection.ts +39 -0
- package/dist/templates/nuvler-default/src/product-detail-interactive.tsx +420 -115
- package/dist/templates/nuvler-default/src/product-detail.tsx +141 -59
- package/dist/templates/nuvler-default/src/products.tsx +143 -12
- package/dist/templates/nuvler-default/src/server-shell.tsx +21 -3
- package/dist/templates/nuvler-default/src/theme-component.tsx +85 -24
- package/dist/templates/nuvler-default/src/theme.css +673 -6
- package/dist/templates/nuvler-default/src/whatsapp-message.ts +82 -0
- package/dist/templates/nuvler-default/test/catalog-filters.test.mjs +44 -0
- package/dist/templates/nuvler-default/test/interaction-colors.test.mjs +74 -0
- package/dist/templates/nuvler-default/test/kit-composition.test.mjs +28 -0
- package/dist/templates/nuvler-default/test/kit-detail.test.mjs +292 -0
- package/dist/templates/nuvler-default/test/whatsapp-message.test.mjs +126 -0
- package/dist/templates/starter/package.json +2 -2
- package/package.json +3 -3
- package/preview-host/package.json +1 -1
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import type { ProductDetailProps, ThemeImage } from "@nuvler/theme-sdk";
|
|
2
2
|
|
|
3
3
|
import { ProductDetailInteractive } from "./product-detail-interactive.js";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
displayPrice,
|
|
6
|
+
ThemeImageView,
|
|
7
|
+
type ThemeImageComponent,
|
|
8
|
+
} from "./shared.js";
|
|
5
9
|
|
|
6
|
-
function discountPercent(
|
|
7
|
-
|
|
10
|
+
function discountPercent(
|
|
11
|
+
price: number | null,
|
|
12
|
+
promotionalPrice: number | null,
|
|
13
|
+
) {
|
|
14
|
+
if (
|
|
15
|
+
price === null ||
|
|
16
|
+
promotionalPrice === null ||
|
|
17
|
+
promotionalPrice >= price ||
|
|
18
|
+
price <= 0
|
|
19
|
+
)
|
|
20
|
+
return null;
|
|
8
21
|
return Math.round((1 - promotionalPrice / price) * 100);
|
|
9
22
|
}
|
|
10
23
|
|
|
@@ -28,47 +41,56 @@ export function ProductDetail({
|
|
|
28
41
|
if (image?.url) uniqueImages.set(image.url, image);
|
|
29
42
|
});
|
|
30
43
|
const images = [...uniqueImages.values()];
|
|
31
|
-
const galleryImages =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
const galleryImages =
|
|
45
|
+
images.length > 0 ? (
|
|
46
|
+
images.map((image, index) => (
|
|
47
|
+
<span
|
|
48
|
+
data-product-main-image={image.url}
|
|
49
|
+
hidden={index !== 0}
|
|
50
|
+
key={image.url}
|
|
51
|
+
>
|
|
52
|
+
<ImageComponent
|
|
53
|
+
image={image}
|
|
54
|
+
fallbackAlt={initialVariant?.name || product.title}
|
|
55
|
+
priority={index === 0}
|
|
56
|
+
sizes="(max-width: 900px) 100vw, 50vw"
|
|
57
|
+
fallbackWidth={1000}
|
|
58
|
+
fallbackHeight={1000}
|
|
59
|
+
/>
|
|
60
|
+
</span>
|
|
61
|
+
))
|
|
62
|
+
) : (
|
|
63
|
+
<span key="empty-image" data-product-main-image="">
|
|
64
|
+
<ImageComponent image={null} fallbackAlt={product.title} />
|
|
46
65
|
</span>
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const previousPrice =
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
);
|
|
67
|
+
const galleryThumbnails =
|
|
68
|
+
images.length > 1
|
|
69
|
+
? images.map((image, index) => (
|
|
70
|
+
<button
|
|
71
|
+
className={index === 0 ? "active" : ""}
|
|
72
|
+
type="button"
|
|
73
|
+
aria-pressed={index === 0}
|
|
74
|
+
aria-label={`Exibir imagem ${index + 1} de ${product.title}`}
|
|
75
|
+
data-product-thumbnail={image.url}
|
|
76
|
+
key={`${image.url}-${index}`}
|
|
77
|
+
>
|
|
78
|
+
<ImageComponent
|
|
79
|
+
image={image}
|
|
80
|
+
fallbackAlt={`${product.title} ${index + 1}`}
|
|
81
|
+
sizes="96px"
|
|
82
|
+
fallbackWidth={192}
|
|
83
|
+
fallbackHeight={192}
|
|
84
|
+
/>
|
|
85
|
+
</button>
|
|
86
|
+
))
|
|
87
|
+
: null;
|
|
88
|
+
const previousPrice =
|
|
89
|
+
product.promotionalPrice !== null &&
|
|
90
|
+
product.price !== null &&
|
|
91
|
+
product.promotionalPrice < product.price
|
|
92
|
+
? displayPrice({ ...product, promotionalPrice: null })
|
|
93
|
+
: null;
|
|
72
94
|
const currentPrice = displayPrice(product);
|
|
73
95
|
const discount = discountPercent(product.price, product.promotionalPrice);
|
|
74
96
|
const details = [
|
|
@@ -76,25 +98,85 @@ export function ProductDetail({
|
|
|
76
98
|
product.model && { label: "Modelo", value: product.model },
|
|
77
99
|
product.ean && { label: "EAN", value: product.ean },
|
|
78
100
|
product.sku && { label: "Referência", value: product.sku },
|
|
79
|
-
].filter((detail): detail is { label: string; value: string } =>
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
101
|
+
].filter((detail): detail is { label: string; value: string } =>
|
|
102
|
+
Boolean(detail),
|
|
103
|
+
);
|
|
104
|
+
const stockLabel =
|
|
105
|
+
product.stockQuantity === 0
|
|
106
|
+
? "Indisponível no momento"
|
|
107
|
+
: product.stockQuantity !== null
|
|
108
|
+
? "Disponível"
|
|
109
|
+
: null;
|
|
110
|
+
const information = (
|
|
111
|
+
<>
|
|
112
|
+
{product.categories[0] && (
|
|
113
|
+
<span key="category" className="product-category">
|
|
114
|
+
{product.categories[0].name}
|
|
115
|
+
</span>
|
|
116
|
+
)}
|
|
117
|
+
<h1 key="title">{product.title}</h1>
|
|
118
|
+
{showPrices && (
|
|
119
|
+
<div key="price" className="product-price-block">
|
|
120
|
+
{previousPrice && <s>De: {previousPrice}</s>}
|
|
121
|
+
{currentPrice ? (
|
|
122
|
+
<strong>
|
|
123
|
+
{previousPrice ? "por " : ""}
|
|
124
|
+
{currentPrice}
|
|
125
|
+
</strong>
|
|
126
|
+
) : (
|
|
127
|
+
<span>Consulte condições com a loja</span>
|
|
128
|
+
)}
|
|
129
|
+
{discount && <small>{discount}% de desconto</small>}
|
|
130
|
+
</div>
|
|
131
|
+
)}
|
|
132
|
+
{stockLabel && (
|
|
133
|
+
<p
|
|
134
|
+
key="availability"
|
|
135
|
+
className={`product-availability${product.stockQuantity === 0 ? " unavailable" : ""}`}
|
|
136
|
+
>
|
|
137
|
+
{stockLabel}
|
|
138
|
+
</p>
|
|
139
|
+
)}
|
|
140
|
+
{product.sku && (
|
|
141
|
+
<p key="reference" className="product-reference">
|
|
142
|
+
Ref. {product.sku}
|
|
143
|
+
</p>
|
|
144
|
+
)}
|
|
145
|
+
<div key="description" className="product-description">
|
|
146
|
+
{descriptionContent}
|
|
147
|
+
</div>
|
|
148
|
+
{details.length > 0 && (
|
|
149
|
+
<section
|
|
150
|
+
key="specifications"
|
|
151
|
+
className="product-specifications"
|
|
152
|
+
aria-labelledby="product-specifications-title"
|
|
153
|
+
>
|
|
154
|
+
<h2 id="product-specifications-title">Informações do produto</h2>
|
|
155
|
+
<dl>
|
|
156
|
+
{details.map((detail) => (
|
|
157
|
+
<div key={detail.label}>
|
|
158
|
+
<dt>{detail.label}</dt>
|
|
159
|
+
<dd>{detail.value}</dd>
|
|
160
|
+
</div>
|
|
161
|
+
))}
|
|
162
|
+
</dl>
|
|
163
|
+
</section>
|
|
164
|
+
)}
|
|
165
|
+
</>
|
|
166
|
+
);
|
|
167
|
+
const benefits =
|
|
168
|
+
contact?.whatsapp || contact?.email || contact?.phone ? (
|
|
169
|
+
<div key="benefits" className="purchase-benefits">
|
|
170
|
+
<span>
|
|
171
|
+
<strong>Precisa de ajuda?</strong> Fale com a loja para tirar dúvidas
|
|
172
|
+
sobre este produto.
|
|
173
|
+
</span>
|
|
174
|
+
</div>
|
|
175
|
+
) : null;
|
|
95
176
|
|
|
96
177
|
return (
|
|
97
178
|
<ProductDetailInteractive
|
|
179
|
+
key={product.slug}
|
|
98
180
|
product={product}
|
|
99
181
|
showPrices={showPrices}
|
|
100
182
|
contact={contact}
|
|
@@ -1,13 +1,38 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
productUrl,
|
|
3
|
+
type ProductGridProps,
|
|
4
|
+
type ThemeProduct,
|
|
5
|
+
} from "@nuvler/theme-sdk";
|
|
2
6
|
import { ProductCardAction } from "./product-detail-interactive.js";
|
|
3
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
displayPrice,
|
|
9
|
+
effectivePrice,
|
|
10
|
+
plainText,
|
|
11
|
+
ThemeImageView,
|
|
12
|
+
type ThemeImageComponent,
|
|
13
|
+
} from "./shared.js";
|
|
4
14
|
|
|
5
|
-
function discountPercent(
|
|
6
|
-
|
|
15
|
+
function discountPercent(
|
|
16
|
+
price: number | null,
|
|
17
|
+
promotionalPrice: number | null,
|
|
18
|
+
) {
|
|
19
|
+
if (
|
|
20
|
+
price === null ||
|
|
21
|
+
promotionalPrice === null ||
|
|
22
|
+
promotionalPrice >= price ||
|
|
23
|
+
price <= 0
|
|
24
|
+
)
|
|
25
|
+
return null;
|
|
7
26
|
return Math.round((1 - promotionalPrice / price) * 100);
|
|
8
27
|
}
|
|
9
28
|
|
|
10
|
-
export function ProductCard({
|
|
29
|
+
export function ProductCard({
|
|
30
|
+
product,
|
|
31
|
+
showPrices = true,
|
|
32
|
+
showCategory = true,
|
|
33
|
+
showDescription = true,
|
|
34
|
+
ImageComponent = ThemeImageView,
|
|
35
|
+
}: {
|
|
11
36
|
product: ThemeProduct;
|
|
12
37
|
showPrices?: boolean;
|
|
13
38
|
showCategory?: boolean;
|
|
@@ -18,13 +43,119 @@ export function ProductCard({ product, showPrices = true, showCategory = true, s
|
|
|
18
43
|
const unavailable = product.stockQuantity === 0;
|
|
19
44
|
const discount = discountPercent(product.price, product.promotionalPrice);
|
|
20
45
|
const currentPrice = displayPrice(product);
|
|
21
|
-
const previousPrice =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
46
|
+
const previousPrice =
|
|
47
|
+
product.promotionalPrice !== null &&
|
|
48
|
+
product.price !== null &&
|
|
49
|
+
product.promotionalPrice < product.price
|
|
50
|
+
? displayPrice({ ...product, promotionalPrice: null })
|
|
51
|
+
: null;
|
|
52
|
+
return (
|
|
53
|
+
<article
|
|
54
|
+
className="product-card"
|
|
55
|
+
data-unavailable={unavailable || undefined}
|
|
56
|
+
>
|
|
57
|
+
<a
|
|
58
|
+
className="product-card-image"
|
|
59
|
+
href={href}
|
|
60
|
+
aria-label={`Ver ${product.title}`}
|
|
61
|
+
>
|
|
62
|
+
{showPrices && discount && (
|
|
63
|
+
<span className="product-card-badge">-{discount}%</span>
|
|
64
|
+
)}
|
|
65
|
+
{unavailable && (
|
|
66
|
+
<span className="product-card-stock">Indisponível</span>
|
|
67
|
+
)}
|
|
68
|
+
<ImageComponent
|
|
69
|
+
image={product.image}
|
|
70
|
+
fallbackAlt={product.title}
|
|
71
|
+
sizes="(max-width: 720px) 92vw, (max-width: 1100px) 45vw, 25vw"
|
|
72
|
+
fallbackWidth={720}
|
|
73
|
+
fallbackHeight={720}
|
|
74
|
+
/>
|
|
75
|
+
</a>
|
|
76
|
+
<div className="product-card-content">
|
|
77
|
+
{showCategory && (
|
|
78
|
+
<span
|
|
79
|
+
className={`product-category${product.categories[0] ? "" : " product-category-empty"}`}
|
|
80
|
+
>
|
|
81
|
+
{product.categories[0]?.name || "Sem categoria"}
|
|
82
|
+
</span>
|
|
83
|
+
)}
|
|
84
|
+
<h3>
|
|
85
|
+
<a className="product-card-details-link" href={href}>
|
|
86
|
+
{product.title}
|
|
87
|
+
</a>
|
|
88
|
+
</h3>
|
|
89
|
+
{showDescription && product.description && (
|
|
90
|
+
<p className="product-card-description">
|
|
91
|
+
{plainText(product.description)}
|
|
92
|
+
</p>
|
|
93
|
+
)}
|
|
94
|
+
{showPrices && (
|
|
95
|
+
<div className="product-card-price">
|
|
96
|
+
{previousPrice && <s>De: {previousPrice}</s>}
|
|
97
|
+
{currentPrice ? (
|
|
98
|
+
<strong>
|
|
99
|
+
{previousPrice ? "por " : ""}
|
|
100
|
+
{currentPrice}
|
|
101
|
+
</strong>
|
|
102
|
+
) : (
|
|
103
|
+
<span>Consulte condições</span>
|
|
104
|
+
)}
|
|
105
|
+
</div>
|
|
106
|
+
)}
|
|
107
|
+
{product.sku && (
|
|
108
|
+
<small className="product-card-sku">Ref. {product.sku}</small>
|
|
109
|
+
)}
|
|
110
|
+
<ProductCardAction
|
|
111
|
+
href={href}
|
|
112
|
+
hasVariants={
|
|
113
|
+
Boolean(product.kitGroups?.length || product.kitSize) ||
|
|
114
|
+
product.variantOptions.length > 0
|
|
115
|
+
}
|
|
116
|
+
unavailable={unavailable}
|
|
117
|
+
item={{
|
|
118
|
+
productSlug: product.slug,
|
|
119
|
+
productUrl: href,
|
|
120
|
+
title: product.title,
|
|
121
|
+
sku: product.sku,
|
|
122
|
+
image: product.image,
|
|
123
|
+
unitPrice: showPrices ? effectivePrice(product) : null,
|
|
124
|
+
}}
|
|
125
|
+
/>
|
|
126
|
+
</div>
|
|
127
|
+
</article>
|
|
128
|
+
);
|
|
25
129
|
}
|
|
26
130
|
|
|
27
|
-
export function ProductGrid({
|
|
28
|
-
|
|
29
|
-
|
|
131
|
+
export function ProductGrid({
|
|
132
|
+
products,
|
|
133
|
+
columns = 4,
|
|
134
|
+
showPrices = true,
|
|
135
|
+
showCategory = true,
|
|
136
|
+
showDescription = true,
|
|
137
|
+
ImageComponent = ThemeImageView,
|
|
138
|
+
}: ProductGridProps & { ImageComponent?: ThemeImageComponent }) {
|
|
139
|
+
if (!products.length)
|
|
140
|
+
return (
|
|
141
|
+
<div className="empty-state">
|
|
142
|
+
<span>7</span>
|
|
143
|
+
<h2>Nenhum produto encontrado</h2>
|
|
144
|
+
<p>Novos itens aparecerão aqui assim que forem publicados.</p>
|
|
145
|
+
</div>
|
|
146
|
+
);
|
|
147
|
+
return (
|
|
148
|
+
<div className="product-grid" data-columns={columns}>
|
|
149
|
+
{products.map((product) => (
|
|
150
|
+
<ProductCard
|
|
151
|
+
key={product.slug}
|
|
152
|
+
product={product}
|
|
153
|
+
showPrices={showPrices}
|
|
154
|
+
showCategory={showCategory}
|
|
155
|
+
showDescription={showDescription}
|
|
156
|
+
ImageComponent={ImageComponent}
|
|
157
|
+
/>
|
|
158
|
+
))}
|
|
159
|
+
</div>
|
|
160
|
+
);
|
|
30
161
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import { interactionColorVariables } from "./interaction-colors.js";
|
|
1
2
|
import type { CSSProperties, ReactNode } from "react";
|
|
2
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
ThemeCategory,
|
|
5
|
+
ThemeNavigationHeaderButton,
|
|
6
|
+
ThemeNavigationItem,
|
|
7
|
+
ThemePageSummary,
|
|
8
|
+
ThemeSite,
|
|
9
|
+
} from "@nuvler/theme-sdk";
|
|
3
10
|
|
|
4
11
|
import { Footer } from "./footer.js";
|
|
5
12
|
import { Header } from "./header.js";
|
|
@@ -42,9 +49,20 @@ export function NuvlerDefaultShell({
|
|
|
42
49
|
colors: { ...nuvlerDefaultTokens.colors, ...configured?.colors },
|
|
43
50
|
layout: { ...nuvlerDefaultTokens.layout, ...configured?.layout },
|
|
44
51
|
};
|
|
45
|
-
const containerWidth = Math.min(
|
|
46
|
-
|
|
52
|
+
const containerWidth = Math.min(
|
|
53
|
+
1600,
|
|
54
|
+
Math.max(
|
|
55
|
+
960,
|
|
56
|
+
Number(tokens.layout.containerWidth) ||
|
|
57
|
+
nuvlerDefaultTokens.layout.containerWidth,
|
|
58
|
+
),
|
|
59
|
+
);
|
|
60
|
+
const borderRadius = Math.min(
|
|
61
|
+
32,
|
|
62
|
+
Math.max(0, Number(tokens.layout.borderRadius) || 0),
|
|
63
|
+
);
|
|
47
64
|
const style = {
|
|
65
|
+
...interactionColorVariables(tokens.colors),
|
|
48
66
|
"--color-primary": tokens.colors.primary,
|
|
49
67
|
"--color-primary-text": tokens.colors.primaryText,
|
|
50
68
|
"--color-secondary": tokens.colors.secondary,
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import { interactionColorVariables } from "./interaction-colors.js";
|
|
4
|
+
import { CatalogFilters } from "./catalog-filters.js";
|
|
5
|
+
import { kitCompositionText } from "./kit-composition.js";
|
|
6
|
+
import {
|
|
7
|
+
formatWhatsappRequest,
|
|
8
|
+
whatsappRequestLabel,
|
|
9
|
+
whatsappRequestUrl,
|
|
10
|
+
} from "./whatsapp-message.js";
|
|
11
|
+
|
|
3
12
|
import {
|
|
4
13
|
useEffect,
|
|
5
14
|
useMemo,
|
|
@@ -9,6 +18,8 @@ import {
|
|
|
9
18
|
} from "react";
|
|
10
19
|
import {
|
|
11
20
|
productUrl,
|
|
21
|
+
themeCartKey,
|
|
22
|
+
verifyKitCart,
|
|
12
23
|
type NuvlerStoreThemeDefinition,
|
|
13
24
|
type ThemeCartItem,
|
|
14
25
|
type ThemeCategory,
|
|
@@ -245,7 +256,7 @@ function readStoredCart(storageKey: string): PreviewCartItem[] {
|
|
|
245
256
|
key?: unknown;
|
|
246
257
|
quantity?: unknown;
|
|
247
258
|
};
|
|
248
|
-
const key =
|
|
259
|
+
const key = themeCartKey(item);
|
|
249
260
|
const quantity =
|
|
250
261
|
typeof item.quantity === "number" && Number.isFinite(item.quantity)
|
|
251
262
|
? Math.min(99, Math.max(1, Math.trunc(item.quantity)))
|
|
@@ -396,14 +407,13 @@ export function createNuvlerDefaultRuntime(
|
|
|
396
407
|
}: NuvlerDefaultThemeProps) {
|
|
397
408
|
const [cartItems, setCartItems] = useState<PreviewCartItem[]>([]);
|
|
398
409
|
const [cartOpen, setCartOpen] = useState(false);
|
|
410
|
+
const [kitError, setKitError] = useState("");
|
|
399
411
|
const [cartToast, setCartToast] = useState<string | null>(null);
|
|
400
412
|
const [cartViewportHeight, setCartViewportHeight] = useState<number | null>(
|
|
401
413
|
null,
|
|
402
414
|
);
|
|
403
415
|
const [hydratedCartKey, setHydratedCartKey] = useState<string | null>(null);
|
|
404
|
-
const cartToastTimeout = useRef<
|
|
405
|
-
typeof window.setTimeout
|
|
406
|
-
> | null>(null);
|
|
416
|
+
const cartToastTimeout = useRef<number | null>(null);
|
|
407
417
|
const cartStorageKey = `nuvler:cart:${context.store.slug}`;
|
|
408
418
|
|
|
409
419
|
useEffect(() => {
|
|
@@ -471,6 +481,7 @@ export function createNuvlerDefaultRuntime(
|
|
|
471
481
|
Math.max(0, Number(tokens.layout.borderRadius) || 0),
|
|
472
482
|
);
|
|
473
483
|
const style = {
|
|
484
|
+
...interactionColorVariables(tokens.colors),
|
|
474
485
|
"--color-primary": tokens.colors.primary,
|
|
475
486
|
"--color-primary-text": tokens.colors.primaryText,
|
|
476
487
|
"--color-secondary": tokens.colors.secondary,
|
|
@@ -501,27 +512,22 @@ export function createNuvlerDefaultRuntime(
|
|
|
501
512
|
const hasCompletePrices =
|
|
502
513
|
cartItems.length > 0 &&
|
|
503
514
|
cartItems.every(({ unitPrice }) => typeof unitPrice === "number");
|
|
504
|
-
const cartMessage = useMemo(
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
showPrices && hasCompletePrices
|
|
514
|
-
? `\n\nTotal estimado: ${money(cartTotal)}`
|
|
515
|
-
: "";
|
|
516
|
-
return `Olá! Gostaria de solicitar um orçamento para os itens abaixo:\n\n${lines.join("\n\n")}${summary}`;
|
|
517
|
-
}, [cartItems, cartTotal, hasCompletePrices, showPrices]);
|
|
515
|
+
const cartMessage = useMemo(
|
|
516
|
+
() =>
|
|
517
|
+
formatWhatsappRequest(
|
|
518
|
+
cartItems,
|
|
519
|
+
showPrices,
|
|
520
|
+
typeof window === "undefined" ? undefined : window.location.origin,
|
|
521
|
+
),
|
|
522
|
+
[cartItems, showPrices],
|
|
523
|
+
);
|
|
518
524
|
const whatsapp = site.settings?.contact.whatsapp?.replace(/\D/g, "");
|
|
519
525
|
const checkoutUrl =
|
|
520
526
|
whatsapp && cartItems.length
|
|
521
|
-
?
|
|
527
|
+
? whatsappRequestUrl(whatsapp, cartMessage)
|
|
522
528
|
: null;
|
|
523
529
|
const addToCart = (item: ThemeCartItem) => {
|
|
524
|
-
const key =
|
|
530
|
+
const key = themeCartKey(item);
|
|
525
531
|
setCartItems((current) => {
|
|
526
532
|
const existing = current.find((candidate) => candidate.key === key);
|
|
527
533
|
if (existing)
|
|
@@ -606,7 +612,21 @@ export function createNuvlerDefaultRuntime(
|
|
|
606
612
|
</div>
|
|
607
613
|
</section>
|
|
608
614
|
<div className="store-container catalog-layout">
|
|
609
|
-
<
|
|
615
|
+
<CatalogFilters
|
|
616
|
+
key={JSON.stringify([
|
|
617
|
+
route.categoryPath,
|
|
618
|
+
route.search,
|
|
619
|
+
route.variants,
|
|
620
|
+
route.pagination.page,
|
|
621
|
+
])}
|
|
622
|
+
total={route.pagination.total}
|
|
623
|
+
activeCount={route.variants.length + (route.search ? 1 : 0)}
|
|
624
|
+
resetHref={
|
|
625
|
+
route.categoryPath.length
|
|
626
|
+
? `/${route.categoryPath.join("/")}`
|
|
627
|
+
: "/produtos"
|
|
628
|
+
}
|
|
629
|
+
>
|
|
610
630
|
<form
|
|
611
631
|
action={
|
|
612
632
|
route.categoryPath.length
|
|
@@ -615,6 +635,14 @@ export function createNuvlerDefaultRuntime(
|
|
|
615
635
|
}
|
|
616
636
|
className="catalog-filter-form"
|
|
617
637
|
>
|
|
638
|
+
{route.variants.map((token) => (
|
|
639
|
+
<input
|
|
640
|
+
key={token}
|
|
641
|
+
type="hidden"
|
|
642
|
+
name="variante"
|
|
643
|
+
value={token}
|
|
644
|
+
/>
|
|
645
|
+
))}
|
|
618
646
|
<label htmlFor="preview-catalog-search">
|
|
619
647
|
Buscar no catálogo
|
|
620
648
|
</label>
|
|
@@ -632,7 +660,14 @@ export function createNuvlerDefaultRuntime(
|
|
|
632
660
|
</div>
|
|
633
661
|
</form>
|
|
634
662
|
{route.facets.length > 0 && (
|
|
635
|
-
<form
|
|
663
|
+
<form
|
|
664
|
+
action={
|
|
665
|
+
route.categoryPath.length
|
|
666
|
+
? `/${route.categoryPath.join("/")}`
|
|
667
|
+
: "/produtos"
|
|
668
|
+
}
|
|
669
|
+
className="catalog-variant-filters"
|
|
670
|
+
>
|
|
636
671
|
{route.search && (
|
|
637
672
|
<input type="hidden" name="busca" value={route.search} />
|
|
638
673
|
)}
|
|
@@ -670,7 +705,7 @@ export function createNuvlerDefaultRuntime(
|
|
|
670
705
|
</button>
|
|
671
706
|
</form>
|
|
672
707
|
)}
|
|
673
|
-
</
|
|
708
|
+
</CatalogFilters>
|
|
674
709
|
<section className="catalog-results">
|
|
675
710
|
<ProductGrid
|
|
676
711
|
products={route.products}
|
|
@@ -688,6 +723,8 @@ export function createNuvlerDefaultRuntime(
|
|
|
688
723
|
className={
|
|
689
724
|
route.pagination.hasPreviousPage ? "" : "disabled"
|
|
690
725
|
}
|
|
726
|
+
aria-disabled={!route.pagination.hasPreviousPage}
|
|
727
|
+
tabIndex={route.pagination.hasPreviousPage ? undefined : -1}
|
|
691
728
|
href={catalogHref(
|
|
692
729
|
route,
|
|
693
730
|
Math.max(1, route.pagination.page - 1),
|
|
@@ -707,6 +744,8 @@ export function createNuvlerDefaultRuntime(
|
|
|
707
744
|
</div>
|
|
708
745
|
<a
|
|
709
746
|
className={route.pagination.hasNextPage ? "" : "disabled"}
|
|
747
|
+
aria-disabled={!route.pagination.hasNextPage}
|
|
748
|
+
tabIndex={route.pagination.hasNextPage ? undefined : -1}
|
|
710
749
|
href={catalogHref(
|
|
711
750
|
route,
|
|
712
751
|
Math.min(
|
|
@@ -950,6 +989,9 @@ export function createNuvlerDefaultRuntime(
|
|
|
950
989
|
<div>
|
|
951
990
|
<strong>{item.title}</strong>
|
|
952
991
|
{item.variantName && <small>{item.variantName}</small>}
|
|
992
|
+
{(item.kitGroups?.length || item.kitSize) && (
|
|
993
|
+
<small>{kitCompositionText(item)}</small>
|
|
994
|
+
)}
|
|
953
995
|
{item.sku && <small>Ref. {item.sku}</small>}
|
|
954
996
|
{showPrices && typeof item.unitPrice === "number" && (
|
|
955
997
|
<b>{money(item.unitPrice)}</b>
|
|
@@ -1018,6 +1060,7 @@ export function createNuvlerDefaultRuntime(
|
|
|
1018
1060
|
</div>
|
|
1019
1061
|
{cartItems.length > 0 && (
|
|
1020
1062
|
<footer className="cart-footer">
|
|
1063
|
+
{kitError && <p role="alert">{kitError}</p>}
|
|
1021
1064
|
{showPrices && hasCompletePrices && (
|
|
1022
1065
|
<div>
|
|
1023
1066
|
<span>Total estimado</span>
|
|
@@ -1031,10 +1074,28 @@ export function createNuvlerDefaultRuntime(
|
|
|
1031
1074
|
<a
|
|
1032
1075
|
className="button button-primary button-block"
|
|
1033
1076
|
href={checkoutUrl}
|
|
1077
|
+
onClick={async (event) => {
|
|
1078
|
+
if (
|
|
1079
|
+
!cartItems.some(
|
|
1080
|
+
(item) => item.kitGroups?.length || item.kitSize,
|
|
1081
|
+
)
|
|
1082
|
+
)
|
|
1083
|
+
return;
|
|
1084
|
+
event.preventDefault();
|
|
1085
|
+
try {
|
|
1086
|
+
await verifyKitCart(cartItems);
|
|
1087
|
+
setKitError("");
|
|
1088
|
+
window.location.assign(checkoutUrl);
|
|
1089
|
+
} catch {
|
|
1090
|
+
setKitError(
|
|
1091
|
+
"Não foi possível confirmar os kits. Revise os sabores e quantidades ou tente novamente.",
|
|
1092
|
+
);
|
|
1093
|
+
}
|
|
1094
|
+
}}
|
|
1034
1095
|
target="_blank"
|
|
1035
1096
|
rel="noreferrer"
|
|
1036
1097
|
>
|
|
1037
|
-
|
|
1098
|
+
{whatsappRequestLabel}
|
|
1038
1099
|
</a>
|
|
1039
1100
|
) : (
|
|
1040
1101
|
<p className="cart-warning">
|