@uptrademedia/site-kit 1.1.4 → 1.1.5
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/{chunk-TI5CH4WT.mjs → chunk-NNKC3X7O.mjs} +293 -29
- package/dist/chunk-NNKC3X7O.mjs.map +1 -0
- package/dist/{chunk-YZRNC2Z6.js → chunk-TGX5Q6UK.js} +294 -28
- package/dist/chunk-TGX5Q6UK.js.map +1 -0
- package/dist/commerce/index.d.mts +1 -1
- package/dist/commerce/index.d.ts +1 -1
- package/dist/commerce/index.js +48 -40
- package/dist/commerce/index.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +25 -25
- package/dist/index.mjs +1 -1
- package/dist/{useEventModal-CaDHkAMI.d.ts → useEventModal-TppA_tfZ.d.ts} +53 -9
- package/dist/{useEventModal-CfeDPU95.d.mts → useEventModal-cZr3PMWl.d.mts} +53 -9
- package/package.json +1 -1
- package/dist/chunk-TI5CH4WT.mjs.map +0 -1
- package/dist/chunk-YZRNC2Z6.js.map +0 -1
|
@@ -112,7 +112,14 @@ async function apiPost(endpoint, body = {}) {
|
|
|
112
112
|
body: JSON.stringify(body)
|
|
113
113
|
});
|
|
114
114
|
if (!response.ok) {
|
|
115
|
-
|
|
115
|
+
const text = await response.text();
|
|
116
|
+
let body2 = null;
|
|
117
|
+
try {
|
|
118
|
+
body2 = text ? JSON.parse(text) : null;
|
|
119
|
+
} catch {
|
|
120
|
+
body2 = text;
|
|
121
|
+
}
|
|
122
|
+
console.error(`[Commerce] API error:`, response.status, response.statusText || "Unknown", body2);
|
|
116
123
|
return null;
|
|
117
124
|
}
|
|
118
125
|
return await response.json();
|
|
@@ -141,9 +148,20 @@ async function fetchOffering(slug) {
|
|
|
141
148
|
"/api/public/commerce/offering",
|
|
142
149
|
{ slug }
|
|
143
150
|
);
|
|
144
|
-
|
|
151
|
+
if (!result) return null;
|
|
152
|
+
const offering = result.offering ?? result;
|
|
153
|
+
return offering?.id ? offering : null;
|
|
145
154
|
}
|
|
146
155
|
async function fetchLatestOffering(type, category) {
|
|
156
|
+
if (type === "product") {
|
|
157
|
+
const { products } = await fetchProductsPublic({
|
|
158
|
+
category,
|
|
159
|
+
limit: 1,
|
|
160
|
+
orderBy: "created_at",
|
|
161
|
+
order: "desc"
|
|
162
|
+
});
|
|
163
|
+
return products[0] || null;
|
|
164
|
+
}
|
|
147
165
|
const result = await apiPost(
|
|
148
166
|
"/api/public/commerce/offerings",
|
|
149
167
|
{
|
|
@@ -174,7 +192,15 @@ async function fetchNextEvent(category) {
|
|
|
174
192
|
return events[0] || null;
|
|
175
193
|
}
|
|
176
194
|
async function fetchProducts(options = {}) {
|
|
177
|
-
|
|
195
|
+
const { products } = await fetchProductsPublic({
|
|
196
|
+
category: options.category,
|
|
197
|
+
limit: options.limit,
|
|
198
|
+
offset: options.offset,
|
|
199
|
+
orderBy: options.orderBy || "sort_order",
|
|
200
|
+
order: options.order || "asc",
|
|
201
|
+
search: options.search
|
|
202
|
+
});
|
|
203
|
+
return products;
|
|
178
204
|
}
|
|
179
205
|
async function fetchServices(options = {}) {
|
|
180
206
|
return fetchOfferings({ ...options, type: "service" });
|
|
@@ -203,6 +229,37 @@ async function fetchCategories() {
|
|
|
203
229
|
);
|
|
204
230
|
return result?.categories || [];
|
|
205
231
|
}
|
|
232
|
+
async function fetchShippingRates(shippingAddress, offerings) {
|
|
233
|
+
const result = await apiPost(
|
|
234
|
+
"/api/public/commerce/shipping-rates",
|
|
235
|
+
{
|
|
236
|
+
shippingAddress: {
|
|
237
|
+
street1: shippingAddress.street1,
|
|
238
|
+
street2: shippingAddress.street2,
|
|
239
|
+
city: shippingAddress.city,
|
|
240
|
+
state: shippingAddress.state,
|
|
241
|
+
zip: shippingAddress.zip,
|
|
242
|
+
country: shippingAddress.country || "US"
|
|
243
|
+
},
|
|
244
|
+
offerings
|
|
245
|
+
}
|
|
246
|
+
);
|
|
247
|
+
return Array.isArray(result) ? result : [];
|
|
248
|
+
}
|
|
249
|
+
async function validateAddress(address) {
|
|
250
|
+
const result = await apiPost(
|
|
251
|
+
"/api/public/commerce/validate-address",
|
|
252
|
+
{
|
|
253
|
+
street1: address.street1,
|
|
254
|
+
street2: address.street2,
|
|
255
|
+
city: address.city,
|
|
256
|
+
state: address.state,
|
|
257
|
+
zip: address.zip,
|
|
258
|
+
country: address.country || "US"
|
|
259
|
+
}
|
|
260
|
+
);
|
|
261
|
+
return result || { isValid: true, messages: [] };
|
|
262
|
+
}
|
|
206
263
|
async function fetchActiveProcessor() {
|
|
207
264
|
const { apiUrl, apiKey } = getApiConfig();
|
|
208
265
|
if (!apiKey) return null;
|
|
@@ -571,8 +628,9 @@ function OfferingList({
|
|
|
571
628
|
setError(null);
|
|
572
629
|
try {
|
|
573
630
|
let data;
|
|
574
|
-
if (type === "product") {
|
|
575
|
-
|
|
631
|
+
if (type === "product" || Array.isArray(type) && type.includes("product")) {
|
|
632
|
+
const { products } = await fetchProductsPublic({ category, limit, orderBy: "sort_order", order: "asc" });
|
|
633
|
+
data = products;
|
|
576
634
|
} else if (type === "event") {
|
|
577
635
|
data = await fetchUpcomingEvents({ category, limit });
|
|
578
636
|
} else {
|
|
@@ -1058,7 +1116,7 @@ function ProductEmbed({
|
|
|
1058
1116
|
try {
|
|
1059
1117
|
let data = null;
|
|
1060
1118
|
if (mode === "specific" && slug) {
|
|
1061
|
-
data = await
|
|
1119
|
+
data = await fetchProductBySlug(slug);
|
|
1062
1120
|
} else if (mode === "latest" || mode === "featured") {
|
|
1063
1121
|
data = await fetchLatestOffering("product", category);
|
|
1064
1122
|
}
|
|
@@ -1147,7 +1205,7 @@ function ProductDetail({
|
|
|
1147
1205
|
async function load() {
|
|
1148
1206
|
setLoading(true);
|
|
1149
1207
|
try {
|
|
1150
|
-
const data = await
|
|
1208
|
+
const data = await fetchProductBySlug(slug);
|
|
1151
1209
|
setProduct(data);
|
|
1152
1210
|
if (data?.variants?.length) {
|
|
1153
1211
|
const defaultVariant = data.variants.find((v) => v.is_default) || data.variants[0];
|
|
@@ -1562,6 +1620,7 @@ function ProductGrid({
|
|
|
1562
1620
|
style
|
|
1563
1621
|
}) {
|
|
1564
1622
|
const [products, setProducts] = React5.useState(propProducts || []);
|
|
1623
|
+
const [total, setTotal] = React5.useState(0);
|
|
1565
1624
|
const [loading, setLoading] = React5.useState(!propProducts);
|
|
1566
1625
|
const [searchQuery, setSearchQuery] = React5.useState("");
|
|
1567
1626
|
const [selectedCategory, setSelectedCategory] = React5.useState(propCategory);
|
|
@@ -1578,19 +1637,20 @@ function ProductGrid({
|
|
|
1578
1637
|
React5.useEffect(() => {
|
|
1579
1638
|
if (propProducts) {
|
|
1580
1639
|
setProducts(propProducts);
|
|
1640
|
+
setTotal(propProducts.length);
|
|
1581
1641
|
return;
|
|
1582
1642
|
}
|
|
1583
1643
|
async function load() {
|
|
1584
1644
|
setLoading(true);
|
|
1585
1645
|
try {
|
|
1586
|
-
const data = await
|
|
1587
|
-
type: "product",
|
|
1646
|
+
const { products: data, total: count } = await fetchProductsPublic({
|
|
1588
1647
|
category: selectedCategory,
|
|
1589
1648
|
limit,
|
|
1590
1649
|
orderBy: "created_at",
|
|
1591
1650
|
order: "desc"
|
|
1592
1651
|
});
|
|
1593
1652
|
setProducts(data);
|
|
1653
|
+
setTotal(count);
|
|
1594
1654
|
} catch (e) {
|
|
1595
1655
|
console.error("Failed to load products:", e);
|
|
1596
1656
|
} finally {
|
|
@@ -1716,9 +1776,9 @@ function ProductGrid({
|
|
|
1716
1776
|
fontSize: "0.875rem",
|
|
1717
1777
|
color: "#6b7280"
|
|
1718
1778
|
}, children: [
|
|
1719
|
-
filteredProducts.length,
|
|
1779
|
+
searchQuery ? filteredProducts.length : total,
|
|
1720
1780
|
" product",
|
|
1721
|
-
filteredProducts.length !== 1 ? "s" : ""
|
|
1781
|
+
(searchQuery ? filteredProducts.length : total) !== 1 ? "s" : ""
|
|
1722
1782
|
] })
|
|
1723
1783
|
] }),
|
|
1724
1784
|
loading && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "site-kit-product-grid__grid", style: {
|
|
@@ -1817,7 +1877,7 @@ function ProductPage({
|
|
|
1817
1877
|
async function load() {
|
|
1818
1878
|
setLoading(true);
|
|
1819
1879
|
try {
|
|
1820
|
-
const data = await
|
|
1880
|
+
const data = await fetchProductBySlug(slug);
|
|
1821
1881
|
setProduct(data);
|
|
1822
1882
|
} catch (e) {
|
|
1823
1883
|
console.error("Failed to load product:", e);
|
|
@@ -1831,13 +1891,12 @@ function ProductPage({
|
|
|
1831
1891
|
if (!product || !showRelatedProducts) return;
|
|
1832
1892
|
async function loadRelated() {
|
|
1833
1893
|
try {
|
|
1834
|
-
const
|
|
1835
|
-
type: "product",
|
|
1894
|
+
const { products } = await fetchProductsPublic({
|
|
1836
1895
|
category: product?.category_id,
|
|
1837
1896
|
limit: relatedProductsLimit + 1
|
|
1838
1897
|
// Fetch one extra to exclude current
|
|
1839
1898
|
});
|
|
1840
|
-
const filtered =
|
|
1899
|
+
const filtered = products.filter((p) => p.id !== product?.id).slice(0, relatedProductsLimit);
|
|
1841
1900
|
setRelatedProducts(filtered);
|
|
1842
1901
|
} catch (e) {
|
|
1843
1902
|
console.error("Failed to load related products:", e);
|
|
@@ -2093,21 +2152,62 @@ function CheckoutForm({
|
|
|
2093
2152
|
const [success, setSuccess] = React5.useState(false);
|
|
2094
2153
|
const [quantity, setQuantity] = React5.useState(initialQuantity);
|
|
2095
2154
|
const [processor, setProcessor] = React5.useState(null);
|
|
2155
|
+
const [shippingEnabled, setShippingEnabled] = React5.useState(false);
|
|
2156
|
+
const [shippingStep, setShippingStep] = React5.useState("address");
|
|
2157
|
+
const [shippingAddress, setShippingAddress] = React5.useState({
|
|
2158
|
+
street1: "",
|
|
2159
|
+
street2: "",
|
|
2160
|
+
city: "",
|
|
2161
|
+
state: "",
|
|
2162
|
+
zip: "",
|
|
2163
|
+
country: "US"
|
|
2164
|
+
});
|
|
2165
|
+
const [shippingRates, setShippingRates] = React5.useState([]);
|
|
2166
|
+
const [selectedRate, setSelectedRate] = React5.useState(null);
|
|
2167
|
+
const [loadingRates, setLoadingRates] = React5.useState(false);
|
|
2096
2168
|
const [customer, setCustomer] = React5.useState({
|
|
2097
2169
|
email: "",
|
|
2098
2170
|
name: "",
|
|
2099
2171
|
phone: ""
|
|
2100
2172
|
});
|
|
2173
|
+
const isProduct = offering.type === "product";
|
|
2101
2174
|
React5.useEffect(() => {
|
|
2102
|
-
|
|
2103
|
-
if (
|
|
2175
|
+
fetchProcessorConfig().then((config) => {
|
|
2176
|
+
if (config?.processor) setProcessor(config.processor);
|
|
2177
|
+
if (config?.shipping_enabled && isProduct) setShippingEnabled(true);
|
|
2104
2178
|
});
|
|
2105
|
-
}, []);
|
|
2179
|
+
}, [isProduct]);
|
|
2106
2180
|
const isEvent = offering.type === "event" || offering.type === "class";
|
|
2107
2181
|
const isFree = !offering.price || offering.price === 0;
|
|
2108
2182
|
const actualMode = isEvent && isFree ? "register" : mode;
|
|
2109
2183
|
const defaultSubmitText = actualMode === "register" ? "Register" : isFree ? "Complete Order" : "Continue to Payment";
|
|
2110
|
-
const
|
|
2184
|
+
const subtotal = offering.price ? offering.price * quantity : 0;
|
|
2185
|
+
const shippingCost = selectedRate ? parseFloat(selectedRate.amount) : 0;
|
|
2186
|
+
const total = subtotal + shippingCost;
|
|
2187
|
+
const updateShippingAddress = (field, value) => {
|
|
2188
|
+
setShippingAddress((prev) => ({ ...prev, [field]: value }));
|
|
2189
|
+
};
|
|
2190
|
+
const handleGetShippingRates = async () => {
|
|
2191
|
+
if (!shippingAddress.street1 || !shippingAddress.city || !shippingAddress.state || !shippingAddress.zip) {
|
|
2192
|
+
setError("Please fill in all required address fields.");
|
|
2193
|
+
return;
|
|
2194
|
+
}
|
|
2195
|
+
setLoadingRates(true);
|
|
2196
|
+
setError(null);
|
|
2197
|
+
try {
|
|
2198
|
+
const rates = await fetchShippingRates(
|
|
2199
|
+
{ ...shippingAddress, name: customer.name, phone: customer.phone },
|
|
2200
|
+
[{ offering_id: offering.id, quantity }]
|
|
2201
|
+
);
|
|
2202
|
+
setShippingRates(rates);
|
|
2203
|
+
if (rates.length > 0) setSelectedRate(rates[0]);
|
|
2204
|
+
setShippingStep("rates");
|
|
2205
|
+
} catch (e) {
|
|
2206
|
+
setError("Failed to get shipping rates. Please check your address.");
|
|
2207
|
+
} finally {
|
|
2208
|
+
setLoadingRates(false);
|
|
2209
|
+
}
|
|
2210
|
+
};
|
|
2111
2211
|
const handleSubmit = async (e) => {
|
|
2112
2212
|
e.preventDefault();
|
|
2113
2213
|
setLoading(true);
|
|
@@ -2123,12 +2223,23 @@ function CheckoutForm({
|
|
|
2123
2223
|
onError?.(result.error || "Registration failed");
|
|
2124
2224
|
}
|
|
2125
2225
|
} else {
|
|
2126
|
-
const
|
|
2226
|
+
const checkoutOptions = {
|
|
2127
2227
|
variantId,
|
|
2128
2228
|
scheduleId,
|
|
2129
2229
|
quantity,
|
|
2130
2230
|
customer
|
|
2131
|
-
}
|
|
2231
|
+
};
|
|
2232
|
+
if (shippingEnabled && shippingAddress.street1 && selectedRate) {
|
|
2233
|
+
checkoutOptions.shippingAddress = {
|
|
2234
|
+
...shippingAddress,
|
|
2235
|
+
name: customer.name,
|
|
2236
|
+
phone: customer.phone
|
|
2237
|
+
};
|
|
2238
|
+
checkoutOptions.shippingCarrier = selectedRate.carrier;
|
|
2239
|
+
checkoutOptions.shippingService = selectedRate.service;
|
|
2240
|
+
checkoutOptions.shippingCost = parseFloat(selectedRate.amount);
|
|
2241
|
+
}
|
|
2242
|
+
const result = await createCheckoutSession(offering.id, checkoutOptions);
|
|
2132
2243
|
if (result.success && result.payment_url) {
|
|
2133
2244
|
window.location.href = result.payment_url;
|
|
2134
2245
|
} else {
|
|
@@ -2147,6 +2258,7 @@ function CheckoutForm({
|
|
|
2147
2258
|
const updateCustomer = (field, value) => {
|
|
2148
2259
|
setCustomer((prev) => ({ ...prev, [field]: value }));
|
|
2149
2260
|
};
|
|
2261
|
+
const canProceedToPayment = !shippingEnabled || shippingStep === "rates" && selectedRate;
|
|
2150
2262
|
if (success) {
|
|
2151
2263
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `site-kit-checkout-success ${className}`, style: {
|
|
2152
2264
|
padding: "2rem",
|
|
@@ -2191,10 +2303,7 @@ function CheckoutForm({
|
|
|
2191
2303
|
children: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map((n) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: n, children: n }, n))
|
|
2192
2304
|
}
|
|
2193
2305
|
),
|
|
2194
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2195
|
-
"Total: ",
|
|
2196
|
-
formatPrice(total, offering.currency)
|
|
2197
|
-
] })
|
|
2306
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { marginLeft: "auto", fontWeight: 600 }, children: shippingEnabled && selectedRate ? `Subtotal: ${formatPrice(subtotal, offering.currency)}` : `Total: ${formatPrice(total, offering.currency)}` })
|
|
2198
2307
|
] })
|
|
2199
2308
|
] }),
|
|
2200
2309
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "1rem" }, children: [
|
|
@@ -2258,6 +2367,161 @@ function CheckoutForm({
|
|
|
2258
2367
|
)
|
|
2259
2368
|
] })
|
|
2260
2369
|
] }),
|
|
2370
|
+
shippingEnabled && !isEvent && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginTop: "1.5rem", paddingTop: "1.5rem", borderTop: "1px solid #e5e7eb" }, children: [
|
|
2371
|
+
/* @__PURE__ */ jsxRuntime.jsx("h4", { style: { margin: "0 0 1rem", fontSize: "1rem" }, children: "Shipping Address" }),
|
|
2372
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "1rem" }, children: [
|
|
2373
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2374
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { style: { display: "block", fontSize: "0.875rem", fontWeight: 500, marginBottom: "0.25rem" }, children: "Street Address *" }),
|
|
2375
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2376
|
+
"input",
|
|
2377
|
+
{
|
|
2378
|
+
type: "text",
|
|
2379
|
+
required: shippingEnabled,
|
|
2380
|
+
value: shippingAddress.street1,
|
|
2381
|
+
onChange: (e) => updateShippingAddress("street1", e.target.value),
|
|
2382
|
+
className: inputClassName,
|
|
2383
|
+
placeholder: "123 Main St",
|
|
2384
|
+
style: { width: "100%", padding: "0.625rem 0.75rem", borderRadius: "6px", border: "1px solid #d1d5db", fontSize: "1rem" }
|
|
2385
|
+
}
|
|
2386
|
+
)
|
|
2387
|
+
] }),
|
|
2388
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2389
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { style: { display: "block", fontSize: "0.875rem", fontWeight: 500, marginBottom: "0.25rem" }, children: "Apartment, suite, etc." }),
|
|
2390
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2391
|
+
"input",
|
|
2392
|
+
{
|
|
2393
|
+
type: "text",
|
|
2394
|
+
value: shippingAddress.street2 || "",
|
|
2395
|
+
onChange: (e) => updateShippingAddress("street2", e.target.value),
|
|
2396
|
+
className: inputClassName,
|
|
2397
|
+
style: { width: "100%", padding: "0.625rem 0.75rem", borderRadius: "6px", border: "1px solid #d1d5db", fontSize: "1rem" }
|
|
2398
|
+
}
|
|
2399
|
+
)
|
|
2400
|
+
] }),
|
|
2401
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: "1rem" }, children: [
|
|
2402
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2403
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { style: { display: "block", fontSize: "0.875rem", fontWeight: 500, marginBottom: "0.25rem" }, children: "City *" }),
|
|
2404
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2405
|
+
"input",
|
|
2406
|
+
{
|
|
2407
|
+
type: "text",
|
|
2408
|
+
required: shippingEnabled,
|
|
2409
|
+
value: shippingAddress.city,
|
|
2410
|
+
onChange: (e) => updateShippingAddress("city", e.target.value),
|
|
2411
|
+
className: inputClassName,
|
|
2412
|
+
style: { width: "100%", padding: "0.625rem 0.75rem", borderRadius: "6px", border: "1px solid #d1d5db", fontSize: "1rem" }
|
|
2413
|
+
}
|
|
2414
|
+
)
|
|
2415
|
+
] }),
|
|
2416
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2417
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { style: { display: "block", fontSize: "0.875rem", fontWeight: 500, marginBottom: "0.25rem" }, children: "State *" }),
|
|
2418
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2419
|
+
"input",
|
|
2420
|
+
{
|
|
2421
|
+
type: "text",
|
|
2422
|
+
required: shippingEnabled,
|
|
2423
|
+
value: shippingAddress.state,
|
|
2424
|
+
onChange: (e) => updateShippingAddress("state", e.target.value),
|
|
2425
|
+
className: inputClassName,
|
|
2426
|
+
style: { width: "100%", padding: "0.625rem 0.75rem", borderRadius: "6px", border: "1px solid #d1d5db", fontSize: "1rem" }
|
|
2427
|
+
}
|
|
2428
|
+
)
|
|
2429
|
+
] })
|
|
2430
|
+
] }),
|
|
2431
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2432
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { style: { display: "block", fontSize: "0.875rem", fontWeight: 500, marginBottom: "0.25rem" }, children: "ZIP Code *" }),
|
|
2433
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2434
|
+
"input",
|
|
2435
|
+
{
|
|
2436
|
+
type: "text",
|
|
2437
|
+
required: shippingEnabled,
|
|
2438
|
+
value: shippingAddress.zip,
|
|
2439
|
+
onChange: (e) => updateShippingAddress("zip", e.target.value),
|
|
2440
|
+
className: inputClassName,
|
|
2441
|
+
style: { width: "100%", maxWidth: "120px", padding: "0.625rem 0.75rem", borderRadius: "6px", border: "1px solid #d1d5db", fontSize: "1rem" }
|
|
2442
|
+
}
|
|
2443
|
+
)
|
|
2444
|
+
] })
|
|
2445
|
+
] }),
|
|
2446
|
+
shippingStep === "address" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2447
|
+
"button",
|
|
2448
|
+
{
|
|
2449
|
+
type: "button",
|
|
2450
|
+
onClick: handleGetShippingRates,
|
|
2451
|
+
disabled: loadingRates || !shippingAddress.street1 || !shippingAddress.city || !shippingAddress.state || !shippingAddress.zip,
|
|
2452
|
+
style: {
|
|
2453
|
+
marginTop: "1rem",
|
|
2454
|
+
padding: "0.625rem 1.25rem",
|
|
2455
|
+
borderRadius: "6px",
|
|
2456
|
+
border: "1px solid #2563eb",
|
|
2457
|
+
background: "white",
|
|
2458
|
+
color: "#2563eb",
|
|
2459
|
+
fontSize: "0.875rem",
|
|
2460
|
+
fontWeight: 500,
|
|
2461
|
+
cursor: loadingRates ? "not-allowed" : "pointer"
|
|
2462
|
+
},
|
|
2463
|
+
children: loadingRates ? "Getting rates..." : "Get shipping options"
|
|
2464
|
+
}
|
|
2465
|
+
),
|
|
2466
|
+
shippingStep === "rates" && shippingRates.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginTop: "1rem" }, children: [
|
|
2467
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { style: { display: "block", fontSize: "0.875rem", fontWeight: 500, marginBottom: "0.5rem" }, children: "Select shipping method" }),
|
|
2468
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: shippingRates.map((rate) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2469
|
+
"label",
|
|
2470
|
+
{
|
|
2471
|
+
style: {
|
|
2472
|
+
display: "flex",
|
|
2473
|
+
alignItems: "center",
|
|
2474
|
+
gap: "0.75rem",
|
|
2475
|
+
padding: "0.75rem",
|
|
2476
|
+
borderRadius: "6px",
|
|
2477
|
+
border: `2px solid ${selectedRate === rate ? "#2563eb" : "#e5e7eb"}`,
|
|
2478
|
+
background: selectedRate === rate ? "#eff6ff" : "white",
|
|
2479
|
+
cursor: "pointer"
|
|
2480
|
+
},
|
|
2481
|
+
children: [
|
|
2482
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2483
|
+
"input",
|
|
2484
|
+
{
|
|
2485
|
+
type: "radio",
|
|
2486
|
+
name: "shipping-rate",
|
|
2487
|
+
checked: selectedRate === rate,
|
|
2488
|
+
onChange: () => setSelectedRate(rate)
|
|
2489
|
+
}
|
|
2490
|
+
),
|
|
2491
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { flex: 1 }, children: [
|
|
2492
|
+
rate.carrier,
|
|
2493
|
+
" - ",
|
|
2494
|
+
rate.service
|
|
2495
|
+
] }),
|
|
2496
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontWeight: 600 }, children: formatPrice(parseFloat(rate.amount), rate.currency || "USD") }),
|
|
2497
|
+
rate.estimatedDays && /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { fontSize: "0.75rem", color: "#666" }, children: [
|
|
2498
|
+
"(",
|
|
2499
|
+
rate.estimatedDays,
|
|
2500
|
+
" days)"
|
|
2501
|
+
] })
|
|
2502
|
+
]
|
|
2503
|
+
},
|
|
2504
|
+
rate.objectId || `${rate.carrier}-${rate.service}`
|
|
2505
|
+
)) }),
|
|
2506
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2507
|
+
"button",
|
|
2508
|
+
{
|
|
2509
|
+
type: "button",
|
|
2510
|
+
onClick: () => setShippingStep("address"),
|
|
2511
|
+
style: {
|
|
2512
|
+
marginTop: "0.75rem",
|
|
2513
|
+
fontSize: "0.875rem",
|
|
2514
|
+
color: "#6b7280",
|
|
2515
|
+
background: "none",
|
|
2516
|
+
border: "none",
|
|
2517
|
+
cursor: "pointer",
|
|
2518
|
+
textDecoration: "underline"
|
|
2519
|
+
},
|
|
2520
|
+
children: "Change address"
|
|
2521
|
+
}
|
|
2522
|
+
)
|
|
2523
|
+
] })
|
|
2524
|
+
] }),
|
|
2261
2525
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2262
2526
|
marginTop: "1rem",
|
|
2263
2527
|
padding: "0.75rem",
|
|
@@ -2271,7 +2535,7 @@ function CheckoutForm({
|
|
|
2271
2535
|
"button",
|
|
2272
2536
|
{
|
|
2273
2537
|
type: "submit",
|
|
2274
|
-
disabled: loading,
|
|
2538
|
+
disabled: loading || !isEvent && !isFree && !canProceedToPayment,
|
|
2275
2539
|
className: buttonClassName,
|
|
2276
2540
|
style: {
|
|
2277
2541
|
width: "100%",
|
|
@@ -4177,6 +4441,7 @@ exports.fetchProductBySlug = fetchProductBySlug;
|
|
|
4177
4441
|
exports.fetchProducts = fetchProducts;
|
|
4178
4442
|
exports.fetchProductsPublic = fetchProductsPublic;
|
|
4179
4443
|
exports.fetchServices = fetchServices;
|
|
4444
|
+
exports.fetchShippingRates = fetchShippingRates;
|
|
4180
4445
|
exports.fetchUpcomingEvents = fetchUpcomingEvents;
|
|
4181
4446
|
exports.formatDate = formatDate;
|
|
4182
4447
|
exports.formatDateRange = formatDateRange;
|
|
@@ -4189,5 +4454,6 @@ exports.getSpotsRemaining = getSpotsRemaining;
|
|
|
4189
4454
|
exports.isEventSoldOut = isEventSoldOut;
|
|
4190
4455
|
exports.registerForEvent = registerForEvent;
|
|
4191
4456
|
exports.useEventModal = useEventModal;
|
|
4192
|
-
|
|
4193
|
-
//# sourceMappingURL=chunk-
|
|
4457
|
+
exports.validateAddress = validateAddress;
|
|
4458
|
+
//# sourceMappingURL=chunk-TGX5Q6UK.js.map
|
|
4459
|
+
//# sourceMappingURL=chunk-TGX5Q6UK.js.map
|