@nextblock-cms/ecom 0.8.0 → 0.8.6
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/AddToCartButton-DsSEH9yp.cjs +1 -0
- package/AddToCartButton-ffE0DhHu.js +59 -0
- package/CouponForm-BI_5SBHQ.js +152 -0
- package/CouponForm-D_uu2bLP.cjs +1 -0
- package/CurrencyProvider-Cg-Q6ucj.cjs +1 -0
- package/CurrencyProvider-OzlRN96V.js +120 -0
- package/CurrencyProvider.cjs.js +1 -0
- package/CurrencyProvider.es.js +10 -0
- package/ProductDetailsLayout-BxJH_BxR.cjs +1 -0
- package/ProductDetailsLayout-Dg8dRTYp.js +530 -0
- package/ProductGrid-BdL7iglO.cjs +1 -0
- package/ProductGrid-D3AWM8sr.js +130 -0
- package/actions-AHmBrS5e.cjs +48 -0
- package/actions-j5fuSZX-.js +820 -0
- package/cart-store.cjs.js +1 -0
- package/cart-store.es.js +116 -0
- package/components/Cart.cjs.js +1 -0
- package/components/Cart.es.js +259 -0
- package/components/CartDrawer.cjs.js +1 -0
- package/components/CartDrawer.es.js +118 -0
- package/components/CartIcon.cjs.js +1 -0
- package/components/CartIcon.es.js +33 -0
- package/components/Checkout.cjs.js +1 -0
- package/components/Checkout.es.js +1020 -0
- package/components/CurrencySwitcher.cjs.js +1 -0
- package/components/CurrencySwitcher.es.js +17 -0
- package/components/FeaturedProduct.cjs.js +1 -0
- package/components/FeaturedProduct.es.js +71 -0
- package/components/ProductDetailsLayout.cjs.js +1 -0
- package/components/ProductDetailsLayout.es.js +19 -0
- package/components/ProductGrid.cjs.js +1 -0
- package/components/ProductGrid.es.js +6 -0
- package/components/SimpleTiptapRenderer.cjs.js +1 -0
- package/components/SimpleTiptapRenderer.es.js +187 -0
- package/coupon-server-C9ySm3I5.cjs +1 -0
- package/coupon-server-DUKVtyYs.js +248 -0
- package/currency-constants.cjs.js +1 -0
- package/currency-constants.es.js +4 -0
- package/currency.cjs.js +1 -0
- package/currency.es.js +312 -0
- package/customer-C-UPvrYN.cjs +1 -0
- package/customer-C3xccjUg.js +57 -0
- package/index.cjs.js +1 -1
- package/index.es.js +414 -3105
- package/invoice-ui-CAnJPu6n.cjs +29 -0
- package/invoice-ui-DtpbTJE1.js +2886 -0
- package/package.json +10 -5
- package/product-actions-CONBF8i6.cjs +251 -0
- package/product-actions-DjlIWCMH.js +691 -0
- package/resolver-Fz_FKsfX.cjs +7 -0
- package/resolver-cfrCaHpE.js +128 -0
- package/server-actions/product-actions.cjs.js +1 -0
- package/server-actions/product-actions.es.js +15 -0
- package/server.cjs.js +27 -27
- package/server.es.js +478 -463
- package/shipping-actions-BnHjlo2q.js +25 -0
- package/shipping-actions-D6zt20gg.cjs +1 -0
- package/states-CWYRxV4B.cjs +1 -0
- package/states-DlHJezQ1.js +200 -0
- package/tax-calculation-Dab89aHd.js +181 -0
- package/tax-calculation-MkDKOEkL.cjs +1 -0
- package/trials-DvZaOtNy.cjs +1 -0
- package/trials-RDcRAZKx.js +29 -0
- package/types.cjs.js +1 -0
- package/types.es.js +33 -0
- package/use-cart.cjs.js +1 -0
- package/use-cart.es.js +43 -0
- package/variation-utils.cjs.js +1 -0
- package/variation-utils.es.js +246 -0
- package/invoice-ui-BJZfedDd.cjs +0 -332
- package/invoice-ui-GJ1ADAjn.js +0 -5759
package/server.es.js
CHANGED
|
@@ -1,39 +1,54 @@
|
|
|
1
1
|
import na from "stripe";
|
|
2
|
-
import { createClient as
|
|
2
|
+
import { createClient as Qe } from "@supabase/supabase-js";
|
|
3
3
|
import { verifyPackageOnline as ia, getServiceRoleSupabaseClient as re, createClient as ue, getActiveLanguagesServerSide as At } from "@nextblock-cms/db/server";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import "
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
4
|
+
import { r as oa, s as Pt, n as Zt } from "./resolver-cfrCaHpE.js";
|
|
5
|
+
import { getDefaultCurrency as Tt, resolveEffectivePriceForCurrency as vt, normalizeCurrencyRecord as Se, normalizePriceMap as rt, convertMinorUnitAmount as wt } from "./currency.es.js";
|
|
6
|
+
import { CURRENCY_ROUNDING_MODES as jo, applyCurrencyRounding as Ko, describeCurrencyRoundingRule as Vo, getCurrencyLookup as Go, getExchangeRateForCurrency as Ho, inferCurrencyCodeFromLocale as Wo, isSaleWindowActive as Qo, isScheduledPriceDue as Xo, normalizeCurrencyRoundingMode as Yo, normalizeSalePriceMap as Zo, resolvePriceForCurrency as Jo, resolvePriceRangeForCurrency as ec, sortCurrencies as tc } from "./currency.es.js";
|
|
7
|
+
import { b as nt, n as ca } from "./customer-C3xccjUg.js";
|
|
8
|
+
import { a as ac, e as sc, i as nc } from "./customer-C3xccjUg.js";
|
|
9
|
+
import { u as Sr, f as la, F as da, r as Jt, p as ua, a as ma, t as pa, b as ha, c as It, d as fa, e as ga, h as _a, i as ya, j as xa, k as ba } from "./actions-j5fuSZX-.js";
|
|
10
|
+
import { l as oc, m as cc, n as lc, s as dc, o as uc } from "./actions-j5fuSZX-.js";
|
|
11
|
+
import "server-only";
|
|
12
|
+
import va from "postgres";
|
|
13
|
+
import { E as wa, n as Na, g as Xe, a as er, d as tr, c as Ca, S as Sa, e as rr, f as ka, u as kr } from "./tax-calculation-Dab89aHd.js";
|
|
14
|
+
import { I as Ea, p as Aa, D as Pa, q as Er, g as Ta, f as Ia, e as Ra, b as Fa, v as Ua, w as $a, x as Ar, y as Oa, z as La, A as Ma, B as qa, C as Da, E as za, c as Pr, F as Ba, G as ja, H as Ka, J as Va, K as Ga, L as it, M as Tr } from "./invoice-ui-DtpbTJE1.js";
|
|
15
|
+
import { d as pc, h as hc, i as fc, j as gc, l as _c, m as yc, n as xc, r as bc, s as vc, N as wc, O as Nc } from "./invoice-ui-DtpbTJE1.js";
|
|
16
|
+
import { a as Ha, b as Wa, g as Qa, r as Xa, n as Ya } from "./coupon-server-DUKVtyYs.js";
|
|
17
|
+
import { CURRENCY_COOKIE_NAME as Sc } from "./currency-constants.es.js";
|
|
18
|
+
import { normalizeCurrencyCode as ie, formatPrice as Fe, minorUnitAmountToMajor as ve, getCurrencyMinorUnitFactor as ze, majorUnitAmountToMinor as Ir } from "@nextblock-cms/utils";
|
|
19
|
+
import { s as Rr, g as Fr } from "./product-actions-DjlIWCMH.js";
|
|
20
|
+
import { c as Ec, a as Ac, d as Pc, f as Tc, b as Ic, e as Rc, h as Fc, i as Uc, u as $c } from "./product-actions-DjlIWCMH.js";
|
|
21
|
+
import { c as De, n as Rt, b as Ft, g as Nt, r as Ur, a as Za } from "./states-DlHJezQ1.js";
|
|
22
|
+
import { isDigitalItem as Ja, DEFAULT_ENABLED_PAYMENT_PROVIDERS as es, normalizeEnabledPaymentProviders as ts } from "./types.es.js";
|
|
23
|
+
import { resolveTranslatedText as rs, mapRawVariantRelations as $r } from "./variation-utils.es.js";
|
|
9
24
|
import ar from "crypto";
|
|
10
|
-
import { Freemius as as } from "
|
|
25
|
+
import { Freemius as as } from "@freemius/sdk";
|
|
11
26
|
import { jsxs as s, jsx as e, Fragment as Be } from "react/jsx-runtime";
|
|
12
27
|
import te from "next/link";
|
|
13
28
|
import { useState as P, useTransition as $e, useMemo as ee, useEffect as Ue, useRef as ss } from "react";
|
|
14
29
|
import { Dialog as ot, DialogTrigger as ct, Button as T, DialogContent as lt, DialogHeader as dt, DialogTitle as ut, DialogDescription as mt, Label as D, Input as V, Select as je, SelectTrigger as Ke, SelectValue as Ve, SelectContent as Ge, SelectItem as _e, DialogFooter as pt, Table as Ut, TableHeader as $t, TableRow as ye, TableHead as Y, Checkbox as He, TableBody as Ot, TableCell as G, Badge as ae, DialogClose as ns, Card as oe, Textarea as Ct, CardHeader as we, CardTitle as ge, CardDescription as Ne, CardContent as pe, TooltipProvider as is, Tooltip as os, TooltipTrigger as cs, TooltipContent as ls } from "@nextblock-cms/ui";
|
|
15
|
-
import { Download as St, FileDown as ds, Calendar as sr, Loader2 as Or, Printer as us, Trash2 as
|
|
16
|
-
import { toast as X } from "
|
|
17
|
-
import Is from "
|
|
30
|
+
import { Download as St, FileDown as ds, Calendar as sr, Loader2 as Or, Printer as us, Trash2 as xe, Search as ht, Archive as ms, RefreshCw as Lr, Upload as ps, RotateCcw as hs, Save as fs, Plus as We, ChevronUp as gs, ChevronDown as _s, ArrowLeft as ft, ExternalLink as ys, Copy as xs, CheckCircle2 as kt, AlertCircle as Mr, FolderPlus as bs, FolderKanban as vs, HelpCircle as ws, Edit2 as Lt, MapPin as Ns, Languages as Cs, DollarSign as xt, Gift as Ss, Boxes as ks, Truck as nr, Globe as ir, Info as Es, Settings2 as As, ShieldCheck as Ps, ImageIcon as Ts } from "lucide-react";
|
|
31
|
+
import { toast as X } from "sonner";
|
|
32
|
+
import Is from "papaparse";
|
|
18
33
|
import { useRouter as Oe, notFound as Mt, redirect as gt } from "next/navigation";
|
|
19
34
|
import Rs from "next/image";
|
|
20
|
-
import { revalidatePath as
|
|
35
|
+
import { revalidatePath as Q } from "next/cache";
|
|
21
36
|
import { useFormStatus as Fs } from "react-dom";
|
|
22
37
|
import { Button as at } from "@nextblock-cms/ui/button";
|
|
23
38
|
import { Dialog as Us, DialogTrigger as $s, DialogContent as Os, DialogHeader as Ls, DialogTitle as Ms } from "@nextblock-cms/ui/dialog";
|
|
24
39
|
import { Input as qs } from "@nextblock-cms/ui/input";
|
|
25
40
|
const Ce = new na(process.env.STRIPE_SECRET_KEY || "sk_test_dummy", {
|
|
26
41
|
typescript: !0
|
|
27
|
-
}),
|
|
42
|
+
}), fo = async (t, r, a, n) => {
|
|
28
43
|
const i = process.env.NEXT_PUBLIC_SUPABASE_URL, o = process.env.SUPABASE_SERVICE_ROLE_KEY;
|
|
29
44
|
if (!i || !o)
|
|
30
45
|
return console.error("Missing Supabase credentials for checkout (Service Key required)."), { error: "Internal Server Error", url: null };
|
|
31
|
-
const c =
|
|
46
|
+
const c = Qe(i, o), d = process.env.NEXT_PUBLIC_URL || "http://localhost:4200";
|
|
32
47
|
if (!t.length)
|
|
33
48
|
return { error: "Cart is empty", url: null };
|
|
34
49
|
const { data: l } = await c.from("currencies").select(
|
|
35
50
|
"code, symbol, exchange_rate, is_default, is_active, auto_sync_product_prices, auto_update_exchange_rate, exchange_rate_source, exchange_rate_updated_at, rounding_mode, rounding_increment, rounding_charm_amount"
|
|
36
|
-
).eq("is_active", !0).order("code", { ascending: !0 }), u = l ?? [], p =
|
|
51
|
+
).eq("is_active", !0).order("code", { ascending: !0 }), u = l ?? [], p = Tt(u), h = u.find(($) => $.code === (n || "").toUpperCase()) ?? p;
|
|
37
52
|
if (!await ia("ecommerce"))
|
|
38
53
|
return { error: "E-Commerce Package not active. Please purchase a license to accept payments.", url: null };
|
|
39
54
|
const g = t.map(($) => $.product_id), { data: N, error: S } = await c.from("products").select("id, title, price, prices, sale_price, sale_prices, sale_start_at, sale_end_at, scheduled_price, scheduled_prices, scheduled_price_at").in("id", g);
|
|
@@ -96,8 +111,8 @@ const Ce = new na(process.env.STRIPE_SECRET_KEY || "sk_test_dummy", {
|
|
|
96
111
|
product_id: $.product_id,
|
|
97
112
|
quantity: $.quantity,
|
|
98
113
|
price_at_purchase: $.price_at_purchase
|
|
99
|
-
})), { error:
|
|
100
|
-
|
|
114
|
+
})), { error: b } = await c.from("order_items").insert(f);
|
|
115
|
+
b && console.error("Failed to insert order items:", b);
|
|
101
116
|
let M = [], q = a;
|
|
102
117
|
if (!q && r) {
|
|
103
118
|
const { data: $ } = await c.from("user_addresses").select("country_code, state_code, postal_code").eq("user_id", r).eq("address_type", "shipping").limit(1).single();
|
|
@@ -205,7 +220,7 @@ async function zs(t) {
|
|
|
205
220
|
const r = Ds();
|
|
206
221
|
if (!r)
|
|
207
222
|
throw new Error("Missing POSTGRES_URL or DATABASE_URL for inventory fallback");
|
|
208
|
-
const a =
|
|
223
|
+
const a = va(r, {
|
|
209
224
|
ssl: "require",
|
|
210
225
|
onnotice: () => {
|
|
211
226
|
}
|
|
@@ -223,10 +238,10 @@ async function zs(t) {
|
|
|
223
238
|
const d = await i`
|
|
224
239
|
SELECT value
|
|
225
240
|
FROM public.site_settings
|
|
226
|
-
WHERE key = ${
|
|
241
|
+
WHERE key = ${wa}
|
|
227
242
|
LIMIT 1
|
|
228
243
|
`;
|
|
229
|
-
if (!
|
|
244
|
+
if (!Na(
|
|
230
245
|
d[0]?.value
|
|
231
246
|
).trackQuantities) {
|
|
232
247
|
await i`
|
|
@@ -247,7 +262,7 @@ async function zs(t) {
|
|
|
247
262
|
`;
|
|
248
263
|
for (const p of u) {
|
|
249
264
|
if (p.variant_id) {
|
|
250
|
-
const
|
|
265
|
+
const x = (await i`
|
|
251
266
|
SELECT
|
|
252
267
|
sku,
|
|
253
268
|
stock_quantity
|
|
@@ -255,23 +270,23 @@ async function zs(t) {
|
|
|
255
270
|
WHERE id = ${p.variant_id}
|
|
256
271
|
LIMIT 1
|
|
257
272
|
`)[0];
|
|
258
|
-
if (!
|
|
273
|
+
if (!x?.sku)
|
|
259
274
|
continue;
|
|
260
275
|
await i`
|
|
261
276
|
INSERT INTO public.inventory_items (sku, quantity)
|
|
262
|
-
VALUES (${
|
|
277
|
+
VALUES (${x.sku}, ${Math.max(0, x.stock_quantity ?? 0)})
|
|
263
278
|
ON CONFLICT (sku) DO NOTHING
|
|
264
279
|
`, await i`
|
|
265
280
|
UPDATE public.inventory_items
|
|
266
281
|
SET
|
|
267
282
|
quantity = GREATEST(COALESCE(quantity, 0) - ${p.quantity}, 0),
|
|
268
283
|
updated_at = now()
|
|
269
|
-
WHERE sku = ${
|
|
284
|
+
WHERE sku = ${x.sku}
|
|
270
285
|
`;
|
|
271
286
|
continue;
|
|
272
287
|
}
|
|
273
288
|
if (p.product_id) {
|
|
274
|
-
const
|
|
289
|
+
const x = (await i`
|
|
275
290
|
SELECT
|
|
276
291
|
sku,
|
|
277
292
|
stock
|
|
@@ -279,18 +294,18 @@ async function zs(t) {
|
|
|
279
294
|
WHERE id = ${p.product_id}
|
|
280
295
|
LIMIT 1
|
|
281
296
|
`)[0];
|
|
282
|
-
if (!
|
|
297
|
+
if (!x?.sku)
|
|
283
298
|
continue;
|
|
284
299
|
await i`
|
|
285
300
|
INSERT INTO public.inventory_items (sku, quantity)
|
|
286
|
-
VALUES (${
|
|
301
|
+
VALUES (${x.sku}, ${Math.max(0, x.stock ?? 0)})
|
|
287
302
|
ON CONFLICT (sku) DO NOTHING
|
|
288
303
|
`, await i`
|
|
289
304
|
UPDATE public.inventory_items
|
|
290
305
|
SET
|
|
291
306
|
quantity = GREATEST(COALESCE(quantity, 0) - ${p.quantity}, 0),
|
|
292
307
|
updated_at = now()
|
|
293
|
-
WHERE sku = ${
|
|
308
|
+
WHERE sku = ${x.sku}
|
|
294
309
|
`;
|
|
295
310
|
}
|
|
296
311
|
}
|
|
@@ -340,7 +355,7 @@ function js(t) {
|
|
|
340
355
|
}
|
|
341
356
|
async function Ks(t) {
|
|
342
357
|
const r = _t(t), [a, n] = await Promise.all([
|
|
343
|
-
r.from("site_settings").select("value").eq("key",
|
|
358
|
+
r.from("site_settings").select("value").eq("key", Ea).maybeSingle(),
|
|
344
359
|
r.from("logos").select(
|
|
345
360
|
`
|
|
346
361
|
id,
|
|
@@ -355,7 +370,7 @@ async function Ks(t) {
|
|
|
355
370
|
).order("created_at", { ascending: !1 }).limit(1).maybeSingle()
|
|
356
371
|
]);
|
|
357
372
|
return {
|
|
358
|
-
settings:
|
|
373
|
+
settings: Aa(a.data?.value ?? Pa),
|
|
359
374
|
logo: js(n.data)
|
|
360
375
|
};
|
|
361
376
|
}
|
|
@@ -436,7 +451,7 @@ async function Vs(t, r) {
|
|
|
436
451
|
tax_total: typeof n.tax_total == "number" ? n.tax_total : 0,
|
|
437
452
|
total: n.total,
|
|
438
453
|
customer_details: nt(n.customer_details ?? {}),
|
|
439
|
-
tax_details:
|
|
454
|
+
tax_details: Er(n.tax_details),
|
|
440
455
|
items: h
|
|
441
456
|
};
|
|
442
457
|
}
|
|
@@ -452,11 +467,11 @@ async function qr(t, r) {
|
|
|
452
467
|
};
|
|
453
468
|
}
|
|
454
469
|
const Gs = ["total_details.breakdown"], Hs = ["data.taxes.rate"];
|
|
455
|
-
function
|
|
470
|
+
function Ws() {
|
|
456
471
|
const t = process.env.NEXT_PUBLIC_SUPABASE_URL, r = process.env.SUPABASE_SERVICE_ROLE_KEY;
|
|
457
472
|
if (!t || !r)
|
|
458
473
|
throw new Error("Missing Supabase Service Role environment variables");
|
|
459
|
-
return
|
|
474
|
+
return Qe(t, r, {
|
|
460
475
|
auth: {
|
|
461
476
|
autoRefreshToken: !1,
|
|
462
477
|
persistSession: !1
|
|
@@ -464,7 +479,7 @@ function Qs() {
|
|
|
464
479
|
});
|
|
465
480
|
}
|
|
466
481
|
function or(t, r) {
|
|
467
|
-
return t ?
|
|
482
|
+
return t ? ca({
|
|
468
483
|
recipient_name: r,
|
|
469
484
|
line1: t.line1 ?? null,
|
|
470
485
|
line2: t.line2 ?? null,
|
|
@@ -474,7 +489,7 @@ function or(t, r) {
|
|
|
474
489
|
country_code: t.country ?? null
|
|
475
490
|
}) : null;
|
|
476
491
|
}
|
|
477
|
-
function
|
|
492
|
+
function Qs(t) {
|
|
478
493
|
const r = t ?? {};
|
|
479
494
|
return nt({
|
|
480
495
|
email: typeof r.email == "string" ? r.email : null,
|
|
@@ -485,7 +500,7 @@ function Ws(t) {
|
|
|
485
500
|
});
|
|
486
501
|
}
|
|
487
502
|
async function Xs(t) {
|
|
488
|
-
const r =
|
|
503
|
+
const r = Ws();
|
|
489
504
|
let a = t;
|
|
490
505
|
try {
|
|
491
506
|
a = await Ce.checkout.sessions.retrieve(t.id, {
|
|
@@ -504,13 +519,13 @@ async function Xs(t) {
|
|
|
504
519
|
const { data: o, error: c } = await i;
|
|
505
520
|
if (c || !o)
|
|
506
521
|
throw new Error(c?.message || "Order lookup failed");
|
|
507
|
-
const d =
|
|
522
|
+
const d = Qs(o.customer_details), l = Er(o.tax_details), u = or(
|
|
508
523
|
a.customer_details?.address,
|
|
509
524
|
a.customer_details?.name ?? d.name
|
|
510
525
|
), p = a, h = or(
|
|
511
526
|
p.shipping_details?.address,
|
|
512
527
|
p.shipping_details?.name ?? d.name
|
|
513
|
-
),
|
|
528
|
+
), x = nt({
|
|
514
529
|
email: a.customer_details?.email ?? d.email,
|
|
515
530
|
name: a.customer_details?.name ?? d.name,
|
|
516
531
|
phone: a.customer_details?.phone ?? d.phone,
|
|
@@ -519,7 +534,7 @@ async function Xs(t) {
|
|
|
519
534
|
}), g = o.status === "paid", N = await Ce.checkout.sessions.listLineItems(a.id, {
|
|
520
535
|
limit: 100,
|
|
521
536
|
expand: [...Hs]
|
|
522
|
-
}), S =
|
|
537
|
+
}), S = Ta({
|
|
523
538
|
session: a,
|
|
524
539
|
lineItems: N.data,
|
|
525
540
|
subtotal: typeof o.subtotal == "number" ? o.subtotal : l?.subtotal ?? 0,
|
|
@@ -531,7 +546,7 @@ async function Xs(t) {
|
|
|
531
546
|
stripe_session_id: a.id,
|
|
532
547
|
payment_intent_id: typeof a.payment_intent == "string" ? a.payment_intent : null,
|
|
533
548
|
provider: "stripe",
|
|
534
|
-
customer_details:
|
|
549
|
+
customer_details: x,
|
|
535
550
|
total: typeof a.amount_total == "number" ? a.amount_total : o.total,
|
|
536
551
|
currency: C,
|
|
537
552
|
tax_total: y,
|
|
@@ -541,10 +556,10 @@ async function Xs(t) {
|
|
|
541
556
|
throw new Error(F.message);
|
|
542
557
|
if (o.user_id)
|
|
543
558
|
try {
|
|
544
|
-
await
|
|
559
|
+
await Sr({
|
|
545
560
|
userId: o.user_id,
|
|
546
|
-
billingAddress:
|
|
547
|
-
shippingAddress:
|
|
561
|
+
billingAddress: x.billing,
|
|
562
|
+
shippingAddress: x.shipping,
|
|
548
563
|
client: r
|
|
549
564
|
});
|
|
550
565
|
} catch (f) {
|
|
@@ -557,7 +572,7 @@ async function Xs(t) {
|
|
|
557
572
|
return await qt(r, o.id), {
|
|
558
573
|
orderId: o.id,
|
|
559
574
|
alreadyPaid: g,
|
|
560
|
-
customerDetails:
|
|
575
|
+
customerDetails: x,
|
|
561
576
|
order: {
|
|
562
577
|
id: o.id,
|
|
563
578
|
invoice_number: _.invoiceNumber,
|
|
@@ -571,7 +586,7 @@ async function Xs(t) {
|
|
|
571
586
|
}
|
|
572
587
|
};
|
|
573
588
|
}
|
|
574
|
-
const
|
|
589
|
+
const go = async (t, r) => {
|
|
575
590
|
const a = process.env.STRIPE_WEBHOOK_SECRET;
|
|
576
591
|
if (!a)
|
|
577
592
|
return console.error("Missing STRIPE_WEBHOOK_SECRET"), { received: !1, error: "Server configuration error" };
|
|
@@ -608,7 +623,7 @@ async function Dr(t) {
|
|
|
608
623
|
throw new Error("Unauthorized");
|
|
609
624
|
return r;
|
|
610
625
|
}
|
|
611
|
-
async function
|
|
626
|
+
async function _o(t) {
|
|
612
627
|
const r = zt(t), a = await Dr(r), { data: n, error: i } = await r.from("orders").select(
|
|
613
628
|
"id, invoice_number, paid_at, created_at, currency, status, provider, subtotal, shipping_total, tax_total, total"
|
|
614
629
|
).eq("user_id", a.id).order("created_at", { ascending: !1 });
|
|
@@ -624,7 +639,7 @@ async function Ys(t, r) {
|
|
|
624
639
|
throw new Error(o.message);
|
|
625
640
|
return i ?? null;
|
|
626
641
|
}
|
|
627
|
-
async function
|
|
642
|
+
async function yo(t, r) {
|
|
628
643
|
const a = zt(r), n = await Ys(t, a);
|
|
629
644
|
if (!n)
|
|
630
645
|
return null;
|
|
@@ -669,7 +684,7 @@ async function zr() {
|
|
|
669
684
|
currencies: r || []
|
|
670
685
|
};
|
|
671
686
|
}
|
|
672
|
-
async function
|
|
687
|
+
async function xo(t) {
|
|
673
688
|
const r = ie(t.newDefaultCurrencyCode), a = Number(t.previousBaseRate);
|
|
674
689
|
if (!Number.isFinite(a) || a <= 0)
|
|
675
690
|
throw new Error("Cannot rebase exchange rates without a valid previous base rate.");
|
|
@@ -679,13 +694,13 @@ async function co(t) {
|
|
|
679
694
|
))
|
|
680
695
|
throw new Error(`Currency ${r} was not found for rebasing.`);
|
|
681
696
|
const c = (/* @__PURE__ */ new Date()).toISOString(), d = [], l = i.map((p) => {
|
|
682
|
-
const h = Et(p),
|
|
683
|
-
return d.push(
|
|
697
|
+
const h = Et(p), x = ie(p.code), g = x === r ? 1 : Number((p.exchange_rate / a).toFixed(10));
|
|
698
|
+
return d.push(x), {
|
|
684
699
|
...p,
|
|
685
700
|
id: h,
|
|
686
701
|
exchange_rate: g,
|
|
687
|
-
auto_update_exchange_rate:
|
|
688
|
-
exchange_rate_source:
|
|
702
|
+
auto_update_exchange_rate: x === r ? !1 : p.auto_update_exchange_rate,
|
|
703
|
+
exchange_rate_source: x === r ? "store-default" : p.exchange_rate_source || "rebased-default",
|
|
689
704
|
exchange_rate_updated_at: c,
|
|
690
705
|
updated_at: c
|
|
691
706
|
};
|
|
@@ -700,13 +715,13 @@ async function co(t) {
|
|
|
700
715
|
updatedCurrencies: d
|
|
701
716
|
};
|
|
702
717
|
}
|
|
703
|
-
async function
|
|
718
|
+
async function bo() {
|
|
704
719
|
const { supabase: t, currencies: r } = await zr();
|
|
705
720
|
if (!r.length)
|
|
706
721
|
throw new Error("No currencies are configured yet.");
|
|
707
722
|
const a = r.map(
|
|
708
723
|
(C) => Se(C)
|
|
709
|
-
), n =
|
|
724
|
+
), n = Tt(a), i = ie(n.code), o = r.find(
|
|
710
725
|
(C) => ie(C.code) === i
|
|
711
726
|
);
|
|
712
727
|
if (!o)
|
|
@@ -745,19 +760,19 @@ async function lo() {
|
|
|
745
760
|
","
|
|
746
761
|
)
|
|
747
762
|
);
|
|
748
|
-
const
|
|
763
|
+
const x = await fetch(h.toString(), {
|
|
749
764
|
cache: "no-store",
|
|
750
765
|
headers: {
|
|
751
766
|
Accept: "application/json"
|
|
752
767
|
}
|
|
753
768
|
});
|
|
754
|
-
if (!
|
|
755
|
-
const C = await
|
|
769
|
+
if (!x.ok) {
|
|
770
|
+
const C = await x.text();
|
|
756
771
|
throw new Error(
|
|
757
|
-
`FX provider request failed (${
|
|
772
|
+
`FX provider request failed (${x.status}): ${C || "Unexpected response body."}`
|
|
758
773
|
);
|
|
759
774
|
}
|
|
760
|
-
const g = await
|
|
775
|
+
const g = await x.json();
|
|
761
776
|
if (!an(g))
|
|
762
777
|
throw new Error("FX provider returned an unexpected response payload.");
|
|
763
778
|
const N = /* @__PURE__ */ new Map();
|
|
@@ -795,7 +810,7 @@ async function lo() {
|
|
|
795
810
|
updatedCurrencies: S
|
|
796
811
|
};
|
|
797
812
|
}
|
|
798
|
-
async function
|
|
813
|
+
async function vo(t) {
|
|
799
814
|
const r = ie(t), a = re(), { error: n } = await a.rpc("clear_currency_price_overrides", {
|
|
800
815
|
target_currency: r
|
|
801
816
|
});
|
|
@@ -867,7 +882,7 @@ function on(t) {
|
|
|
867
882
|
return n;
|
|
868
883
|
}
|
|
869
884
|
function cn(t, r) {
|
|
870
|
-
return
|
|
885
|
+
return rs(
|
|
871
886
|
t.name,
|
|
872
887
|
t.name_translations || null,
|
|
873
888
|
r
|
|
@@ -917,10 +932,10 @@ class dn {
|
|
|
917
932
|
couponCode: p,
|
|
918
933
|
couponContextItems: h
|
|
919
934
|
}) {
|
|
920
|
-
const
|
|
921
|
-
if (!
|
|
935
|
+
const x = process.env.NEXT_PUBLIC_SUPABASE_URL, g = process.env.SUPABASE_SERVICE_ROLE_KEY;
|
|
936
|
+
if (!x || !g)
|
|
922
937
|
return console.error("Missing Supabase credentials for checkout (Service Key required)."), { error: "Internal Server Error", url: null };
|
|
923
|
-
const N =
|
|
938
|
+
const N = Qe(x, g), S = process.env.NEXT_PUBLIC_URL || "http://localhost:4200", R = r.some((w) => !Ja(w));
|
|
924
939
|
if (!r.length)
|
|
925
940
|
return { error: "Cart is empty", url: null };
|
|
926
941
|
const { data: y, error: C } = await N.from("currencies").select(
|
|
@@ -928,7 +943,7 @@ class dn {
|
|
|
928
943
|
).eq("is_active", !0).order("code", { ascending: !0 }), k = y ?? [];
|
|
929
944
|
if (C || k.length === 0)
|
|
930
945
|
return console.error("Error fetching currencies for checkout:", C), { error: "Failed to resolve store currencies", url: null };
|
|
931
|
-
const F =
|
|
946
|
+
const F = Tt(k), _ = k.find((w) => w.code === (l || "").toUpperCase()) ?? F, f = _.code.toLowerCase(), b = await Xe(N), M = r.map((w) => w.product_id), q = r.map((w) => w.variant_id).filter((w) => !!w), { data: $, error: z } = await N.from("products").select("id, title, sku, price, prices, sale_price, sale_prices, sale_start_at, sale_end_at, scheduled_price, scheduled_prices, scheduled_price_at, stock, is_taxable").in("id", M);
|
|
932
947
|
if (z || !$)
|
|
933
948
|
return console.error("Error fetching products for validation:", z), { error: "Failed to validate product prices", url: null };
|
|
934
949
|
const { data: se, error: E } = q.length ? await N.from("product_variants").select("id, product_id, sku, price, prices, sale_price, sale_prices, sale_start_at, sale_end_at, scheduled_price, scheduled_prices, scheduled_price_at, stock_quantity").in("id", q) : { data: [], error: null };
|
|
@@ -945,9 +960,9 @@ class dn {
|
|
|
945
960
|
(A.get(ne) ?? 0) + w.quantity
|
|
946
961
|
));
|
|
947
962
|
}
|
|
948
|
-
const { data: O, error:
|
|
949
|
-
if (
|
|
950
|
-
return console.error("Error fetching SKU inventory for validation:",
|
|
963
|
+
const { data: O, error: W } = m.size ? await N.from("inventory_items").select("sku, quantity").in("sku", [...m]) : { data: [], error: null };
|
|
964
|
+
if (W)
|
|
965
|
+
return console.error("Error fetching SKU inventory for validation:", W), { error: "Failed to validate SKU inventory", url: null };
|
|
951
966
|
const le = new Map(
|
|
952
967
|
(O || []).map((w) => [
|
|
953
968
|
w.sku,
|
|
@@ -956,7 +971,7 @@ class dn {
|
|
|
956
971
|
), v = [], L = [], I = [];
|
|
957
972
|
let B = 0, ce = 0, J = null;
|
|
958
973
|
if (p) {
|
|
959
|
-
const w = await
|
|
974
|
+
const w = await Ha({
|
|
960
975
|
client: N,
|
|
961
976
|
code: p,
|
|
962
977
|
items: h && h.length > 0 ? h : r,
|
|
@@ -971,7 +986,7 @@ class dn {
|
|
|
971
986
|
};
|
|
972
987
|
J = w.quote;
|
|
973
988
|
}
|
|
974
|
-
const me =
|
|
989
|
+
const me = Wa(J), Je = (w) => {
|
|
975
990
|
const j = w.unitAmount * w.quantity, ke = Math.max(0, j - w.lineDiscount);
|
|
976
991
|
if (ke <= 0)
|
|
977
992
|
return;
|
|
@@ -981,7 +996,7 @@ class dn {
|
|
|
981
996
|
currency: w.currency,
|
|
982
997
|
product_data: {
|
|
983
998
|
name: w.name,
|
|
984
|
-
tax_code:
|
|
999
|
+
tax_code: ka(w.isTaxable),
|
|
985
1000
|
metadata: {
|
|
986
1001
|
productId: w.productId,
|
|
987
1002
|
variantId: w.variantId || ""
|
|
@@ -1000,7 +1015,7 @@ class dn {
|
|
|
1000
1015
|
if (!j)
|
|
1001
1016
|
return console.warn(`Product ${w.product_id} not found in DB.`), {
|
|
1002
1017
|
url: null,
|
|
1003
|
-
...
|
|
1018
|
+
...er(w.title)
|
|
1004
1019
|
};
|
|
1005
1020
|
const ke = vt({
|
|
1006
1021
|
prices: rt(j.prices),
|
|
@@ -1021,13 +1036,13 @@ class dn {
|
|
|
1021
1036
|
if (!Z || Z.product_id !== w.product_id)
|
|
1022
1037
|
return {
|
|
1023
1038
|
url: null,
|
|
1024
|
-
...
|
|
1039
|
+
...er(w.title)
|
|
1025
1040
|
};
|
|
1026
1041
|
const tt = A.get(Z.sku) ?? w.quantity, Xt = le.has(Z.sku) ? le.get(Z.sku) ?? 0 : Math.max(0, Z.stock_quantity ?? 0);
|
|
1027
|
-
if (
|
|
1042
|
+
if (b.trackQuantities && tt > Xt)
|
|
1028
1043
|
return {
|
|
1029
1044
|
url: null,
|
|
1030
|
-
...
|
|
1045
|
+
...tr(w.title, Xt)
|
|
1031
1046
|
};
|
|
1032
1047
|
const Yt = vt({
|
|
1033
1048
|
prices: rt(Z.prices),
|
|
@@ -1045,10 +1060,10 @@ class dn {
|
|
|
1045
1060
|
ne = Yt.sale_price ?? Yt.price, Te = Z.id, Le = w.variant_label ? `${j.title} - ${w.variant_label}` : `${j.title} - ${Z.sku}`;
|
|
1046
1061
|
} else {
|
|
1047
1062
|
const Z = A.get(j.sku) ?? w.quantity, tt = le.has(j.sku) ? le.get(j.sku) ?? 0 : Math.max(0, j.stock ?? 0);
|
|
1048
|
-
if (
|
|
1063
|
+
if (b.trackQuantities && Z > tt)
|
|
1049
1064
|
return {
|
|
1050
1065
|
url: null,
|
|
1051
|
-
...
|
|
1066
|
+
...tr(w.title, tt)
|
|
1052
1067
|
};
|
|
1053
1068
|
}
|
|
1054
1069
|
const Me = j.is_taxable ?? !0;
|
|
@@ -1056,7 +1071,7 @@ class dn {
|
|
|
1056
1071
|
return { error: "A product variation produced an invalid price.", url: null };
|
|
1057
1072
|
const Ie = Math.min(
|
|
1058
1073
|
ne * w.quantity,
|
|
1059
|
-
me.get(
|
|
1074
|
+
me.get(Qa(w)) ?? 0
|
|
1060
1075
|
);
|
|
1061
1076
|
Je({
|
|
1062
1077
|
name: Le,
|
|
@@ -1089,12 +1104,12 @@ class dn {
|
|
|
1089
1104
|
};
|
|
1090
1105
|
if (v.length === 0)
|
|
1091
1106
|
return { error: "No valid items in cart", url: null };
|
|
1092
|
-
let
|
|
1107
|
+
let be = 0, yt = null;
|
|
1093
1108
|
if (d) {
|
|
1094
1109
|
const { data: w, error: j } = await N.from("shipping_zone_methods").select("id, name, name_translations, cost_amount, cost_currency").eq("id", d).single();
|
|
1095
1110
|
if (j)
|
|
1096
1111
|
return console.error("Failed to load shipping method:", j), { error: "Failed to load shipping method", url: null };
|
|
1097
|
-
|
|
1112
|
+
be = wt({
|
|
1098
1113
|
amount: w.cost_amount ?? 0,
|
|
1099
1114
|
fromCurrencyCode: w.cost_currency || F.code,
|
|
1100
1115
|
toCurrencyCode: _.code,
|
|
@@ -1104,7 +1119,7 @@ class dn {
|
|
|
1104
1119
|
const Vt = R ? c ?? o : o;
|
|
1105
1120
|
let de;
|
|
1106
1121
|
try {
|
|
1107
|
-
de = await
|
|
1122
|
+
de = await Ca(N, {
|
|
1108
1123
|
items: L,
|
|
1109
1124
|
destination: {
|
|
1110
1125
|
country_code: Vt?.country_code,
|
|
@@ -1114,15 +1129,15 @@ class dn {
|
|
|
1114
1129
|
} catch (w) {
|
|
1115
1130
|
return console.error("Failed to calculate checkout taxes:", w), { error: "Failed to calculate taxes", url: null };
|
|
1116
1131
|
}
|
|
1117
|
-
|
|
1132
|
+
be > 0 && yt && v.push({
|
|
1118
1133
|
price_data: {
|
|
1119
1134
|
currency: f,
|
|
1120
1135
|
product_data: {
|
|
1121
1136
|
name: yt,
|
|
1122
|
-
tax_code: de.enabled && de.mode === "automatic" ?
|
|
1137
|
+
tax_code: de.enabled && de.mode === "automatic" ? Sa : rr
|
|
1123
1138
|
},
|
|
1124
1139
|
tax_behavior: "exclusive",
|
|
1125
|
-
unit_amount:
|
|
1140
|
+
unit_amount: be
|
|
1126
1141
|
},
|
|
1127
1142
|
quantity: 1
|
|
1128
1143
|
});
|
|
@@ -1132,7 +1147,7 @@ class dn {
|
|
|
1132
1147
|
currency: f,
|
|
1133
1148
|
product_data: {
|
|
1134
1149
|
name: "Tax",
|
|
1135
|
-
tax_code:
|
|
1150
|
+
tax_code: rr
|
|
1136
1151
|
},
|
|
1137
1152
|
tax_behavior: "exclusive",
|
|
1138
1153
|
unit_amount: Ae
|
|
@@ -1145,19 +1160,19 @@ class dn {
|
|
|
1145
1160
|
name: o?.recipient_name,
|
|
1146
1161
|
billing: o,
|
|
1147
1162
|
shipping: c
|
|
1148
|
-
}), Gt = _.code, aa =
|
|
1163
|
+
}), Gt = _.code, aa = Ia({
|
|
1149
1164
|
calculation: de,
|
|
1150
1165
|
subtotal: B,
|
|
1151
|
-
shippingTotal:
|
|
1152
|
-
total: Math.max(0, B - ce) +
|
|
1166
|
+
shippingTotal: be,
|
|
1167
|
+
total: Math.max(0, B - ce) + be + Ae,
|
|
1153
1168
|
currency: Gt
|
|
1154
|
-
}), sa = Math.max(0, B - ce) +
|
|
1169
|
+
}), sa = Math.max(0, B - ce) + be + Ae, { data: Ht, error: Wt } = await N.from("orders").insert({
|
|
1155
1170
|
status: "pending",
|
|
1156
1171
|
total: sa,
|
|
1157
1172
|
currency: Gt,
|
|
1158
1173
|
exchange_rate_at_purchase: _.exchange_rate,
|
|
1159
1174
|
subtotal: B,
|
|
1160
|
-
shipping_total:
|
|
1175
|
+
shipping_total: be,
|
|
1161
1176
|
tax_total: Ae,
|
|
1162
1177
|
tax_details: aa,
|
|
1163
1178
|
coupon_id: J?.couponId ?? null,
|
|
@@ -1175,9 +1190,9 @@ class dn {
|
|
|
1175
1190
|
user_id: i,
|
|
1176
1191
|
customer_details: ra
|
|
1177
1192
|
}).select("id").single();
|
|
1178
|
-
if (
|
|
1179
|
-
return console.error("Failed to create pending order:",
|
|
1180
|
-
const Pe = Ht.id, { error:
|
|
1193
|
+
if (Wt || !Ht)
|
|
1194
|
+
return console.error("Failed to create pending order:", Wt), { error: "Failed to initiate order", url: null };
|
|
1195
|
+
const Pe = Ht.id, { error: Qt } = await N.from("order_items").insert(
|
|
1181
1196
|
I.map((w) => ({
|
|
1182
1197
|
order_id: Pe,
|
|
1183
1198
|
product_id: w.product_id,
|
|
@@ -1186,16 +1201,16 @@ class dn {
|
|
|
1186
1201
|
price_at_purchase: w.price_at_purchase
|
|
1187
1202
|
}))
|
|
1188
1203
|
);
|
|
1189
|
-
if (
|
|
1190
|
-
return console.error("Failed to insert order items:",
|
|
1204
|
+
if (Qt)
|
|
1205
|
+
return console.error("Failed to insert order items:", Qt), await N.from("orders").update({ status: "failed" }).eq("id", Pe), { error: "Failed to record order items", url: null };
|
|
1191
1206
|
if (i)
|
|
1192
1207
|
try {
|
|
1193
|
-
await
|
|
1208
|
+
await Sr({
|
|
1194
1209
|
userId: i,
|
|
1195
1210
|
billingAddress: o,
|
|
1196
1211
|
shippingAddress: c,
|
|
1197
1212
|
client: N
|
|
1198
|
-
}), await
|
|
1213
|
+
}), await la({
|
|
1199
1214
|
userId: i,
|
|
1200
1215
|
fullName: o?.recipient_name ?? c?.recipient_name ?? null,
|
|
1201
1216
|
phone: n,
|
|
@@ -1207,7 +1222,7 @@ class dn {
|
|
|
1207
1222
|
w
|
|
1208
1223
|
);
|
|
1209
1224
|
}
|
|
1210
|
-
J && await
|
|
1225
|
+
J && await Xa({
|
|
1211
1226
|
client: N,
|
|
1212
1227
|
quote: J,
|
|
1213
1228
|
orderId: Pe,
|
|
@@ -1218,7 +1233,7 @@ class dn {
|
|
|
1218
1233
|
metadata: {
|
|
1219
1234
|
currency: _.code,
|
|
1220
1235
|
subtotal: B,
|
|
1221
|
-
shipping_total:
|
|
1236
|
+
shipping_total: be,
|
|
1222
1237
|
tax_total: Ae
|
|
1223
1238
|
}
|
|
1224
1239
|
});
|
|
@@ -1262,8 +1277,8 @@ class dn {
|
|
|
1262
1277
|
}
|
|
1263
1278
|
}
|
|
1264
1279
|
}
|
|
1265
|
-
function
|
|
1266
|
-
return t === "freemius" ? new
|
|
1280
|
+
function wo(t) {
|
|
1281
|
+
return t === "freemius" ? new da() : new dn();
|
|
1267
1282
|
}
|
|
1268
1283
|
function U(t) {
|
|
1269
1284
|
return t == null || t === "" ? null : String(t);
|
|
@@ -1358,7 +1373,7 @@ function jr() {
|
|
|
1358
1373
|
const t = process.env.NEXT_PUBLIC_SUPABASE_URL, r = process.env.SUPABASE_SERVICE_ROLE_KEY;
|
|
1359
1374
|
if (!t || !r)
|
|
1360
1375
|
throw new Error("Missing Supabase Service Role environment variables");
|
|
1361
|
-
return
|
|
1376
|
+
return Qe(t, r, {
|
|
1362
1377
|
auth: {
|
|
1363
1378
|
autoRefreshToken: !1,
|
|
1364
1379
|
persistSession: !1
|
|
@@ -1392,7 +1407,7 @@ async function Kr(t) {
|
|
|
1392
1407
|
client: t.client
|
|
1393
1408
|
}), await qt(t.client, t.order.id)), n;
|
|
1394
1409
|
}
|
|
1395
|
-
async function
|
|
1410
|
+
async function No(t) {
|
|
1396
1411
|
const r = t.client ?? jr(), a = await _n(r, t.orderId);
|
|
1397
1412
|
if (a.provider !== "freemius")
|
|
1398
1413
|
return {
|
|
@@ -1456,7 +1471,7 @@ function Gr(t, r) {
|
|
|
1456
1471
|
async function Hr(t, r) {
|
|
1457
1472
|
if (!t)
|
|
1458
1473
|
return null;
|
|
1459
|
-
const a =
|
|
1474
|
+
const a = ma(t);
|
|
1460
1475
|
return !a.apiKey || !a.secretKey || !a.publicKey ? null : new as({
|
|
1461
1476
|
productId: Number(t),
|
|
1462
1477
|
apiKey: a.apiKey,
|
|
@@ -1464,7 +1479,7 @@ async function Hr(t, r) {
|
|
|
1464
1479
|
publicKey: a.publicKey
|
|
1465
1480
|
}).purchase.retrievePurchaseData(r);
|
|
1466
1481
|
}
|
|
1467
|
-
async function
|
|
1482
|
+
async function Co(t) {
|
|
1468
1483
|
const r = t.client ?? jr(), a = Vr(t.event);
|
|
1469
1484
|
if (!a)
|
|
1470
1485
|
return {
|
|
@@ -1509,11 +1524,11 @@ async function ho(t) {
|
|
|
1509
1524
|
type: t.event.type
|
|
1510
1525
|
};
|
|
1511
1526
|
}
|
|
1512
|
-
function
|
|
1527
|
+
function xn() {
|
|
1513
1528
|
const t = [
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
...Object.values(
|
|
1529
|
+
Jt("FREEMIUS_SECRET_KEY"),
|
|
1530
|
+
Jt("FREEMIUS_ECOMMERCE_SANDBOX_SECRET_KEY"),
|
|
1531
|
+
...Object.values(ua() ?? {}).map(
|
|
1517
1532
|
(r) => r.secretKey ?? null
|
|
1518
1533
|
)
|
|
1519
1534
|
];
|
|
@@ -1521,8 +1536,8 @@ function bn() {
|
|
|
1521
1536
|
new Set(t.filter((r) => !!r))
|
|
1522
1537
|
);
|
|
1523
1538
|
}
|
|
1524
|
-
function
|
|
1525
|
-
return r ?
|
|
1539
|
+
function So(t, r) {
|
|
1540
|
+
return r ? xn().some((a) => {
|
|
1526
1541
|
const n = ar.createHmac("sha256", a).update(t).digest("hex");
|
|
1527
1542
|
try {
|
|
1528
1543
|
return ar.timingSafeEqual(
|
|
@@ -1551,15 +1566,15 @@ async function jt() {
|
|
|
1551
1566
|
}
|
|
1552
1567
|
async function Ye() {
|
|
1553
1568
|
const t = ue(), { data: r, error: a } = await t.from("site_settings").select("value").eq("key", "enabled_payment_providers").maybeSingle();
|
|
1554
|
-
return a || !r ? { ...
|
|
1569
|
+
return a || !r ? { ...es } : ts(r.value);
|
|
1555
1570
|
}
|
|
1556
|
-
async function
|
|
1571
|
+
async function ko() {
|
|
1557
1572
|
const t = await Ye();
|
|
1558
1573
|
return t.stripe ? "stripe" : t.freemius ? "freemius" : "stripe";
|
|
1559
1574
|
}
|
|
1560
|
-
const
|
|
1561
|
-
async function
|
|
1562
|
-
const n = await ue(), i = (t - 1) *
|
|
1575
|
+
const bt = 20;
|
|
1576
|
+
async function bn(t = 1, r, a) {
|
|
1577
|
+
const n = await ue(), i = (t - 1) * bt, o = i + bt - 1;
|
|
1563
1578
|
let c = n.from("orders").select(
|
|
1564
1579
|
`
|
|
1565
1580
|
*,
|
|
@@ -1571,18 +1586,18 @@ async function xn(t = 1, r, a) {
|
|
|
1571
1586
|
const { data: d, error: l, count: u } = await c;
|
|
1572
1587
|
if (l)
|
|
1573
1588
|
throw console.error("Error fetching orders:", l), new Error("Failed to fetch orders");
|
|
1574
|
-
const p = d || [], h = Array.from(new Set(p.map((N) => N.user_id).filter(Boolean))),
|
|
1589
|
+
const p = d || [], h = Array.from(new Set(p.map((N) => N.user_id).filter(Boolean))), x = /* @__PURE__ */ new Map();
|
|
1575
1590
|
if (h.length > 0) {
|
|
1576
1591
|
const { data: N, error: S } = await n.from("profiles").select("*").in("id", h);
|
|
1577
|
-
!S && N && N.forEach((R) =>
|
|
1592
|
+
!S && N && N.forEach((R) => x.set(R.id, R));
|
|
1578
1593
|
}
|
|
1579
1594
|
return {
|
|
1580
1595
|
data: p.map((N) => ({
|
|
1581
1596
|
...N,
|
|
1582
|
-
customer: N.user_id ?
|
|
1597
|
+
customer: N.user_id ? x.get(N.user_id) : null
|
|
1583
1598
|
})),
|
|
1584
1599
|
total: u || 0,
|
|
1585
|
-
totalPages: u ? Math.ceil(u /
|
|
1600
|
+
totalPages: u ? Math.ceil(u / bt) : 0
|
|
1586
1601
|
};
|
|
1587
1602
|
}
|
|
1588
1603
|
async function vn(t) {
|
|
@@ -1778,20 +1793,20 @@ function En() {
|
|
|
1778
1793
|
X.error("No orders found for the selected date range"), n(!1);
|
|
1779
1794
|
return;
|
|
1780
1795
|
}
|
|
1781
|
-
let
|
|
1796
|
+
let x = [];
|
|
1782
1797
|
const g = `report_${l}_${i}_to_${c}`;
|
|
1783
1798
|
switch (l) {
|
|
1784
1799
|
case "general_ledger":
|
|
1785
|
-
|
|
1800
|
+
x = Cn(h);
|
|
1786
1801
|
break;
|
|
1787
1802
|
case "tax_liability":
|
|
1788
|
-
|
|
1803
|
+
x = Sn(h);
|
|
1789
1804
|
break;
|
|
1790
1805
|
case "currency_summary":
|
|
1791
|
-
|
|
1806
|
+
x = kn(h);
|
|
1792
1807
|
break;
|
|
1793
1808
|
}
|
|
1794
|
-
Nn(
|
|
1809
|
+
Nn(x, `${g}.csv`), X.success("Download complete!"), r(!1);
|
|
1795
1810
|
} catch (h) {
|
|
1796
1811
|
console.error("Export error:", h), X.error("Failed to generate report");
|
|
1797
1812
|
} finally {
|
|
@@ -1816,10 +1831,10 @@ const dr = (t, r = "usd") => new Intl.NumberFormat("en-US", {
|
|
|
1816
1831
|
style: "currency",
|
|
1817
1832
|
currency: r
|
|
1818
1833
|
}).format(t / 100);
|
|
1819
|
-
async function
|
|
1834
|
+
async function Eo({
|
|
1820
1835
|
searchParams: t
|
|
1821
1836
|
}) {
|
|
1822
|
-
const r = await t, a = Number(r.page) || 1, n = r.status || "all", { data: i, totalPages: o } = await
|
|
1837
|
+
const r = await t, a = Number(r.page) || 1, n = r.status || "all", { data: i, totalPages: o } = await bn(a, n);
|
|
1823
1838
|
return /* @__PURE__ */ s("div", { className: "p-6 space-y-6", children: [
|
|
1824
1839
|
/* @__PURE__ */ s("div", { className: "flex justify-between items-center", children: [
|
|
1825
1840
|
/* @__PURE__ */ e("h1", { className: "text-2xl font-bold tracking-tight", children: "Orders" }),
|
|
@@ -1943,7 +1958,7 @@ function Rn() {
|
|
|
1943
1958
|
const t = process.env.SUPABASE_SERVICE_ROLE_KEY, r = process.env.NEXT_PUBLIC_SUPABASE_URL;
|
|
1944
1959
|
if (!t || !r)
|
|
1945
1960
|
throw new Error("Server configuration error");
|
|
1946
|
-
return
|
|
1961
|
+
return Qe(r, t, {
|
|
1947
1962
|
auth: {
|
|
1948
1963
|
autoRefreshToken: !1,
|
|
1949
1964
|
persistSession: !1
|
|
@@ -2037,13 +2052,13 @@ const mr = (t, r = "usd") => new Intl.NumberFormat("en-US", {
|
|
|
2037
2052
|
style: "currency",
|
|
2038
2053
|
currency: r
|
|
2039
2054
|
}).format(t / 100);
|
|
2040
|
-
async function
|
|
2055
|
+
async function Ao({ params: t }) {
|
|
2041
2056
|
const { id: r } = await t, [a, n] = await Promise.all([
|
|
2042
2057
|
vn(r),
|
|
2043
2058
|
qr(r).catch(() => null)
|
|
2044
2059
|
]);
|
|
2045
2060
|
a || Mt();
|
|
2046
|
-
const i = n?.order.customer_details ?? a.customer_details, o =
|
|
2061
|
+
const i = n?.order.customer_details ?? a.customer_details, o = Ra((c) => c);
|
|
2047
2062
|
return /* @__PURE__ */ s("div", { className: "mx-auto w-full max-w-6xl px-4 py-10 md:px-6", children: [
|
|
2048
2063
|
/* @__PURE__ */ s("div", { className: "flex flex-col gap-4 border-b pb-6 md:flex-row md:items-start md:justify-between", children: [
|
|
2049
2064
|
/* @__PURE__ */ s("div", { children: [
|
|
@@ -2124,7 +2139,7 @@ async function yo({ params: t }) {
|
|
|
2124
2139
|
] }),
|
|
2125
2140
|
/* @__PURE__ */ e("div", { className: "mt-6 flex justify-end print:hidden", children: /* @__PURE__ */ e(Pn, { disabled: !n }) }),
|
|
2126
2141
|
/* @__PURE__ */ e(
|
|
2127
|
-
|
|
2142
|
+
Fa,
|
|
2128
2143
|
{
|
|
2129
2144
|
invoice: n,
|
|
2130
2145
|
labels: o,
|
|
@@ -2158,7 +2173,7 @@ function $n({ status: t, size: r = "md" }) {
|
|
|
2158
2173
|
let a = "bg-gray-100 text-gray-700 dark:bg-slate-800 dark:text-gray-300";
|
|
2159
2174
|
return t === "paid" && (a = "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400"), t === "trial" && (a = "bg-cyan-100 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-300"), t === "pending" && (a = "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"), t === "shipped" && (a = "bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"), t === "cancelled" && (a = "bg-slate-200 text-slate-700 dark:bg-slate-800 dark:text-slate-300"), t === "refunded" && (a = "bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300"), t === "failed" && (a = "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"), /* @__PURE__ */ e("span", { className: `${r === "lg" ? "px-3 py-1 text-sm" : "px-2 py-0.5 text-xs"} rounded-full font-medium capitalize ${a}`, children: t });
|
|
2160
2175
|
}
|
|
2161
|
-
function
|
|
2176
|
+
function Wr({
|
|
2162
2177
|
productName: t,
|
|
2163
2178
|
isIcon: r = !1,
|
|
2164
2179
|
className: a,
|
|
@@ -2183,7 +2198,7 @@ function Qr({
|
|
|
2183
2198
|
disabled: o,
|
|
2184
2199
|
className: `text-red-500 hover:text-red-600 hover:bg-red-50 ${a}`,
|
|
2185
2200
|
title: "Delete Product",
|
|
2186
|
-
children: /* @__PURE__ */ e(
|
|
2201
|
+
children: /* @__PURE__ */ e(xe, { className: "h-4 w-4" })
|
|
2187
2202
|
}
|
|
2188
2203
|
) : /* @__PURE__ */ e(
|
|
2189
2204
|
T,
|
|
@@ -2209,7 +2224,7 @@ function Ln({
|
|
|
2209
2224
|
bulkDeleteProductsAction: i,
|
|
2210
2225
|
bulkDraftProductsAction: o
|
|
2211
2226
|
}) {
|
|
2212
|
-
const c = Oe(), [d, l] = P(() => /* @__PURE__ */ new Set()), [u, p] = P(""), [h,
|
|
2227
|
+
const c = Oe(), [d, l] = P(() => /* @__PURE__ */ new Set()), [u, p] = P(""), [h, x] = P(null), [g, N] = P(null), [S, R] = $e(), y = ee(() => {
|
|
2213
2228
|
const E = u.trim().toLowerCase();
|
|
2214
2229
|
return E ? t.filter((K) => {
|
|
2215
2230
|
const H = r[String(K.language_id)] || "";
|
|
@@ -2227,9 +2242,9 @@ function Ln({
|
|
|
2227
2242
|
), _ = ee(
|
|
2228
2243
|
() => t.filter((E) => d.has(E.id)),
|
|
2229
2244
|
[t, d]
|
|
2230
|
-
).length, f = _ > 1,
|
|
2245
|
+
).length, f = _ > 1, b = k.filter(
|
|
2231
2246
|
(E) => d.has(E)
|
|
2232
|
-
).length, M = k.length > 0 && k.every((E) => d.has(E)), q =
|
|
2247
|
+
).length, M = k.length > 0 && k.every((E) => d.has(E)), q = b > 0 && !M;
|
|
2233
2248
|
Ue(() => {
|
|
2234
2249
|
const E = new Set(C);
|
|
2235
2250
|
l((K) => {
|
|
@@ -2251,19 +2266,19 @@ function Ln({
|
|
|
2251
2266
|
});
|
|
2252
2267
|
}, se = (E, K, H) => {
|
|
2253
2268
|
if (_ === 0) {
|
|
2254
|
-
|
|
2269
|
+
x("Select at least one product first.");
|
|
2255
2270
|
return;
|
|
2256
2271
|
}
|
|
2257
|
-
window.confirm(K) && (
|
|
2272
|
+
window.confirm(K) && (x(null), N(E), R(async () => {
|
|
2258
2273
|
try {
|
|
2259
2274
|
const m = await H(Array.from(d));
|
|
2260
2275
|
if (!m.success) {
|
|
2261
|
-
|
|
2276
|
+
x(m.error || "Bulk action failed. Please try again."), N(null);
|
|
2262
2277
|
return;
|
|
2263
2278
|
}
|
|
2264
2279
|
l(/* @__PURE__ */ new Set()), c.refresh();
|
|
2265
2280
|
} catch (m) {
|
|
2266
|
-
console.error("Bulk product action failed:", m),
|
|
2281
|
+
console.error("Bulk product action failed:", m), x("Bulk action failed. Please try again.");
|
|
2267
2282
|
} finally {
|
|
2268
2283
|
N(null);
|
|
2269
2284
|
}
|
|
@@ -2321,7 +2336,7 @@ function Ln({
|
|
|
2321
2336
|
i
|
|
2322
2337
|
),
|
|
2323
2338
|
children: [
|
|
2324
|
-
/* @__PURE__ */ e(
|
|
2339
|
+
/* @__PURE__ */ e(xe, { className: "mr-2 h-4 w-4" }),
|
|
2325
2340
|
g === "Deleting..." ? g : "Delete"
|
|
2326
2341
|
]
|
|
2327
2342
|
}
|
|
@@ -2396,7 +2411,7 @@ function Ln({
|
|
|
2396
2411
|
E.slug ? /* @__PURE__ */ e(te, { href: `/product/${E.slug}`, target: "_blank", rel: "noopener noreferrer", children: /* @__PURE__ */ e(T, { variant: "outline", size: "sm", children: "View Product" }) }) : null,
|
|
2397
2412
|
/* @__PURE__ */ e(te, { href: `/cms/products/${E.id}/edit`, children: /* @__PURE__ */ e(T, { variant: "ghost", size: "sm", children: "Edit" }) }),
|
|
2398
2413
|
/* @__PURE__ */ e(
|
|
2399
|
-
|
|
2414
|
+
Wr,
|
|
2400
2415
|
{
|
|
2401
2416
|
productName: E.title,
|
|
2402
2417
|
isIcon: !0,
|
|
@@ -2421,7 +2436,7 @@ function Mn({ title: t = "Sync Full Store" }) {
|
|
|
2421
2436
|
onClick: async () => {
|
|
2422
2437
|
a(!0);
|
|
2423
2438
|
try {
|
|
2424
|
-
const i = await
|
|
2439
|
+
const i = await pa();
|
|
2425
2440
|
i.error ? X.error(i.error) : X.success(`Full store sync complete! Found ${i.data?.count || 0} products.`);
|
|
2426
2441
|
} catch (i) {
|
|
2427
2442
|
X.error(i.message || "An unexpected error occurred during sync");
|
|
@@ -2438,7 +2453,7 @@ function Mn({ title: t = "Sync Full Store" }) {
|
|
|
2438
2453
|
}
|
|
2439
2454
|
);
|
|
2440
2455
|
}
|
|
2441
|
-
async function
|
|
2456
|
+
async function Po({
|
|
2442
2457
|
searchParams: t,
|
|
2443
2458
|
languageFilterNode: r,
|
|
2444
2459
|
transferControlsNode: a
|
|
@@ -2446,7 +2461,7 @@ async function bo({
|
|
|
2446
2461
|
const n = re(), [i, { data: o }] = await Promise.all([
|
|
2447
2462
|
At(),
|
|
2448
2463
|
n.from("currencies").select("code, is_default").eq("is_active", !0).order("is_default", { ascending: !1 }).order("code", { ascending: !0 })
|
|
2449
|
-
]), c = t?.lang ? parseInt(t.lang, 10) : void 0, { data: d } = await
|
|
2464
|
+
]), c = t?.lang ? parseInt(t.lang, 10) : void 0, { data: d } = await ha({ languageId: c }), l = Object.fromEntries(
|
|
2450
2465
|
i.map((p) => [String(p.id), p.code.toUpperCase()])
|
|
2451
2466
|
), u = o?.find((p) => p.is_default)?.code || o?.[0]?.code || "USD";
|
|
2452
2467
|
return /* @__PURE__ */ s("div", { className: "p-8 space-y-6", children: [
|
|
@@ -2466,9 +2481,9 @@ async function bo({
|
|
|
2466
2481
|
products: d || [],
|
|
2467
2482
|
languageLabels: l,
|
|
2468
2483
|
defaultCurrencyCode: u,
|
|
2469
|
-
deleteProductAction:
|
|
2470
|
-
bulkDeleteProductsAction:
|
|
2471
|
-
bulkDraftProductsAction:
|
|
2484
|
+
deleteProductAction: Ar,
|
|
2485
|
+
bulkDeleteProductsAction: $a,
|
|
2486
|
+
bulkDraftProductsAction: Ua
|
|
2472
2487
|
}
|
|
2473
2488
|
)
|
|
2474
2489
|
] });
|
|
@@ -2502,10 +2517,10 @@ function Dn(t) {
|
|
|
2502
2517
|
async function zn(t) {
|
|
2503
2518
|
try {
|
|
2504
2519
|
const r = Math.max(0, Math.trunc(t.stock));
|
|
2505
|
-
return await
|
|
2520
|
+
return await Rr({
|
|
2506
2521
|
sku: t.sku,
|
|
2507
2522
|
stock: r
|
|
2508
|
-
}),
|
|
2523
|
+
}), Q("/cms/products"), Q("/cms/products/inventory"), {
|
|
2509
2524
|
success: !0,
|
|
2510
2525
|
itemKey: Dn(t),
|
|
2511
2526
|
stock: r
|
|
@@ -2531,24 +2546,24 @@ async function Bn(t) {
|
|
|
2531
2546
|
const d = re();
|
|
2532
2547
|
let l = 0;
|
|
2533
2548
|
for (const p of n) {
|
|
2534
|
-
const h = (p[o] || "").trim(),
|
|
2549
|
+
const h = (p[o] || "").trim(), x = Number.parseInt((p[c] || "").trim(), 10);
|
|
2535
2550
|
if (h) {
|
|
2536
|
-
if (!Number.isFinite(
|
|
2551
|
+
if (!Number.isFinite(x) || x < 0)
|
|
2537
2552
|
return {
|
|
2538
2553
|
success: !1,
|
|
2539
2554
|
error: `Invalid stock value for SKU "${h}".`
|
|
2540
2555
|
};
|
|
2541
|
-
await
|
|
2556
|
+
await Rr(
|
|
2542
2557
|
{
|
|
2543
2558
|
sku: h,
|
|
2544
|
-
stock:
|
|
2559
|
+
stock: x
|
|
2545
2560
|
},
|
|
2546
2561
|
d
|
|
2547
2562
|
), l += 1;
|
|
2548
2563
|
}
|
|
2549
2564
|
}
|
|
2550
|
-
const u = await
|
|
2551
|
-
return
|
|
2565
|
+
const u = await Fr(d);
|
|
2566
|
+
return Q("/cms/products"), Q("/cms/products/inventory"), {
|
|
2552
2567
|
success: !0,
|
|
2553
2568
|
updatedCount: l,
|
|
2554
2569
|
items: u
|
|
@@ -2594,7 +2609,7 @@ function Gn(t) {
|
|
|
2594
2609
|
function Hn({ initialItems: t }) {
|
|
2595
2610
|
const [r, a] = P(t), [n, i] = P(
|
|
2596
2611
|
() => t.reduce((y, C) => (y[C.key] = String(C.stock), y), {})
|
|
2597
|
-
), [o, c] = P(""), [d, l] = $e(), [u, p] = P(null), h = ss(null),
|
|
2612
|
+
), [o, c] = P(""), [d, l] = $e(), [u, p] = P(null), h = ss(null), x = ee(() => {
|
|
2598
2613
|
const y = o.trim().toLowerCase();
|
|
2599
2614
|
return y ? r.filter((C) => C.sku.toLowerCase().includes(y) || C.productTitles.join(" ").toLowerCase().includes(y) || C.parentProductSkus.join(" ").toLowerCase().includes(y) || C.languages.join(" ").toLowerCase().includes(y)) : r;
|
|
2600
2615
|
}, [r, o]), g = () => {
|
|
@@ -2618,10 +2633,10 @@ function Hn({ initialItems: t }) {
|
|
|
2618
2633
|
const _ = typeof F.stock == "number" ? F.stock : k;
|
|
2619
2634
|
a(
|
|
2620
2635
|
(f) => f.map(
|
|
2621
|
-
(
|
|
2622
|
-
...
|
|
2636
|
+
(b) => b.key === y.key ? {
|
|
2637
|
+
...b,
|
|
2623
2638
|
stock: _
|
|
2624
|
-
} :
|
|
2639
|
+
} : b
|
|
2625
2640
|
)
|
|
2626
2641
|
), i((f) => ({
|
|
2627
2642
|
...f,
|
|
@@ -2695,7 +2710,7 @@ function Hn({ initialItems: t }) {
|
|
|
2695
2710
|
/* @__PURE__ */ e(Y, { className: "w-[160px]", children: "Quantity" }),
|
|
2696
2711
|
/* @__PURE__ */ e(Y, { className: "text-right", children: "Actions" })
|
|
2697
2712
|
] }) }),
|
|
2698
|
-
/* @__PURE__ */ e(Ot, { children:
|
|
2713
|
+
/* @__PURE__ */ e(Ot, { children: x.length > 0 ? x.map((y) => {
|
|
2699
2714
|
const C = n[y.key] ?? String(y.stock), k = Number.parseInt(C, 10), F = Number.isFinite(k) && k !== y.stock, _ = u === y.key;
|
|
2700
2715
|
return /* @__PURE__ */ s(ye, { children: [
|
|
2701
2716
|
/* @__PURE__ */ e(G, { className: "font-mono text-sm", children: y.sku }),
|
|
@@ -2720,8 +2735,8 @@ function Hn({ initialItems: t }) {
|
|
|
2720
2735
|
step: 1,
|
|
2721
2736
|
value: C,
|
|
2722
2737
|
disabled: d,
|
|
2723
|
-
onChange: (f) => i((
|
|
2724
|
-
...
|
|
2738
|
+
onChange: (f) => i((b) => ({
|
|
2739
|
+
...b,
|
|
2725
2740
|
[y.key]: f.target.value
|
|
2726
2741
|
})),
|
|
2727
2742
|
className: "w-28"
|
|
@@ -2764,8 +2779,8 @@ function Hn({ initialItems: t }) {
|
|
|
2764
2779
|
] }) })
|
|
2765
2780
|
] });
|
|
2766
2781
|
}
|
|
2767
|
-
async function
|
|
2768
|
-
const t = await
|
|
2782
|
+
async function To() {
|
|
2783
|
+
const t = await Fr();
|
|
2769
2784
|
return /* @__PURE__ */ s("div", { className: "p-8 space-y-6", children: [
|
|
2770
2785
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
2771
2786
|
/* @__PURE__ */ e("h1", { className: "text-3xl font-bold", children: "Inventory" }),
|
|
@@ -2774,7 +2789,7 @@ async function xo() {
|
|
|
2774
2789
|
/* @__PURE__ */ e(Hn, { initialItems: t })
|
|
2775
2790
|
] });
|
|
2776
2791
|
}
|
|
2777
|
-
function
|
|
2792
|
+
function Wn({
|
|
2778
2793
|
attributes: t,
|
|
2779
2794
|
languages: r,
|
|
2780
2795
|
createAttributeAction: a,
|
|
@@ -2784,9 +2799,9 @@ function Qn({
|
|
|
2784
2799
|
reorderTermsAction: c,
|
|
2785
2800
|
updateTranslationsAction: d
|
|
2786
2801
|
}) {
|
|
2787
|
-
const l = Oe(), [u, p] = P(""), [h,
|
|
2802
|
+
const l = Oe(), [u, p] = P(""), [h, x] = P(null), [g, N] = P(null), [S, R] = P(null), [y, C] = P(null), [k, F] = P({}), [_, f] = P(
|
|
2788
2803
|
() => t.reduce((m, A) => (m[A.id] = A.name_translations || {}, m), {})
|
|
2789
|
-
), [
|
|
2804
|
+
), [b, M] = P(
|
|
2790
2805
|
() => t.reduce((m, A) => {
|
|
2791
2806
|
for (const O of A.terms)
|
|
2792
2807
|
m[O.id] = O.value_translations || {};
|
|
@@ -2801,17 +2816,17 @@ function Qn({
|
|
|
2801
2816
|
}
|
|
2802
2817
|
p(""), l.refresh();
|
|
2803
2818
|
}, z = async (m, A) => {
|
|
2804
|
-
m.preventDefault(),
|
|
2819
|
+
m.preventDefault(), x(A);
|
|
2805
2820
|
const O = await i({
|
|
2806
2821
|
attributeId: A,
|
|
2807
2822
|
value: k[A] || ""
|
|
2808
2823
|
});
|
|
2809
|
-
if (
|
|
2824
|
+
if (x(null), !O.success) {
|
|
2810
2825
|
alert(O.error || "Failed to create term.");
|
|
2811
2826
|
return;
|
|
2812
2827
|
}
|
|
2813
|
-
F((
|
|
2814
|
-
...
|
|
2828
|
+
F((W) => ({
|
|
2829
|
+
...W,
|
|
2815
2830
|
[A]: ""
|
|
2816
2831
|
})), l.refresh();
|
|
2817
2832
|
}, se = async (m) => {
|
|
@@ -2832,10 +2847,10 @@ function Qn({
|
|
|
2832
2847
|
}
|
|
2833
2848
|
l.refresh();
|
|
2834
2849
|
}, K = async (m, A, O) => {
|
|
2835
|
-
const
|
|
2836
|
-
if (
|
|
2850
|
+
const W = m.terms.findIndex((B) => B.id === A), le = W + O;
|
|
2851
|
+
if (W === -1 || le < 0 || le >= m.terms.length)
|
|
2837
2852
|
return;
|
|
2838
|
-
const v = [...m.terms], [L] = v.splice(
|
|
2853
|
+
const v = [...m.terms], [L] = v.splice(W, 1);
|
|
2839
2854
|
v.splice(le, 0, L), R(m.id);
|
|
2840
2855
|
const I = await c({
|
|
2841
2856
|
attributeId: m.id,
|
|
@@ -2853,7 +2868,7 @@ function Qn({
|
|
|
2853
2868
|
nameTranslations: _[m.id] || {},
|
|
2854
2869
|
termTranslations: m.terms.map((O) => ({
|
|
2855
2870
|
termId: O.id,
|
|
2856
|
-
valueTranslations:
|
|
2871
|
+
valueTranslations: b[O.id] || {}
|
|
2857
2872
|
}))
|
|
2858
2873
|
});
|
|
2859
2874
|
if (C(null), !A.success) {
|
|
@@ -2877,7 +2892,7 @@ function Qn({
|
|
|
2877
2892
|
)
|
|
2878
2893
|
] }),
|
|
2879
2894
|
/* @__PURE__ */ s(T, { type: "submit", disabled: !u.trim(), children: [
|
|
2880
|
-
/* @__PURE__ */ e(
|
|
2895
|
+
/* @__PURE__ */ e(We, { className: "mr-2 h-4 w-4" }),
|
|
2881
2896
|
"Create Attribute"
|
|
2882
2897
|
] })
|
|
2883
2898
|
] }) }),
|
|
@@ -2895,7 +2910,7 @@ function Qn({
|
|
|
2895
2910
|
size: "icon",
|
|
2896
2911
|
onClick: () => se(m.id),
|
|
2897
2912
|
className: "text-muted-foreground hover:text-destructive",
|
|
2898
|
-
children: /* @__PURE__ */ e(
|
|
2913
|
+
children: /* @__PURE__ */ e(xe, { className: "h-4 w-4" })
|
|
2899
2914
|
}
|
|
2900
2915
|
)
|
|
2901
2916
|
] }),
|
|
@@ -2945,7 +2960,7 @@ function Qn({
|
|
|
2945
2960
|
onClick: () => E(A.id),
|
|
2946
2961
|
className: "h-8 w-8 text-muted-foreground hover:text-destructive",
|
|
2947
2962
|
disabled: g === A.id,
|
|
2948
|
-
children: /* @__PURE__ */ e(
|
|
2963
|
+
children: /* @__PURE__ */ e(xe, { className: "h-4 w-4" })
|
|
2949
2964
|
}
|
|
2950
2965
|
)
|
|
2951
2966
|
] })
|
|
@@ -2981,7 +2996,7 @@ function Qn({
|
|
|
2981
2996
|
variant: "outline",
|
|
2982
2997
|
disabled: !k[m.id]?.trim() || h === m.id,
|
|
2983
2998
|
children: [
|
|
2984
|
-
/* @__PURE__ */ e(
|
|
2999
|
+
/* @__PURE__ */ e(We, { className: "mr-2 h-4 w-4" }),
|
|
2985
3000
|
h === m.id ? "Saving..." : "Add Term"
|
|
2986
3001
|
]
|
|
2987
3002
|
}
|
|
@@ -3017,10 +3032,10 @@ function Qn({
|
|
|
3017
3032
|
{
|
|
3018
3033
|
id: `attribute-translation-${m.id}-${A.code}`,
|
|
3019
3034
|
value: _[m.id]?.[A.code] || "",
|
|
3020
|
-
onChange: (O) => f((
|
|
3021
|
-
...
|
|
3035
|
+
onChange: (O) => f((W) => ({
|
|
3036
|
+
...W,
|
|
3022
3037
|
[m.id]: {
|
|
3023
|
-
...
|
|
3038
|
+
...W[m.id] || {},
|
|
3024
3039
|
[A.code]: O.target.value
|
|
3025
3040
|
}
|
|
3026
3041
|
})),
|
|
@@ -3039,12 +3054,12 @@ function Qn({
|
|
|
3039
3054
|
V,
|
|
3040
3055
|
{
|
|
3041
3056
|
id: `term-translation-${A.id}-${O.code}`,
|
|
3042
|
-
value:
|
|
3043
|
-
onChange: (
|
|
3057
|
+
value: b[A.id]?.[O.code] || "",
|
|
3058
|
+
onChange: (W) => M((le) => ({
|
|
3044
3059
|
...le,
|
|
3045
3060
|
[A.id]: {
|
|
3046
3061
|
...le[A.id] || {},
|
|
3047
|
-
[O.code]:
|
|
3062
|
+
[O.code]: W.target.value
|
|
3048
3063
|
}
|
|
3049
3064
|
})),
|
|
3050
3065
|
placeholder: A.value
|
|
@@ -3056,9 +3071,9 @@ function Qn({
|
|
|
3056
3071
|
] }, m.id)) })
|
|
3057
3072
|
] });
|
|
3058
3073
|
}
|
|
3059
|
-
async function
|
|
3074
|
+
async function Io() {
|
|
3060
3075
|
const [t, r] = await Promise.all([
|
|
3061
|
-
|
|
3076
|
+
It(),
|
|
3062
3077
|
At()
|
|
3063
3078
|
]), a = (t || []).map((n) => ({
|
|
3064
3079
|
id: n.id,
|
|
@@ -3079,21 +3094,21 @@ async function vo() {
|
|
|
3079
3094
|
] })
|
|
3080
3095
|
] }) }),
|
|
3081
3096
|
/* @__PURE__ */ e(
|
|
3082
|
-
|
|
3097
|
+
Wn,
|
|
3083
3098
|
{
|
|
3084
3099
|
attributes: a,
|
|
3085
|
-
createAttributeAction:
|
|
3086
|
-
deleteAttributeAction:
|
|
3087
|
-
createTermAction:
|
|
3088
|
-
deleteTermAction:
|
|
3089
|
-
reorderTermsAction:
|
|
3090
|
-
updateTranslationsAction:
|
|
3100
|
+
createAttributeAction: za,
|
|
3101
|
+
deleteAttributeAction: Da,
|
|
3102
|
+
createTermAction: qa,
|
|
3103
|
+
deleteTermAction: Ma,
|
|
3104
|
+
reorderTermsAction: La,
|
|
3105
|
+
updateTranslationsAction: Oa,
|
|
3091
3106
|
languages: r
|
|
3092
3107
|
}
|
|
3093
3108
|
)
|
|
3094
3109
|
] });
|
|
3095
3110
|
}
|
|
3096
|
-
async function
|
|
3111
|
+
async function Ro({
|
|
3097
3112
|
mediaPickerNode: t,
|
|
3098
3113
|
availableLanguagesProp: r,
|
|
3099
3114
|
translationGroupId: a,
|
|
@@ -3103,7 +3118,7 @@ async function wo({
|
|
|
3103
3118
|
const [o, c, d, l] = await Promise.all([
|
|
3104
3119
|
Ye(),
|
|
3105
3120
|
jt(),
|
|
3106
|
-
|
|
3121
|
+
It(),
|
|
3107
3122
|
re().from("currencies").select(
|
|
3108
3123
|
"code, symbol, exchange_rate, is_default, is_active, auto_sync_product_prices, auto_update_exchange_rate, exchange_rate_source, exchange_rate_updated_at, rounding_mode, rounding_increment, rounding_charm_amount"
|
|
3109
3124
|
).eq("is_active", !0).order("code", { ascending: !0 }).then((S) => S.data || [])
|
|
@@ -3118,12 +3133,12 @@ async function wo({
|
|
|
3118
3133
|
...R,
|
|
3119
3134
|
value_translations: R.value_translations || {}
|
|
3120
3135
|
}))
|
|
3121
|
-
})), h = r.find((S) => S.id === i?.language_id)?.code || r.find((S) => S.id === (n ? parseInt(n, 10) : void 0))?.code || r.find((S) => S.is_default)?.code, { attributes:
|
|
3136
|
+
})), h = r.find((S) => S.id === i?.language_id)?.code || r.find((S) => S.id === (n ? parseInt(n, 10) : void 0))?.code || r.find((S) => S.is_default)?.code, { attributes: x, variants: g } = $r(
|
|
3122
3137
|
i?.product_variants || [],
|
|
3123
3138
|
h
|
|
3124
3139
|
), N = i && {
|
|
3125
3140
|
...i,
|
|
3126
|
-
variation_attributes: i.variation_attributes ||
|
|
3141
|
+
variation_attributes: i.variation_attributes || x.map((S) => ({
|
|
3127
3142
|
attribute_id: S.id,
|
|
3128
3143
|
term_ids: S.terms.map((R) => R.id)
|
|
3129
3144
|
})),
|
|
@@ -3142,7 +3157,7 @@ async function wo({
|
|
|
3142
3157
|
}))
|
|
3143
3158
|
};
|
|
3144
3159
|
return /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ e(
|
|
3145
|
-
|
|
3160
|
+
Pr,
|
|
3146
3161
|
{
|
|
3147
3162
|
mediaPickerNode: t,
|
|
3148
3163
|
availableLanguagesProp: r,
|
|
@@ -3153,11 +3168,11 @@ async function wo({
|
|
|
3153
3168
|
initialData: N,
|
|
3154
3169
|
enabledProviders: o,
|
|
3155
3170
|
configStatus: c,
|
|
3156
|
-
createAction:
|
|
3171
|
+
createAction: Ba
|
|
3157
3172
|
}
|
|
3158
3173
|
) });
|
|
3159
3174
|
}
|
|
3160
|
-
function
|
|
3175
|
+
function Qn({ plans: t }) {
|
|
3161
3176
|
return /* @__PURE__ */ e("div", { className: "w-full", children: t && t.length > 0 ? /* @__PURE__ */ e("div", { className: "space-y-8", children: t.map((r) => /* @__PURE__ */ s("div", { className: "w-full", children: [
|
|
3162
3177
|
t.length > 1 && /* @__PURE__ */ e("h3", { className: "font-semibold text-lg text-slate-700 dark:text-slate-300 border-b pb-2 mb-4 mt-6", children: r.title || r.name }),
|
|
3163
3178
|
/* @__PURE__ */ e("div", { className: `${t.length > 1 ? "rounded-lg border" : "rounded-b-lg border-x border-b"} overflow-x-auto dark:border-slate-700 bg-card`, children: /* @__PURE__ */ s(Ut, { children: [
|
|
@@ -3181,7 +3196,7 @@ function Xn({ pricing: t }) {
|
|
|
3181
3196
|
const [r, a] = $e(), n = (i, o) => {
|
|
3182
3197
|
const c = o === "" ? null : parseFloat(o);
|
|
3183
3198
|
o !== "" && Number.isNaN(c) || a(async () => {
|
|
3184
|
-
const { success: d, error: l } = await
|
|
3199
|
+
const { success: d, error: l } = await fa(t.id, { [i]: c });
|
|
3185
3200
|
d ? X.success("Pricing override saved") : X.error(l || "Failed to update pricing");
|
|
3186
3201
|
});
|
|
3187
3202
|
};
|
|
@@ -3234,7 +3249,7 @@ function Xn({ pricing: t }) {
|
|
|
3234
3249
|
) })
|
|
3235
3250
|
] });
|
|
3236
3251
|
}
|
|
3237
|
-
async function
|
|
3252
|
+
async function Fo({
|
|
3238
3253
|
params: t,
|
|
3239
3254
|
mediaPickerNode: r,
|
|
3240
3255
|
availableLanguagesProp: a,
|
|
@@ -3242,22 +3257,22 @@ async function No({
|
|
|
3242
3257
|
copyContentNode: i,
|
|
3243
3258
|
translationCtaNode: o
|
|
3244
3259
|
}) {
|
|
3245
|
-
const { id: c } = await t, d = await
|
|
3260
|
+
const { id: c } = await t, d = await ga(c);
|
|
3246
3261
|
d || Mt();
|
|
3247
|
-
const l = d.product_type === "digital" || d.payment_provider === "freemius", [u, p, h,
|
|
3262
|
+
const l = d.product_type === "digital" || d.payment_provider === "freemius", [u, p, h, x, g] = await Promise.all([
|
|
3248
3263
|
Ye(),
|
|
3249
3264
|
jt(),
|
|
3250
|
-
l && d.freemius_product_id ?
|
|
3251
|
-
|
|
3265
|
+
l && d.freemius_product_id ? _a(d.id) : Promise.resolve(null),
|
|
3266
|
+
It(),
|
|
3252
3267
|
re().from("currencies").select(
|
|
3253
3268
|
"code, symbol, exchange_rate, is_default, is_active, auto_sync_product_prices, auto_update_exchange_rate, exchange_rate_source, exchange_rate_updated_at, rounding_mode, rounding_increment, rounding_charm_amount"
|
|
3254
3269
|
).eq("is_active", !0).order("code", { ascending: !0 }).then((_) => _.data || [])
|
|
3255
3270
|
]), N = (g || []).map(
|
|
3256
3271
|
(_) => Se(_)
|
|
3257
|
-
), S = a.find((_) => _.id === d.language_id)?.code, { attributes: R, variants: y } =
|
|
3272
|
+
), S = a.find((_) => _.id === d.language_id)?.code, { attributes: R, variants: y } = $r(
|
|
3258
3273
|
d.product_variants || [],
|
|
3259
3274
|
S
|
|
3260
|
-
), C = (
|
|
3275
|
+
), C = (x || []).map((_) => ({
|
|
3261
3276
|
id: _.id,
|
|
3262
3277
|
name: _.name,
|
|
3263
3278
|
name_translations: _.name_translations || {},
|
|
@@ -3266,7 +3281,7 @@ async function No({
|
|
|
3266
3281
|
...f,
|
|
3267
3282
|
value_translations: f.value_translations || {}
|
|
3268
3283
|
}))
|
|
3269
|
-
})), k =
|
|
3284
|
+
})), k = Wr, F = Qn;
|
|
3270
3285
|
return /* @__PURE__ */ s("div", { className: "space-y-8 w-full max-w-[1400px] mx-auto px-6 py-8", children: [
|
|
3271
3286
|
/* @__PURE__ */ s("div", { className: "flex justify-between items-center flex-wrap gap-4 w-full", children: [
|
|
3272
3287
|
/* @__PURE__ */ s("div", { className: "flex items-center gap-3", children: [
|
|
@@ -3295,7 +3310,7 @@ async function No({
|
|
|
3295
3310
|
productName: d.title,
|
|
3296
3311
|
redirectTo: "/cms/products",
|
|
3297
3312
|
className: "border-red-200 hover:bg-red-50 hover:text-red-700",
|
|
3298
|
-
deleteAction:
|
|
3313
|
+
deleteAction: Ar.bind(null, d.id)
|
|
3299
3314
|
}
|
|
3300
3315
|
) : null,
|
|
3301
3316
|
d.slug && d.status === "active" && /* @__PURE__ */ e(T, { variant: "outline", asChild: !0, children: /* @__PURE__ */ s(te, { href: `/product/${d.slug}`, target: "_blank", children: [
|
|
@@ -3305,7 +3320,7 @@ async function No({
|
|
|
3305
3320
|
] })
|
|
3306
3321
|
] }),
|
|
3307
3322
|
/* @__PURE__ */ e(
|
|
3308
|
-
|
|
3323
|
+
Pr,
|
|
3309
3324
|
{
|
|
3310
3325
|
initialData: {
|
|
3311
3326
|
id: d.id,
|
|
@@ -3316,7 +3331,7 @@ async function No({
|
|
|
3316
3331
|
stock: d.stock || 0,
|
|
3317
3332
|
price: d.price || 0,
|
|
3318
3333
|
prices: Object.entries(d.prices || {}).reduce(
|
|
3319
|
-
(_, [f,
|
|
3334
|
+
(_, [f, b]) => (_[f] = ve(b, f), _),
|
|
3320
3335
|
{}
|
|
3321
3336
|
),
|
|
3322
3337
|
is_taxable: typeof d.is_taxable == "boolean" ? d.is_taxable : !0,
|
|
@@ -3326,7 +3341,7 @@ async function No({
|
|
|
3326
3341
|
short_description: d.short_description ?? void 0,
|
|
3327
3342
|
description_json: d.description_json,
|
|
3328
3343
|
sale_price: typeof d.sale_price == "number" ? d.sale_price : void 0,
|
|
3329
|
-
sale_prices: Object.entries(d.sale_prices || {}).reduce((_, [f,
|
|
3344
|
+
sale_prices: Object.entries(d.sale_prices || {}).reduce((_, [f, b]) => (_[f] = typeof b == "number" ? ve(b, f) : null, _), {}),
|
|
3330
3345
|
freemius_plan_id: d.freemius_plan_id ?? void 0,
|
|
3331
3346
|
freemius_product_id: d.freemius_product_id ?? void 0,
|
|
3332
3347
|
trial_period_days: d.trial_period_days ?? 0,
|
|
@@ -3343,11 +3358,11 @@ async function No({
|
|
|
3343
3358
|
upc: _.upc ?? null,
|
|
3344
3359
|
price: _.price / 100,
|
|
3345
3360
|
prices: Object.entries(_.prices || {}).reduce(
|
|
3346
|
-
(f, [
|
|
3361
|
+
(f, [b, M]) => (f[b] = ve(M, b), f),
|
|
3347
3362
|
{}
|
|
3348
3363
|
),
|
|
3349
3364
|
sale_price: typeof _.sale_price == "number" ? _.sale_price / 100 : null,
|
|
3350
|
-
sale_prices: Object.entries(_.sale_prices || {}).reduce((f, [
|
|
3365
|
+
sale_prices: Object.entries(_.sale_prices || {}).reduce((f, [b, M]) => (f[b] = typeof M == "number" ? ve(M, b) : null, f), {}),
|
|
3351
3366
|
main_media_id: _.main_media_id ?? null,
|
|
3352
3367
|
main_image_url: _.image_url ?? null
|
|
3353
3368
|
}))
|
|
@@ -3359,7 +3374,7 @@ async function No({
|
|
|
3359
3374
|
currenciesProp: N,
|
|
3360
3375
|
enabledProviders: u,
|
|
3361
3376
|
configStatus: p,
|
|
3362
|
-
updateAction:
|
|
3377
|
+
updateAction: ja.bind(null, d.id),
|
|
3363
3378
|
freemiusDashboardNode: l && d.freemius_product_id && h && F ? /* @__PURE__ */ e(
|
|
3364
3379
|
F,
|
|
3365
3380
|
{
|
|
@@ -3372,18 +3387,18 @@ async function No({
|
|
|
3372
3387
|
)
|
|
3373
3388
|
] });
|
|
3374
3389
|
}
|
|
3375
|
-
function
|
|
3390
|
+
function Uo({
|
|
3376
3391
|
productId: t,
|
|
3377
3392
|
currentLanguageId: r,
|
|
3378
3393
|
translationGroupId: a,
|
|
3379
3394
|
allSiteLanguages: n
|
|
3380
3395
|
}) {
|
|
3381
|
-
const [i, o] = P(!1), [c, d] = P(null), [l, u] = P([]), [p, h] = P(!1), [
|
|
3396
|
+
const [i, o] = P(!1), [c, d] = P(null), [l, u] = P([]), [p, h] = P(!1), [x, g] = P(null), [N, S] = $e(), R = Oe();
|
|
3382
3397
|
Ue(() => {
|
|
3383
3398
|
i && a && (async () => {
|
|
3384
3399
|
h(!0);
|
|
3385
3400
|
try {
|
|
3386
|
-
const _ = (await
|
|
3401
|
+
const _ = (await ya(a)).filter((f) => f.id !== t);
|
|
3387
3402
|
u(_);
|
|
3388
3403
|
} catch (F) {
|
|
3389
3404
|
console.error("Error fetching translations:", F);
|
|
@@ -3401,7 +3416,7 @@ function Co({
|
|
|
3401
3416
|
return;
|
|
3402
3417
|
}
|
|
3403
3418
|
g(null), S(async () => {
|
|
3404
|
-
const k = await
|
|
3419
|
+
const k = await xa(t, c);
|
|
3405
3420
|
k.success ? (g({
|
|
3406
3421
|
type: "success",
|
|
3407
3422
|
text: "Content copied successfully. The page will now refresh."
|
|
@@ -3415,7 +3430,7 @@ function Co({
|
|
|
3415
3430
|
}, C = n.find((k) => k.id === r);
|
|
3416
3431
|
return /* @__PURE__ */ s(ot, { open: i, onOpenChange: o, children: [
|
|
3417
3432
|
/* @__PURE__ */ e(ct, { asChild: !0, children: /* @__PURE__ */ s(T, { variant: "outline", title: "Copy content from another language", children: [
|
|
3418
|
-
/* @__PURE__ */ e(
|
|
3433
|
+
/* @__PURE__ */ e(xs, { className: "h-4 w-4 mr-2" }),
|
|
3419
3434
|
"Copy Content..."
|
|
3420
3435
|
] }) }),
|
|
3421
3436
|
/* @__PURE__ */ s(lt, { children: [
|
|
@@ -3451,13 +3466,13 @@ function Co({
|
|
|
3451
3466
|
}
|
|
3452
3467
|
)
|
|
3453
3468
|
] }),
|
|
3454
|
-
|
|
3469
|
+
x && /* @__PURE__ */ s(
|
|
3455
3470
|
"div",
|
|
3456
3471
|
{
|
|
3457
|
-
className: `p-3 rounded-md text-sm flex items-center gap-2 ${
|
|
3472
|
+
className: `p-3 rounded-md text-sm flex items-center gap-2 ${x.type === "success" ? "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400" : "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"}`,
|
|
3458
3473
|
children: [
|
|
3459
|
-
|
|
3460
|
-
|
|
3474
|
+
x.type === "success" ? /* @__PURE__ */ e(kt, { className: "h-5 w-5" }) : /* @__PURE__ */ e(Mr, { className: "h-5 w-5" }),
|
|
3475
|
+
x.text
|
|
3461
3476
|
]
|
|
3462
3477
|
}
|
|
3463
3478
|
)
|
|
@@ -3483,7 +3498,7 @@ function Yn({
|
|
|
3483
3498
|
updateCategory: n,
|
|
3484
3499
|
deleteCategory: i
|
|
3485
3500
|
}) {
|
|
3486
|
-
const o = Oe(), [c, d] = P(t), [l, u] = P(!1), [p, h] = P(null), [
|
|
3501
|
+
const o = Oe(), [c, d] = P(t), [l, u] = P(!1), [p, h] = P(null), [x, g] = P(""), [N, S] = P(""), [R, y] = P(""), [C, k] = P({}), [F, _] = P({}), [f, b] = P(!1), M = (r || []).filter((m) => !m.is_default);
|
|
3487
3502
|
Ue(() => {
|
|
3488
3503
|
d(t);
|
|
3489
3504
|
}, [t]);
|
|
@@ -3491,13 +3506,13 @@ function Yn({
|
|
|
3491
3506
|
const A = m.target.value;
|
|
3492
3507
|
g(A), !f && !p && S(q(A));
|
|
3493
3508
|
}, z = (m) => {
|
|
3494
|
-
S(q(m.target.value)),
|
|
3509
|
+
S(q(m.target.value)), b(!0);
|
|
3495
3510
|
}, se = (m) => {
|
|
3496
|
-
h(m), g(m.name), S(m.slug), y(m.description || ""), k(m.name_translations || {}), _(m.description_translations || {}),
|
|
3511
|
+
h(m), g(m.name), S(m.slug), y(m.description || ""), k(m.name_translations || {}), _(m.description_translations || {}), b(!0);
|
|
3497
3512
|
}, E = () => {
|
|
3498
|
-
h(null), g(""), S(""), y(""), k({}), _({}),
|
|
3513
|
+
h(null), g(""), S(""), y(""), k({}), _({}), b(!1);
|
|
3499
3514
|
}, K = async (m) => {
|
|
3500
|
-
if (m.preventDefault(), !
|
|
3515
|
+
if (m.preventDefault(), !x.trim()) {
|
|
3501
3516
|
X.error("Category name is required.");
|
|
3502
3517
|
return;
|
|
3503
3518
|
}
|
|
@@ -3507,17 +3522,17 @@ function Yn({
|
|
|
3507
3522
|
);
|
|
3508
3523
|
try {
|
|
3509
3524
|
const O = {
|
|
3510
|
-
name:
|
|
3525
|
+
name: x.trim(),
|
|
3511
3526
|
slug: N.trim() || void 0,
|
|
3512
3527
|
description: R.trim() || void 0,
|
|
3513
3528
|
nameTranslations: C,
|
|
3514
3529
|
descriptionTranslations: F
|
|
3515
3530
|
};
|
|
3516
|
-
let
|
|
3517
|
-
p ?
|
|
3531
|
+
let W;
|
|
3532
|
+
p ? W = await n(p.id, O) : W = await a(O), W.success ? (X.success(
|
|
3518
3533
|
p ? "Category updated successfully!" : "Category created successfully!",
|
|
3519
3534
|
{ id: A }
|
|
3520
|
-
), E(), o.refresh()) : X.error(
|
|
3535
|
+
), E(), o.refresh()) : X.error(W.error || "Failed to save category.", { id: A });
|
|
3521
3536
|
} catch (O) {
|
|
3522
3537
|
X.error(O.message || "An unexpected error occurred.", { id: A });
|
|
3523
3538
|
} finally {
|
|
@@ -3530,10 +3545,10 @@ function Yn({
|
|
|
3530
3545
|
u(!0);
|
|
3531
3546
|
const O = X.loading("Deleting category...");
|
|
3532
3547
|
try {
|
|
3533
|
-
const
|
|
3534
|
-
|
|
3535
|
-
} catch (
|
|
3536
|
-
X.error(
|
|
3548
|
+
const W = await i(m.id);
|
|
3549
|
+
W.success ? (X.success("Category deleted successfully!", { id: O }), p?.id === m.id && E(), o.refresh()) : X.error(W.error || "Failed to delete category.", { id: O });
|
|
3550
|
+
} catch (W) {
|
|
3551
|
+
X.error(W.message || "An unexpected error occurred.", { id: O });
|
|
3537
3552
|
} finally {
|
|
3538
3553
|
u(!1);
|
|
3539
3554
|
}
|
|
@@ -3541,7 +3556,7 @@ function Yn({
|
|
|
3541
3556
|
return /* @__PURE__ */ s("div", { className: "grid gap-6 md:grid-cols-12 items-start", children: [
|
|
3542
3557
|
/* @__PURE__ */ e("div", { className: "md:col-span-4 space-y-4", children: /* @__PURE__ */ s(oe, { className: "p-5 shadow-lg border-t-4 border-t-amber-500 bg-card/65 backdrop-blur-md transition-all duration-300", children: [
|
|
3543
3558
|
/* @__PURE__ */ s("div", { className: "flex items-center gap-2 mb-4", children: [
|
|
3544
|
-
/* @__PURE__ */ e(
|
|
3559
|
+
/* @__PURE__ */ e(bs, { className: "h-5 w-5 text-amber-500" }),
|
|
3545
3560
|
/* @__PURE__ */ e("h2", { className: "text-base font-bold tracking-tight", children: p ? "Edit Category" : "Add New Category" })
|
|
3546
3561
|
] }),
|
|
3547
3562
|
/* @__PURE__ */ s("form", { onSubmit: K, className: "space-y-4", children: [
|
|
@@ -3552,7 +3567,7 @@ function Yn({
|
|
|
3552
3567
|
{
|
|
3553
3568
|
id: "name",
|
|
3554
3569
|
placeholder: "e.g. T-Shirts",
|
|
3555
|
-
value:
|
|
3570
|
+
value: x,
|
|
3556
3571
|
onChange: $,
|
|
3557
3572
|
disabled: l,
|
|
3558
3573
|
className: "h-8 text-sm",
|
|
@@ -3605,7 +3620,7 @@ function Yn({
|
|
|
3605
3620
|
V,
|
|
3606
3621
|
{
|
|
3607
3622
|
id: `name-${m.code}`,
|
|
3608
|
-
placeholder: `Translation for ${
|
|
3623
|
+
placeholder: `Translation for ${x || "Name"}`,
|
|
3609
3624
|
value: C[m.code] || "",
|
|
3610
3625
|
onChange: (A) => k((O) => ({ ...O, [m.code]: A.target.value })),
|
|
3611
3626
|
disabled: l,
|
|
@@ -3717,7 +3732,7 @@ function Yn({
|
|
|
3717
3732
|
onClick: () => H(m),
|
|
3718
3733
|
className: "h-7 w-7 opacity-85 hover:opacity-100 group-hover:border-red-500/30 cursor-pointer",
|
|
3719
3734
|
title: "Delete Category",
|
|
3720
|
-
children: /* @__PURE__ */ e(
|
|
3735
|
+
children: /* @__PURE__ */ e(xe, { className: "h-3.5 w-3.5 text-muted-foreground group-hover:text-red-500" })
|
|
3721
3736
|
}
|
|
3722
3737
|
)
|
|
3723
3738
|
] }) })
|
|
@@ -3729,9 +3744,9 @@ function Yn({
|
|
|
3729
3744
|
] }) })
|
|
3730
3745
|
] });
|
|
3731
3746
|
}
|
|
3732
|
-
async function
|
|
3747
|
+
async function $o() {
|
|
3733
3748
|
const [t, r] = await Promise.all([
|
|
3734
|
-
|
|
3749
|
+
ba(),
|
|
3735
3750
|
At()
|
|
3736
3751
|
]);
|
|
3737
3752
|
return /* @__PURE__ */ s("div", { className: "space-y-8 w-full max-w-[1200px] mx-auto px-6 py-8", children: [
|
|
@@ -3746,9 +3761,9 @@ async function So() {
|
|
|
3746
3761
|
Yn,
|
|
3747
3762
|
{
|
|
3748
3763
|
initialCategories: t,
|
|
3749
|
-
createCategory:
|
|
3750
|
-
updateCategory:
|
|
3751
|
-
deleteCategory:
|
|
3764
|
+
createCategory: Ga,
|
|
3765
|
+
updateCategory: Va,
|
|
3766
|
+
deleteCategory: Ka,
|
|
3752
3767
|
languages: r
|
|
3753
3768
|
}
|
|
3754
3769
|
)
|
|
@@ -3769,7 +3784,7 @@ async function Zn(t) {
|
|
|
3769
3784
|
});
|
|
3770
3785
|
if (i)
|
|
3771
3786
|
throw console.error("Error updating payment providers:", i), new Error("Failed to update settings");
|
|
3772
|
-
return
|
|
3787
|
+
return Q("/cms/payments"), Q("/cms/taxes"), Q("/", "layout"), { success: !0 };
|
|
3773
3788
|
}
|
|
3774
3789
|
function Jn({
|
|
3775
3790
|
initialEnabledProviders: t,
|
|
@@ -3950,7 +3965,7 @@ function fr({
|
|
|
3950
3965
|
] })
|
|
3951
3966
|
] });
|
|
3952
3967
|
}
|
|
3953
|
-
async function
|
|
3968
|
+
async function Oo() {
|
|
3954
3969
|
const [t, r] = await Promise.all([
|
|
3955
3970
|
Ye(),
|
|
3956
3971
|
jt()
|
|
@@ -3972,7 +3987,7 @@ async function ko() {
|
|
|
3972
3987
|
}
|
|
3973
3988
|
);
|
|
3974
3989
|
}
|
|
3975
|
-
function
|
|
3990
|
+
function Qr(t) {
|
|
3976
3991
|
return Object.entries(t || {}).reduce((r, [a, n]) => {
|
|
3977
3992
|
const i = a.trim().toLowerCase(), o = n.trim();
|
|
3978
3993
|
return i && o && (r[i] = o), r;
|
|
@@ -3987,14 +4002,14 @@ async function ti(t) {
|
|
|
3987
4002
|
const { data: n } = await r.from("profiles").select("role").eq("id", a.id).single();
|
|
3988
4003
|
if (!n || n.role !== "ADMIN")
|
|
3989
4004
|
throw new Error("Forbidden");
|
|
3990
|
-
const i = t.getAll("trackQuantities").includes("true"), o = await Xe(r), { error: c } = await
|
|
4005
|
+
const i = t.getAll("trackQuantities").includes("true"), o = await Xe(r), { error: c } = await kr(r, {
|
|
3991
4006
|
trackQuantities: i,
|
|
3992
4007
|
enableTaxes: o.enableTaxes,
|
|
3993
4008
|
taxCalculationMode: o.taxCalculationMode
|
|
3994
4009
|
});
|
|
3995
4010
|
if (c)
|
|
3996
4011
|
throw new Error(c.message);
|
|
3997
|
-
|
|
4012
|
+
Q("/cms/shipping"), gt("/cms/shipping?success=Inventory settings updated");
|
|
3998
4013
|
}
|
|
3999
4014
|
function Xr(t) {
|
|
4000
4015
|
const r = /* @__PURE__ */ new Map();
|
|
@@ -4029,7 +4044,7 @@ async function ri(t, r, a) {
|
|
|
4029
4044
|
if (l)
|
|
4030
4045
|
return { error: l.message };
|
|
4031
4046
|
}
|
|
4032
|
-
return
|
|
4047
|
+
return Q("/cms/shipping"), { success: !0 };
|
|
4033
4048
|
}
|
|
4034
4049
|
async function ai(t, r, a, n) {
|
|
4035
4050
|
const i = re(), o = Xr(n), { error: c } = await i.from("shipping_zones").update({ name: r, priority_order: a, updated_at: (/* @__PURE__ */ new Date()).toISOString() }).eq("id", t);
|
|
@@ -4047,17 +4062,17 @@ async function ai(t, r, a, n) {
|
|
|
4047
4062
|
if (u)
|
|
4048
4063
|
return { error: u.message };
|
|
4049
4064
|
}
|
|
4050
|
-
return
|
|
4065
|
+
return Q("/cms/shipping"), { success: !0 };
|
|
4051
4066
|
}
|
|
4052
4067
|
async function si(t) {
|
|
4053
4068
|
const r = re(), { error: a } = await r.from("shipping_zones").delete().eq("id", t);
|
|
4054
|
-
return a ? { error: a.message } : (
|
|
4069
|
+
return a ? { error: a.message } : (Q("/cms/shipping"), { success: !0 });
|
|
4055
4070
|
}
|
|
4056
4071
|
async function ni(t, r) {
|
|
4057
4072
|
const a = re(), n = await Yr(a);
|
|
4058
4073
|
if ("error" in n)
|
|
4059
4074
|
return { error: n.error };
|
|
4060
|
-
const i =
|
|
4075
|
+
const i = Pt({
|
|
4061
4076
|
currencies: n.currencies.map(
|
|
4062
4077
|
(c) => Se(c)
|
|
4063
4078
|
),
|
|
@@ -4070,7 +4085,7 @@ async function ni(t, r) {
|
|
|
4070
4085
|
}), { error: o } = await a.from("shipping_zone_methods").insert({
|
|
4071
4086
|
zone_id: t,
|
|
4072
4087
|
name: r.name.trim(),
|
|
4073
|
-
name_translations:
|
|
4088
|
+
name_translations: Qr(r.nameTranslations),
|
|
4074
4089
|
method_type: r.type,
|
|
4075
4090
|
currency_pricing_mode: i.mode,
|
|
4076
4091
|
cost_amount: i.costAmounts[i.sourceCurrencyCode],
|
|
@@ -4079,13 +4094,13 @@ async function ni(t, r) {
|
|
|
4079
4094
|
min_order_amount: i.minOrderAmounts[i.sourceCurrencyCode],
|
|
4080
4095
|
min_order_amounts: i.minOrderAmounts
|
|
4081
4096
|
});
|
|
4082
|
-
return o ? { error: o.message } : (
|
|
4097
|
+
return o ? { error: o.message } : (Q("/cms/shipping"), { success: !0 });
|
|
4083
4098
|
}
|
|
4084
4099
|
async function ii(t, r) {
|
|
4085
4100
|
const a = re(), n = await Yr(a);
|
|
4086
4101
|
if ("error" in n)
|
|
4087
4102
|
return { error: n.error };
|
|
4088
|
-
const i =
|
|
4103
|
+
const i = Pt({
|
|
4089
4104
|
currencies: n.currencies.map(
|
|
4090
4105
|
(c) => Se(c)
|
|
4091
4106
|
),
|
|
@@ -4097,7 +4112,7 @@ async function ii(t, r) {
|
|
|
4097
4112
|
fallbackMinOrderAmount: r.minOrderAmount
|
|
4098
4113
|
}), { error: o } = await a.from("shipping_zone_methods").update({
|
|
4099
4114
|
name: r.name.trim(),
|
|
4100
|
-
name_translations:
|
|
4115
|
+
name_translations: Qr(r.nameTranslations),
|
|
4101
4116
|
method_type: r.type,
|
|
4102
4117
|
currency_pricing_mode: i.mode,
|
|
4103
4118
|
cost_amount: i.costAmounts[i.sourceCurrencyCode],
|
|
@@ -4107,11 +4122,11 @@ async function ii(t, r) {
|
|
|
4107
4122
|
min_order_amounts: i.minOrderAmounts,
|
|
4108
4123
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
4109
4124
|
}).eq("id", t);
|
|
4110
|
-
return o ? { error: o.message } : (
|
|
4125
|
+
return o ? { error: o.message } : (Q("/cms/shipping"), { success: !0 });
|
|
4111
4126
|
}
|
|
4112
4127
|
async function oi(t) {
|
|
4113
4128
|
const r = re(), { error: a } = await r.from("shipping_zone_methods").delete().eq("id", t);
|
|
4114
|
-
return a ? { error: a.message } : (
|
|
4129
|
+
return a ? { error: a.message } : (Q("/cms/shipping"), { success: !0 });
|
|
4115
4130
|
}
|
|
4116
4131
|
function gr(t = []) {
|
|
4117
4132
|
return [...new Set(t.map((r) => r.country_code))];
|
|
@@ -4136,31 +4151,31 @@ function ci(t, r) {
|
|
|
4136
4151
|
function yr({ mode: t = "create", initialData: r }) {
|
|
4137
4152
|
const [a, n] = P(!1), i = t === "edit", [o, c] = P(r?.name || ""), [d, l] = P(r?.priority_order || 0), [u, p] = P(
|
|
4138
4153
|
gr(r?.locations)
|
|
4139
|
-
), [h,
|
|
4154
|
+
), [h, x] = P(
|
|
4140
4155
|
_r(r?.locations)
|
|
4141
4156
|
), [g, N] = P(""), [S, R] = P(!1);
|
|
4142
4157
|
Ue(() => {
|
|
4143
|
-
a && (c(r?.name || ""), l(r?.priority_order || 0), p(gr(r?.locations)),
|
|
4158
|
+
a && (c(r?.name || ""), l(r?.priority_order || 0), p(gr(r?.locations)), x(_r(r?.locations)), N(""));
|
|
4144
4159
|
}, [r, a]);
|
|
4145
4160
|
const y = ee(() => {
|
|
4146
4161
|
const f = g.trim().toLowerCase();
|
|
4147
4162
|
return f ? De.filter(
|
|
4148
|
-
(
|
|
4163
|
+
(b) => b.name.toLowerCase().includes(f) || b.code.toLowerCase().includes(f)
|
|
4149
4164
|
) : De;
|
|
4150
4165
|
}, [g]), C = ee(() => De.filter((f) => u.includes(f.code)), [u]), k = (f) => {
|
|
4151
4166
|
p(
|
|
4152
|
-
(
|
|
4153
|
-
),
|
|
4154
|
-
if (
|
|
4155
|
-
const M = { ...
|
|
4167
|
+
(b) => b.includes(f) ? b.filter((M) => M !== f) : [...b, f]
|
|
4168
|
+
), x((b) => {
|
|
4169
|
+
if (b[f]) {
|
|
4170
|
+
const M = { ...b };
|
|
4156
4171
|
return delete M[f], M;
|
|
4157
4172
|
}
|
|
4158
|
-
return
|
|
4173
|
+
return b;
|
|
4159
4174
|
});
|
|
4160
|
-
}, F = (f,
|
|
4161
|
-
|
|
4175
|
+
}, F = (f, b) => {
|
|
4176
|
+
x((M) => {
|
|
4162
4177
|
const q = new Set(M[f] || []);
|
|
4163
|
-
return q.has(
|
|
4178
|
+
return q.has(b) ? q.delete(b) : q.add(b), {
|
|
4164
4179
|
...M,
|
|
4165
4180
|
[f]: [...q]
|
|
4166
4181
|
};
|
|
@@ -4168,15 +4183,15 @@ function yr({ mode: t = "create", initialData: r }) {
|
|
|
4168
4183
|
};
|
|
4169
4184
|
return /* @__PURE__ */ s(ot, { open: a, onOpenChange: n, children: [
|
|
4170
4185
|
/* @__PURE__ */ e(ct, { asChild: !0, children: i ? /* @__PURE__ */ e(T, { variant: "ghost", size: "icon", className: "h-8 w-8 text-slate-400 hover:text-primary", children: /* @__PURE__ */ e(Lt, { className: "h-4 w-4" }) }) : /* @__PURE__ */ s(T, { className: "gap-2 shadow-sm", children: [
|
|
4171
|
-
/* @__PURE__ */ e(
|
|
4186
|
+
/* @__PURE__ */ e(We, { className: "h-4 w-4" }),
|
|
4172
4187
|
"New Zone"
|
|
4173
4188
|
] }) }),
|
|
4174
4189
|
/* @__PURE__ */ e(lt, { className: "max-w-4xl max-h-[90vh] flex flex-col overflow-hidden", children: /* @__PURE__ */ s("form", { onSubmit: async (f) => {
|
|
4175
4190
|
if (f.preventDefault(), !o || u.length === 0)
|
|
4176
4191
|
return;
|
|
4177
4192
|
R(!0);
|
|
4178
|
-
const
|
|
4179
|
-
R(!1), M.success ? (n(!1), i || (c(""), l(0), p([]),
|
|
4193
|
+
const b = ci(u, h), M = i && r?.id ? await ai(r.id, o, d, b) : await ri(o, d, b);
|
|
4194
|
+
R(!1), M.success ? (n(!1), i || (c(""), l(0), p([]), x({}), N(""))) : M.error && alert(M.error);
|
|
4180
4195
|
}, className: "flex h-full flex-col overflow-hidden", children: [
|
|
4181
4196
|
/* @__PURE__ */ s(dt, { children: [
|
|
4182
4197
|
/* @__PURE__ */ e(ut, { children: i ? "Edit Shipping Zone" : "Create Shipping Zone" }),
|
|
@@ -4232,17 +4247,17 @@ function yr({ mode: t = "create", initialData: r }) {
|
|
|
4232
4247
|
] })
|
|
4233
4248
|
] }),
|
|
4234
4249
|
/* @__PURE__ */ e(oe, { className: "border-slate-200 bg-slate-50/30 p-4 dark:border-slate-800 dark:bg-slate-900/30", children: /* @__PURE__ */ e("div", { className: "grid max-h-[360px] grid-cols-1 gap-3 overflow-y-auto pr-1 sm:grid-cols-2", children: y.map((f) => {
|
|
4235
|
-
const
|
|
4250
|
+
const b = u.includes(f.code);
|
|
4236
4251
|
return /* @__PURE__ */ s(
|
|
4237
4252
|
"div",
|
|
4238
4253
|
{
|
|
4239
|
-
className: `flex items-center space-x-2 rounded-md border p-2 transition-colors ${
|
|
4254
|
+
className: `flex items-center space-x-2 rounded-md border p-2 transition-colors ${b ? "border-primary/30 bg-primary/5 text-primary" : "border-transparent hover:bg-slate-100 dark:hover:bg-slate-800/60"}`,
|
|
4240
4255
|
children: [
|
|
4241
4256
|
/* @__PURE__ */ e(
|
|
4242
4257
|
He,
|
|
4243
4258
|
{
|
|
4244
4259
|
id: `country-${f.code}`,
|
|
4245
|
-
checked:
|
|
4260
|
+
checked: b,
|
|
4246
4261
|
onCheckedChange: () => k(f.code)
|
|
4247
4262
|
}
|
|
4248
4263
|
),
|
|
@@ -4271,7 +4286,7 @@ function yr({ mode: t = "create", initialData: r }) {
|
|
|
4271
4286
|
/* @__PURE__ */ e(D, { className: "text-sm font-semibold", children: "States / Provinces" })
|
|
4272
4287
|
] }),
|
|
4273
4288
|
C.length === 0 ? /* @__PURE__ */ e(oe, { className: "border-dashed p-4 text-sm text-muted-foreground", children: "Select one or more countries to optionally narrow the zone to specific states or provinces." }) : /* @__PURE__ */ e("div", { className: "space-y-4", children: C.map((f) => {
|
|
4274
|
-
const
|
|
4289
|
+
const b = Nt(f.code), M = h[f.code] || [];
|
|
4275
4290
|
return /* @__PURE__ */ e(oe, { className: "p-4", children: /* @__PURE__ */ s("div", { className: "space-y-3", children: [
|
|
4276
4291
|
/* @__PURE__ */ s("div", { className: "flex items-center justify-between gap-3", children: [
|
|
4277
4292
|
/* @__PURE__ */ s("div", { children: [
|
|
@@ -4281,11 +4296,11 @@ function yr({ mode: t = "create", initialData: r }) {
|
|
|
4281
4296
|
f.code,
|
|
4282
4297
|
")"
|
|
4283
4298
|
] }),
|
|
4284
|
-
/* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children:
|
|
4299
|
+
/* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: b.length > 0 ? "Leave all unchecked to apply this zone to the whole country." : "This country uses a country-level zone in the current UI." })
|
|
4285
4300
|
] }),
|
|
4286
4301
|
/* @__PURE__ */ e("span", { className: "text-xs text-muted-foreground", children: M.length > 0 ? `${M.length} selected` : "Whole country" })
|
|
4287
4302
|
] }),
|
|
4288
|
-
|
|
4303
|
+
b.length > 0 ? /* @__PURE__ */ e("div", { className: "grid max-h-[220px] grid-cols-1 gap-2 overflow-y-auto pr-1 sm:grid-cols-2", children: b.map((q) => {
|
|
4289
4304
|
const $ = M.includes(q.code);
|
|
4290
4305
|
return /* @__PURE__ */ s(
|
|
4291
4306
|
"div",
|
|
@@ -4344,15 +4359,15 @@ function Re(t, r) {
|
|
|
4344
4359
|
if (!a)
|
|
4345
4360
|
return null;
|
|
4346
4361
|
const n = Number(a);
|
|
4347
|
-
return !Number.isFinite(n) || n < 0 ? null :
|
|
4362
|
+
return !Number.isFinite(n) || n < 0 ? null : Ir(n, r);
|
|
4348
4363
|
}
|
|
4349
|
-
function
|
|
4364
|
+
function xr(t) {
|
|
4350
4365
|
return t.currencies.reduce((r, a) => (r[a.code] = qe(
|
|
4351
4366
|
t.amounts[a.code],
|
|
4352
4367
|
a.code
|
|
4353
4368
|
), r), {});
|
|
4354
4369
|
}
|
|
4355
|
-
function
|
|
4370
|
+
function br({
|
|
4356
4371
|
zoneId: t,
|
|
4357
4372
|
zoneName: r,
|
|
4358
4373
|
languages: a,
|
|
@@ -4367,16 +4382,16 @@ function xr({
|
|
|
4367
4382
|
), h = ee(
|
|
4368
4383
|
() => a.filter((v) => !v.is_default),
|
|
4369
4384
|
[a]
|
|
4370
|
-
),
|
|
4385
|
+
), x = ie(i), g = ee(() => {
|
|
4371
4386
|
const v = Se({
|
|
4372
|
-
code:
|
|
4373
|
-
symbol:
|
|
4387
|
+
code: x,
|
|
4388
|
+
symbol: x,
|
|
4374
4389
|
exchange_rate: 1,
|
|
4375
4390
|
is_default: !0,
|
|
4376
4391
|
is_active: !0
|
|
4377
4392
|
}), L = (n.length > 0 ? n : [v]).map((I) => Se(I)).filter((I) => I.is_active !== !1).sort((I, B) => I.is_default !== B.is_default ? I.is_default ? -1 : 1 : I.code.localeCompare(B.code));
|
|
4378
4393
|
return L.length > 0 ? L : [v];
|
|
4379
|
-
}, [n,
|
|
4394
|
+
}, [n, x]), N = ee(
|
|
4380
4395
|
() => g.find((v) => v.is_default) || g[0],
|
|
4381
4396
|
[g]
|
|
4382
4397
|
), [S, R] = P(c?.name || ""), [y, C] = P(
|
|
@@ -4384,30 +4399,30 @@ function xr({
|
|
|
4384
4399
|
), [k, F] = P(
|
|
4385
4400
|
c?.method_type || "flat_rate"
|
|
4386
4401
|
), [_, f] = P(
|
|
4387
|
-
|
|
4388
|
-
), [
|
|
4389
|
-
ie(c?.cost_currency || N?.code ||
|
|
4402
|
+
Zt(c?.currency_pricing_mode)
|
|
4403
|
+
), [b, M] = P(
|
|
4404
|
+
ie(c?.cost_currency || N?.code || x)
|
|
4390
4405
|
), [q, $] = P({}), [z, se] = P({}), [E, K] = P(!1), H = ee(() => {
|
|
4391
4406
|
if (_ === "manual")
|
|
4392
4407
|
return g.reduce((I, B) => (I[B.code] = q[B.code] ?? "", I), {});
|
|
4393
4408
|
const v = g.reduce(
|
|
4394
|
-
(I, B) => (I[B.code] = q[B.code] ?? (B.code ===
|
|
4409
|
+
(I, B) => (I[B.code] = q[B.code] ?? (B.code === b, ""), I),
|
|
4395
4410
|
{}
|
|
4396
4411
|
), L = Re(
|
|
4397
|
-
q[
|
|
4398
|
-
|
|
4412
|
+
q[b],
|
|
4413
|
+
b
|
|
4399
4414
|
);
|
|
4400
4415
|
if (L === null)
|
|
4401
4416
|
return v;
|
|
4402
4417
|
for (const I of g) {
|
|
4403
|
-
if (I.code ===
|
|
4418
|
+
if (I.code === b) {
|
|
4404
4419
|
v[I.code] = q[I.code] ?? qe(L, I.code);
|
|
4405
4420
|
continue;
|
|
4406
4421
|
}
|
|
4407
4422
|
v[I.code] = qe(
|
|
4408
4423
|
wt({
|
|
4409
4424
|
amount: L,
|
|
4410
|
-
fromCurrencyCode:
|
|
4425
|
+
fromCurrencyCode: b,
|
|
4411
4426
|
toCurrencyCode: I.code,
|
|
4412
4427
|
currencies: g
|
|
4413
4428
|
}),
|
|
@@ -4415,27 +4430,27 @@ function xr({
|
|
|
4415
4430
|
);
|
|
4416
4431
|
}
|
|
4417
4432
|
return v;
|
|
4418
|
-
}, [g, q, _,
|
|
4433
|
+
}, [g, q, _, b]), m = ee(() => {
|
|
4419
4434
|
if (_ === "manual")
|
|
4420
4435
|
return g.reduce((I, B) => (I[B.code] = z[B.code] ?? "", I), {});
|
|
4421
4436
|
const v = g.reduce(
|
|
4422
4437
|
(I, B) => (I[B.code] = z[B.code] ?? "", I),
|
|
4423
4438
|
{}
|
|
4424
4439
|
), L = Re(
|
|
4425
|
-
z[
|
|
4426
|
-
|
|
4440
|
+
z[b],
|
|
4441
|
+
b
|
|
4427
4442
|
);
|
|
4428
4443
|
if (L === null)
|
|
4429
4444
|
return v;
|
|
4430
4445
|
for (const I of g) {
|
|
4431
|
-
if (I.code ===
|
|
4446
|
+
if (I.code === b) {
|
|
4432
4447
|
v[I.code] = z[I.code] ?? qe(L, I.code);
|
|
4433
4448
|
continue;
|
|
4434
4449
|
}
|
|
4435
4450
|
v[I.code] = qe(
|
|
4436
4451
|
wt({
|
|
4437
4452
|
amount: L,
|
|
4438
|
-
fromCurrencyCode:
|
|
4453
|
+
fromCurrencyCode: b,
|
|
4439
4454
|
toCurrencyCode: I.code,
|
|
4440
4455
|
currencies: g
|
|
4441
4456
|
}),
|
|
@@ -4443,15 +4458,15 @@ function xr({
|
|
|
4443
4458
|
);
|
|
4444
4459
|
}
|
|
4445
4460
|
return v;
|
|
4446
|
-
}, [g, z, _,
|
|
4461
|
+
}, [g, z, _, b]);
|
|
4447
4462
|
Ue(() => {
|
|
4448
|
-
N && (g.some((v) => v.code ===
|
|
4449
|
-
}, [g, N,
|
|
4463
|
+
N && (g.some((v) => v.code === b) || M(N.code));
|
|
4464
|
+
}, [g, N, b]), Ue(() => {
|
|
4450
4465
|
if (!d || !N)
|
|
4451
4466
|
return;
|
|
4452
|
-
const v =
|
|
4467
|
+
const v = Zt(
|
|
4453
4468
|
c?.currency_pricing_mode
|
|
4454
|
-
), L =
|
|
4469
|
+
), L = Pt({
|
|
4455
4470
|
currencies: g,
|
|
4456
4471
|
mode: v,
|
|
4457
4472
|
sourceCurrencyCode: c?.cost_currency || N.code,
|
|
@@ -4461,12 +4476,12 @@ function xr({
|
|
|
4461
4476
|
fallbackMinOrderAmount: c?.min_order_amount
|
|
4462
4477
|
});
|
|
4463
4478
|
R(c?.name || ""), C(c?.name_translations || {}), F(c?.method_type || "flat_rate"), f(v), M(L.sourceCurrencyCode), $(
|
|
4464
|
-
|
|
4479
|
+
xr({
|
|
4465
4480
|
amounts: L.costAmounts,
|
|
4466
4481
|
currencies: g
|
|
4467
4482
|
})
|
|
4468
4483
|
), se(
|
|
4469
|
-
|
|
4484
|
+
xr({
|
|
4470
4485
|
amounts: L.minOrderAmounts,
|
|
4471
4486
|
currencies: g
|
|
4472
4487
|
})
|
|
@@ -4483,12 +4498,12 @@ function xr({
|
|
|
4483
4498
|
...I,
|
|
4484
4499
|
[L]: m[L] ?? I[L] ?? ""
|
|
4485
4500
|
})), M(L);
|
|
4486
|
-
},
|
|
4501
|
+
}, W = (v) => {
|
|
4487
4502
|
F(v), v === "free_shipping" && $(li(g));
|
|
4488
4503
|
};
|
|
4489
4504
|
return /* @__PURE__ */ s(ot, { open: d, onOpenChange: l, children: [
|
|
4490
4505
|
/* @__PURE__ */ e(ct, { asChild: !0, children: u ? /* @__PURE__ */ e(T, { variant: "ghost", size: "icon", className: "h-7 w-7 text-slate-400 hover:text-primary", children: /* @__PURE__ */ e(Lt, { className: "h-3 w-3" }) }) : /* @__PURE__ */ s(T, { variant: "outline", size: "sm", className: "h-8 gap-1.5 border-dashed hover:border-solid shadow-sm", children: [
|
|
4491
|
-
/* @__PURE__ */ e(
|
|
4506
|
+
/* @__PURE__ */ e(We, { className: "h-3.5 w-3.5" }),
|
|
4492
4507
|
"Add Rate"
|
|
4493
4508
|
] }) }),
|
|
4494
4509
|
/* @__PURE__ */ e(lt, { className: "max-h-[85vh] max-w-4xl overflow-y-auto", children: /* @__PURE__ */ s("form", { onSubmit: async (v) => {
|
|
@@ -4514,16 +4529,16 @@ function xr({
|
|
|
4514
4529
|
}
|
|
4515
4530
|
else {
|
|
4516
4531
|
const J = k === "free_shipping" ? 0 : Re(
|
|
4517
|
-
q[
|
|
4518
|
-
|
|
4532
|
+
q[b],
|
|
4533
|
+
b
|
|
4519
4534
|
);
|
|
4520
4535
|
if (J === null) {
|
|
4521
|
-
K(!1), alert(`Enter a valid shipping cost for ${
|
|
4536
|
+
K(!1), alert(`Enter a valid shipping cost for ${b}.`);
|
|
4522
4537
|
return;
|
|
4523
4538
|
}
|
|
4524
|
-
L[
|
|
4525
|
-
z[
|
|
4526
|
-
|
|
4539
|
+
L[b] = J, I[b] = Re(
|
|
4540
|
+
z[b],
|
|
4541
|
+
b
|
|
4527
4542
|
) ?? 0;
|
|
4528
4543
|
}
|
|
4529
4544
|
const B = {
|
|
@@ -4531,7 +4546,7 @@ function xr({
|
|
|
4531
4546
|
nameTranslations: y,
|
|
4532
4547
|
type: k,
|
|
4533
4548
|
currencyPricingMode: _,
|
|
4534
|
-
sourceCurrencyCode:
|
|
4549
|
+
sourceCurrencyCode: b,
|
|
4535
4550
|
costAmounts: L,
|
|
4536
4551
|
minOrderAmounts: I
|
|
4537
4552
|
}, ce = u && c?.id ? await ii(c.id, B) : await ni(t, B);
|
|
@@ -4592,7 +4607,7 @@ function xr({
|
|
|
4592
4607
|
je,
|
|
4593
4608
|
{
|
|
4594
4609
|
value: k,
|
|
4595
|
-
onValueChange:
|
|
4610
|
+
onValueChange: W,
|
|
4596
4611
|
children: [
|
|
4597
4612
|
/* @__PURE__ */ e(
|
|
4598
4613
|
Ke,
|
|
@@ -4604,7 +4619,7 @@ function xr({
|
|
|
4604
4619
|
),
|
|
4605
4620
|
/* @__PURE__ */ s(Ge, { children: [
|
|
4606
4621
|
/* @__PURE__ */ e(_e, { value: "flat_rate", children: /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
|
|
4607
|
-
/* @__PURE__ */ e("div", { className: "p-1 min-w-5 h-5 rounded bg-emerald-100 dark:bg-emerald-900/30 text-emerald-600", children: /* @__PURE__ */ e(
|
|
4622
|
+
/* @__PURE__ */ e("div", { className: "p-1 min-w-5 h-5 rounded bg-emerald-100 dark:bg-emerald-900/30 text-emerald-600", children: /* @__PURE__ */ e(xt, { className: "h-3 w-3" }) }),
|
|
4608
4623
|
/* @__PURE__ */ e("span", { children: "Flat Rate" })
|
|
4609
4624
|
] }) }),
|
|
4610
4625
|
/* @__PURE__ */ e(_e, { value: "free_shipping", children: /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
|
|
@@ -4639,7 +4654,7 @@ function xr({
|
|
|
4639
4654
|
/* @__PURE__ */ s(
|
|
4640
4655
|
je,
|
|
4641
4656
|
{
|
|
4642
|
-
value:
|
|
4657
|
+
value: b,
|
|
4643
4658
|
onValueChange: O,
|
|
4644
4659
|
children: [
|
|
4645
4660
|
/* @__PURE__ */ e(
|
|
@@ -4663,10 +4678,10 @@ function xr({
|
|
|
4663
4678
|
/* @__PURE__ */ s("div", { className: "space-y-3", children: [
|
|
4664
4679
|
/* @__PURE__ */ s("div", { children: [
|
|
4665
4680
|
/* @__PURE__ */ e("p", { className: "text-sm font-medium", children: "Currency Rates" }),
|
|
4666
|
-
/* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: k === "free_shipping" ? "Free-shipping methods keep cost at zero, but you can still control the threshold per currency." : _ === "auto" ? `Only ${
|
|
4681
|
+
/* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: k === "free_shipping" ? "Free-shipping methods keep cost at zero, but you can still control the threshold per currency." : _ === "auto" ? `Only ${b} is editable. The rest are derived automatically.` : "Set the exact shopper-facing shipping price for each active currency." })
|
|
4667
4682
|
] }),
|
|
4668
4683
|
/* @__PURE__ */ e("div", { className: "grid gap-4 md:grid-cols-2 xl:grid-cols-3", children: g.map((v) => {
|
|
4669
|
-
const L = _ === "auto" && v.code !==
|
|
4684
|
+
const L = _ === "auto" && v.code !== b, I = ze(v.code) === 1 ? "1" : "0.01";
|
|
4670
4685
|
return /* @__PURE__ */ s(
|
|
4671
4686
|
"div",
|
|
4672
4687
|
{
|
|
@@ -4682,7 +4697,7 @@ function xr({
|
|
|
4682
4697
|
] }),
|
|
4683
4698
|
/* @__PURE__ */ s("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
4684
4699
|
v.is_default ? /* @__PURE__ */ e(ae, { variant: "outline", children: "Default" }) : null,
|
|
4685
|
-
_ === "auto" && v.code ===
|
|
4700
|
+
_ === "auto" && v.code === b ? /* @__PURE__ */ e(ae, { children: "Source" }) : null,
|
|
4686
4701
|
L ? /* @__PURE__ */ e(ae, { variant: "outline", children: "Derived" }) : null
|
|
4687
4702
|
] })
|
|
4688
4703
|
] }),
|
|
@@ -4693,7 +4708,7 @@ function xr({
|
|
|
4693
4708
|
")"
|
|
4694
4709
|
] }),
|
|
4695
4710
|
/* @__PURE__ */ s("div", { className: "relative", children: [
|
|
4696
|
-
/* @__PURE__ */ e(
|
|
4711
|
+
/* @__PURE__ */ e(xt, { className: "absolute left-2.5 top-2.5 h-4 w-4 text-slate-400" }),
|
|
4697
4712
|
/* @__PURE__ */ e(
|
|
4698
4713
|
V,
|
|
4699
4714
|
{
|
|
@@ -4720,7 +4735,7 @@ function xr({
|
|
|
4720
4735
|
")"
|
|
4721
4736
|
] }),
|
|
4722
4737
|
/* @__PURE__ */ s("div", { className: "relative", children: [
|
|
4723
|
-
/* @__PURE__ */ e(
|
|
4738
|
+
/* @__PURE__ */ e(xt, { className: "absolute left-2.5 top-2.5 h-4 w-4 text-slate-400" }),
|
|
4724
4739
|
/* @__PURE__ */ e(
|
|
4725
4740
|
V,
|
|
4726
4741
|
{
|
|
@@ -4742,7 +4757,7 @@ function xr({
|
|
|
4742
4757
|
] }),
|
|
4743
4758
|
L ? /* @__PURE__ */ s("p", { className: "text-[10px] text-muted-foreground", children: [
|
|
4744
4759
|
"This currency is synced automatically from ",
|
|
4745
|
-
|
|
4760
|
+
b,
|
|
4746
4761
|
"."
|
|
4747
4762
|
] }) : _ === "manual" ? /* @__PURE__ */ e("p", { className: "text-[10px] text-muted-foreground", children: "Enter the exact amount shoppers should see in this currency." }) : null
|
|
4748
4763
|
]
|
|
@@ -4759,7 +4774,7 @@ function xr({
|
|
|
4759
4774
|
] }) })
|
|
4760
4775
|
] });
|
|
4761
4776
|
}
|
|
4762
|
-
async function
|
|
4777
|
+
async function Lo({
|
|
4763
4778
|
searchParams: t
|
|
4764
4779
|
}) {
|
|
4765
4780
|
const r = re(), [{ data: a }, n, { data: i }, { data: o }] = await Promise.all([
|
|
@@ -4858,7 +4873,7 @@ async function Eo({
|
|
|
4858
4873
|
/* @__PURE__ */ e("form", { action: async () => {
|
|
4859
4874
|
"use server";
|
|
4860
4875
|
await si(l.id);
|
|
4861
|
-
}, children: /* @__PURE__ */ e(T, { type: "submit", variant: "ghost", size: "icon", className: "h-8 w-8 text-slate-400 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20", children: /* @__PURE__ */ e(
|
|
4876
|
+
}, children: /* @__PURE__ */ e(T, { type: "submit", variant: "ghost", size: "icon", className: "h-8 w-8 text-slate-400 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20", children: /* @__PURE__ */ e(xe, { className: "h-4 w-4" }) }) })
|
|
4862
4877
|
] })
|
|
4863
4878
|
] }) }),
|
|
4864
4879
|
/* @__PURE__ */ e(pe, { className: "p-0", children: /* @__PURE__ */ s("div", { className: "grid md:grid-cols-2 divide-y md:divide-y-0 md:divide-x divide-slate-100 dark:divide-slate-800", children: [
|
|
@@ -4871,7 +4886,7 @@ async function Eo({
|
|
|
4871
4886
|
u.country_code,
|
|
4872
4887
|
u.state_code ? /* @__PURE__ */ s("span", { className: "text-slate-400 ml-1", children: [
|
|
4873
4888
|
"(",
|
|
4874
|
-
|
|
4889
|
+
Ur(u.country_code, u.state_code),
|
|
4875
4890
|
")"
|
|
4876
4891
|
] }) : ""
|
|
4877
4892
|
] }, u.id)) : /* @__PURE__ */ e("p", { className: "text-sm text-slate-400 italic", children: "No specific locations assigned." }) })
|
|
@@ -4883,7 +4898,7 @@ async function Eo({
|
|
|
4883
4898
|
" Shipping Methods"
|
|
4884
4899
|
] }),
|
|
4885
4900
|
/* @__PURE__ */ e(
|
|
4886
|
-
|
|
4901
|
+
br,
|
|
4887
4902
|
{
|
|
4888
4903
|
zoneId: l.id,
|
|
4889
4904
|
zoneName: l.name,
|
|
@@ -4924,7 +4939,7 @@ async function Eo({
|
|
|
4924
4939
|
) }),
|
|
4925
4940
|
/* @__PURE__ */ s("div", { className: "flex opacity-0 group-hover:opacity-100 transition-opacity", children: [
|
|
4926
4941
|
/* @__PURE__ */ e(
|
|
4927
|
-
|
|
4942
|
+
br,
|
|
4928
4943
|
{
|
|
4929
4944
|
zoneId: l.id,
|
|
4930
4945
|
zoneName: l.name,
|
|
@@ -4945,7 +4960,7 @@ async function Eo({
|
|
|
4945
4960
|
variant: "ghost",
|
|
4946
4961
|
size: "icon",
|
|
4947
4962
|
className: "h-7 w-7 text-slate-400 hover:text-red-500",
|
|
4948
|
-
children: /* @__PURE__ */ e(
|
|
4963
|
+
children: /* @__PURE__ */ e(xe, { className: "h-3 w-3" })
|
|
4949
4964
|
}
|
|
4950
4965
|
) })
|
|
4951
4966
|
] })
|
|
@@ -4968,14 +4983,14 @@ async function Kt() {
|
|
|
4968
4983
|
return t;
|
|
4969
4984
|
}
|
|
4970
4985
|
async function di(t) {
|
|
4971
|
-
const r = await Kt(), a = await Xe(r), n = t.getAll("enableTaxes").includes("true"), i = t.get("taxCalculationMode") === "automatic" ? "automatic" : "manual", { error: o } = await
|
|
4986
|
+
const r = await Kt(), a = await Xe(r), n = t.getAll("enableTaxes").includes("true"), i = t.get("taxCalculationMode") === "automatic" ? "automatic" : "manual", { error: o } = await kr(r, {
|
|
4972
4987
|
trackQuantities: a.trackQuantities,
|
|
4973
4988
|
enableTaxes: n,
|
|
4974
4989
|
taxCalculationMode: i
|
|
4975
4990
|
});
|
|
4976
4991
|
if (o)
|
|
4977
4992
|
throw new Error(o.message);
|
|
4978
|
-
|
|
4993
|
+
Q("/cms/shipping"), Q("/cms/settings/taxes"), gt("/cms/settings/taxes?success=Tax settings updated");
|
|
4979
4994
|
}
|
|
4980
4995
|
async function ui(t) {
|
|
4981
4996
|
const r = await Kt(), a = String(t.get("id") || "").trim(), n = Rt(String(t.get("country_code") || "").trim()), i = String(t.get("state_code") || "").trim(), o = String(t.get("tax_name") || "").trim(), c = Number(t.get("tax_rate"));
|
|
@@ -4993,13 +5008,13 @@ async function ui(t) {
|
|
|
4993
5008
|
}, l = a ? r.from("tax_rates").update(d).eq("id", a) : r.from("tax_rates").insert(d), { error: u } = await l;
|
|
4994
5009
|
if (u)
|
|
4995
5010
|
throw new Error(u.message);
|
|
4996
|
-
|
|
5011
|
+
Q("/cms/settings/taxes");
|
|
4997
5012
|
}
|
|
4998
5013
|
async function mi(t) {
|
|
4999
5014
|
const r = await Kt(), { error: a } = await r.from("tax_rates").delete().eq("id", t);
|
|
5000
5015
|
if (a)
|
|
5001
5016
|
throw new Error(a.message);
|
|
5002
|
-
|
|
5017
|
+
Q("/cms/settings/taxes");
|
|
5003
5018
|
}
|
|
5004
5019
|
function vr({
|
|
5005
5020
|
initialData: t,
|
|
@@ -5008,7 +5023,7 @@ function vr({
|
|
|
5008
5023
|
}) {
|
|
5009
5024
|
const n = Rt(t?.country_code) || "US", [i, o] = P(n), [c, d] = P(
|
|
5010
5025
|
Ft(n, t?.state_code) || t?.state_code || ""
|
|
5011
|
-
), l = ee(() => Nt(i), [i]), u =
|
|
5026
|
+
), l = ee(() => Nt(i), [i]), u = Za(i);
|
|
5012
5027
|
return /* @__PURE__ */ s("form", { action: ui, className: "space-y-4", children: [
|
|
5013
5028
|
t?.id ? /* @__PURE__ */ e("input", { type: "hidden", name: "id", value: t.id }) : null,
|
|
5014
5029
|
/* @__PURE__ */ s("div", { className: a ? "grid gap-4 md:grid-cols-4" : "grid gap-4 md:grid-cols-2 xl:grid-cols-4", children: [
|
|
@@ -5021,9 +5036,9 @@ function vr({
|
|
|
5021
5036
|
name: "country_code",
|
|
5022
5037
|
value: i,
|
|
5023
5038
|
onChange: (p) => {
|
|
5024
|
-
const h = p.target.value,
|
|
5039
|
+
const h = p.target.value, x = Nt(h);
|
|
5025
5040
|
o(h), d(
|
|
5026
|
-
|
|
5041
|
+
x.some((g) => g.code === c) ? c : ""
|
|
5027
5042
|
);
|
|
5028
5043
|
},
|
|
5029
5044
|
className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
|
|
@@ -5095,9 +5110,9 @@ function pi(t) {
|
|
|
5095
5110
|
return `${t.toFixed(4).replace(/\.?0+$/, "")}%`;
|
|
5096
5111
|
}
|
|
5097
5112
|
function hi(t) {
|
|
5098
|
-
return t.state_code ? `${t.country_code} - ${
|
|
5113
|
+
return t.state_code ? `${t.country_code} - ${Ur(t.country_code, t.state_code)}` : `${t.country_code} - Country-wide`;
|
|
5099
5114
|
}
|
|
5100
|
-
async function
|
|
5115
|
+
async function Mo({
|
|
5101
5116
|
searchParams: t
|
|
5102
5117
|
}) {
|
|
5103
5118
|
const r = ue(), a = re(), [n, i, o] = await Promise.all([
|
|
@@ -5222,7 +5237,7 @@ async function Ao({
|
|
|
5222
5237
|
variant: "ghost",
|
|
5223
5238
|
size: "icon",
|
|
5224
5239
|
"aria-label": "Delete tax rate",
|
|
5225
|
-
children: /* @__PURE__ */ e(
|
|
5240
|
+
children: /* @__PURE__ */ e(xe, { className: "h-4 w-4" })
|
|
5226
5241
|
}
|
|
5227
5242
|
)
|
|
5228
5243
|
}
|
|
@@ -5275,13 +5290,13 @@ function fi(t) {
|
|
|
5275
5290
|
const r = he(t.value), a = r ? Number.parseFloat(r) : Number.NaN;
|
|
5276
5291
|
if (!Number.isFinite(a) || a <= 0)
|
|
5277
5292
|
throw new Error("Discount amount must be greater than zero.");
|
|
5278
|
-
return t.discountType === "fixed" ?
|
|
5293
|
+
return t.discountType === "fixed" ? Ir(a, t.currencyCode) : Math.round(a);
|
|
5279
5294
|
}
|
|
5280
5295
|
function gi(t, r) {
|
|
5281
5296
|
return t.getAll(r).some((a) => a === "true");
|
|
5282
5297
|
}
|
|
5283
5298
|
function Zr(t) {
|
|
5284
|
-
const r =
|
|
5299
|
+
const r = Ya(he(t.get("code"))), a = he(t.get("name")), n = he(t.get("provider_scope")) || "all", i = he(t.get("discount_type")) || "percent", o = ie(he(t.get("currency_code"))), c = fi({
|
|
5285
5300
|
value: t.get("discount_amount"),
|
|
5286
5301
|
discountType: i,
|
|
5287
5302
|
currencyCode: o
|
|
@@ -5330,7 +5345,7 @@ async function _i(t) {
|
|
|
5330
5345
|
client: r,
|
|
5331
5346
|
couponId: n.id,
|
|
5332
5347
|
productIds: a.productIds
|
|
5333
|
-
}), await it({ couponId: n.id, client: r }),
|
|
5348
|
+
}), await it({ couponId: n.id, client: r }), Q("/cms/coupons"), gt("/cms/coupons");
|
|
5334
5349
|
}
|
|
5335
5350
|
async function yi(t, r) {
|
|
5336
5351
|
const a = await Ze(), n = Zr(r), { error: i } = await a.from("coupons").update(n.coupon).eq("id", t);
|
|
@@ -5340,9 +5355,9 @@ async function yi(t, r) {
|
|
|
5340
5355
|
client: a,
|
|
5341
5356
|
couponId: t,
|
|
5342
5357
|
productIds: n.productIds
|
|
5343
|
-
}), n.coupon.provider_scope === "stripe" ? await
|
|
5358
|
+
}), n.coupon.provider_scope === "stripe" ? await Tr({ couponId: t, client: a }) : await it({ couponId: t, client: a }), Q("/cms/coupons"), Q(`/cms/coupons/${t}/edit`), gt("/cms/coupons");
|
|
5344
5359
|
}
|
|
5345
|
-
async function
|
|
5360
|
+
async function xi(t, r) {
|
|
5346
5361
|
const a = await Ze(), { error: n } = await a.from("coupons").update({
|
|
5347
5362
|
is_active: r,
|
|
5348
5363
|
freemius_sync_status: "pending",
|
|
@@ -5350,19 +5365,19 @@ async function bi(t, r) {
|
|
|
5350
5365
|
}).eq("id", t);
|
|
5351
5366
|
if (n)
|
|
5352
5367
|
throw new Error(n.message);
|
|
5353
|
-
await it({ couponId: t, client: a }),
|
|
5368
|
+
await it({ couponId: t, client: a }), Q("/cms/coupons");
|
|
5354
5369
|
}
|
|
5355
|
-
async function
|
|
5370
|
+
async function bi(t) {
|
|
5356
5371
|
const r = await Ze();
|
|
5357
|
-
await it({ couponId: t, client: r }),
|
|
5372
|
+
await it({ couponId: t, client: r }), Q("/cms/coupons"), Q(`/cms/coupons/${t}/edit`);
|
|
5358
5373
|
}
|
|
5359
5374
|
async function vi(t) {
|
|
5360
5375
|
const r = await Ze();
|
|
5361
|
-
await
|
|
5376
|
+
await Tr({ couponId: t, client: r });
|
|
5362
5377
|
const { error: a } = await r.from("coupons").delete().eq("id", t);
|
|
5363
5378
|
if (a)
|
|
5364
5379
|
throw new Error(a.message);
|
|
5365
|
-
|
|
5380
|
+
Q("/cms/coupons");
|
|
5366
5381
|
}
|
|
5367
5382
|
function wi(t) {
|
|
5368
5383
|
const r = t.sku?.trim();
|
|
@@ -5393,7 +5408,7 @@ function Ci({
|
|
|
5393
5408
|
const a = ee(() => new Set(r), [r]), [n, i] = P(a), [o, c] = P(""), d = ee(() => Ni(t), [t]), l = ee(() => {
|
|
5394
5409
|
const p = o.trim().toLowerCase();
|
|
5395
5410
|
return p ? d.filter(
|
|
5396
|
-
(h) => [h.title, h.sku].some((
|
|
5411
|
+
(h) => [h.title, h.sku].some((x) => x.toLowerCase().includes(p))
|
|
5397
5412
|
) : d;
|
|
5398
5413
|
}, [d, o]), u = (p) => {
|
|
5399
5414
|
i(
|
|
@@ -5432,7 +5447,7 @@ function Ci({
|
|
|
5432
5447
|
] }),
|
|
5433
5448
|
/* @__PURE__ */ s("div", { className: "grid max-h-[420px] gap-2 overflow-y-auto rounded-lg border p-3 md:grid-cols-2", children: [
|
|
5434
5449
|
l.map((p) => {
|
|
5435
|
-
const h = p.productIds.some((
|
|
5450
|
+
const h = p.productIds.some((x) => n.has(x));
|
|
5436
5451
|
return /* @__PURE__ */ s(
|
|
5437
5452
|
"label",
|
|
5438
5453
|
{
|
|
@@ -5443,16 +5458,16 @@ function Ci({
|
|
|
5443
5458
|
{
|
|
5444
5459
|
type: "checkbox",
|
|
5445
5460
|
checked: h,
|
|
5446
|
-
onChange: (
|
|
5461
|
+
onChange: (x) => {
|
|
5447
5462
|
const g = new Set(n);
|
|
5448
5463
|
for (const N of p.productIds)
|
|
5449
|
-
|
|
5464
|
+
x.target.checked ? g.add(N) : g.delete(N);
|
|
5450
5465
|
i(g);
|
|
5451
5466
|
},
|
|
5452
5467
|
className: "mt-0.5 h-4 w-4 rounded border-slate-300 text-primary focus:ring-primary"
|
|
5453
5468
|
}
|
|
5454
5469
|
),
|
|
5455
|
-
h ? p.productIds.map((
|
|
5470
|
+
h ? p.productIds.map((x) => /* @__PURE__ */ e("input", { type: "hidden", name: "product_ids", value: x }, x)) : null,
|
|
5456
5471
|
/* @__PURE__ */ e("span", { className: "flex h-12 w-12 shrink-0 items-center justify-center overflow-hidden rounded-md border bg-muted", children: p.thumbnailUrl ? /* @__PURE__ */ e(
|
|
5457
5472
|
"img",
|
|
5458
5473
|
{
|
|
@@ -5665,7 +5680,7 @@ function Ei({
|
|
|
5665
5680
|
const [n, i] = P(!1);
|
|
5666
5681
|
return /* @__PURE__ */ s(Us, { open: n, onOpenChange: i, children: [
|
|
5667
5682
|
/* @__PURE__ */ e($s, { asChild: !0, children: /* @__PURE__ */ s(at, { type: "button", className: "gap-2", children: [
|
|
5668
|
-
/* @__PURE__ */ e(
|
|
5683
|
+
/* @__PURE__ */ e(We, { className: "h-4 w-4" }),
|
|
5669
5684
|
"Create Coupon"
|
|
5670
5685
|
] }) }),
|
|
5671
5686
|
/* @__PURE__ */ s(Os, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[92vw] lg:max-w-5xl xl:max-w-6xl", children: [
|
|
@@ -5724,7 +5739,7 @@ function Ui(t, r) {
|
|
|
5724
5739
|
const a = Fi(t, r);
|
|
5725
5740
|
return a === 0 ? "All eligible products" : `${a} scoped SKU${a === 1 ? "" : "s"}`;
|
|
5726
5741
|
}
|
|
5727
|
-
async function
|
|
5742
|
+
async function qo({
|
|
5728
5743
|
searchParams: t
|
|
5729
5744
|
}) {
|
|
5730
5745
|
const r = re();
|
|
@@ -5829,11 +5844,11 @@ async function Po({
|
|
|
5829
5844
|
/* @__PURE__ */ e(T, { asChild: !0, variant: "outline", size: "sm", children: /* @__PURE__ */ e(te, { href: `/cms/coupons/${l.id}/edit`, children: "Edit" }) }),
|
|
5830
5845
|
/* @__PURE__ */ e("form", { action: async () => {
|
|
5831
5846
|
"use server";
|
|
5832
|
-
await
|
|
5847
|
+
await xi(l.id, !l.is_active);
|
|
5833
5848
|
}, children: /* @__PURE__ */ e(T, { type: "submit", variant: "outline", size: "sm", children: l.is_active ? "Disable" : "Enable" }) }),
|
|
5834
5849
|
/* @__PURE__ */ e("form", { action: async () => {
|
|
5835
5850
|
"use server";
|
|
5836
|
-
await
|
|
5851
|
+
await bi(l.id);
|
|
5837
5852
|
}, children: /* @__PURE__ */ e(
|
|
5838
5853
|
T,
|
|
5839
5854
|
{
|
|
@@ -5856,7 +5871,7 @@ async function Po({
|
|
|
5856
5871
|
size: "icon",
|
|
5857
5872
|
className: "text-destructive",
|
|
5858
5873
|
"aria-label": `Delete coupon ${l.code}`,
|
|
5859
|
-
children: /* @__PURE__ */ e(
|
|
5874
|
+
children: /* @__PURE__ */ e(xe, { className: "h-4 w-4" })
|
|
5860
5875
|
}
|
|
5861
5876
|
) })
|
|
5862
5877
|
] }) })
|
|
@@ -5865,7 +5880,7 @@ async function Po({
|
|
|
5865
5880
|
] })
|
|
5866
5881
|
] });
|
|
5867
5882
|
}
|
|
5868
|
-
async function
|
|
5883
|
+
async function Do({ params: t }) {
|
|
5869
5884
|
const { id: r } = await t, a = re(), [
|
|
5870
5885
|
{ data: n },
|
|
5871
5886
|
{ data: i },
|
|
@@ -5903,137 +5918,137 @@ async function To({ params: t }) {
|
|
|
5903
5918
|
] });
|
|
5904
5919
|
}
|
|
5905
5920
|
export {
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5921
|
+
Io as AttributeManagementPage,
|
|
5922
|
+
Sc as CURRENCY_COOKIE_NAME,
|
|
5923
|
+
jo as CURRENCY_ROUNDING_MODES,
|
|
5924
|
+
$o as CategoryManagementPage,
|
|
5925
|
+
Uo as CopyProductFromLanguage,
|
|
5926
|
+
qo as CouponsPage,
|
|
5927
|
+
Pa as DEFAULT_INVOICE_SETTINGS,
|
|
5928
|
+
Do as EditCouponPage,
|
|
5929
|
+
Fo as EditProductPage,
|
|
5915
5930
|
En as ExportReportsDialog,
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5931
|
+
da as FreemiusProvider,
|
|
5932
|
+
Ea as INVOICE_SETTINGS_KEY,
|
|
5933
|
+
To as InventoryPage,
|
|
5934
|
+
Ro as NewProductPage,
|
|
5935
|
+
Ao as OrderDetailPage,
|
|
5936
|
+
Eo as OrdersPage,
|
|
5937
|
+
Oo as PaymentsPage,
|
|
5938
|
+
Po as ProductsPage,
|
|
5939
|
+
Lo as ShippingPage,
|
|
5925
5940
|
dn as StripeProvider,
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
5941
|
+
Mo as TaxesPage,
|
|
5942
|
+
ac as addressesMatch,
|
|
5943
|
+
pc as aggregateOrderTaxLines,
|
|
5944
|
+
Ko as applyCurrencyRounding,
|
|
5930
5945
|
qt as applyOrderInventoryDeduction,
|
|
5931
5946
|
Dt as assignInvoiceMetadata,
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5947
|
+
Ia as buildOrderTaxDetailsFromCalculation,
|
|
5948
|
+
Ta as buildOrderTaxDetailsFromStripeSession,
|
|
5949
|
+
vo as clearAutoSyncedCurrencyPriceOverrides,
|
|
5935
5950
|
wt as convertMinorUnitAmount,
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5951
|
+
Ec as copyProductFromLanguage,
|
|
5952
|
+
Ga as createCategoryAction,
|
|
5953
|
+
fo as createCheckoutSession,
|
|
5954
|
+
Ac as createProduct,
|
|
5955
|
+
Ba as createProductAction,
|
|
5941
5956
|
ni as createShippingRate,
|
|
5942
5957
|
ri as createShippingZone,
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5958
|
+
Ka as deleteCategoryAction,
|
|
5959
|
+
Tr as deleteCouponFromFreemius,
|
|
5960
|
+
Pc as deleteProduct,
|
|
5961
|
+
Ar as deleteProductAction,
|
|
5947
5962
|
oi as deleteShippingRate,
|
|
5948
5963
|
si as deleteShippingZone,
|
|
5949
5964
|
mi as deleteTaxRateAction,
|
|
5950
|
-
|
|
5951
|
-
|
|
5965
|
+
Vo as describeCurrencyRoundingRule,
|
|
5966
|
+
sc as emptyCustomerAddress,
|
|
5952
5967
|
hn as extractFreemiusCheckoutMetadata,
|
|
5953
5968
|
wn as fetchOrderReportData,
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5969
|
+
Tc as fetchTranslatedProductsForCartInternal,
|
|
5970
|
+
la as fillMissingUserProfileCheckoutDetails,
|
|
5971
|
+
hc as formatInvoiceCurrency,
|
|
5972
|
+
fc as formatInvoiceDate,
|
|
5973
|
+
ba as getCategoriesWithCount,
|
|
5974
|
+
oc as getCategoryBySlug,
|
|
5975
|
+
ga as getCmsProduct,
|
|
5976
|
+
ha as getCmsProducts,
|
|
5977
|
+
Ha as getCouponQuote,
|
|
5978
|
+
Go as getCurrencyLookup,
|
|
5964
5979
|
Ys as getCurrentCustomerOrder,
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5980
|
+
yo as getCurrentCustomerOrderInvoice,
|
|
5981
|
+
_o as getCurrentCustomerOrders,
|
|
5982
|
+
Tt as getDefaultCurrency,
|
|
5983
|
+
cc as getDefaultUserAddresses,
|
|
5969
5984
|
Ye as getEnabledPaymentProviders,
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
|
|
5985
|
+
Ho as getExchangeRateForCurrency,
|
|
5986
|
+
xn as getFreemiusWebhookSecretCandidates,
|
|
5987
|
+
It as getGlobalProductAttributes,
|
|
5988
|
+
gc as getInvoiceAddressLines,
|
|
5974
5989
|
Ks as getInvoiceBrandingData,
|
|
5975
5990
|
Vs as getInvoiceOrder,
|
|
5976
5991
|
qr as getInvoicePresentationData,
|
|
5977
5992
|
vn as getOrderDetails,
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
|
|
5993
|
+
_c as getOrderTaxRateJurisdiction,
|
|
5994
|
+
yc as getOrderTaxRateLabel,
|
|
5995
|
+
xc as getOrderTaxRatePercentage,
|
|
5996
|
+
bn as getOrders,
|
|
5997
|
+
wo as getPaymentProvider,
|
|
5998
|
+
ko as getPaymentSettings,
|
|
5999
|
+
Ic as getProduct,
|
|
6000
|
+
Rc as getProductBySlug,
|
|
6001
|
+
lc as getProductCategories,
|
|
6002
|
+
ya as getProductTranslations,
|
|
6003
|
+
Fc as getProducts,
|
|
6004
|
+
Wa as getQuoteLineDiscountMap,
|
|
5990
6005
|
jt as getStoreConfigStatus,
|
|
5991
|
-
|
|
5992
|
-
|
|
6006
|
+
go as handleStripeWebhook,
|
|
6007
|
+
Wo as inferCurrencyCodeFromLocale,
|
|
5993
6008
|
nc as isCustomerAddressComplete,
|
|
5994
|
-
|
|
5995
|
-
|
|
6009
|
+
Qo as isSaleWindowActive,
|
|
6010
|
+
Xo as isScheduledPriceDue,
|
|
5996
6011
|
Se as normalizeCurrencyRecord,
|
|
5997
|
-
|
|
5998
|
-
|
|
5999
|
-
|
|
6012
|
+
Yo as normalizeCurrencyRoundingMode,
|
|
6013
|
+
ca as normalizeCustomerAddress,
|
|
6014
|
+
Aa as normalizeInvoiceSettings,
|
|
6000
6015
|
nt as normalizeOrderCustomerDetails,
|
|
6001
|
-
|
|
6016
|
+
Er as normalizeOrderTaxDetails,
|
|
6002
6017
|
rt as normalizePriceMap,
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6018
|
+
Zo as normalizeSalePriceMap,
|
|
6019
|
+
ua as parseFreemiusCheckoutCredentialsMap,
|
|
6020
|
+
bc as productSchema,
|
|
6021
|
+
Jt as readFreemiusEnvValue,
|
|
6022
|
+
xo as rebaseStoreCurrencyExchangeRates,
|
|
6023
|
+
Xa as recordCouponRedemption,
|
|
6009
6024
|
vt as resolveEffectivePriceForCurrency,
|
|
6010
|
-
|
|
6025
|
+
ma as resolveFreemiusCheckoutCredentials,
|
|
6011
6026
|
fn as resolveFreemiusStatusFromCheckoutResponse,
|
|
6012
6027
|
Br as resolveFreemiusStatusFromWebhookEvent,
|
|
6013
|
-
|
|
6014
|
-
|
|
6028
|
+
Jo as resolvePriceForCurrency,
|
|
6029
|
+
ec as resolvePriceRangeForCurrency,
|
|
6015
6030
|
ui as saveTaxRateAction,
|
|
6016
|
-
|
|
6017
|
-
|
|
6031
|
+
vc as serializeInvoiceSettings,
|
|
6032
|
+
tc as sortCurrencies,
|
|
6018
6033
|
Ce as stripe,
|
|
6019
|
-
|
|
6034
|
+
Uc as syncCategoriesForTranslationGroup,
|
|
6020
6035
|
it as syncCouponToFreemius,
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6036
|
+
No as syncFreemiusCheckoutOrder,
|
|
6037
|
+
Co as syncFreemiusOrderFromWebhookEvent,
|
|
6038
|
+
dc as syncFreemiusProductsToSupabase,
|
|
6039
|
+
wc as syncProductCategoriesAction,
|
|
6040
|
+
Nc as syncProductSaleCouponToFreemius,
|
|
6041
|
+
uc as syncSingleFreemiusProduct,
|
|
6042
|
+
bo as syncStoreCurrencyRates,
|
|
6028
6043
|
Xs as syncStripeOrderFromSession,
|
|
6029
|
-
|
|
6044
|
+
Va as updateCategoryAction,
|
|
6030
6045
|
ti as updateInventoryTrackingAction,
|
|
6031
6046
|
Zn as updatePaymentSettings,
|
|
6032
|
-
|
|
6033
|
-
|
|
6047
|
+
$c as updateProduct,
|
|
6048
|
+
ja as updateProductAction,
|
|
6034
6049
|
ii as updateShippingRate,
|
|
6035
6050
|
ai as updateShippingZone,
|
|
6036
6051
|
di as updateTaxSettingsAction,
|
|
6037
|
-
|
|
6038
|
-
|
|
6052
|
+
Sr as upsertDefaultUserAddresses,
|
|
6053
|
+
So as verifyFreemiusWebhookSignature
|
|
6039
6054
|
};
|