@nextblock-cms/ecom 0.8.6 → 0.8.7
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/index.cjs.js +1 -1
- package/index.es.js +136 -533
- package/lib/CurrencyProvider.cjs.js +1 -0
- package/lib/CurrencyProvider.es.js +99 -0
- package/lib/cart-store.cjs.js +1 -0
- package/{cart-store.es.js → lib/cart-store.es.js} +13 -13
- package/lib/components/AccountNavigationMenu.cjs.js +1 -0
- package/lib/components/AccountNavigationMenu.es.js +44 -0
- package/lib/components/AddToCartButton.cjs.js +1 -0
- package/{AddToCartButton-ffE0DhHu.js → lib/components/AddToCartButton.es.js} +14 -13
- package/lib/components/Cart.cjs.js +1 -0
- package/lib/components/Cart.es.js +148 -0
- package/lib/components/CartDrawer.cjs.js +1 -0
- package/{components → lib/components}/CartDrawer.es.js +15 -14
- package/{components → lib/components}/CartIcon.cjs.js +1 -1
- package/{components → lib/components}/CartIcon.es.js +1 -0
- package/lib/components/Checkout.cjs.js +1 -0
- package/{components → lib/components}/Checkout.es.js +330 -363
- package/lib/components/CouponForm.cjs.js +1 -0
- package/lib/components/CouponForm.es.js +136 -0
- package/lib/components/CurrencySwitcher.cjs.js +1 -0
- package/{components → lib/components}/CurrencySwitcher.es.js +5 -4
- package/lib/components/CustomerProfileForm.cjs.js +1 -0
- package/lib/components/CustomerProfileForm.es.js +355 -0
- package/lib/components/FeaturedProduct.cjs.js +1 -0
- package/{components → lib/components}/FeaturedProduct.es.js +9 -8
- package/lib/components/InvoiceDocument.cjs.js +1 -0
- package/lib/components/InvoiceDocument.es.js +196 -0
- package/lib/components/InvoiceViewerShell.cjs.js +29 -0
- package/lib/components/InvoiceViewerShell.es.js +100 -0
- package/lib/components/ProductCard.cjs.js +1 -0
- package/lib/components/ProductCard.es.js +119 -0
- package/lib/components/ProductDetailsLayout.cjs.js +1 -0
- package/lib/components/ProductDetailsLayout.es.js +361 -0
- package/lib/components/ProductGallery.cjs.js +1 -0
- package/lib/components/ProductGallery.es.js +41 -0
- package/lib/components/ProductGrid.cjs.js +1 -0
- package/lib/components/ProductGrid.es.js +19 -0
- package/lib/components/ShippingEstimator.cjs.js +1 -0
- package/lib/components/ShippingEstimator.es.js +125 -0
- package/lib/components/SubscriptionSelector.cjs.js +1 -0
- package/lib/components/SubscriptionSelector.es.js +140 -0
- package/lib/countries.cjs.js +1 -0
- package/lib/countries.es.js +77 -0
- package/lib/coupon-server.cjs.js +1 -0
- package/{coupon-server-DUKVtyYs.js → lib/coupon-server.es.js} +68 -82
- package/lib/coupons.cjs.js +1 -0
- package/lib/coupons.es.js +17 -0
- package/lib/currency-store.cjs.js +1 -0
- package/lib/currency-store.es.js +27 -0
- package/lib/currency-sync.cjs.js +1 -0
- package/lib/currency-sync.es.js +180 -0
- package/lib/customer-addresses.cjs.js +1 -0
- package/lib/customer-addresses.es.js +116 -0
- package/lib/customer-orders.cjs.js +1 -0
- package/lib/customer-orders.es.js +45 -0
- package/lib/customer.cjs.js +1 -0
- package/{customer-C3xccjUg.js → lib/customer.es.js} +15 -14
- package/lib/export-helpers.cjs.js +1 -0
- package/lib/export-helpers.es.js +56 -0
- package/lib/factory.cjs.js +1 -0
- package/lib/factory.es.js +8 -0
- package/lib/freemius-coupons.cjs.js +1 -0
- package/lib/freemius-coupons.es.js +272 -0
- package/lib/freemius-order-sync.cjs.js +1 -0
- package/lib/freemius-order-sync.es.js +284 -0
- package/lib/inventory-settings.cjs.js +1 -0
- package/lib/inventory-settings.es.js +86 -0
- package/lib/invoice-server.cjs.js +33 -0
- package/lib/invoice-server.es.js +141 -0
- package/lib/invoice-ui.cjs.js +1 -0
- package/lib/invoice-ui.es.js +71 -0
- package/lib/invoice.cjs.js +1 -0
- package/lib/invoice.es.js +102 -0
- package/lib/order-inventory.cjs.js +61 -0
- package/lib/order-inventory.es.js +128 -0
- package/lib/order-tax-details.cjs.js +1 -0
- package/lib/order-tax-details.es.js +164 -0
- package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -0
- package/lib/pages/cms/coupons/CouponEditorForm.es.js +189 -0
- package/lib/pages/cms/coupons/CouponsPage.cjs.js +5 -0
- package/lib/pages/cms/coupons/CouponsPage.es.js +171 -0
- package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -0
- package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -0
- package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -0
- package/lib/pages/cms/coupons/EditCouponPage.es.js +48 -0
- package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -0
- package/lib/pages/cms/coupons/ProductScopePicker.es.js +120 -0
- package/lib/pages/cms/coupons/actions.cjs.js +1 -0
- package/lib/pages/cms/coupons/actions.es.js +128 -0
- package/lib/pages/cms/coupons/product-options.cjs.js +1 -0
- package/lib/pages/cms/coupons/product-options.es.js +27 -0
- package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -0
- package/lib/pages/cms/orders/ExportReportsDialog.es.js +130 -0
- package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -0
- package/lib/pages/cms/orders/OrderDetailPage.es.js +137 -0
- package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -0
- package/lib/pages/cms/orders/OrderPrintButton.es.js +22 -0
- package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -0
- package/lib/pages/cms/orders/OrderStatusForm.es.js +71 -0
- package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -0
- package/lib/pages/cms/orders/OrdersPage.es.js +104 -0
- package/lib/pages/cms/orders/actions.cjs.js +7 -0
- package/lib/pages/cms/orders/actions.es.js +71 -0
- package/lib/pages/cms/orders/export-actions.cjs.js +1 -0
- package/lib/pages/cms/orders/export-actions.es.js +27 -0
- package/lib/pages/cms/orders/server-actions.cjs.js +1 -0
- package/lib/pages/cms/orders/server-actions.es.js +55 -0
- package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -0
- package/lib/pages/cms/payments/PaymentsClient.es.js +188 -0
- package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -0
- package/lib/pages/cms/payments/PaymentsPage.es.js +29 -0
- package/lib/pages/cms/payments/actions.cjs.js +1 -0
- package/lib/pages/cms/payments/actions.es.js +23 -0
- package/lib/pages/cms/payments/queries.cjs.js +1 -0
- package/lib/pages/cms/payments/queries.es.js +30 -0
- package/lib/pages/cms/products/ProductsPage.cjs.js +1 -0
- package/lib/pages/cms/products/ProductsPage.es.js +46 -0
- package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -0
- package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +156 -0
- package/lib/pages/cms/products/actions.cjs.js +44 -0
- package/lib/pages/cms/products/actions.es.js +175 -0
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -0
- package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +48 -0
- package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -0
- package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +291 -0
- package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -0
- package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +36 -0
- package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -0
- package/lib/pages/cms/products/categories/components/CategoryManager.es.js +263 -0
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -0
- package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +114 -0
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -0
- package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +107 -0
- package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -0
- package/lib/pages/cms/products/components/DeleteProductButton.es.js +48 -0
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -0
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +86 -0
- package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -0
- package/lib/pages/cms/products/components/ProductCategorySelector.es.js +160 -0
- package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -0
- package/lib/pages/cms/products/components/ProductForm.es.js +702 -0
- package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -0
- package/lib/pages/cms/products/components/ProductMediaManager.es.js +104 -0
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -0
- package/lib/pages/cms/products/components/ProductsBulkTable.es.js +228 -0
- package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -0
- package/lib/pages/cms/products/components/SaleScheduleFields.es.js +137 -0
- package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -0
- package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +36 -0
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +1 -0
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +40 -0
- package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -0
- package/lib/pages/cms/products/components/VariationsEditor.es.js +408 -0
- package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -0
- package/lib/pages/cms/products/inventory/InventoryPage.es.js +16 -0
- package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -0
- package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +214 -0
- package/lib/pages/cms/products/inventory/actions.cjs.js +3 -0
- package/lib/pages/cms/products/inventory/actions.es.js +95 -0
- package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -0
- package/lib/pages/cms/products/new/NewProductPage.es.js +76 -0
- package/lib/pages/cms/products/product-price-sync.cjs.js +1 -0
- package/lib/pages/cms/products/product-price-sync.es.js +98 -0
- package/lib/pages/cms/products/server-actions.cjs.js +1 -0
- package/lib/pages/cms/products/server-actions.es.js +193 -0
- package/lib/pages/cms/shipping/ShippingPage.cjs.js +5 -0
- package/lib/pages/cms/shipping/ShippingPage.es.js +211 -0
- package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -0
- package/lib/pages/cms/shipping/components/RateForm.es.js +441 -0
- package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -0
- package/lib/pages/cms/shipping/components/ZoneForm.es.js +228 -0
- package/lib/pages/cms/shipping/server-actions.cjs.js +1 -0
- package/lib/pages/cms/shipping/server-actions.es.js +159 -0
- package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -0
- package/lib/pages/cms/taxes/TaxesPage.es.js +172 -0
- package/lib/pages/cms/taxes/actions.cjs.js +1 -0
- package/lib/pages/cms/taxes/actions.es.js +57 -0
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -0
- package/lib/pages/cms/taxes/components/TaxRateForm.es.js +100 -0
- package/lib/product-actions.cjs.js +237 -0
- package/lib/product-actions.es.js +524 -0
- package/lib/product-context.cjs.js +1 -0
- package/lib/product-context.es.js +16 -0
- package/lib/product-schema.cjs.js +1 -0
- package/lib/product-schema.es.js +134 -0
- package/lib/providers/freemius.cjs.js +5 -0
- package/lib/providers/freemius.es.js +538 -0
- package/lib/providers/stripe.cjs.js +1 -0
- package/lib/providers/stripe.es.js +473 -0
- package/lib/server-actions/coupon-actions.cjs.js +1 -0
- package/lib/server-actions/coupon-actions.es.js +23 -0
- package/lib/server-actions/customer-actions.cjs.js +1 -0
- package/lib/server-actions/customer-actions.es.js +30 -0
- package/lib/server-actions/product-actions.cjs.js +1 -0
- package/{server-actions → lib/server-actions}/product-actions.es.js +5 -4
- package/lib/server-actions/shipping-actions.cjs.js +1 -0
- package/{shipping-actions-BnHjlo2q.js → lib/server-actions/shipping-actions.es.js} +9 -7
- package/lib/server-actions/tax-actions.cjs.js +1 -0
- package/lib/server-actions/tax-actions.es.js +40 -0
- package/lib/shared-inventory.cjs.js +15 -0
- package/lib/shared-inventory.es.js +171 -0
- package/lib/shipping/resolver.cjs.js +7 -0
- package/lib/shipping/resolver.es.js +62 -0
- package/lib/shipping-rate-currency.cjs.js +1 -0
- package/lib/shipping-rate-currency.es.js +72 -0
- package/lib/states.cjs.js +1 -0
- package/{states-DlHJezQ1.js → lib/states.es.js} +27 -100
- package/lib/stripe/checkout.cjs.js +1 -0
- package/lib/stripe/checkout.es.js +182 -0
- package/lib/stripe/client.cjs.js +1 -0
- package/lib/stripe/client.es.js +7 -0
- package/lib/stripe/order-sync.cjs.js +1 -0
- package/lib/stripe/order-sync.es.js +130 -0
- package/lib/stripe/webhooks.cjs.js +1 -0
- package/lib/stripe/webhooks.es.js +30 -0
- package/lib/tax-calculation.cjs.js +1 -0
- package/lib/tax-calculation.es.js +101 -0
- package/lib/trials.cjs.js +1 -0
- package/{trials-RDcRAZKx.js → lib/trials.es.js} +9 -9
- package/{use-cart.es.js → lib/use-cart.es.js} +1 -0
- package/lib/zod-config.cjs.js +1 -0
- package/lib/zod-config.es.js +6 -0
- package/package.json +4 -4
- package/server.cjs.js +1 -110
- package/server.es.js +178 -6052
- package/AddToCartButton-DsSEH9yp.cjs +0 -1
- package/CouponForm-BI_5SBHQ.js +0 -152
- package/CouponForm-D_uu2bLP.cjs +0 -1
- package/CurrencyProvider-Cg-Q6ucj.cjs +0 -1
- package/CurrencyProvider-OzlRN96V.js +0 -120
- package/CurrencyProvider.cjs.js +0 -1
- package/CurrencyProvider.es.js +0 -10
- package/ProductDetailsLayout-BxJH_BxR.cjs +0 -1
- package/ProductDetailsLayout-Dg8dRTYp.js +0 -530
- package/ProductGrid-BdL7iglO.cjs +0 -1
- package/ProductGrid-D3AWM8sr.js +0 -130
- package/actions-AHmBrS5e.cjs +0 -48
- package/actions-j5fuSZX-.js +0 -820
- package/cart-store.cjs.js +0 -1
- package/components/Cart.cjs.js +0 -1
- package/components/Cart.es.js +0 -259
- package/components/CartDrawer.cjs.js +0 -1
- package/components/Checkout.cjs.js +0 -1
- package/components/CurrencySwitcher.cjs.js +0 -1
- package/components/FeaturedProduct.cjs.js +0 -1
- package/components/ProductDetailsLayout.cjs.js +0 -1
- package/components/ProductDetailsLayout.es.js +0 -19
- package/components/ProductGrid.cjs.js +0 -1
- package/components/ProductGrid.es.js +0 -6
- package/coupon-server-C9ySm3I5.cjs +0 -1
- package/customer-C-UPvrYN.cjs +0 -1
- package/invoice-ui-CAnJPu6n.cjs +0 -29
- package/invoice-ui-DtpbTJE1.js +0 -2886
- package/product-actions-CONBF8i6.cjs +0 -251
- package/product-actions-DjlIWCMH.js +0 -691
- package/resolver-Fz_FKsfX.cjs +0 -7
- package/resolver-cfrCaHpE.js +0 -128
- package/server-actions/product-actions.cjs.js +0 -1
- package/shipping-actions-D6zt20gg.cjs +0 -1
- package/states-CWYRxV4B.cjs +0 -1
- package/tax-calculation-Dab89aHd.js +0 -181
- package/tax-calculation-MkDKOEkL.cjs +0 -1
- package/trials-DvZaOtNy.cjs +0 -1
- /package/{components → lib/components}/SimpleTiptapRenderer.cjs.js +0 -0
- /package/{components → lib/components}/SimpleTiptapRenderer.es.js +0 -0
- /package/{currency-constants.cjs.js → lib/currency-constants.cjs.js} +0 -0
- /package/{currency-constants.es.js → lib/currency-constants.es.js} +0 -0
- /package/{currency-rest-client-uolJxUkL.cjs → lib/currency-rest-client.cjs.js} +0 -0
- /package/{currency-rest-client-CwoqdgAP.js → lib/currency-rest-client.es.js} +0 -0
- /package/{currency.cjs.js → lib/currency.cjs.js} +0 -0
- /package/{currency.es.js → lib/currency.es.js} +0 -0
- /package/{types.cjs.js → lib/types.cjs.js} +0 -0
- /package/{types.es.js → lib/types.es.js} +0 -0
- /package/{use-cart.cjs.js → lib/use-cart.cjs.js} +0 -0
- /package/{variation-utils.cjs.js → lib/variation-utils.cjs.js} +0 -0
- /package/{variation-utils.es.js → lib/variation-utils.es.js} +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs as s, jsx as l } from "react/jsx-runtime";
|
|
3
|
+
import { useState as c, useTransition as v, useMemo as g } from "react";
|
|
4
|
+
import { useRouter as S } from "next/navigation";
|
|
5
|
+
import { Select as f, SelectTrigger as b, SelectValue as N, SelectContent as T, SelectItem as O, Button as k } from "@nextblock-cms/ui";
|
|
6
|
+
import { updateOrderStatus as w } from "./server-actions.es.js";
|
|
7
|
+
const o = [
|
|
8
|
+
{ value: "pending", label: "Pending" },
|
|
9
|
+
{ value: "trial", label: "Trial" },
|
|
10
|
+
{ value: "paid", label: "Paid" },
|
|
11
|
+
{ value: "shipped", label: "Shipped" },
|
|
12
|
+
{ value: "cancelled", label: "Cancelled" },
|
|
13
|
+
{ value: "refunded", label: "Refunded" }
|
|
14
|
+
];
|
|
15
|
+
function F({
|
|
16
|
+
orderId: u,
|
|
17
|
+
currentStatus: t
|
|
18
|
+
}) {
|
|
19
|
+
const m = S(), [a, p] = c(
|
|
20
|
+
o.some((e) => e.value === t) ? t : "pending"
|
|
21
|
+
), [d, r] = c(null), [i, h] = v(), n = g(
|
|
22
|
+
() => a !== t,
|
|
23
|
+
[t, a]
|
|
24
|
+
), x = () => {
|
|
25
|
+
n && (r(null), h(async () => {
|
|
26
|
+
try {
|
|
27
|
+
const e = await w(u, a);
|
|
28
|
+
if (!e.success) {
|
|
29
|
+
r(e.error || "Failed to update order status.");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
m.refresh();
|
|
33
|
+
} catch (e) {
|
|
34
|
+
console.error(e), r("Unexpected error while saving the order status.");
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
37
|
+
};
|
|
38
|
+
return /* @__PURE__ */ s("div", { className: "rounded-lg border bg-white p-4 dark:border-slate-800 dark:bg-slate-900", children: [
|
|
39
|
+
/* @__PURE__ */ s("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-end", children: [
|
|
40
|
+
/* @__PURE__ */ s("div", { className: "min-w-[220px] flex-1 space-y-2", children: [
|
|
41
|
+
/* @__PURE__ */ l("p", { className: "text-[11px] font-semibold uppercase tracking-[0.18em] text-slate-500", children: "Order Status" }),
|
|
42
|
+
/* @__PURE__ */ s(
|
|
43
|
+
f,
|
|
44
|
+
{
|
|
45
|
+
value: a,
|
|
46
|
+
onValueChange: (e) => {
|
|
47
|
+
p(e), r(null);
|
|
48
|
+
},
|
|
49
|
+
children: [
|
|
50
|
+
/* @__PURE__ */ l(b, { children: /* @__PURE__ */ l(N, { placeholder: "Select status" }) }),
|
|
51
|
+
/* @__PURE__ */ l(T, { children: o.map((e) => /* @__PURE__ */ l(O, { value: e.value, children: e.label }, e.value)) })
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
] }),
|
|
56
|
+
/* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ l(
|
|
57
|
+
k,
|
|
58
|
+
{
|
|
59
|
+
type: "button",
|
|
60
|
+
onClick: x,
|
|
61
|
+
disabled: i || !n,
|
|
62
|
+
children: i ? "Saving..." : "Save"
|
|
63
|
+
}
|
|
64
|
+
) })
|
|
65
|
+
] }),
|
|
66
|
+
d ? /* @__PURE__ */ l("p", { className: "mt-2 text-xs text-red-600 dark:text-red-400", children: d }) : n ? null : /* @__PURE__ */ l("p", { className: "mt-2 text-xs text-slate-500", children: "Status is already up to date." })
|
|
67
|
+
] });
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
F as OrderStatusForm
|
|
71
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("next/link"),m=require("./actions.cjs.js"),g=require("./ExportReportsDialog.cjs.js"),x=(s,a="usd")=>new Intl.NumberFormat("en-US",{style:"currency",currency:a}).format(s/100);async function p({searchParams:s}){const a=await s,r=Number(a.page)||1,l=a.status||"all",{data:c,totalPages:i}=await m.getOrders(r,l);return e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Orders"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g.ExportReportsDialog,{}),e.jsx(d,{href:`/cms/orders?page=${r}&status=${l}`,className:"px-3 py-2 text-sm font-medium border rounded hover:bg-gray-50 dark:hover:bg-slate-800",children:"Refresh"})]})]}),e.jsx("div",{className:"flex gap-2 border-b pb-4",children:["all","paid","trial","pending","failed"].map(t=>e.jsx(d,{href:`/cms/orders?page=1&status=${t}`,className:`px-3 py-1 rounded-full text-sm font-medium capitalize ${l===t?"bg-black text-white dark:bg-white dark:text-black":"bg-gray-100 text-gray-600 hover:bg-gray-200 dark:bg-slate-800 dark:text-gray-300 dark:hover:bg-slate-700"}`,children:t},t))}),e.jsx("div",{className:"border rounded-lg overflow-hidden dark:border-slate-800",children:e.jsxs("table",{className:"w-full text-sm text-left align-middle",children:[e.jsx("thead",{className:"bg-gray-50 text-gray-500 font-medium border-b dark:bg-slate-900 dark:text-slate-400 dark:border-slate-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3",children:"ID"}),e.jsx("th",{className:"px-4 py-3",children:"Customer"}),e.jsx("th",{className:"px-4 py-3",children:"Status"}),e.jsx("th",{className:"px-4 py-3",children:"Provider"}),e.jsx("th",{className:"px-4 py-3 text-right",children:"Amount"}),e.jsx("th",{className:"px-4 py-3 text-right",children:"Date"}),e.jsx("th",{className:"px-4 py-3 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y dark:divide-slate-800",children:c.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-4 py-8 text-center text-gray-500",children:"No orders found."})}):c.map(t=>{const n=t.customer_details,o=n?.name||n?.email||t.customer?.full_name||"Guest Customer";return e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-slate-800/50",children:[e.jsxs("td",{className:"px-4 py-3 font-mono text-gray-500",children:[t.id.slice(0,8),"..."]}),e.jsx("td",{className:"px-4 py-3 font-medium",children:o}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(h,{status:t.status})}),e.jsx("td",{className:"px-4 py-3 capitalize text-gray-600 dark:text-gray-400",children:t.provider==="freemius"?"Freemius":"Stripe"}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsxs("div",{className:"flex flex-col items-end",children:[e.jsx("span",{children:x(t.total,t.currency||"usd")}),t.discount_total?e.jsxs("span",{className:"text-[10px] text-emerald-600",children:[t.coupon_code," -",x(t.discount_total,t.currency||"usd")]}):null]})}),e.jsx("td",{className:"px-4 py-3 text-right text-gray-500 whitespace-nowrap",children:new Date(t.created_at||"").toLocaleDateString()}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx(d,{href:`/cms/orders/${t.id}`,className:"text-blue-600 hover:underline dark:text-blue-400",children:"View"})})]},t.id)})})]})}),e.jsxs("div",{className:"flex justify-between items-center pt-4",children:[e.jsxs("div",{className:"text-sm text-gray-500",children:["Page ",r," of ",i]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(d,{href:`/cms/orders?page=${Math.max(1,r-1)}&status=${l}`,className:`px-3 py-1 border rounded text-sm ${r<=1?"pointer-events-none opacity-50":"hover:bg-gray-50 dark:hover:bg-slate-800"}`,children:"Previous"}),e.jsx(d,{href:`/cms/orders?page=${Math.min(i,r+1)}&status=${l}`,className:`px-3 py-1 border rounded text-sm ${r>=i?"pointer-events-none opacity-50":"hover:bg-gray-50 dark:hover:bg-slate-800"}`,children:"Next"})]})]})]})}function h({status:s}){let a="bg-gray-100 text-gray-700 dark:bg-slate-800 dark:text-gray-300";return s==="paid"&&(a="bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400"),s==="trial"&&(a="bg-cyan-100 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-300"),s==="pending"&&(a="bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"),s==="failed"&&(a="bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"),e.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium capitalize ${a}`,children:s})}exports.OrdersPage=p;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { jsxs as a, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import i from "next/link";
|
|
3
|
+
import { getOrders as h } from "./actions.es.js";
|
|
4
|
+
import { ExportReportsDialog as g } from "./ExportReportsDialog.es.js";
|
|
5
|
+
const m = (s, r = "usd") => new Intl.NumberFormat("en-US", {
|
|
6
|
+
style: "currency",
|
|
7
|
+
currency: r
|
|
8
|
+
}).format(s / 100);
|
|
9
|
+
async function N({
|
|
10
|
+
searchParams: s
|
|
11
|
+
}) {
|
|
12
|
+
const r = await s, l = Number(r.page) || 1, d = r.status || "all", { data: n, totalPages: c } = await h(l, d);
|
|
13
|
+
return /* @__PURE__ */ a("div", { className: "p-6 space-y-6", children: [
|
|
14
|
+
/* @__PURE__ */ a("div", { className: "flex justify-between items-center", children: [
|
|
15
|
+
/* @__PURE__ */ e("h1", { className: "text-2xl font-bold tracking-tight", children: "Orders" }),
|
|
16
|
+
/* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
|
|
17
|
+
/* @__PURE__ */ e(g, {}),
|
|
18
|
+
/* @__PURE__ */ e(i, { href: `/cms/orders?page=${l}&status=${d}`, className: "px-3 py-2 text-sm font-medium border rounded hover:bg-gray-50 dark:hover:bg-slate-800", children: "Refresh" })
|
|
19
|
+
] })
|
|
20
|
+
] }),
|
|
21
|
+
/* @__PURE__ */ e("div", { className: "flex gap-2 border-b pb-4", children: ["all", "paid", "trial", "pending", "failed"].map((t) => /* @__PURE__ */ e(
|
|
22
|
+
i,
|
|
23
|
+
{
|
|
24
|
+
href: `/cms/orders?page=1&status=${t}`,
|
|
25
|
+
className: `px-3 py-1 rounded-full text-sm font-medium capitalize ${d === t ? "bg-black text-white dark:bg-white dark:text-black" : "bg-gray-100 text-gray-600 hover:bg-gray-200 dark:bg-slate-800 dark:text-gray-300 dark:hover:bg-slate-700"}`,
|
|
26
|
+
children: t
|
|
27
|
+
},
|
|
28
|
+
t
|
|
29
|
+
)) }),
|
|
30
|
+
/* @__PURE__ */ e("div", { className: "border rounded-lg overflow-hidden dark:border-slate-800", children: /* @__PURE__ */ a("table", { className: "w-full text-sm text-left align-middle", children: [
|
|
31
|
+
/* @__PURE__ */ e("thead", { className: "bg-gray-50 text-gray-500 font-medium border-b dark:bg-slate-900 dark:text-slate-400 dark:border-slate-800", children: /* @__PURE__ */ a("tr", { children: [
|
|
32
|
+
/* @__PURE__ */ e("th", { className: "px-4 py-3", children: "ID" }),
|
|
33
|
+
/* @__PURE__ */ e("th", { className: "px-4 py-3", children: "Customer" }),
|
|
34
|
+
/* @__PURE__ */ e("th", { className: "px-4 py-3", children: "Status" }),
|
|
35
|
+
/* @__PURE__ */ e("th", { className: "px-4 py-3", children: "Provider" }),
|
|
36
|
+
/* @__PURE__ */ e("th", { className: "px-4 py-3 text-right", children: "Amount" }),
|
|
37
|
+
/* @__PURE__ */ e("th", { className: "px-4 py-3 text-right", children: "Date" }),
|
|
38
|
+
/* @__PURE__ */ e("th", { className: "px-4 py-3 text-right", children: "Actions" })
|
|
39
|
+
] }) }),
|
|
40
|
+
/* @__PURE__ */ e("tbody", { className: "divide-y dark:divide-slate-800", children: n.length === 0 ? /* @__PURE__ */ e("tr", { children: /* @__PURE__ */ e("td", { colSpan: 7, className: "px-4 py-8 text-center text-gray-500", children: "No orders found." }) }) : n.map((t) => {
|
|
41
|
+
const o = t.customer_details, p = o?.name || o?.email || t.customer?.full_name || "Guest Customer";
|
|
42
|
+
return /* @__PURE__ */ a("tr", { className: "hover:bg-gray-50 dark:hover:bg-slate-800/50", children: [
|
|
43
|
+
/* @__PURE__ */ a("td", { className: "px-4 py-3 font-mono text-gray-500", children: [
|
|
44
|
+
t.id.slice(0, 8),
|
|
45
|
+
"..."
|
|
46
|
+
] }),
|
|
47
|
+
/* @__PURE__ */ e("td", { className: "px-4 py-3 font-medium", children: p }),
|
|
48
|
+
/* @__PURE__ */ e("td", { className: "px-4 py-3", children: /* @__PURE__ */ e(x, { status: t.status }) }),
|
|
49
|
+
/* @__PURE__ */ e("td", { className: "px-4 py-3 capitalize text-gray-600 dark:text-gray-400", children: t.provider === "freemius" ? "Freemius" : "Stripe" }),
|
|
50
|
+
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-right", children: /* @__PURE__ */ a("div", { className: "flex flex-col items-end", children: [
|
|
51
|
+
/* @__PURE__ */ e("span", { children: m(t.total, t.currency || "usd") }),
|
|
52
|
+
t.discount_total ? /* @__PURE__ */ a("span", { className: "text-[10px] text-emerald-600", children: [
|
|
53
|
+
t.coupon_code,
|
|
54
|
+
" -",
|
|
55
|
+
m(t.discount_total, t.currency || "usd")
|
|
56
|
+
] }) : null
|
|
57
|
+
] }) }),
|
|
58
|
+
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-right text-gray-500 whitespace-nowrap", children: new Date(t.created_at || "").toLocaleDateString() }),
|
|
59
|
+
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-right", children: /* @__PURE__ */ e(
|
|
60
|
+
i,
|
|
61
|
+
{
|
|
62
|
+
href: `/cms/orders/${t.id}`,
|
|
63
|
+
className: "text-blue-600 hover:underline dark:text-blue-400",
|
|
64
|
+
children: "View"
|
|
65
|
+
}
|
|
66
|
+
) })
|
|
67
|
+
] }, t.id);
|
|
68
|
+
}) })
|
|
69
|
+
] }) }),
|
|
70
|
+
/* @__PURE__ */ a("div", { className: "flex justify-between items-center pt-4", children: [
|
|
71
|
+
/* @__PURE__ */ a("div", { className: "text-sm text-gray-500", children: [
|
|
72
|
+
"Page ",
|
|
73
|
+
l,
|
|
74
|
+
" of ",
|
|
75
|
+
c
|
|
76
|
+
] }),
|
|
77
|
+
/* @__PURE__ */ a("div", { className: "flex gap-2", children: [
|
|
78
|
+
/* @__PURE__ */ e(
|
|
79
|
+
i,
|
|
80
|
+
{
|
|
81
|
+
href: `/cms/orders?page=${Math.max(1, l - 1)}&status=${d}`,
|
|
82
|
+
className: `px-3 py-1 border rounded text-sm ${l <= 1 ? "pointer-events-none opacity-50" : "hover:bg-gray-50 dark:hover:bg-slate-800"}`,
|
|
83
|
+
children: "Previous"
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
/* @__PURE__ */ e(
|
|
87
|
+
i,
|
|
88
|
+
{
|
|
89
|
+
href: `/cms/orders?page=${Math.min(c, l + 1)}&status=${d}`,
|
|
90
|
+
className: `px-3 py-1 border rounded text-sm ${l >= c ? "pointer-events-none opacity-50" : "hover:bg-gray-50 dark:hover:bg-slate-800"}`,
|
|
91
|
+
children: "Next"
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
] })
|
|
95
|
+
] })
|
|
96
|
+
] });
|
|
97
|
+
}
|
|
98
|
+
function x({ status: s }) {
|
|
99
|
+
let r = "bg-gray-100 text-gray-700 dark:bg-slate-800 dark:text-gray-300";
|
|
100
|
+
return s === "paid" && (r = "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400"), s === "trial" && (r = "bg-cyan-100 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-300"), s === "pending" && (r = "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"), s === "failed" && (r = "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"), /* @__PURE__ */ e("span", { className: `px-2 py-0.5 rounded-full text-xs font-medium capitalize ${r}`, children: s });
|
|
101
|
+
}
|
|
102
|
+
export {
|
|
103
|
+
N as OrdersPage
|
|
104
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("@nextblock-cms/db/server"),m=20;async function h(l=1,i,s){const d=await g.createClient(),t=(l-1)*m,n=t+m-1;let o=d.from("orders").select(`
|
|
2
|
+
*,
|
|
3
|
+
order_items (*)
|
|
4
|
+
`,{count:"exact"}).order("created_at",{ascending:!1}).range(t,n);i&&i!=="all"&&(o=o.eq("status",i)),s&&(o=o.or(`id.eq.${s},user_id.eq.${s}`));const{data:u,error:f,count:e}=await o;if(f)throw console.error("Error fetching orders:",f),new Error("Failed to fetch orders");const r=u||[],c=Array.from(new Set(r.map(a=>a.user_id).filter(Boolean))),p=new Map;if(c.length>0){const{data:a,error:w}=await d.from("profiles").select("*").in("id",c);!w&&a&&a.forEach(_=>p.set(_.id,_))}return{data:r.map(a=>({...a,customer:a.user_id?p.get(a.user_id):null})),total:e||0,totalPages:e?Math.ceil(e/m):0}}async function E(l){const i=await g.createClient(),{data:s,error:d}=await i.from("orders").select(`
|
|
5
|
+
*,
|
|
6
|
+
order_items (*)
|
|
7
|
+
`).eq("id",l).single();if(d||!s)return console.error(`Error fetching order ${l}:`,d),null;const t=s;let n=null;if(t.user_id){const{data:e}=await i.from("profiles").select("*").eq("id",t.user_id).single();n=e}const o=t.order_items.map(e=>e.product_id).filter(Boolean),u=new Map;if(o.length>0){const{data:e}=await i.from("products").select("id, title, slug, product_media(media(file_path))").in("id",o);e&&e.forEach(r=>{let c=null;r.product_media&&r.product_media.length>0&&r.product_media[0].media&&(c=r.product_media[0].media.file_path),u.set(r.id,{title:r.title,slug:r.slug,image_url:c})})}const f=t.order_items.map(e=>({...e,product:e.product_id?u.get(e.product_id):null}));return{...t,order_items:f,customer:n}}exports.getOrderDetails=E;exports.getOrders=h;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use server';
|
|
2
|
+
import { createClient as g } from "@nextblock-cms/db/server";
|
|
3
|
+
const m = 20;
|
|
4
|
+
async function q(n = 1, i, s) {
|
|
5
|
+
const d = await g(), t = (n - 1) * m, l = t + m - 1;
|
|
6
|
+
let o = d.from("orders").select(
|
|
7
|
+
`
|
|
8
|
+
*,
|
|
9
|
+
order_items (*)
|
|
10
|
+
`,
|
|
11
|
+
{ count: "exact" }
|
|
12
|
+
).order("created_at", { ascending: !1 }).range(t, l);
|
|
13
|
+
i && i !== "all" && (o = o.eq("status", i)), s && (o = o.or(`id.eq.${s},user_id.eq.${s}`));
|
|
14
|
+
const { data: u, error: f, count: r } = await o;
|
|
15
|
+
if (f)
|
|
16
|
+
throw console.error("Error fetching orders:", f), new Error("Failed to fetch orders");
|
|
17
|
+
const e = u || [], c = Array.from(new Set(e.map((a) => a.user_id).filter(Boolean))), p = /* @__PURE__ */ new Map();
|
|
18
|
+
if (c.length > 0) {
|
|
19
|
+
const { data: a, error: w } = await d.from("profiles").select("*").in("id", c);
|
|
20
|
+
!w && a && a.forEach((_) => p.set(_.id, _));
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
data: e.map((a) => ({
|
|
24
|
+
...a,
|
|
25
|
+
customer: a.user_id ? p.get(a.user_id) : null
|
|
26
|
+
})),
|
|
27
|
+
total: r || 0,
|
|
28
|
+
totalPages: r ? Math.ceil(r / m) : 0
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
async function M(n) {
|
|
32
|
+
const i = await g(), { data: s, error: d } = await i.from("orders").select(
|
|
33
|
+
`
|
|
34
|
+
*,
|
|
35
|
+
order_items (*)
|
|
36
|
+
`
|
|
37
|
+
).eq("id", n).single();
|
|
38
|
+
if (d || !s)
|
|
39
|
+
return console.error(`Error fetching order ${n}:`, d), null;
|
|
40
|
+
const t = s;
|
|
41
|
+
let l = null;
|
|
42
|
+
if (t.user_id) {
|
|
43
|
+
const { data: r } = await i.from("profiles").select("*").eq("id", t.user_id).single();
|
|
44
|
+
l = r;
|
|
45
|
+
}
|
|
46
|
+
const o = t.order_items.map((r) => r.product_id).filter(Boolean), u = /* @__PURE__ */ new Map();
|
|
47
|
+
if (o.length > 0) {
|
|
48
|
+
const { data: r } = await i.from("products").select("id, title, slug, product_media(media(file_path))").in("id", o);
|
|
49
|
+
r && r.forEach((e) => {
|
|
50
|
+
let c = null;
|
|
51
|
+
e.product_media && e.product_media.length > 0 && e.product_media[0].media && (c = e.product_media[0].media.file_path), u.set(e.id, {
|
|
52
|
+
title: e.title,
|
|
53
|
+
slug: e.slug,
|
|
54
|
+
image_url: c
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const f = t.order_items.map((r) => ({
|
|
59
|
+
...r,
|
|
60
|
+
product: r.product_id ? u.get(r.product_id) : null
|
|
61
|
+
}));
|
|
62
|
+
return {
|
|
63
|
+
...t,
|
|
64
|
+
order_items: f,
|
|
65
|
+
customer: l
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
M as getOrderDetails,
|
|
70
|
+
q as getOrders
|
|
71
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@nextblock-cms/db/server");async function f(o,s){const i=l.createClient();let r=i.from("orders").select("*, order_items(*)");if(o&&(r=r.gte("created_at",o)),s){const e=new Date(s);e.setHours(23,59,59,999),r=r.lte("created_at",e.toISOString())}const{data:t,error:a}=await r.order("created_at",{ascending:!0});if(a)throw console.error("Error fetching report data:",a),new Error(`Failed to fetch report data: ${a.message}`);if(!t||t.length===0)return[];const n=Array.from(new Set(t.map(e=>e.user_id).filter(Boolean))),c=new Map;if(n.length>0){const{data:e}=await i.from("profiles").select("id, full_name, email").in("id",n);e&&e.forEach(d=>c.set(d.id,d))}return t.map(e=>({...e,customer:e.user_id?c.get(e.user_id):null}))}exports.fetchOrderReportData=f;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use server';
|
|
2
|
+
import { createClient as d } from "@nextblock-cms/db/server";
|
|
3
|
+
async function u(a, s) {
|
|
4
|
+
const i = d();
|
|
5
|
+
let r = i.from("orders").select("*, order_items(*)");
|
|
6
|
+
if (a && (r = r.gte("created_at", a)), s) {
|
|
7
|
+
const e = new Date(s);
|
|
8
|
+
e.setHours(23, 59, 59, 999), r = r.lte("created_at", e.toISOString());
|
|
9
|
+
}
|
|
10
|
+
const { data: t, error: o } = await r.order("created_at", { ascending: !0 });
|
|
11
|
+
if (o)
|
|
12
|
+
throw console.error("Error fetching report data:", o), new Error(`Failed to fetch report data: ${o.message}`);
|
|
13
|
+
if (!t || t.length === 0)
|
|
14
|
+
return [];
|
|
15
|
+
const n = Array.from(new Set(t.map((e) => e.user_id).filter(Boolean))), c = /* @__PURE__ */ new Map();
|
|
16
|
+
if (n.length > 0) {
|
|
17
|
+
const { data: e } = await i.from("profiles").select("id, full_name, email").in("id", n);
|
|
18
|
+
e && e.forEach((f) => c.set(f.id, f));
|
|
19
|
+
}
|
|
20
|
+
return t.map((e) => ({
|
|
21
|
+
...e,
|
|
22
|
+
customer: e.user_id ? c.get(e.user_id) : null
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
u as fetchOrderReportData
|
|
27
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@nextblock-cms/db/server"),u=require("@supabase/supabase-js"),c=require("../../../order-inventory.cjs.js"),d=require("../../../invoice-server.cjs.js"),l=["pending","trial","paid","shipped","cancelled","refunded"];async function f(){const r=i.createClient(),{data:{user:e},error:t}=await r.auth.getUser();if(t||!e)return{error:"Unauthorized"};const{data:s,error:a}=await r.from("profiles").select("role").eq("id",e.id).single();return a||!s||!["ADMIN","WRITER"].includes(s.role)?{error:"Forbidden"}:{supabase:r,user:e}}function p(){const r=process.env.SUPABASE_SERVICE_ROLE_KEY,e=process.env.NEXT_PUBLIC_SUPABASE_URL;if(!r||!e)throw new Error("Server configuration error");return u.createClient(e,r,{auth:{autoRefreshToken:!1,persistSession:!1}})}async function E(r,e){const t=await f();if("error"in t)return{success:!1,error:t.error};if(!l.includes(e))return{success:!1,error:"Invalid order status"};let s;try{s=p()}catch(n){return{success:!1,error:n instanceof Error?n.message:"Server configuration error"}}const{data:a,error:o}=await s.from("orders").update({status:e}).eq("id",r).select();return o?(console.error("Order status update error:",o),{success:!1,error:o.message}):!a||a.length===0?{success:!1,error:"Order not found or update failed."}:(e==="paid"&&(await d.assignInvoiceMetadata({orderId:r,client:s}),await c.applyOrderInventoryDeduction(s,r)),{success:!0})}exports.updateOrderStatus=E;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use server';
|
|
2
|
+
import { createClient as i } from "@nextblock-cms/db/server";
|
|
3
|
+
import { createClient as c } from "@supabase/supabase-js";
|
|
4
|
+
import { applyOrderInventoryDeduction as u } from "../../../order-inventory.es.js";
|
|
5
|
+
import { assignInvoiceMetadata as d } from "../../../invoice-server.es.js";
|
|
6
|
+
const f = [
|
|
7
|
+
"pending",
|
|
8
|
+
"trial",
|
|
9
|
+
"paid",
|
|
10
|
+
"shipped",
|
|
11
|
+
"cancelled",
|
|
12
|
+
"refunded"
|
|
13
|
+
];
|
|
14
|
+
async function l() {
|
|
15
|
+
const r = i(), { data: { user: e }, error: a } = await r.auth.getUser();
|
|
16
|
+
if (a || !e)
|
|
17
|
+
return { error: "Unauthorized" };
|
|
18
|
+
const { data: t, error: s } = await r.from("profiles").select("role").eq("id", e.id).single();
|
|
19
|
+
return s || !t || !["ADMIN", "WRITER"].includes(t.role) ? { error: "Forbidden" } : { supabase: r, user: e };
|
|
20
|
+
}
|
|
21
|
+
function p() {
|
|
22
|
+
const r = process.env.SUPABASE_SERVICE_ROLE_KEY, e = process.env.NEXT_PUBLIC_SUPABASE_URL;
|
|
23
|
+
if (!r || !e)
|
|
24
|
+
throw new Error("Server configuration error");
|
|
25
|
+
return c(e, r, {
|
|
26
|
+
auth: {
|
|
27
|
+
autoRefreshToken: !1,
|
|
28
|
+
persistSession: !1
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async function h(r, e) {
|
|
33
|
+
const a = await l();
|
|
34
|
+
if ("error" in a)
|
|
35
|
+
return { success: !1, error: a.error };
|
|
36
|
+
if (!f.includes(e))
|
|
37
|
+
return { success: !1, error: "Invalid order status" };
|
|
38
|
+
let t;
|
|
39
|
+
try {
|
|
40
|
+
t = p();
|
|
41
|
+
} catch (n) {
|
|
42
|
+
return {
|
|
43
|
+
success: !1,
|
|
44
|
+
error: n instanceof Error ? n.message : "Server configuration error"
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const { data: s, error: o } = await t.from("orders").update({ status: e }).eq("id", r).select();
|
|
48
|
+
return o ? (console.error("Order status update error:", o), { success: !1, error: o.message }) : !s || s.length === 0 ? { success: !1, error: "Order not found or update failed." } : (e === "paid" && (await d({
|
|
49
|
+
orderId: r,
|
|
50
|
+
client: t
|
|
51
|
+
}), await u(t, r)), { success: !0 });
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
h as updateOrderStatus
|
|
55
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("react"),t=require("@nextblock-cms/ui"),m=require("lucide-react"),p=require("react-dom");function j({initialEnabledProviders:r,configStatus:i,saveAction:n}){const[s,a]=x.useState(r),d=i?.stripe?.hasKeys,l=i?.freemius?.hasKeys;return e.jsxs("form",{action:n,className:"space-y-6 max-w-3xl p-8",children:[e.jsx("input",{type:"hidden",name:"stripe_enabled",value:s.stripe?"true":"false"}),e.jsx("input",{type:"hidden",name:"freemius_enabled",value:s.freemius?"true":"false"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Payment Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Enable the payment providers your store needs. Physical products use Stripe and digital products use Freemius."})]}),e.jsxs(t.Card,{children:[e.jsxs(t.CardHeader,{children:[e.jsx(t.CardTitle,{children:"Payment Providers"}),e.jsx(t.CardDescription,{children:"You can run both providers at the same time. Each product picks its provider from its product type."})]}),e.jsxs(t.CardContent,{className:"space-y-6",children:[e.jsx(u,{id:"stripe-enabled",label:"Stripe for Physical Products",description:"Use Stripe Checkout for physical merchandise and other shippable goods.",checked:s.stripe,disabled:!d,onCheckedChange:c=>a(o=>({...o,stripe:c})),ready:d,children:d?e.jsxs("div",{className:"mt-2 text-sm text-green-600 flex items-center gap-2",children:[e.jsx(m.CheckCircle2,{className:"w-4 h-4"}),e.jsx("span",{children:"Ready to process physical product checkout"})]}):e.jsx(h,{provider:"Stripe",missingKeys:i.stripe.missing,docsUrl:"https://dashboard.stripe.com/apikeys",docsLabel:"Stripe Dashboard -> Developers -> API Keys"})}),e.jsx(u,{id:"freemius-enabled",label:"Freemius for Digital Products",description:"Use Freemius for software licenses, SaaS plans, and other digital products.",checked:s.freemius,disabled:!l,onCheckedChange:c=>a(o=>({...o,freemius:c})),ready:l,children:l?e.jsxs("div",{className:"mt-2 text-sm text-green-600 flex items-center gap-2",children:[e.jsx(m.CheckCircle2,{className:"w-4 h-4"}),e.jsx("span",{children:"Ready to process digital product checkout"})]}):e.jsx(h,{provider:"Freemius",missingKeys:i.freemius.missing,docsUrl:"https://dashboard.freemius.com/",docsLabel:"Freemius Dashboard -> Developers -> Credentials"})}),e.jsx("div",{className:"flex justify-end pt-4",children:e.jsx(b,{})})]})]})]})}function b(){const{pending:r}=p.useFormStatus();return e.jsx(t.Button,{type:"submit",disabled:r,children:r?"Saving...":"Save Changes"})}function u({id:r,label:i,description:n,checked:s,disabled:a,ready:d,onCheckedChange:l,children:c}){return e.jsx("div",{className:"rounded-md border p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(t.Checkbox,{id:r,checked:s,disabled:a,onCheckedChange:o=>l(!!o),className:"mt-1"}),e.jsxs("div",{className:"grid gap-1.5 leading-none w-full",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsx(t.Label,{htmlFor:r,className:"font-semibold text-base cursor-pointer",children:i}),e.jsx("span",{className:`text-xs font-medium ${s?"text-foreground":"text-muted-foreground"}`,children:s?"Enabled":"Disabled"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n}),!d&&e.jsx("p",{className:"text-xs text-amber-700",children:"This provider cannot be enabled until all required environment variables are present."}),c]})]})})}function h({provider:r,missingKeys:i,docsUrl:n,docsLabel:s}){return e.jsxs("div",{className:"mt-3 text-sm p-4 rounded-md border border-destructive/20 bg-destructive/5 text-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2 font-semibold text-destructive mb-2",children:[e.jsx(m.AlertCircle,{className:"w-4 h-4"}),e.jsx("span",{children:"Configuration Required"})]}),e.jsxs("p",{className:"mb-2",children:["The ",r," integration is missing the following environment variables:"]}),e.jsx("ul",{className:"list-disc list-inside bg-white/50 dark:bg-black/20 p-2 rounded mb-3 font-mono text-xs",children:i.map(a=>e.jsx("li",{children:a},a))}),e.jsx("p",{className:"mb-2",children:e.jsx("strong",{children:"How to fix:"})}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 ml-1 mb-3",children:[e.jsxs("li",{children:["Go to"," ",e.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"underline font-medium hover:text-destructive/80",children:s}),"."]}),e.jsx("li",{children:"Copy your API keys."}),e.jsxs("li",{children:["Open your ",e.jsx("code",{children:".env"})," (or variables settings in Vercel/Railway)."]}),e.jsx("li",{children:"Add the keys listed above."}),e.jsx("li",{children:"Restart your development server."})]})]})}exports.PaymentsClient=j;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs as r, jsx as e } from "react/jsx-runtime";
|
|
3
|
+
import { useState as u } from "react";
|
|
4
|
+
import { Card as b, CardHeader as f, CardTitle as g, CardDescription as v, CardContent as x, Checkbox as y, Label as N, Button as C } from "@nextblock-cms/ui";
|
|
5
|
+
import { CheckCircle2 as m, AlertCircle as k } from "lucide-react";
|
|
6
|
+
import { useFormStatus as P } from "react-dom";
|
|
7
|
+
function j({
|
|
8
|
+
initialEnabledProviders: i,
|
|
9
|
+
configStatus: t,
|
|
10
|
+
saveAction: d
|
|
11
|
+
}) {
|
|
12
|
+
const [s, a] = u(i), n = t?.stripe?.hasKeys, l = t?.freemius?.hasKeys;
|
|
13
|
+
return /* @__PURE__ */ r("form", { action: d, className: "space-y-6 max-w-3xl p-8", children: [
|
|
14
|
+
/* @__PURE__ */ e(
|
|
15
|
+
"input",
|
|
16
|
+
{
|
|
17
|
+
type: "hidden",
|
|
18
|
+
name: "stripe_enabled",
|
|
19
|
+
value: s.stripe ? "true" : "false"
|
|
20
|
+
}
|
|
21
|
+
),
|
|
22
|
+
/* @__PURE__ */ e(
|
|
23
|
+
"input",
|
|
24
|
+
{
|
|
25
|
+
type: "hidden",
|
|
26
|
+
name: "freemius_enabled",
|
|
27
|
+
value: s.freemius ? "true" : "false"
|
|
28
|
+
}
|
|
29
|
+
),
|
|
30
|
+
/* @__PURE__ */ r("div", { children: [
|
|
31
|
+
/* @__PURE__ */ e("h1", { className: "text-3xl font-bold tracking-tight", children: "Payment Settings" }),
|
|
32
|
+
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "Enable the payment providers your store needs. Physical products use Stripe and digital products use Freemius." })
|
|
33
|
+
] }),
|
|
34
|
+
/* @__PURE__ */ r(b, { children: [
|
|
35
|
+
/* @__PURE__ */ r(f, { children: [
|
|
36
|
+
/* @__PURE__ */ e(g, { children: "Payment Providers" }),
|
|
37
|
+
/* @__PURE__ */ e(v, { children: "You can run both providers at the same time. Each product picks its provider from its product type." })
|
|
38
|
+
] }),
|
|
39
|
+
/* @__PURE__ */ r(x, { className: "space-y-6", children: [
|
|
40
|
+
/* @__PURE__ */ e(
|
|
41
|
+
h,
|
|
42
|
+
{
|
|
43
|
+
id: "stripe-enabled",
|
|
44
|
+
label: "Stripe for Physical Products",
|
|
45
|
+
description: "Use Stripe Checkout for physical merchandise and other shippable goods.",
|
|
46
|
+
checked: s.stripe,
|
|
47
|
+
disabled: !n,
|
|
48
|
+
onCheckedChange: (o) => a((c) => ({
|
|
49
|
+
...c,
|
|
50
|
+
stripe: o
|
|
51
|
+
})),
|
|
52
|
+
ready: n,
|
|
53
|
+
children: n ? /* @__PURE__ */ r("div", { className: "mt-2 text-sm text-green-600 flex items-center gap-2", children: [
|
|
54
|
+
/* @__PURE__ */ e(m, { className: "w-4 h-4" }),
|
|
55
|
+
/* @__PURE__ */ e("span", { children: "Ready to process physical product checkout" })
|
|
56
|
+
] }) : /* @__PURE__ */ e(
|
|
57
|
+
p,
|
|
58
|
+
{
|
|
59
|
+
provider: "Stripe",
|
|
60
|
+
missingKeys: t.stripe.missing,
|
|
61
|
+
docsUrl: "https://dashboard.stripe.com/apikeys",
|
|
62
|
+
docsLabel: "Stripe Dashboard -> Developers -> API Keys"
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
),
|
|
67
|
+
/* @__PURE__ */ e(
|
|
68
|
+
h,
|
|
69
|
+
{
|
|
70
|
+
id: "freemius-enabled",
|
|
71
|
+
label: "Freemius for Digital Products",
|
|
72
|
+
description: "Use Freemius for software licenses, SaaS plans, and other digital products.",
|
|
73
|
+
checked: s.freemius,
|
|
74
|
+
disabled: !l,
|
|
75
|
+
onCheckedChange: (o) => a((c) => ({
|
|
76
|
+
...c,
|
|
77
|
+
freemius: o
|
|
78
|
+
})),
|
|
79
|
+
ready: l,
|
|
80
|
+
children: l ? /* @__PURE__ */ r("div", { className: "mt-2 text-sm text-green-600 flex items-center gap-2", children: [
|
|
81
|
+
/* @__PURE__ */ e(m, { className: "w-4 h-4" }),
|
|
82
|
+
/* @__PURE__ */ e("span", { children: "Ready to process digital product checkout" })
|
|
83
|
+
] }) : /* @__PURE__ */ e(
|
|
84
|
+
p,
|
|
85
|
+
{
|
|
86
|
+
provider: "Freemius",
|
|
87
|
+
missingKeys: t.freemius.missing,
|
|
88
|
+
docsUrl: "https://dashboard.freemius.com/",
|
|
89
|
+
docsLabel: "Freemius Dashboard -> Developers -> Credentials"
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
/* @__PURE__ */ e("div", { className: "flex justify-end pt-4", children: /* @__PURE__ */ e(w, {}) })
|
|
95
|
+
] })
|
|
96
|
+
] })
|
|
97
|
+
] });
|
|
98
|
+
}
|
|
99
|
+
function w() {
|
|
100
|
+
const { pending: i } = P();
|
|
101
|
+
return /* @__PURE__ */ e(C, { type: "submit", disabled: i, children: i ? "Saving..." : "Save Changes" });
|
|
102
|
+
}
|
|
103
|
+
function h({
|
|
104
|
+
id: i,
|
|
105
|
+
label: t,
|
|
106
|
+
description: d,
|
|
107
|
+
checked: s,
|
|
108
|
+
disabled: a,
|
|
109
|
+
ready: n,
|
|
110
|
+
onCheckedChange: l,
|
|
111
|
+
children: o
|
|
112
|
+
}) {
|
|
113
|
+
return /* @__PURE__ */ e("div", { className: "rounded-md border p-4", children: /* @__PURE__ */ r("div", { className: "flex items-start gap-3", children: [
|
|
114
|
+
/* @__PURE__ */ e(
|
|
115
|
+
y,
|
|
116
|
+
{
|
|
117
|
+
id: i,
|
|
118
|
+
checked: s,
|
|
119
|
+
disabled: a,
|
|
120
|
+
onCheckedChange: (c) => l(!!c),
|
|
121
|
+
className: "mt-1"
|
|
122
|
+
}
|
|
123
|
+
),
|
|
124
|
+
/* @__PURE__ */ r("div", { className: "grid gap-1.5 leading-none w-full", children: [
|
|
125
|
+
/* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-3 flex-wrap", children: [
|
|
126
|
+
/* @__PURE__ */ e(N, { htmlFor: i, className: "font-semibold text-base cursor-pointer", children: t }),
|
|
127
|
+
/* @__PURE__ */ e(
|
|
128
|
+
"span",
|
|
129
|
+
{
|
|
130
|
+
className: `text-xs font-medium ${s ? "text-foreground" : "text-muted-foreground"}`,
|
|
131
|
+
children: s ? "Enabled" : "Disabled"
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
] }),
|
|
135
|
+
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: d }),
|
|
136
|
+
!n && /* @__PURE__ */ e("p", { className: "text-xs text-amber-700", children: "This provider cannot be enabled until all required environment variables are present." }),
|
|
137
|
+
o
|
|
138
|
+
] })
|
|
139
|
+
] }) });
|
|
140
|
+
}
|
|
141
|
+
function p({
|
|
142
|
+
provider: i,
|
|
143
|
+
missingKeys: t,
|
|
144
|
+
docsUrl: d,
|
|
145
|
+
docsLabel: s
|
|
146
|
+
}) {
|
|
147
|
+
return /* @__PURE__ */ r("div", { className: "mt-3 text-sm p-4 rounded-md border border-destructive/20 bg-destructive/5 text-foreground", children: [
|
|
148
|
+
/* @__PURE__ */ r("div", { className: "flex items-center gap-2 font-semibold text-destructive mb-2", children: [
|
|
149
|
+
/* @__PURE__ */ e(k, { className: "w-4 h-4" }),
|
|
150
|
+
/* @__PURE__ */ e("span", { children: "Configuration Required" })
|
|
151
|
+
] }),
|
|
152
|
+
/* @__PURE__ */ r("p", { className: "mb-2", children: [
|
|
153
|
+
"The ",
|
|
154
|
+
i,
|
|
155
|
+
" integration is missing the following environment variables:"
|
|
156
|
+
] }),
|
|
157
|
+
/* @__PURE__ */ e("ul", { className: "list-disc list-inside bg-white/50 dark:bg-black/20 p-2 rounded mb-3 font-mono text-xs", children: t.map((a) => /* @__PURE__ */ e("li", { children: a }, a)) }),
|
|
158
|
+
/* @__PURE__ */ e("p", { className: "mb-2", children: /* @__PURE__ */ e("strong", { children: "How to fix:" }) }),
|
|
159
|
+
/* @__PURE__ */ r("ol", { className: "list-decimal list-inside space-y-1 ml-1 mb-3", children: [
|
|
160
|
+
/* @__PURE__ */ r("li", { children: [
|
|
161
|
+
"Go to",
|
|
162
|
+
" ",
|
|
163
|
+
/* @__PURE__ */ e(
|
|
164
|
+
"a",
|
|
165
|
+
{
|
|
166
|
+
href: d,
|
|
167
|
+
target: "_blank",
|
|
168
|
+
rel: "noopener noreferrer",
|
|
169
|
+
className: "underline font-medium hover:text-destructive/80",
|
|
170
|
+
children: s
|
|
171
|
+
}
|
|
172
|
+
),
|
|
173
|
+
"."
|
|
174
|
+
] }),
|
|
175
|
+
/* @__PURE__ */ e("li", { children: "Copy your API keys." }),
|
|
176
|
+
/* @__PURE__ */ r("li", { children: [
|
|
177
|
+
"Open your ",
|
|
178
|
+
/* @__PURE__ */ e("code", { children: ".env" }),
|
|
179
|
+
" (or variables settings in Vercel/Railway)."
|
|
180
|
+
] }),
|
|
181
|
+
/* @__PURE__ */ e("li", { children: "Add the keys listed above." }),
|
|
182
|
+
/* @__PURE__ */ e("li", { children: "Restart your development server." })
|
|
183
|
+
] })
|
|
184
|
+
] });
|
|
185
|
+
}
|
|
186
|
+
export {
|
|
187
|
+
j as PaymentsClient
|
|
188
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),u=require("./actions.cjs.js"),s=require("./queries.cjs.js"),o=require("./PaymentsClient.cjs.js");async function c(){const[n,e]=await Promise.all([s.getEnabledPaymentProviders(),s.getStoreConfigStatus()]);async function i(t){"use server";const r={stripe:t.get("stripe_enabled")==="true"&&e.stripe.hasKeys,freemius:t.get("freemius_enabled")==="true"&&e.freemius.hasKeys};await u.updatePaymentSettings(r)}return a.jsx(o.PaymentsClient,{initialEnabledProviders:n,configStatus:e,saveAction:i})}exports.PaymentsPage=c;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { updatePaymentSettings as a } from "./actions.es.js";
|
|
3
|
+
import { getEnabledPaymentProviders as o, getStoreConfigStatus as m } from "./queries.es.js";
|
|
4
|
+
import { PaymentsClient as u } from "./PaymentsClient.es.js";
|
|
5
|
+
async function P() {
|
|
6
|
+
const [s, e] = await Promise.all([
|
|
7
|
+
o(),
|
|
8
|
+
m()
|
|
9
|
+
]);
|
|
10
|
+
async function i(t) {
|
|
11
|
+
"use server";
|
|
12
|
+
const n = {
|
|
13
|
+
stripe: t.get("stripe_enabled") === "true" && e.stripe.hasKeys,
|
|
14
|
+
freemius: t.get("freemius_enabled") === "true" && e.freemius.hasKeys
|
|
15
|
+
};
|
|
16
|
+
await a(n);
|
|
17
|
+
}
|
|
18
|
+
return /* @__PURE__ */ r(
|
|
19
|
+
u,
|
|
20
|
+
{
|
|
21
|
+
initialEnabledProviders: s,
|
|
22
|
+
configStatus: e,
|
|
23
|
+
saveAction: i
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
P as PaymentsPage
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@nextblock-cms/db/server"),t=require("next/cache");async function n(o){const e=await i.createClient(),{data:{user:r}}=await e.auth.getUser();if(!r)throw new Error("Unauthorized");const{data:a}=await e.from("profiles").select("role").eq("id",r.id).single();if(!a||a.role!=="ADMIN")throw new Error("Forbidden");const{error:s}=await e.from("site_settings").upsert({key:"enabled_payment_providers",value:o});if(s)throw console.error("Error updating payment providers:",s),new Error("Failed to update settings");return t.revalidatePath("/cms/payments"),t.revalidatePath("/cms/taxes"),t.revalidatePath("/","layout"),{success:!0}}exports.updatePaymentSettings=n;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use server';
|
|
2
|
+
import { createClient as i } from "@nextblock-cms/db/server";
|
|
3
|
+
import { revalidatePath as r } from "next/cache";
|
|
4
|
+
async function p(s) {
|
|
5
|
+
const e = await i(), {
|
|
6
|
+
data: { user: t }
|
|
7
|
+
} = await e.auth.getUser();
|
|
8
|
+
if (!t)
|
|
9
|
+
throw new Error("Unauthorized");
|
|
10
|
+
const { data: a } = await e.from("profiles").select("role").eq("id", t.id).single();
|
|
11
|
+
if (!a || a.role !== "ADMIN")
|
|
12
|
+
throw new Error("Forbidden");
|
|
13
|
+
const { error: o } = await e.from("site_settings").upsert({
|
|
14
|
+
key: "enabled_payment_providers",
|
|
15
|
+
value: s
|
|
16
|
+
});
|
|
17
|
+
if (o)
|
|
18
|
+
throw console.error("Error updating payment providers:", o), new Error("Failed to update settings");
|
|
19
|
+
return r("/cms/payments"), r("/cms/taxes"), r("/", "layout"), { success: !0 };
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
p as updatePaymentSettings
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@nextblock-cms/db/server"),t=require("../../../types.cjs.js");async function E(){const e=[];process.env.STRIPE_SECRET_KEY||e.push("STRIPE_SECRET_KEY"),process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY||e.push("NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY"),process.env.STRIPE_WEBHOOK_SECRET||e.push("STRIPE_WEBHOOK_SECRET");const s=[];return process.env.FREEMIUS_PUBLIC_KEY||s.push("FREEMIUS_PUBLIC_KEY"),process.env.FREEMIUS_SECRET_KEY||s.push("FREEMIUS_SECRET_KEY"),{stripe:{hasKeys:e.length===0,missing:e},freemius:{hasKeys:s.length===0,missing:s}}}async function n(){const e=i.createClient(),{data:s,error:r}=await e.from("site_settings").select("value").eq("key","enabled_payment_providers").maybeSingle();return r||!s?{...t.DEFAULT_ENABLED_PAYMENT_PROVIDERS}:t.normalizeEnabledPaymentProviders(s.value)}async function a(){const e=await n();return e.stripe?"stripe":e.freemius?"freemius":"stripe"}exports.getEnabledPaymentProviders=n;exports.getPaymentSettings=a;exports.getStoreConfigStatus=E;
|