@nextblock-cms/ecom 0.8.1 → 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 -3224
- package/lib/CurrencyProvider.cjs.js +1 -0
- package/lib/CurrencyProvider.es.js +99 -0
- package/lib/cart-store.cjs.js +1 -0
- package/lib/cart-store.es.js +116 -0
- 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/lib/components/AddToCartButton.es.js +60 -0
- 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/lib/components/CartDrawer.es.js +119 -0
- package/lib/components/CartIcon.cjs.js +1 -0
- package/lib/components/CartIcon.es.js +34 -0
- package/lib/components/Checkout.cjs.js +1 -0
- package/lib/components/Checkout.es.js +987 -0
- 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/lib/components/CurrencySwitcher.es.js +18 -0
- 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/lib/components/FeaturedProduct.es.js +72 -0
- 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/SimpleTiptapRenderer.cjs.js +1 -0
- package/lib/components/SimpleTiptapRenderer.es.js +187 -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/lib/coupon-server.es.js +234 -0
- package/lib/coupons.cjs.js +1 -0
- package/lib/coupons.es.js +17 -0
- package/lib/currency-constants.cjs.js +1 -0
- package/lib/currency-constants.es.js +4 -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/currency.cjs.js +1 -0
- package/lib/currency.es.js +312 -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/lib/customer.es.js +58 -0
- 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/lib/server-actions/product-actions.es.js +16 -0
- package/lib/server-actions/shipping-actions.cjs.js +1 -0
- package/lib/server-actions/shipping-actions.es.js +27 -0
- 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/lib/states.es.js +127 -0
- 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/lib/trials.es.js +29 -0
- package/lib/types.cjs.js +1 -0
- package/lib/types.es.js +33 -0
- package/lib/use-cart.cjs.js +1 -0
- package/lib/use-cart.es.js +44 -0
- package/lib/variation-utils.cjs.js +1 -0
- package/lib/variation-utils.es.js +246 -0
- package/lib/zod-config.cjs.js +1 -0
- package/lib/zod-config.es.js +6 -0
- package/package.json +10 -5
- package/server.cjs.js +1 -110
- package/server.es.js +178 -6037
- package/invoice-ui-BJZfedDd.cjs +0 -332
- package/invoice-ui-GJ1ADAjn.js +0 -5759
- /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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),p=require("@nextblock-cms/ui/button"),j=require("@nextblock-cms/ui/input"),y=require("lucide-react");function k(s){const r=s.sku?.trim();return r?r.toUpperCase():`PRODUCT:${s.id}`}function v(s){const r=new Map;for(const o of s){const c=k(o),i=r.get(c);if(i){i.productIds.push(o.id);continue}r.set(c,{key:c,title:o.title,sku:o.sku?.trim()||"No SKU",thumbnailUrl:o.thumbnailUrl??null,productIds:[o.id]})}return[...r.values()]}function S({products:s,selectedProductIds:r=[]}){const o=a.useMemo(()=>new Set(r),[r]),[c,i]=a.useState(o),[u,b]=a.useState(""),d=a.useMemo(()=>v(s),[s]),h=a.useMemo(()=>{const t=u.trim().toLowerCase();return t?d.filter(n=>[n.title,n.sku].some(l=>l.toLowerCase().includes(t))):d},[d,u]),x=t=>{i(new Set(s.filter(n=>n.payment_provider===t).map(n=>n.id)))};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(p.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>i(new Set(s.map(t=>t.id))),children:"Select All"}),e.jsx(p.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>x("stripe"),children:"Stripe"}),e.jsx(p.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>x("freemius"),children:"Freemius"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(y.Search,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(j.Input,{type:"search",value:u,onChange:t=>b(t.target.value),placeholder:"Search products by title or SKU",className:"pl-9"})]}),e.jsxs("div",{className:"grid max-h-[420px] gap-2 overflow-y-auto rounded-lg border p-3 md:grid-cols-2",children:[h.map(t=>{const n=t.productIds.some(l=>c.has(l));return e.jsxs("label",{className:"flex cursor-pointer items-center gap-3 rounded-md px-2 py-2 hover:bg-muted/40",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:l=>{const m=new Set(c);for(const f of t.productIds)l.target.checked?m.add(f):m.delete(f);i(m)},className:"mt-0.5 h-4 w-4 rounded border-slate-300 text-primary focus:ring-primary"}),n?t.productIds.map(l=>e.jsx("input",{type:"hidden",name:"product_ids",value:l},l)):null,e.jsx("span",{className:"flex h-12 w-12 shrink-0 items-center justify-center overflow-hidden rounded-md border bg-muted",children:t.thumbnailUrl?e.jsx("img",{src:t.thumbnailUrl,alt:"",loading:"lazy",className:"h-full w-full object-cover"}):e.jsx(y.ImageIcon,{className:"h-5 w-5 text-muted-foreground","aria-hidden":"true"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block whitespace-normal break-words text-sm font-medium",children:t.title}),e.jsx("span",{className:"block font-mono text-xs text-muted-foreground",children:t.sku})]})]},t.key)}),h.length===0?e.jsx("div",{className:"px-2 py-8 text-center text-sm text-muted-foreground md:col-span-2",children:"No matching products."}):null]})]})}exports.ProductScopePicker=S;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs as c, jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo as p, useState as b } from "react";
|
|
4
|
+
import { Button as h } from "@nextblock-cms/ui/button";
|
|
5
|
+
import { Input as v } from "@nextblock-cms/ui/input";
|
|
6
|
+
import { Search as w, ImageIcon as g } from "lucide-react";
|
|
7
|
+
function N(r) {
|
|
8
|
+
const s = r.sku?.trim();
|
|
9
|
+
return s ? s.toUpperCase() : `PRODUCT:${r.id}`;
|
|
10
|
+
}
|
|
11
|
+
function S(r) {
|
|
12
|
+
const s = /* @__PURE__ */ new Map();
|
|
13
|
+
for (const o of r) {
|
|
14
|
+
const a = N(o), i = s.get(a);
|
|
15
|
+
if (i) {
|
|
16
|
+
i.productIds.push(o.id);
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
s.set(a, {
|
|
20
|
+
key: a,
|
|
21
|
+
title: o.title,
|
|
22
|
+
sku: o.sku?.trim() || "No SKU",
|
|
23
|
+
thumbnailUrl: o.thumbnailUrl ?? null,
|
|
24
|
+
productIds: [o.id]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return [...s.values()];
|
|
28
|
+
}
|
|
29
|
+
function P({
|
|
30
|
+
products: r,
|
|
31
|
+
selectedProductIds: s = []
|
|
32
|
+
}) {
|
|
33
|
+
const o = p(() => new Set(s), [s]), [a, i] = b(o), [d, k] = b(""), u = p(() => S(r), [r]), f = p(() => {
|
|
34
|
+
const e = d.trim().toLowerCase();
|
|
35
|
+
return e ? u.filter(
|
|
36
|
+
(n) => [n.title, n.sku].some((l) => l.toLowerCase().includes(e))
|
|
37
|
+
) : u;
|
|
38
|
+
}, [u, d]), x = (e) => {
|
|
39
|
+
i(
|
|
40
|
+
new Set(
|
|
41
|
+
r.filter((n) => n.payment_provider === e).map((n) => n.id)
|
|
42
|
+
)
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
return /* @__PURE__ */ c("div", { className: "space-y-3", children: [
|
|
46
|
+
/* @__PURE__ */ c("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
47
|
+
/* @__PURE__ */ t(
|
|
48
|
+
h,
|
|
49
|
+
{
|
|
50
|
+
type: "button",
|
|
51
|
+
variant: "outline",
|
|
52
|
+
size: "sm",
|
|
53
|
+
onClick: () => i(new Set(r.map((e) => e.id))),
|
|
54
|
+
children: "Select All"
|
|
55
|
+
}
|
|
56
|
+
),
|
|
57
|
+
/* @__PURE__ */ t(h, { type: "button", variant: "outline", size: "sm", onClick: () => x("stripe"), children: "Stripe" }),
|
|
58
|
+
/* @__PURE__ */ t(h, { type: "button", variant: "outline", size: "sm", onClick: () => x("freemius"), children: "Freemius" })
|
|
59
|
+
] }),
|
|
60
|
+
/* @__PURE__ */ c("div", { className: "relative", children: [
|
|
61
|
+
/* @__PURE__ */ t(w, { className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
|
|
62
|
+
/* @__PURE__ */ t(
|
|
63
|
+
v,
|
|
64
|
+
{
|
|
65
|
+
type: "search",
|
|
66
|
+
value: d,
|
|
67
|
+
onChange: (e) => k(e.target.value),
|
|
68
|
+
placeholder: "Search products by title or SKU",
|
|
69
|
+
className: "pl-9"
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
] }),
|
|
73
|
+
/* @__PURE__ */ c("div", { className: "grid max-h-[420px] gap-2 overflow-y-auto rounded-lg border p-3 md:grid-cols-2", children: [
|
|
74
|
+
f.map((e) => {
|
|
75
|
+
const n = e.productIds.some((l) => a.has(l));
|
|
76
|
+
return /* @__PURE__ */ c(
|
|
77
|
+
"label",
|
|
78
|
+
{
|
|
79
|
+
className: "flex cursor-pointer items-center gap-3 rounded-md px-2 py-2 hover:bg-muted/40",
|
|
80
|
+
children: [
|
|
81
|
+
/* @__PURE__ */ t(
|
|
82
|
+
"input",
|
|
83
|
+
{
|
|
84
|
+
type: "checkbox",
|
|
85
|
+
checked: n,
|
|
86
|
+
onChange: (l) => {
|
|
87
|
+
const m = new Set(a);
|
|
88
|
+
for (const y of e.productIds)
|
|
89
|
+
l.target.checked ? m.add(y) : m.delete(y);
|
|
90
|
+
i(m);
|
|
91
|
+
},
|
|
92
|
+
className: "mt-0.5 h-4 w-4 rounded border-slate-300 text-primary focus:ring-primary"
|
|
93
|
+
}
|
|
94
|
+
),
|
|
95
|
+
n ? e.productIds.map((l) => /* @__PURE__ */ t("input", { type: "hidden", name: "product_ids", value: l }, l)) : null,
|
|
96
|
+
/* @__PURE__ */ t("span", { className: "flex h-12 w-12 shrink-0 items-center justify-center overflow-hidden rounded-md border bg-muted", children: e.thumbnailUrl ? /* @__PURE__ */ t(
|
|
97
|
+
"img",
|
|
98
|
+
{
|
|
99
|
+
src: e.thumbnailUrl,
|
|
100
|
+
alt: "",
|
|
101
|
+
loading: "lazy",
|
|
102
|
+
className: "h-full w-full object-cover"
|
|
103
|
+
}
|
|
104
|
+
) : /* @__PURE__ */ t(g, { className: "h-5 w-5 text-muted-foreground", "aria-hidden": "true" }) }),
|
|
105
|
+
/* @__PURE__ */ c("span", { className: "min-w-0 flex-1", children: [
|
|
106
|
+
/* @__PURE__ */ t("span", { className: "block whitespace-normal break-words text-sm font-medium", children: e.title }),
|
|
107
|
+
/* @__PURE__ */ t("span", { className: "block font-mono text-xs text-muted-foreground", children: e.sku })
|
|
108
|
+
] })
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
e.key
|
|
112
|
+
);
|
|
113
|
+
}),
|
|
114
|
+
f.length === 0 ? /* @__PURE__ */ t("div", { className: "px-2 py-8 text-center text-sm text-muted-foreground md:col-span-2", children: "No matching products." }) : null
|
|
115
|
+
] })
|
|
116
|
+
] });
|
|
117
|
+
}
|
|
118
|
+
export {
|
|
119
|
+
P as ProductScopePicker
|
|
120
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@nextblock-cms/db/server"),w=require("@nextblock-cms/utils"),c=require("next/cache"),g=require("next/navigation"),C=require("../../../coupons.cjs.js"),s=require("../../../freemius-coupons.cjs.js");async function u(){const e=l.createClient(),{data:{user:o}}=await e.auth.getUser();if(!o)throw new Error("Unauthorized");const{data:t}=await e.from("profiles").select("role").eq("id",o.id).single();if(t?.role!=="ADMIN")throw new Error("Forbidden");return l.getServiceRoleSupabaseClient()}function i(e){return(typeof e=="string"?e.trim():"")||null}function m(e){const o=i(e);if(!o)return null;const t=new Date(o);return Number.isNaN(t.getTime())?null:t.toISOString()}function h(e){const o=i(e.value),t=o?Number.parseFloat(o):Number.NaN;if(!Number.isFinite(t)||t<=0)throw new Error("Discount amount must be greater than zero.");return e.discountType==="fixed"?w.majorUnitAmountToMinor(t,e.currencyCode):Math.round(t)}function v(e,o){return e.getAll(o).some(t=>t==="true")}function f(e){const o=C.normalizeCouponCode(i(e.get("code"))),t=i(e.get("name")),n=i(e.get("provider_scope"))||"all",r=i(e.get("discount_type"))||"percent",y=w.normalizeCurrencyCode(i(e.get("currency_code"))),a=h({value:e.get("discount_amount"),discountType:r,currencyCode:y}),d=i(e.get("redemption_limit"));if(!o)throw new Error("Coupon code is required.");if(!t)throw new Error("Coupon name is required.");if(r==="percent"&&a>100)throw new Error("Percent discounts cannot exceed 100.");return{coupon:{code:o,name:t,internal_note:i(e.get("internal_note")),provider_scope:n,discount_type:r,discount_amount:a,is_active:v(e,"is_active"),starts_at:m(e.get("starts_at")),ends_at:m(e.get("ends_at")),redemption_limit:d?Number.parseInt(d,10):null,freemius_sync_status:n==="stripe"?"not_required":"pending",freemius_sync_error:null},productIds:e.getAll("product_ids").map(p=>typeof p=="string"?p.trim():"").filter(Boolean)}}async function _(e){if(await e.client.from("coupon_products").delete().eq("coupon_id",e.couponId),e.productIds.length===0)return;const{error:o}=await e.client.from("coupon_products").insert(e.productIds.map(t=>({coupon_id:e.couponId,product_id:t})));if(o)throw new Error(o.message)}async function A(e){const o=await u(),t=f(e),{data:n,error:r}=await o.from("coupons").insert(t.coupon).select("id").single();if(r||!n)throw new Error(r?.message||"Failed to create coupon.");await _({client:o,couponId:n.id,productIds:t.productIds}),await s.syncCouponToFreemius({couponId:n.id,client:o}),c.revalidatePath("/cms/coupons"),g.redirect("/cms/coupons")}async function q(e,o){const t=await u(),n=f(o),{error:r}=await t.from("coupons").update(n.coupon).eq("id",e);if(r)throw new Error(r.message);await _({client:t,couponId:e,productIds:n.productIds}),n.coupon.provider_scope==="stripe"?await s.deleteCouponFromFreemius({couponId:e,client:t}):await s.syncCouponToFreemius({couponId:e,client:t}),c.revalidatePath("/cms/coupons"),c.revalidatePath(`/cms/coupons/${e}/edit`),g.redirect("/cms/coupons")}async function b(e,o){const t=await u(),{error:n}=await t.from("coupons").update({is_active:o,freemius_sync_status:"pending",updated_at:new Date().toISOString()}).eq("id",e);if(n)throw new Error(n.message);await s.syncCouponToFreemius({couponId:e,client:t}),c.revalidatePath("/cms/coupons")}async function F(e){const o=await u();await s.syncCouponToFreemius({couponId:e,client:o}),c.revalidatePath("/cms/coupons"),c.revalidatePath(`/cms/coupons/${e}/edit`)}async function E(e){const o=await u();await s.deleteCouponFromFreemius({couponId:e,client:o});const{error:t}=await o.from("coupons").delete().eq("id",e);if(t)throw new Error(t.message);c.revalidatePath("/cms/coupons")}exports.createCouponAction=A;exports.deleteCouponAction=E;exports.syncCouponAction=F;exports.toggleCouponActiveAction=b;exports.updateCouponAction=q;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
'use server';
|
|
2
|
+
import { createClient as y, getServiceRoleSupabaseClient as C } from "@nextblock-cms/db/server";
|
|
3
|
+
import { normalizeCurrencyCode as h, majorUnitAmountToMinor as A } from "@nextblock-cms/utils";
|
|
4
|
+
import { revalidatePath as c } from "next/cache";
|
|
5
|
+
import { redirect as l } from "next/navigation";
|
|
6
|
+
import { normalizeCouponCode as E } from "../../../coupons.es.js";
|
|
7
|
+
import { syncCouponToFreemius as a, deleteCouponFromFreemius as w } from "../../../freemius-coupons.es.js";
|
|
8
|
+
async function s() {
|
|
9
|
+
const e = y(), {
|
|
10
|
+
data: { user: o }
|
|
11
|
+
} = await e.auth.getUser();
|
|
12
|
+
if (!o)
|
|
13
|
+
throw new Error("Unauthorized");
|
|
14
|
+
const { data: t } = await e.from("profiles").select("role").eq("id", o.id).single();
|
|
15
|
+
if (t?.role !== "ADMIN")
|
|
16
|
+
throw new Error("Forbidden");
|
|
17
|
+
return C();
|
|
18
|
+
}
|
|
19
|
+
function i(e) {
|
|
20
|
+
return (typeof e == "string" ? e.trim() : "") || null;
|
|
21
|
+
}
|
|
22
|
+
function m(e) {
|
|
23
|
+
const o = i(e);
|
|
24
|
+
if (!o)
|
|
25
|
+
return null;
|
|
26
|
+
const t = new Date(o);
|
|
27
|
+
return Number.isNaN(t.getTime()) ? null : t.toISOString();
|
|
28
|
+
}
|
|
29
|
+
function b(e) {
|
|
30
|
+
const o = i(e.value), t = o ? Number.parseFloat(o) : Number.NaN;
|
|
31
|
+
if (!Number.isFinite(t) || t <= 0)
|
|
32
|
+
throw new Error("Discount amount must be greater than zero.");
|
|
33
|
+
return e.discountType === "fixed" ? A(t, e.currencyCode) : Math.round(t);
|
|
34
|
+
}
|
|
35
|
+
function v(e, o) {
|
|
36
|
+
return e.getAll(o).some((t) => t === "true");
|
|
37
|
+
}
|
|
38
|
+
function f(e) {
|
|
39
|
+
const o = E(i(e.get("code"))), t = i(e.get("name")), n = i(e.get("provider_scope")) || "all", r = i(e.get("discount_type")) || "percent", _ = h(i(e.get("currency_code"))), u = b({
|
|
40
|
+
value: e.get("discount_amount"),
|
|
41
|
+
discountType: r,
|
|
42
|
+
currencyCode: _
|
|
43
|
+
}), d = i(e.get("redemption_limit"));
|
|
44
|
+
if (!o)
|
|
45
|
+
throw new Error("Coupon code is required.");
|
|
46
|
+
if (!t)
|
|
47
|
+
throw new Error("Coupon name is required.");
|
|
48
|
+
if (r === "percent" && u > 100)
|
|
49
|
+
throw new Error("Percent discounts cannot exceed 100.");
|
|
50
|
+
return {
|
|
51
|
+
coupon: {
|
|
52
|
+
code: o,
|
|
53
|
+
name: t,
|
|
54
|
+
internal_note: i(e.get("internal_note")),
|
|
55
|
+
provider_scope: n,
|
|
56
|
+
discount_type: r,
|
|
57
|
+
discount_amount: u,
|
|
58
|
+
is_active: v(e, "is_active"),
|
|
59
|
+
starts_at: m(e.get("starts_at")),
|
|
60
|
+
ends_at: m(e.get("ends_at")),
|
|
61
|
+
redemption_limit: d ? Number.parseInt(d, 10) : null,
|
|
62
|
+
freemius_sync_status: n === "stripe" ? "not_required" : "pending",
|
|
63
|
+
freemius_sync_error: null
|
|
64
|
+
},
|
|
65
|
+
productIds: e.getAll("product_ids").map((p) => typeof p == "string" ? p.trim() : "").filter(Boolean)
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
async function g(e) {
|
|
69
|
+
if (await e.client.from("coupon_products").delete().eq("coupon_id", e.couponId), e.productIds.length === 0)
|
|
70
|
+
return;
|
|
71
|
+
const { error: o } = await e.client.from("coupon_products").insert(
|
|
72
|
+
e.productIds.map((t) => ({
|
|
73
|
+
coupon_id: e.couponId,
|
|
74
|
+
product_id: t
|
|
75
|
+
}))
|
|
76
|
+
);
|
|
77
|
+
if (o)
|
|
78
|
+
throw new Error(o.message);
|
|
79
|
+
}
|
|
80
|
+
async function T(e) {
|
|
81
|
+
const o = await s(), t = f(e), { data: n, error: r } = await o.from("coupons").insert(t.coupon).select("id").single();
|
|
82
|
+
if (r || !n)
|
|
83
|
+
throw new Error(r?.message || "Failed to create coupon.");
|
|
84
|
+
await g({
|
|
85
|
+
client: o,
|
|
86
|
+
couponId: n.id,
|
|
87
|
+
productIds: t.productIds
|
|
88
|
+
}), await a({ couponId: n.id, client: o }), c("/cms/coupons"), l("/cms/coupons");
|
|
89
|
+
}
|
|
90
|
+
async function z(e, o) {
|
|
91
|
+
const t = await s(), n = f(o), { error: r } = await t.from("coupons").update(n.coupon).eq("id", e);
|
|
92
|
+
if (r)
|
|
93
|
+
throw new Error(r.message);
|
|
94
|
+
await g({
|
|
95
|
+
client: t,
|
|
96
|
+
couponId: e,
|
|
97
|
+
productIds: n.productIds
|
|
98
|
+
}), n.coupon.provider_scope === "stripe" ? await w({ couponId: e, client: t }) : await a({ couponId: e, client: t }), c("/cms/coupons"), c(`/cms/coupons/${e}/edit`), l("/cms/coupons");
|
|
99
|
+
}
|
|
100
|
+
async function P(e, o) {
|
|
101
|
+
const t = await s(), { error: n } = await t.from("coupons").update({
|
|
102
|
+
is_active: o,
|
|
103
|
+
freemius_sync_status: "pending",
|
|
104
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
105
|
+
}).eq("id", e);
|
|
106
|
+
if (n)
|
|
107
|
+
throw new Error(n.message);
|
|
108
|
+
await a({ couponId: e, client: t }), c("/cms/coupons");
|
|
109
|
+
}
|
|
110
|
+
async function M(e) {
|
|
111
|
+
const o = await s();
|
|
112
|
+
await a({ couponId: e, client: o }), c("/cms/coupons"), c(`/cms/coupons/${e}/edit`);
|
|
113
|
+
}
|
|
114
|
+
async function U(e) {
|
|
115
|
+
const o = await s();
|
|
116
|
+
await w({ couponId: e, client: o });
|
|
117
|
+
const { error: t } = await o.from("coupons").delete().eq("id", e);
|
|
118
|
+
if (t)
|
|
119
|
+
throw new Error(t.message);
|
|
120
|
+
c("/cms/coupons");
|
|
121
|
+
}
|
|
122
|
+
export {
|
|
123
|
+
T as createCouponAction,
|
|
124
|
+
U as deleteCouponAction,
|
|
125
|
+
M as syncCouponAction,
|
|
126
|
+
P as toggleCouponActiveAction,
|
|
127
|
+
z as updateCouponAction
|
|
128
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function u(r){return Array.isArray(r)?r[0]??null:r??null}const i=process.env.NEXT_PUBLIC_R2_BASE_URL||"";function l(r){return r?r.startsWith("http")||!i?r:`${i.replace(/\/+$/,"")}/${r.replace(/^\/+/,"")}`:null}function a(r){const e=Array.isArray(r.product_media)?[...r.product_media].sort((t,o)=>(t.sort_order??0)-(o.sort_order??0)):[],n=e[0]?.media?.file_path||e[0]?.media?.object_key||null;return l(n)}function s(r){return(r||[]).map(e=>({id:e.id,title:e.title,sku:e.sku??null,payment_provider:e.payment_provider||"stripe",freemius_product_id:e.freemius_product_id??null,thumbnailUrl:a(e),language:u(e.language)}))}exports.normalizeCouponProductOptions=s;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
function l(r) {
|
|
2
|
+
return Array.isArray(r) ? r[0] ?? null : r ?? null;
|
|
3
|
+
}
|
|
4
|
+
const i = process.env.NEXT_PUBLIC_R2_BASE_URL || "";
|
|
5
|
+
function o(r) {
|
|
6
|
+
return r ? r.startsWith("http") || !i ? r : `${i.replace(/\/+$/, "")}/${r.replace(/^\/+/, "")}` : null;
|
|
7
|
+
}
|
|
8
|
+
function a(r) {
|
|
9
|
+
const e = Array.isArray(r.product_media) ? [...r.product_media].sort(
|
|
10
|
+
(t, u) => (t.sort_order ?? 0) - (u.sort_order ?? 0)
|
|
11
|
+
) : [], n = e[0]?.media?.file_path || e[0]?.media?.object_key || null;
|
|
12
|
+
return o(n);
|
|
13
|
+
}
|
|
14
|
+
function s(r) {
|
|
15
|
+
return (r || []).map((e) => ({
|
|
16
|
+
id: e.id,
|
|
17
|
+
title: e.title,
|
|
18
|
+
sku: e.sku ?? null,
|
|
19
|
+
payment_provider: e.payment_provider || "stripe",
|
|
20
|
+
freemius_product_id: e.freemius_product_id ?? null,
|
|
21
|
+
thumbnailUrl: a(e),
|
|
22
|
+
language: l(e.language)
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
s as normalizeCouponProductOptions
|
|
27
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),t=require("@nextblock-cms/ui"),r=require("lucide-react"),l=require("sonner"),b=require("./export-actions.cjs.js"),c=require("../../../export-helpers.cjs.js");function D(){const[g,p]=s.useState(!1),[x,d]=s.useState(!1),[n,m]=s.useState(""),[o,h]=s.useState(""),[u,j]=s.useState("general_ledger"),y=async()=>{if(!n||!o){l.toast.error("Please select both start and end dates");return}d(!0);try{l.toast.info("Generating report...");const a=await b.fetchOrderReportData(n,o);if(!a||a.length===0){l.toast.error("No orders found for the selected date range"),d(!1);return}let i=[];const f=`report_${u}_${n}_to_${o}`;switch(u){case"general_ledger":i=c.mapGeneralSalesLedger(a);break;case"tax_liability":i=c.mapTaxLiabilitySummary(a);break;case"currency_summary":i=c.mapMultiCurrencyRevenue(a);break}c.generateCSV(i,`${f}.csv`),l.toast.success("Download complete!"),p(!1)}catch(a){console.error("Export error:",a),l.toast.error("Failed to generate report")}finally{d(!1)}};return e.jsxs(t.Dialog,{open:g,onOpenChange:p,children:[e.jsx(t.DialogTrigger,{asChild:!0,children:e.jsxs(t.Button,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(r.Download,{className:"h-4 w-4"}),"Export Reports"]})}),e.jsxs(t.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(t.DialogHeader,{children:[e.jsxs(t.DialogTitle,{className:"flex items-center gap-2",children:[e.jsx(r.FileDown,{className:"h-5 w-5 text-blue-600"}),"Accounting Reports"]}),e.jsx(t.DialogDescription,{children:"Generate and download accountant-friendly order reports."})]}),e.jsxs("div",{className:"grid gap-6 py-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(t.Label,{htmlFor:"start-date",className:"text-xs font-semibold uppercase text-gray-500 tracking-wider",children:"Start Date"}),e.jsxs("div",{className:"relative",children:[e.jsx(t.Input,{id:"start-date",type:"date",value:n,onChange:a=>m(a.target.value),className:"pl-8"}),e.jsx(r.Calendar,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(t.Label,{htmlFor:"end-date",className:"text-xs font-semibold uppercase text-gray-500 tracking-wider",children:"End Date"}),e.jsxs("div",{className:"relative",children:[e.jsx(t.Input,{id:"end-date",type:"date",value:o,onChange:a=>h(a.target.value),className:"pl-8"}),e.jsx(r.Calendar,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(t.Label,{htmlFor:"report-type",className:"text-xs font-semibold uppercase text-gray-500 tracking-wider",children:"Report Type"}),e.jsxs(t.Select,{value:u,onValueChange:a=>j(a),children:[e.jsx(t.SelectTrigger,{id:"report-type",className:"w-full",children:e.jsx(t.SelectValue,{placeholder:"Select report type"})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"general_ledger",children:"General Sales Ledger"}),e.jsx(t.SelectItem,{value:"tax_liability",children:"Tax Liability Summary"}),e.jsx(t.SelectItem,{value:"currency_summary",children:"Multi-Currency Revenue Summary"})]})]})]})]}),e.jsx(t.DialogFooter,{children:e.jsx(t.Button,{onClick:y,disabled:x,className:"w-full bg-blue-600 hover:bg-blue-700 text-white",children:x?e.jsxs(e.Fragment,{children:[e.jsx(r.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(r.Download,{className:"mr-2 h-4 w-4"}),"Download Report"]})})})]})]})}exports.ExportReportsDialog=D;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs as a, jsx as e, Fragment as h } from "react/jsx-runtime";
|
|
3
|
+
import { useState as t } from "react";
|
|
4
|
+
import { Dialog as S, DialogTrigger as C, Button as u, DialogContent as _, DialogHeader as R, DialogTitle as T, DialogDescription as k, Label as d, Input as f, Select as F, SelectTrigger as L, SelectValue as E, SelectContent as G, SelectItem as m, DialogFooter as $ } from "@nextblock-cms/ui";
|
|
5
|
+
import { Download as y, FileDown as O, Calendar as x, Loader2 as V } from "lucide-react";
|
|
6
|
+
import { toast as l } from "sonner";
|
|
7
|
+
import { fetchOrderReportData as j } from "./export-actions.es.js";
|
|
8
|
+
import { mapMultiCurrencyRevenue as I, mapTaxLiabilitySummary as M, mapGeneralSalesLedger as A, generateCSV as B } from "../../../export-helpers.es.js";
|
|
9
|
+
function W() {
|
|
10
|
+
const [N, p] = t(!1), [g, i] = t(!1), [n, D] = t(""), [o, v] = t(""), [c, w] = t("general_ledger");
|
|
11
|
+
return /* @__PURE__ */ a(S, { open: N, onOpenChange: p, children: [
|
|
12
|
+
/* @__PURE__ */ e(C, { asChild: !0, children: /* @__PURE__ */ a(u, { variant: "outline", className: "flex items-center gap-2", children: [
|
|
13
|
+
/* @__PURE__ */ e(y, { className: "h-4 w-4" }),
|
|
14
|
+
"Export Reports"
|
|
15
|
+
] }) }),
|
|
16
|
+
/* @__PURE__ */ a(_, { className: "sm:max-w-[425px]", children: [
|
|
17
|
+
/* @__PURE__ */ a(R, { children: [
|
|
18
|
+
/* @__PURE__ */ a(T, { className: "flex items-center gap-2", children: [
|
|
19
|
+
/* @__PURE__ */ e(O, { className: "h-5 w-5 text-blue-600" }),
|
|
20
|
+
"Accounting Reports"
|
|
21
|
+
] }),
|
|
22
|
+
/* @__PURE__ */ e(k, { children: "Generate and download accountant-friendly order reports." })
|
|
23
|
+
] }),
|
|
24
|
+
/* @__PURE__ */ a("div", { className: "grid gap-6 py-4", children: [
|
|
25
|
+
/* @__PURE__ */ a("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
26
|
+
/* @__PURE__ */ a("div", { className: "grid gap-2", children: [
|
|
27
|
+
/* @__PURE__ */ e(d, { htmlFor: "start-date", className: "text-xs font-semibold uppercase text-gray-500 tracking-wider", children: "Start Date" }),
|
|
28
|
+
/* @__PURE__ */ a("div", { className: "relative", children: [
|
|
29
|
+
/* @__PURE__ */ e(
|
|
30
|
+
f,
|
|
31
|
+
{
|
|
32
|
+
id: "start-date",
|
|
33
|
+
type: "date",
|
|
34
|
+
value: n,
|
|
35
|
+
onChange: (r) => D(r.target.value),
|
|
36
|
+
className: "pl-8"
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
/* @__PURE__ */ e(x, { className: "absolute left-2.5 top-2.5 h-4 w-4 text-gray-400" })
|
|
40
|
+
] })
|
|
41
|
+
] }),
|
|
42
|
+
/* @__PURE__ */ a("div", { className: "grid gap-2", children: [
|
|
43
|
+
/* @__PURE__ */ e(d, { htmlFor: "end-date", className: "text-xs font-semibold uppercase text-gray-500 tracking-wider", children: "End Date" }),
|
|
44
|
+
/* @__PURE__ */ a("div", { className: "relative", children: [
|
|
45
|
+
/* @__PURE__ */ e(
|
|
46
|
+
f,
|
|
47
|
+
{
|
|
48
|
+
id: "end-date",
|
|
49
|
+
type: "date",
|
|
50
|
+
value: o,
|
|
51
|
+
onChange: (r) => v(r.target.value),
|
|
52
|
+
className: "pl-8"
|
|
53
|
+
}
|
|
54
|
+
),
|
|
55
|
+
/* @__PURE__ */ e(x, { className: "absolute left-2.5 top-2.5 h-4 w-4 text-gray-400" })
|
|
56
|
+
] })
|
|
57
|
+
] })
|
|
58
|
+
] }),
|
|
59
|
+
/* @__PURE__ */ a("div", { className: "grid gap-2", children: [
|
|
60
|
+
/* @__PURE__ */ e(d, { htmlFor: "report-type", className: "text-xs font-semibold uppercase text-gray-500 tracking-wider", children: "Report Type" }),
|
|
61
|
+
/* @__PURE__ */ a(
|
|
62
|
+
F,
|
|
63
|
+
{
|
|
64
|
+
value: c,
|
|
65
|
+
onValueChange: (r) => w(r),
|
|
66
|
+
children: [
|
|
67
|
+
/* @__PURE__ */ e(L, { id: "report-type", className: "w-full", children: /* @__PURE__ */ e(E, { placeholder: "Select report type" }) }),
|
|
68
|
+
/* @__PURE__ */ a(G, { children: [
|
|
69
|
+
/* @__PURE__ */ e(m, { value: "general_ledger", children: "General Sales Ledger" }),
|
|
70
|
+
/* @__PURE__ */ e(m, { value: "tax_liability", children: "Tax Liability Summary" }),
|
|
71
|
+
/* @__PURE__ */ e(m, { value: "currency_summary", children: "Multi-Currency Revenue Summary" })
|
|
72
|
+
] })
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
] })
|
|
77
|
+
] }),
|
|
78
|
+
/* @__PURE__ */ e($, { children: /* @__PURE__ */ e(
|
|
79
|
+
u,
|
|
80
|
+
{
|
|
81
|
+
onClick: async () => {
|
|
82
|
+
if (!n || !o) {
|
|
83
|
+
l.error("Please select both start and end dates");
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
i(!0);
|
|
87
|
+
try {
|
|
88
|
+
l.info("Generating report...");
|
|
89
|
+
const r = await j(n, o);
|
|
90
|
+
if (!r || r.length === 0) {
|
|
91
|
+
l.error("No orders found for the selected date range"), i(!1);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
let s = [];
|
|
95
|
+
const b = `report_${c}_${n}_to_${o}`;
|
|
96
|
+
switch (c) {
|
|
97
|
+
case "general_ledger":
|
|
98
|
+
s = A(r);
|
|
99
|
+
break;
|
|
100
|
+
case "tax_liability":
|
|
101
|
+
s = M(r);
|
|
102
|
+
break;
|
|
103
|
+
case "currency_summary":
|
|
104
|
+
s = I(r);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
B(s, `${b}.csv`), l.success("Download complete!"), p(!1);
|
|
108
|
+
} catch (r) {
|
|
109
|
+
console.error("Export error:", r), l.error("Failed to generate report");
|
|
110
|
+
} finally {
|
|
111
|
+
i(!1);
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
disabled: g,
|
|
115
|
+
className: "w-full bg-blue-600 hover:bg-blue-700 text-white",
|
|
116
|
+
children: g ? /* @__PURE__ */ a(h, { children: [
|
|
117
|
+
/* @__PURE__ */ e(V, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
118
|
+
"Generating..."
|
|
119
|
+
] }) : /* @__PURE__ */ a(h, { children: [
|
|
120
|
+
/* @__PURE__ */ e(y, { className: "mr-2 h-4 w-4" }),
|
|
121
|
+
"Download Report"
|
|
122
|
+
] })
|
|
123
|
+
}
|
|
124
|
+
) })
|
|
125
|
+
] })
|
|
126
|
+
] });
|
|
127
|
+
}
|
|
128
|
+
export {
|
|
129
|
+
W as ExportReportsDialog
|
|
130
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("next/link"),x=require("next/navigation"),m=require("../../../components/InvoiceViewerShell.cjs.js"),u=require("../../../invoice-server.cjs.js"),p=require("../../../invoice-ui.cjs.js"),g=require("./actions.cjs.js"),b=require("./OrderPrintButton.cjs.js"),h=require("./OrderStatusForm.cjs.js"),i=(a,r="usd")=>new Intl.NumberFormat("en-US",{style:"currency",currency:r}).format(a/100);async function f({params:a}){const{id:r}=await a,[t,s]=await Promise.all([g.getOrderDetails(r),u.getInvoicePresentationData(r).catch(()=>null)]);t||x.notFound();const l=s?.order.customer_details??t.customer_details,d=p.buildInvoiceDocumentLabels(c=>c);return e.jsxs("div",{className:"mx-auto w-full max-w-6xl px-4 py-10 md:px-6",children:[e.jsxs("div",{className:"flex flex-col gap-4 border-b pb-6 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(o,{href:"/cms/orders",className:"hover:underline",children:"Orders"}),e.jsx("span",{children:"/"}),e.jsx("span",{className:"font-mono",children:t.id})]}),e.jsxs("h1",{className:"flex flex-wrap items-center gap-3 text-3xl font-bold tracking-tight",children:["Order",e.jsx(y,{status:t.status,size:"lg"})]}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Review the finalized invoice, customer details, and payment metadata in one place."})]}),e.jsx("div",{className:"w-full max-w-md",children:e.jsx(h.OrderStatusForm,{orderId:r,currentStatus:t.status})})]}),e.jsxs("div",{className:"mt-6 grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-lg border bg-white p-4 dark:border-slate-800 dark:bg-slate-900",children:[e.jsx("h3",{className:"mb-3 text-[11px] font-semibold uppercase tracking-[0.18em] text-slate-500",children:"Customer"}),e.jsxs("div",{className:"space-y-2 text-sm",children:[l?.name?e.jsx("p",{className:"font-semibold text-gray-900 dark:text-white",children:l.name}):null,l?.email?e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:l.email}):null,l?.phone?e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:l.phone}):null,!l?.name&&!l?.email&&!l?.phone?e.jsx("p",{className:"italic text-gray-400",children:"No contact info captured."}):null,t.user_id?e.jsxs("p",{className:"pt-1 font-mono text-[10px] uppercase tracking-wider text-gray-400",children:["User ID: ",t.user_id.slice(0,13),"..."]}):null]})]}),e.jsxs("div",{className:"rounded-lg border bg-white p-4 dark:border-slate-800 dark:bg-slate-900",children:[e.jsx("h3",{className:"mb-3 text-[11px] font-semibold uppercase tracking-[0.18em] text-slate-500",children:"Payment Details"}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsx(n,{label:"Provider",value:t.provider||"stripe",capitalize:!0}),e.jsx(n,{label:"Currency",value:(t.currency||"usd").toUpperCase()}),e.jsx(n,{label:"Created",value:new Date(t.created_at||"").toLocaleDateString()}),e.jsx(n,{label:"Invoice #",value:s?.order.invoice_number||"Pending assignment"}),e.jsx(n,{label:"Paid on",value:s?.order.paid_at?new Date(s.order.paid_at).toLocaleString():"Pending payment"}),e.jsx(n,{label:"Total",value:typeof t.total=="number"?i(t.total,t.currency||"usd"):"--"}),t.discount_total?e.jsx(n,{label:"Discount",value:`${t.coupon_code?`${t.coupon_code} `:""}-${i(t.discount_total,t.currency||"usd")}`}):null,t.stripe_session_id?e.jsxs("div",{className:"mt-3 border-t pt-3 dark:border-slate-800",children:[e.jsx("p",{className:"mb-1 text-xs text-gray-500",children:"Session ID"}),e.jsx("p",{className:"break-all rounded bg-gray-50 p-1 font-mono text-xs dark:bg-slate-800",children:t.stripe_session_id})]}):null]})]})]}),e.jsx("div",{className:"mt-6 flex justify-end print:hidden",children:e.jsx(b.OrderPrintButton,{disabled:!s})}),e.jsx(m.InvoiceViewerShell,{invoice:s,labels:d,locale:"en-US",title:s?.order.invoice_number||"Order invoice",description:"Open the printable invoice below and update the order status whenever you need to.",printLabel:"Print / Save as PDF",action:{href:"/cms/orders",label:"Back to orders",variant:"outline"},emptyMessage:"The printable invoice will appear here after the order payment metadata is synced.",className:"max-w-none px-0 py-6 md:px-0",showHeader:!1})]})}function n({label:a,value:r,capitalize:t=!1}){return e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-gray-500",children:a}),e.jsx("span",{className:t?"capitalize font-medium":"font-medium",children:r})]})}function y({status:a,size:r="md"}){let t="bg-gray-100 text-gray-700 dark:bg-slate-800 dark:text-gray-300";a==="paid"&&(t="bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400"),a==="trial"&&(t="bg-cyan-100 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-300"),a==="pending"&&(t="bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"),a==="shipped"&&(t="bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"),a==="cancelled"&&(t="bg-slate-200 text-slate-700 dark:bg-slate-800 dark:text-slate-300"),a==="refunded"&&(t="bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300"),a==="failed"&&(t="bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400");const s=r==="lg"?"px-3 py-1 text-sm":"px-2 py-0.5 text-xs";return e.jsx("span",{className:`${s} rounded-full font-medium capitalize ${t}`,children:a})}exports.OrderDetailPage=f;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { jsxs as r, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import m from "next/link";
|
|
3
|
+
import { notFound as p } from "next/navigation";
|
|
4
|
+
import { InvoiceViewerShell as u } from "../../../components/InvoiceViewerShell.es.js";
|
|
5
|
+
import { getInvoicePresentationData as x } from "../../../invoice-server.es.js";
|
|
6
|
+
import { buildInvoiceDocumentLabels as g } from "../../../invoice-ui.es.js";
|
|
7
|
+
import { getOrderDetails as b } from "./actions.es.js";
|
|
8
|
+
import { OrderPrintButton as f } from "./OrderPrintButton.es.js";
|
|
9
|
+
import { OrderStatusForm as h } from "./OrderStatusForm.es.js";
|
|
10
|
+
const s = (a, l = "usd") => new Intl.NumberFormat("en-US", {
|
|
11
|
+
style: "currency",
|
|
12
|
+
currency: l
|
|
13
|
+
}).format(a / 100);
|
|
14
|
+
async function O({ params: a }) {
|
|
15
|
+
const { id: l } = await a, [e, n] = await Promise.all([
|
|
16
|
+
b(l),
|
|
17
|
+
x(l).catch(() => null)
|
|
18
|
+
]);
|
|
19
|
+
e || p();
|
|
20
|
+
const i = n?.order.customer_details ?? e.customer_details, o = g((c) => c);
|
|
21
|
+
return /* @__PURE__ */ r("div", { className: "mx-auto w-full max-w-6xl px-4 py-10 md:px-6", children: [
|
|
22
|
+
/* @__PURE__ */ r("div", { className: "flex flex-col gap-4 border-b pb-6 md:flex-row md:items-start md:justify-between", children: [
|
|
23
|
+
/* @__PURE__ */ r("div", { children: [
|
|
24
|
+
/* @__PURE__ */ r("div", { className: "mb-2 flex items-center gap-2 text-sm text-gray-500", children: [
|
|
25
|
+
/* @__PURE__ */ t(m, { href: "/cms/orders", className: "hover:underline", children: "Orders" }),
|
|
26
|
+
/* @__PURE__ */ t("span", { children: "/" }),
|
|
27
|
+
/* @__PURE__ */ t("span", { className: "font-mono", children: e.id })
|
|
28
|
+
] }),
|
|
29
|
+
/* @__PURE__ */ r("h1", { className: "flex flex-wrap items-center gap-3 text-3xl font-bold tracking-tight", children: [
|
|
30
|
+
"Order",
|
|
31
|
+
/* @__PURE__ */ t(y, { status: e.status, size: "lg" })
|
|
32
|
+
] }),
|
|
33
|
+
/* @__PURE__ */ t("p", { className: "mt-2 text-sm text-muted-foreground", children: "Review the finalized invoice, customer details, and payment metadata in one place." })
|
|
34
|
+
] }),
|
|
35
|
+
/* @__PURE__ */ t("div", { className: "w-full max-w-md", children: /* @__PURE__ */ t(h, { orderId: l, currentStatus: e.status }) })
|
|
36
|
+
] }),
|
|
37
|
+
/* @__PURE__ */ r("div", { className: "mt-6 grid gap-4 md:grid-cols-2", children: [
|
|
38
|
+
/* @__PURE__ */ r("div", { className: "rounded-lg border bg-white p-4 dark:border-slate-800 dark:bg-slate-900", children: [
|
|
39
|
+
/* @__PURE__ */ t("h3", { className: "mb-3 text-[11px] font-semibold uppercase tracking-[0.18em] text-slate-500", children: "Customer" }),
|
|
40
|
+
/* @__PURE__ */ r("div", { className: "space-y-2 text-sm", children: [
|
|
41
|
+
i?.name ? /* @__PURE__ */ t("p", { className: "font-semibold text-gray-900 dark:text-white", children: i.name }) : null,
|
|
42
|
+
i?.email ? /* @__PURE__ */ t("p", { className: "text-gray-600 dark:text-gray-400", children: i.email }) : null,
|
|
43
|
+
i?.phone ? /* @__PURE__ */ t("p", { className: "text-gray-600 dark:text-gray-400", children: i.phone }) : null,
|
|
44
|
+
!i?.name && !i?.email && !i?.phone ? /* @__PURE__ */ t("p", { className: "italic text-gray-400", children: "No contact info captured." }) : null,
|
|
45
|
+
e.user_id ? /* @__PURE__ */ r("p", { className: "pt-1 font-mono text-[10px] uppercase tracking-wider text-gray-400", children: [
|
|
46
|
+
"User ID: ",
|
|
47
|
+
e.user_id.slice(0, 13),
|
|
48
|
+
"..."
|
|
49
|
+
] }) : null
|
|
50
|
+
] })
|
|
51
|
+
] }),
|
|
52
|
+
/* @__PURE__ */ r("div", { className: "rounded-lg border bg-white p-4 dark:border-slate-800 dark:bg-slate-900", children: [
|
|
53
|
+
/* @__PURE__ */ t("h3", { className: "mb-3 text-[11px] font-semibold uppercase tracking-[0.18em] text-slate-500", children: "Payment Details" }),
|
|
54
|
+
/* @__PURE__ */ r("div", { className: "space-y-2 text-sm", children: [
|
|
55
|
+
/* @__PURE__ */ t(d, { label: "Provider", value: e.provider || "stripe", capitalize: !0 }),
|
|
56
|
+
/* @__PURE__ */ t(d, { label: "Currency", value: (e.currency || "usd").toUpperCase() }),
|
|
57
|
+
/* @__PURE__ */ t(
|
|
58
|
+
d,
|
|
59
|
+
{
|
|
60
|
+
label: "Created",
|
|
61
|
+
value: new Date(e.created_at || "").toLocaleDateString()
|
|
62
|
+
}
|
|
63
|
+
),
|
|
64
|
+
/* @__PURE__ */ t(
|
|
65
|
+
d,
|
|
66
|
+
{
|
|
67
|
+
label: "Invoice #",
|
|
68
|
+
value: n?.order.invoice_number || "Pending assignment"
|
|
69
|
+
}
|
|
70
|
+
),
|
|
71
|
+
/* @__PURE__ */ t(
|
|
72
|
+
d,
|
|
73
|
+
{
|
|
74
|
+
label: "Paid on",
|
|
75
|
+
value: n?.order.paid_at ? new Date(n.order.paid_at).toLocaleString() : "Pending payment"
|
|
76
|
+
}
|
|
77
|
+
),
|
|
78
|
+
/* @__PURE__ */ t(
|
|
79
|
+
d,
|
|
80
|
+
{
|
|
81
|
+
label: "Total",
|
|
82
|
+
value: typeof e.total == "number" ? s(e.total, e.currency || "usd") : "--"
|
|
83
|
+
}
|
|
84
|
+
),
|
|
85
|
+
e.discount_total ? /* @__PURE__ */ t(
|
|
86
|
+
d,
|
|
87
|
+
{
|
|
88
|
+
label: "Discount",
|
|
89
|
+
value: `${e.coupon_code ? `${e.coupon_code} ` : ""}-${s(e.discount_total, e.currency || "usd")}`
|
|
90
|
+
}
|
|
91
|
+
) : null,
|
|
92
|
+
e.stripe_session_id ? /* @__PURE__ */ r("div", { className: "mt-3 border-t pt-3 dark:border-slate-800", children: [
|
|
93
|
+
/* @__PURE__ */ t("p", { className: "mb-1 text-xs text-gray-500", children: "Session ID" }),
|
|
94
|
+
/* @__PURE__ */ t("p", { className: "break-all rounded bg-gray-50 p-1 font-mono text-xs dark:bg-slate-800", children: e.stripe_session_id })
|
|
95
|
+
] }) : null
|
|
96
|
+
] })
|
|
97
|
+
] })
|
|
98
|
+
] }),
|
|
99
|
+
/* @__PURE__ */ t("div", { className: "mt-6 flex justify-end print:hidden", children: /* @__PURE__ */ t(f, { disabled: !n }) }),
|
|
100
|
+
/* @__PURE__ */ t(
|
|
101
|
+
u,
|
|
102
|
+
{
|
|
103
|
+
invoice: n,
|
|
104
|
+
labels: o,
|
|
105
|
+
locale: "en-US",
|
|
106
|
+
title: n?.order.invoice_number || "Order invoice",
|
|
107
|
+
description: "Open the printable invoice below and update the order status whenever you need to.",
|
|
108
|
+
printLabel: "Print / Save as PDF",
|
|
109
|
+
action: {
|
|
110
|
+
href: "/cms/orders",
|
|
111
|
+
label: "Back to orders",
|
|
112
|
+
variant: "outline"
|
|
113
|
+
},
|
|
114
|
+
emptyMessage: "The printable invoice will appear here after the order payment metadata is synced.",
|
|
115
|
+
className: "max-w-none px-0 py-6 md:px-0",
|
|
116
|
+
showHeader: !1
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
] });
|
|
120
|
+
}
|
|
121
|
+
function d({
|
|
122
|
+
label: a,
|
|
123
|
+
value: l,
|
|
124
|
+
capitalize: e = !1
|
|
125
|
+
}) {
|
|
126
|
+
return /* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-3", children: [
|
|
127
|
+
/* @__PURE__ */ t("span", { className: "text-gray-500", children: a }),
|
|
128
|
+
/* @__PURE__ */ t("span", { className: e ? "capitalize font-medium" : "font-medium", children: l })
|
|
129
|
+
] });
|
|
130
|
+
}
|
|
131
|
+
function y({ status: a, size: l = "md" }) {
|
|
132
|
+
let e = "bg-gray-100 text-gray-700 dark:bg-slate-800 dark:text-gray-300";
|
|
133
|
+
return a === "paid" && (e = "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400"), a === "trial" && (e = "bg-cyan-100 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-300"), a === "pending" && (e = "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"), a === "shipped" && (e = "bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"), a === "cancelled" && (e = "bg-slate-200 text-slate-700 dark:bg-slate-800 dark:text-slate-300"), a === "refunded" && (e = "bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300"), a === "failed" && (e = "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"), /* @__PURE__ */ t("span", { className: `${l === "lg" ? "px-3 py-1 text-sm" : "px-2 py-0.5 text-xs"} rounded-full font-medium capitalize ${e}`, children: a });
|
|
134
|
+
}
|
|
135
|
+
export {
|
|
136
|
+
O as OrderDetailPage
|
|
137
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),r=require("lucide-react"),n=require("@nextblock-cms/ui");function i({disabled:e=!1}){return t.jsxs(n.Button,{type:"button",variant:"outline",onClick:()=>window.print(),disabled:e,children:[t.jsx(r.Printer,{className:"mr-2 h-4 w-4"}),"Print / Save as PDF"]})}exports.OrderPrintButton=i;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs as t, jsx as n } from "react/jsx-runtime";
|
|
3
|
+
import { Printer as o } from "lucide-react";
|
|
4
|
+
import { Button as i } from "@nextblock-cms/ui";
|
|
5
|
+
function s({ disabled: r = !1 }) {
|
|
6
|
+
return /* @__PURE__ */ t(
|
|
7
|
+
i,
|
|
8
|
+
{
|
|
9
|
+
type: "button",
|
|
10
|
+
variant: "outline",
|
|
11
|
+
onClick: () => window.print(),
|
|
12
|
+
disabled: r,
|
|
13
|
+
children: [
|
|
14
|
+
/* @__PURE__ */ n(o, { className: "mr-2 h-4 w-4" }),
|
|
15
|
+
"Print / Save as PDF"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
s as OrderPrintButton
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),v=require("next/navigation"),s=require("@nextblock-cms/ui"),S=require("./server-actions.cjs.js"),u=[{value:"pending",label:"Pending"},{value:"trial",label:"Trial"},{value:"paid",label:"Paid"},{value:"shipped",label:"Shipped"},{value:"cancelled",label:"Cancelled"},{value:"refunded",label:"Refunded"}];function g({orderId:o,currentStatus:l}){const x=v.useRouter(),[a,m]=n.useState(u.some(t=>t.value===l)?l:"pending"),[i,r]=n.useState(null),[c,h]=n.useTransition(),d=n.useMemo(()=>a!==l,[l,a]),p=()=>{d&&(r(null),h(async()=>{try{const t=await S.updateOrderStatus(o,a);if(!t.success){r(t.error||"Failed to update order status.");return}x.refresh()}catch(t){console.error(t),r("Unexpected error while saving the order status.")}}))};return e.jsxs("div",{className:"rounded-lg border bg-white p-4 dark:border-slate-800 dark:bg-slate-900",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end",children:[e.jsxs("div",{className:"min-w-[220px] flex-1 space-y-2",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.18em] text-slate-500",children:"Order Status"}),e.jsxs(s.Select,{value:a,onValueChange:t=>{m(t),r(null)},children:[e.jsx(s.SelectTrigger,{children:e.jsx(s.SelectValue,{placeholder:"Select status"})}),e.jsx(s.SelectContent,{children:u.map(t=>e.jsx(s.SelectItem,{value:t.value,children:t.label},t.value))})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(s.Button,{type:"button",onClick:p,disabled:c||!d,children:c?"Saving...":"Save"})})]}),i?e.jsx("p",{className:"mt-2 text-xs text-red-600 dark:text-red-400",children:i}):d?null:e.jsx("p",{className:"mt-2 text-xs text-slate-500",children:"Status is already up to date."})]})}exports.OrderStatusForm=g;
|