@nextblock-cms/ecom 0.20.1 → 0.21.0
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/_virtual/_rolldown/runtime.cjs.js +1 -0
- package/index.cjs.js +1 -1
- package/index.es.js +38 -146
- package/lib/CurrencyProvider.cjs.js +1 -1
- package/lib/CurrencyProvider.d.ts +1 -1
- package/lib/CurrencyProvider.es.js +85 -95
- package/lib/PaymentReadinessProvider.cjs.js +1 -1
- package/lib/PaymentReadinessProvider.d.ts +1 -1
- package/lib/PaymentReadinessProvider.es.js +24 -27
- package/lib/cart-store.cjs.js +1 -1
- package/lib/cart-store.es.js +109 -121
- package/lib/components/AccountNavigationMenu.cjs.js +1 -1
- package/lib/components/AccountNavigationMenu.d.ts +1 -1
- package/lib/components/AccountNavigationMenu.es.js +36 -50
- package/lib/components/AddToCartButton.cjs.js +1 -1
- package/lib/components/AddToCartButton.d.ts +1 -1
- package/lib/components/AddToCartButton.es.js +94 -89
- package/lib/components/Cart.cjs.js +1 -1
- package/lib/components/Cart.d.ts +1 -1
- package/lib/components/Cart.es.js +261 -180
- package/lib/components/CartDrawer.cjs.js +1 -1
- package/lib/components/CartDrawer.d.ts +1 -1
- package/lib/components/CartDrawer.es.js +218 -148
- package/lib/components/CartIcon.cjs.js +1 -1
- package/lib/components/CartIcon.d.ts +1 -1
- package/lib/components/CartIcon.es.js +33 -35
- package/lib/components/Checkout.cjs.js +1 -1
- package/lib/components/Checkout.d.ts +1 -1
- package/lib/components/Checkout.es.js +1092 -1108
- package/lib/components/CouponForm.cjs.js +1 -1
- package/lib/components/CouponForm.d.ts +1 -1
- package/lib/components/CouponForm.es.js +136 -148
- package/lib/components/CurrencySwitcher.cjs.js +1 -1
- package/lib/components/CurrencySwitcher.d.ts +1 -1
- package/lib/components/CurrencySwitcher.es.js +22 -18
- package/lib/components/CustomerProfileForm.cjs.js +1 -1
- package/lib/components/CustomerProfileForm.es.js +454 -313
- package/lib/components/FeaturedProduct.cjs.js +1 -1
- package/lib/components/FeaturedProduct.d.ts +1 -1
- package/lib/components/FeaturedProduct.es.js +98 -83
- package/lib/components/FreemiusLicensePanel.cjs.js +1 -1
- package/lib/components/FreemiusLicensePanel.d.ts +1 -1
- package/lib/components/FreemiusLicensePanel.es.js +70 -65
- package/lib/components/InvoiceDocument.cjs.js +1 -1
- package/lib/components/InvoiceDocument.es.js +256 -192
- package/lib/components/InvoiceViewerShell.cjs.js +2 -2
- package/lib/components/InvoiceViewerShell.d.ts +1 -1
- package/lib/components/InvoiceViewerShell.es.js +75 -106
- package/lib/components/ProductCard.cjs.js +1 -1
- package/lib/components/ProductCard.d.ts +1 -1
- package/lib/components/ProductCard.es.js +186 -171
- package/lib/components/ProductDetailsLayout.cjs.js +1 -1
- package/lib/components/ProductDetailsLayout.es.js +405 -404
- package/lib/components/ProductGallery.cjs.js +1 -1
- package/lib/components/ProductGallery.d.ts +1 -1
- package/lib/components/ProductGallery.es.js +51 -54
- package/lib/components/ProductGrid.cjs.js +1 -1
- package/lib/components/ProductGrid.d.ts +1 -1
- package/lib/components/ProductGrid.es.js +23 -25
- package/lib/components/ShippingEstimator.cjs.js +1 -1
- package/lib/components/ShippingEstimator.d.ts +1 -1
- package/lib/components/ShippingEstimator.es.js +158 -153
- package/lib/components/ShortDescription.cjs.js +1 -1
- package/lib/components/ShortDescription.es.js +17 -17
- package/lib/components/SimpleTiptapRenderer.cjs.js +1 -1
- package/lib/components/SimpleTiptapRenderer.es.js +238 -211
- package/lib/components/SubscriptionSelector.cjs.js +1 -1
- package/lib/components/SubscriptionSelector.es.js +159 -154
- package/lib/countries.cjs.js +1 -1
- package/lib/countries.es.js +232 -75
- package/lib/coupon-server.cjs.js +1 -1
- package/lib/coupon-server.es.js +180 -224
- package/lib/coupons.cjs.js +1 -1
- package/lib/coupons.es.js +12 -14
- package/lib/currency-constants.cjs.js +1 -1
- package/lib/currency-constants.es.js +4 -4
- package/lib/currency-rest-client.cjs.js +1 -1
- package/lib/currency-rest-client.es.js +15 -22
- package/lib/currency-store.cjs.js +1 -1
- package/lib/currency-store.es.js +20 -27
- package/lib/currency-sync.cjs.js +1 -1
- package/lib/currency-sync.es.js +124 -170
- package/lib/currency.cjs.js +1 -1
- package/lib/currency.es.js +242 -310
- package/lib/customer-addresses.cjs.js +1 -1
- package/lib/customer-addresses.es.js +80 -109
- package/lib/customer-orders.cjs.js +1 -1
- package/lib/customer-orders.es.js +31 -43
- package/lib/customer.cjs.js +1 -1
- package/lib/customer.es.js +43 -52
- package/lib/export-helpers.cjs.js +1 -1
- package/lib/export-helpers.es.js +53 -52
- package/lib/factory.cjs.js +1 -1
- package/lib/factory.es.js +10 -7
- package/lib/freemius-coupons.cjs.js +1 -1
- package/lib/freemius-coupons.es.js +245 -262
- package/lib/freemius-license-claim.cjs.js +1 -1
- package/lib/freemius-license-claim.es.js +87 -71
- package/lib/freemius-license.cjs.js +1 -1
- package/lib/freemius-license.es.js +32 -39
- package/lib/freemius-order-sync.cjs.js +1 -1
- package/lib/freemius-order-sync.es.js +226 -290
- package/lib/freemius-trial-provision.cjs.js +1 -1
- package/lib/freemius-trial-provision.es.js +136 -130
- package/lib/inventory-settings.cjs.js +1 -1
- package/lib/inventory-settings.es.js +69 -77
- package/lib/invoice-server.cjs.js +3 -3
- package/lib/invoice-server.es.js +94 -141
- package/lib/invoice-ui.cjs.js +1 -1
- package/lib/invoice-ui.es.js +50 -66
- package/lib/invoice.cjs.js +1 -1
- package/lib/invoice.es.js +85 -94
- package/lib/order-inventory.cjs.js +25 -25
- package/lib/order-inventory.es.js +67 -79
- package/lib/order-tax-details.cjs.js +1 -1
- package/lib/order-tax-details.es.js +142 -153
- package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -1
- package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
- package/lib/pages/cms/coupons/CouponsPage.cjs.js +2 -2
- package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
- package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -1
- package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
- package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
- package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -1
- package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
- package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
- package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -1
- package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
- package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
- package/lib/pages/cms/coupons/actions.cjs.js +1 -1
- package/lib/pages/cms/coupons/actions.es.js +112 -115
- package/lib/pages/cms/coupons/index.cjs.js +1 -0
- package/lib/pages/cms/coupons/index.es.js +3 -0
- package/lib/pages/cms/coupons/product-options.cjs.js +1 -1
- package/lib/pages/cms/coupons/product-options.es.js +21 -23
- package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -1
- package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
- package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
- package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
- package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
- package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
- package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
- package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -1
- package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
- package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
- package/lib/pages/cms/orders/actions.cjs.js +3 -3
- package/lib/pages/cms/orders/actions.es.js +53 -69
- package/lib/pages/cms/orders/export-actions.cjs.js +1 -1
- package/lib/pages/cms/orders/export-actions.es.js +23 -26
- package/lib/pages/cms/orders/index.cjs.js +1 -0
- package/lib/pages/cms/orders/index.es.js +6 -0
- package/lib/pages/cms/orders/server-actions.cjs.js +1 -1
- package/lib/pages/cms/orders/server-actions.es.js +60 -51
- package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -1
- package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
- package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
- package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -1
- package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
- package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
- package/lib/pages/cms/payments/actions.cjs.js +1 -1
- package/lib/pages/cms/payments/actions.es.js +38 -48
- package/lib/pages/cms/payments/index.cjs.js +1 -0
- package/lib/pages/cms/payments/index.es.js +3 -0
- package/lib/pages/cms/payments/queries.cjs.js +1 -1
- package/lib/pages/cms/payments/queries.es.js +38 -48
- package/lib/pages/cms/products/ProductsPage.cjs.js +1 -1
- package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
- package/lib/pages/cms/products/ProductsPage.es.js +63 -66
- package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +138 -155
- package/lib/pages/cms/products/actions.cjs.js +4 -4
- package/lib/pages/cms/products/actions.es.js +121 -162
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -1
- package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
- package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
- package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
- package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
- package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -1
- package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -1
- package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
- package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -1
- package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
- package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
- package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
- package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
- package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
- package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
- package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +2 -2
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
- package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
- package/lib/pages/cms/products/index.cjs.js +1 -0
- package/lib/pages/cms/products/index.es.js +8 -0
- package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -1
- package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
- package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
- package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -2
- package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
- package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
- package/lib/pages/cms/products/inventory/actions.cjs.js +3 -3
- package/lib/pages/cms/products/inventory/actions.es.js +83 -91
- package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -1
- package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
- package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
- package/lib/pages/cms/products/product-price-sync.cjs.js +1 -1
- package/lib/pages/cms/products/product-price-sync.es.js +74 -89
- package/lib/pages/cms/products/server-actions.cjs.js +1 -1
- package/lib/pages/cms/products/server-actions.es.js +250 -233
- package/lib/pages/cms/shipping/ShippingPage.cjs.js +2 -2
- package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
- package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -1
- package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
- package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
- package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -1
- package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
- package/lib/pages/cms/shipping/index.cjs.js +1 -0
- package/lib/pages/cms/shipping/index.es.js +3 -0
- package/lib/pages/cms/shipping/server-actions.cjs.js +1 -1
- package/lib/pages/cms/shipping/server-actions.es.js +131 -149
- package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -1
- package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
- package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
- package/lib/pages/cms/taxes/actions.cjs.js +1 -1
- package/lib/pages/cms/taxes/actions.es.js +41 -53
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
- package/lib/pages/cms/taxes/index.cjs.js +1 -0
- package/lib/pages/cms/taxes/index.es.js +3 -0
- package/lib/payment-config.cjs.js +1 -1
- package/lib/payment-config.es.js +110 -126
- package/lib/product-actions.cjs.js +4 -4
- package/lib/product-actions.es.js +289 -544
- package/lib/product-context.cjs.js +1 -1
- package/lib/product-context.es.js +13 -15
- package/lib/product-schema.cjs.js +1 -1
- package/lib/product-schema.es.js +99 -134
- package/lib/providers/freemius.cjs.js +1 -5
- package/lib/providers/freemius.es.js +446 -530
- package/lib/providers/stripe.cjs.js +1 -1
- package/lib/providers/stripe.es.js +417 -477
- package/lib/server-actions/coupon-actions.cjs.js +1 -1
- package/lib/server-actions/coupon-actions.es.js +22 -22
- package/lib/server-actions/customer-actions.cjs.js +1 -1
- package/lib/server-actions/customer-actions.es.js +26 -28
- package/lib/server-actions/product-actions.cjs.js +1 -1
- package/lib/server-actions/product-actions.es.js +9 -15
- package/lib/server-actions/shipping-actions.cjs.js +1 -1
- package/lib/server-actions/shipping-actions.es.js +27 -24
- package/lib/server-actions/tax-actions.cjs.js +1 -1
- package/lib/server-actions/tax-actions.es.js +33 -39
- package/lib/shared-inventory.cjs.js +2 -2
- package/lib/shared-inventory.es.js +111 -160
- package/lib/shipping/resolver.cjs.js +2 -2
- package/lib/shipping/resolver.es.js +44 -61
- package/lib/shipping-rate-currency.cjs.js +1 -1
- package/lib/shipping-rate-currency.es.js +52 -67
- package/lib/states.cjs.js +1 -1
- package/lib/states.es.js +333 -154
- package/lib/stripe/checkout.cjs.js +1 -1
- package/lib/stripe/checkout.es.js +125 -181
- package/lib/stripe/client.cjs.js +1 -1
- package/lib/stripe/client.es.js +14 -19
- package/lib/stripe/order-sync.cjs.js +1 -1
- package/lib/stripe/order-sync.es.js +106 -126
- package/lib/stripe/webhooks.cjs.js +1 -1
- package/lib/stripe/webhooks.es.js +37 -31
- package/lib/tax-calculation.cjs.js +1 -1
- package/lib/tax-calculation.es.js +84 -98
- package/lib/trials.cjs.js +1 -1
- package/lib/trials.es.js +24 -30
- package/lib/types.cjs.js +1 -1
- package/lib/types.es.js +21 -27
- package/lib/use-cart.cjs.js +1 -1
- package/lib/use-cart.es.js +38 -40
- package/lib/use-price-formatter.cjs.js +1 -1
- package/lib/use-price-formatter.es.js +10 -11
- package/lib/variation-utils.cjs.js +1 -1
- package/lib/variation-utils.es.js +199 -261
- package/lib/zod-config.cjs.js +1 -1
- package/lib/zod-config.es.js +5 -6
- package/package.json +16 -16
- package/server.cjs.js +1 -1
- package/server.es.js +56 -211
|
@@ -1,71 +1,87 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { updateOrderStatus as e } from "./server-actions.es.js";
|
|
3
|
+
import { useMemo as t, useState as n, useTransition as r } from "react";
|
|
4
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
5
|
+
import { useRouter as o } from "next/navigation";
|
|
6
|
+
import { Button as s, Select as c, SelectContent as l, SelectItem as u, SelectTrigger as d, SelectValue as f } from "@nextblock-cms/ui";
|
|
7
|
+
//#region libs/ecommerce/src/lib/pages/cms/orders/OrderStatusForm.tsx
|
|
8
|
+
var p = [
|
|
9
|
+
{
|
|
10
|
+
value: "pending",
|
|
11
|
+
label: "Pending"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
value: "trial",
|
|
15
|
+
label: "Trial"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
value: "paid",
|
|
19
|
+
label: "Paid"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
value: "shipped",
|
|
23
|
+
label: "Shipped"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
value: "cancelled",
|
|
27
|
+
label: "Cancelled"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
value: "refunded",
|
|
31
|
+
label: "Refunded"
|
|
32
|
+
}
|
|
14
33
|
];
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
] });
|
|
34
|
+
function m({ orderId: m, currentStatus: h }) {
|
|
35
|
+
let g = o(), [_, v] = n(p.some((e) => e.value === h) ? h : "pending"), [y, b] = n(null), [x, S] = r(), C = t(() => _ !== h, [h, _]);
|
|
36
|
+
return /* @__PURE__ */ a("div", {
|
|
37
|
+
className: "rounded-lg border bg-white p-4 dark:border-slate-800 dark:bg-slate-900",
|
|
38
|
+
children: [/* @__PURE__ */ a("div", {
|
|
39
|
+
className: "flex flex-col gap-3 sm:flex-row sm:items-end",
|
|
40
|
+
children: [/* @__PURE__ */ a("div", {
|
|
41
|
+
className: "min-w-[220px] flex-1 space-y-2",
|
|
42
|
+
children: [/* @__PURE__ */ i("p", {
|
|
43
|
+
className: "text-[11px] font-semibold uppercase tracking-[0.18em] text-slate-500",
|
|
44
|
+
children: "Order Status"
|
|
45
|
+
}), /* @__PURE__ */ a(c, {
|
|
46
|
+
value: _,
|
|
47
|
+
onValueChange: (e) => {
|
|
48
|
+
v(e), b(null);
|
|
49
|
+
},
|
|
50
|
+
children: [/* @__PURE__ */ i(d, { children: /* @__PURE__ */ i(f, { placeholder: "Select status" }) }), /* @__PURE__ */ i(l, { children: p.map((e) => /* @__PURE__ */ i(u, {
|
|
51
|
+
value: e.value,
|
|
52
|
+
children: e.label
|
|
53
|
+
}, e.value)) })]
|
|
54
|
+
})]
|
|
55
|
+
}), /* @__PURE__ */ i("div", {
|
|
56
|
+
className: "flex items-center gap-2",
|
|
57
|
+
children: /* @__PURE__ */ i(s, {
|
|
58
|
+
type: "button",
|
|
59
|
+
onClick: () => {
|
|
60
|
+
C && (b(null), S(async () => {
|
|
61
|
+
try {
|
|
62
|
+
let t = await e(m, _);
|
|
63
|
+
if (!t.success) {
|
|
64
|
+
b(t.error || "Failed to update order status.");
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
g.refresh();
|
|
68
|
+
} catch (e) {
|
|
69
|
+
console.error(e), b("Unexpected error while saving the order status.");
|
|
70
|
+
}
|
|
71
|
+
}));
|
|
72
|
+
},
|
|
73
|
+
disabled: x || !C,
|
|
74
|
+
children: x ? "Saving..." : "Save"
|
|
75
|
+
})
|
|
76
|
+
})]
|
|
77
|
+
}), y ? /* @__PURE__ */ i("p", {
|
|
78
|
+
className: "mt-2 text-xs text-red-600 dark:text-red-400",
|
|
79
|
+
children: y
|
|
80
|
+
}) : C ? null : /* @__PURE__ */ i("p", {
|
|
81
|
+
className: "mt-2 text-xs text-slate-500",
|
|
82
|
+
children: "Status is already up to date."
|
|
83
|
+
})]
|
|
84
|
+
});
|
|
68
85
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
};
|
|
86
|
+
//#endregion
|
|
87
|
+
export { m as OrderStatusForm };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("../../../../_virtual/_rolldown/runtime.cjs.js"),t=require("./actions.cjs.js"),n=require("./ExportReportsDialog.cjs.js");let r=require("next/link");r=e.__toESM(r,1);let i=require("react/jsx-runtime");var a=(e,t=`usd`)=>new Intl.NumberFormat(`en-US`,{style:`currency`,currency:t}).format(e/100);async function o({searchParams:e}){let o=await e,c=Number(o.page)||1,l=o.status||`all`,{data:u,totalPages:d}=await t.getOrders(c,l);return(0,i.jsxs)(`div`,{className:`p-6 space-y-6`,children:[(0,i.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,i.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`Orders`}),(0,i.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,i.jsx)(n.ExportReportsDialog,{}),(0,i.jsx)(r.default,{href:`/cms/orders?page=${c}&status=${l}`,className:`px-3 py-2 text-sm font-medium border rounded hover:bg-gray-50 dark:hover:bg-slate-800`,children:`Refresh`})]})]}),(0,i.jsx)(`div`,{className:`flex gap-2 border-b pb-4`,children:[`all`,`paid`,`trial`,`pending`,`failed`].map(e=>(0,i.jsx)(r.default,{href:`/cms/orders?page=1&status=${e}`,className:`px-3 py-1 rounded-full text-sm font-medium capitalize ${l===e?`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:e},e))}),(0,i.jsx)(`div`,{className:`border rounded-lg overflow-hidden dark:border-slate-800`,children:(0,i.jsxs)(`table`,{className:`w-full text-sm text-left align-middle`,children:[(0,i.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:(0,i.jsxs)(`tr`,{children:[(0,i.jsx)(`th`,{className:`px-4 py-3`,children:`ID`}),(0,i.jsx)(`th`,{className:`px-4 py-3`,children:`Customer`}),(0,i.jsx)(`th`,{className:`px-4 py-3`,children:`Status`}),(0,i.jsx)(`th`,{className:`px-4 py-3`,children:`Provider`}),(0,i.jsx)(`th`,{className:`px-4 py-3 text-right`,children:`Amount`}),(0,i.jsx)(`th`,{className:`px-4 py-3 text-right`,children:`Date`}),(0,i.jsx)(`th`,{className:`px-4 py-3 text-right`,children:`Actions`})]})}),(0,i.jsx)(`tbody`,{className:`divide-y dark:divide-slate-800`,children:u.length===0?(0,i.jsx)(`tr`,{children:(0,i.jsx)(`td`,{colSpan:7,className:`px-4 py-8 text-center text-gray-500`,children:`No orders found.`})}):u.map(e=>{let t=e.customer_details,n=t?.name||t?.email||e.customer?.full_name||`Guest Customer`;return(0,i.jsxs)(`tr`,{className:`hover:bg-gray-50 dark:hover:bg-slate-800/50`,children:[(0,i.jsxs)(`td`,{className:`px-4 py-3 font-mono text-gray-500`,children:[e.id.slice(0,8),`...`]}),(0,i.jsx)(`td`,{className:`px-4 py-3 font-medium`,children:n}),(0,i.jsx)(`td`,{className:`px-4 py-3`,children:(0,i.jsx)(s,{status:e.status})}),(0,i.jsx)(`td`,{className:`px-4 py-3 capitalize text-gray-600 dark:text-gray-400`,children:e.provider===`freemius`?`Freemius`:`Stripe`}),(0,i.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,i.jsxs)(`div`,{className:`flex flex-col items-end`,children:[(0,i.jsx)(`span`,{children:a(e.total,e.currency||`usd`)}),e.discount_total?(0,i.jsxs)(`span`,{className:`text-[10px] text-emerald-600`,children:[e.coupon_code,` -`,a(e.discount_total,e.currency||`usd`)]}):null]})}),(0,i.jsx)(`td`,{className:`px-4 py-3 text-right text-gray-500 whitespace-nowrap`,children:new Date(e.created_at||``).toLocaleDateString()}),(0,i.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,i.jsx)(r.default,{href:`/cms/orders/${e.id}`,className:`text-blue-600 hover:underline dark:text-blue-400`,children:`View`})})]},e.id)})})]})}),(0,i.jsxs)(`div`,{className:`flex justify-between items-center pt-4`,children:[(0,i.jsxs)(`div`,{className:`text-sm text-gray-500`,children:[`Page `,c,` of `,d]}),(0,i.jsxs)(`div`,{className:`flex gap-2`,children:[(0,i.jsx)(r.default,{href:`/cms/orders?page=${Math.max(1,c-1)}&status=${l}`,className:`px-3 py-1 border rounded text-sm ${c<=1?`pointer-events-none opacity-50`:`hover:bg-gray-50 dark:hover:bg-slate-800`}`,children:`Previous`}),(0,i.jsx)(r.default,{href:`/cms/orders?page=${Math.min(d,c+1)}&status=${l}`,className:`px-3 py-1 border rounded text-sm ${c>=d?`pointer-events-none opacity-50`:`hover:bg-gray-50 dark:hover:bg-slate-800`}`,children:`Next`})]})]})]})}function s({status:e}){let t=`bg-gray-100 text-gray-700 dark:bg-slate-800 dark:text-gray-300`;return e===`paid`&&(t=`bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400`),e===`trial`&&(t=`bg-cyan-100 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-300`),e===`pending`&&(t=`bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400`),e===`failed`&&(t=`bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400`),(0,i.jsx)(`span`,{className:`px-2 py-0.5 rounded-full text-xs font-medium capitalize ${t}`,children:e})}exports.OrdersPage=o;
|
|
@@ -1,104 +1,172 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
1
|
+
import { getOrders as e } from "./actions.es.js";
|
|
2
|
+
import { ExportReportsDialog as t } from "./ExportReportsDialog.es.js";
|
|
3
|
+
import n from "next/link";
|
|
4
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
5
|
+
//#region libs/ecommerce/src/lib/pages/cms/orders/OrdersPage.tsx
|
|
6
|
+
var a = (e, t = "usd") => new Intl.NumberFormat("en-US", {
|
|
7
|
+
style: "currency",
|
|
8
|
+
currency: t
|
|
9
|
+
}).format(e / 100);
|
|
10
|
+
async function o({ searchParams: o }) {
|
|
11
|
+
let c = await o, l = Number(c.page) || 1, u = c.status || "all", { data: d, totalPages: f } = await e(l, u);
|
|
12
|
+
return /* @__PURE__ */ i("div", {
|
|
13
|
+
className: "p-6 space-y-6",
|
|
14
|
+
children: [
|
|
15
|
+
/* @__PURE__ */ i("div", {
|
|
16
|
+
className: "flex justify-between items-center",
|
|
17
|
+
children: [/* @__PURE__ */ r("h1", {
|
|
18
|
+
className: "text-2xl font-bold tracking-tight",
|
|
19
|
+
children: "Orders"
|
|
20
|
+
}), /* @__PURE__ */ i("div", {
|
|
21
|
+
className: "flex items-center gap-2",
|
|
22
|
+
children: [/* @__PURE__ */ r(t, {}), /* @__PURE__ */ r(n, {
|
|
23
|
+
href: `/cms/orders?page=${l}&status=${u}`,
|
|
24
|
+
className: "px-3 py-2 text-sm font-medium border rounded hover:bg-gray-50 dark:hover:bg-slate-800",
|
|
25
|
+
children: "Refresh"
|
|
26
|
+
})]
|
|
27
|
+
})]
|
|
28
|
+
}),
|
|
29
|
+
/* @__PURE__ */ r("div", {
|
|
30
|
+
className: "flex gap-2 border-b pb-4",
|
|
31
|
+
children: [
|
|
32
|
+
"all",
|
|
33
|
+
"paid",
|
|
34
|
+
"trial",
|
|
35
|
+
"pending",
|
|
36
|
+
"failed"
|
|
37
|
+
].map((e) => /* @__PURE__ */ r(n, {
|
|
38
|
+
href: `/cms/orders?page=1&status=${e}`,
|
|
39
|
+
className: `px-3 py-1 rounded-full text-sm font-medium capitalize ${u === e ? "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"}`,
|
|
40
|
+
children: e
|
|
41
|
+
}, e))
|
|
42
|
+
}),
|
|
43
|
+
/* @__PURE__ */ r("div", {
|
|
44
|
+
className: "border rounded-lg overflow-hidden dark:border-slate-800",
|
|
45
|
+
children: /* @__PURE__ */ i("table", {
|
|
46
|
+
className: "w-full text-sm text-left align-middle",
|
|
47
|
+
children: [/* @__PURE__ */ r("thead", {
|
|
48
|
+
className: "bg-gray-50 text-gray-500 font-medium border-b dark:bg-slate-900 dark:text-slate-400 dark:border-slate-800",
|
|
49
|
+
children: /* @__PURE__ */ i("tr", { children: [
|
|
50
|
+
/* @__PURE__ */ r("th", {
|
|
51
|
+
className: "px-4 py-3",
|
|
52
|
+
children: "ID"
|
|
53
|
+
}),
|
|
54
|
+
/* @__PURE__ */ r("th", {
|
|
55
|
+
className: "px-4 py-3",
|
|
56
|
+
children: "Customer"
|
|
57
|
+
}),
|
|
58
|
+
/* @__PURE__ */ r("th", {
|
|
59
|
+
className: "px-4 py-3",
|
|
60
|
+
children: "Status"
|
|
61
|
+
}),
|
|
62
|
+
/* @__PURE__ */ r("th", {
|
|
63
|
+
className: "px-4 py-3",
|
|
64
|
+
children: "Provider"
|
|
65
|
+
}),
|
|
66
|
+
/* @__PURE__ */ r("th", {
|
|
67
|
+
className: "px-4 py-3 text-right",
|
|
68
|
+
children: "Amount"
|
|
69
|
+
}),
|
|
70
|
+
/* @__PURE__ */ r("th", {
|
|
71
|
+
className: "px-4 py-3 text-right",
|
|
72
|
+
children: "Date"
|
|
73
|
+
}),
|
|
74
|
+
/* @__PURE__ */ r("th", {
|
|
75
|
+
className: "px-4 py-3 text-right",
|
|
76
|
+
children: "Actions"
|
|
77
|
+
})
|
|
78
|
+
] })
|
|
79
|
+
}), /* @__PURE__ */ r("tbody", {
|
|
80
|
+
className: "divide-y dark:divide-slate-800",
|
|
81
|
+
children: d.length === 0 ? /* @__PURE__ */ r("tr", { children: /* @__PURE__ */ r("td", {
|
|
82
|
+
colSpan: 7,
|
|
83
|
+
className: "px-4 py-8 text-center text-gray-500",
|
|
84
|
+
children: "No orders found."
|
|
85
|
+
}) }) : d.map((e) => {
|
|
86
|
+
let t = e.customer_details, o = t?.name || t?.email || e.customer?.full_name || "Guest Customer";
|
|
87
|
+
return /* @__PURE__ */ i("tr", {
|
|
88
|
+
className: "hover:bg-gray-50 dark:hover:bg-slate-800/50",
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ i("td", {
|
|
91
|
+
className: "px-4 py-3 font-mono text-gray-500",
|
|
92
|
+
children: [e.id.slice(0, 8), "..."]
|
|
93
|
+
}),
|
|
94
|
+
/* @__PURE__ */ r("td", {
|
|
95
|
+
className: "px-4 py-3 font-medium",
|
|
96
|
+
children: o
|
|
97
|
+
}),
|
|
98
|
+
/* @__PURE__ */ r("td", {
|
|
99
|
+
className: "px-4 py-3",
|
|
100
|
+
children: /* @__PURE__ */ r(s, { status: e.status })
|
|
101
|
+
}),
|
|
102
|
+
/* @__PURE__ */ r("td", {
|
|
103
|
+
className: "px-4 py-3 capitalize text-gray-600 dark:text-gray-400",
|
|
104
|
+
children: e.provider === "freemius" ? "Freemius" : "Stripe"
|
|
105
|
+
}),
|
|
106
|
+
/* @__PURE__ */ r("td", {
|
|
107
|
+
className: "px-4 py-3 text-right",
|
|
108
|
+
children: /* @__PURE__ */ i("div", {
|
|
109
|
+
className: "flex flex-col items-end",
|
|
110
|
+
children: [/* @__PURE__ */ r("span", { children: a(e.total, e.currency || "usd") }), e.discount_total ? /* @__PURE__ */ i("span", {
|
|
111
|
+
className: "text-[10px] text-emerald-600",
|
|
112
|
+
children: [
|
|
113
|
+
e.coupon_code,
|
|
114
|
+
" -",
|
|
115
|
+
a(e.discount_total, e.currency || "usd")
|
|
116
|
+
]
|
|
117
|
+
}) : null]
|
|
118
|
+
})
|
|
119
|
+
}),
|
|
120
|
+
/* @__PURE__ */ r("td", {
|
|
121
|
+
className: "px-4 py-3 text-right text-gray-500 whitespace-nowrap",
|
|
122
|
+
children: new Date(e.created_at || "").toLocaleDateString()
|
|
123
|
+
}),
|
|
124
|
+
/* @__PURE__ */ r("td", {
|
|
125
|
+
className: "px-4 py-3 text-right",
|
|
126
|
+
children: /* @__PURE__ */ r(n, {
|
|
127
|
+
href: `/cms/orders/${e.id}`,
|
|
128
|
+
className: "text-blue-600 hover:underline dark:text-blue-400",
|
|
129
|
+
children: "View"
|
|
130
|
+
})
|
|
131
|
+
})
|
|
132
|
+
]
|
|
133
|
+
}, e.id);
|
|
134
|
+
})
|
|
135
|
+
})]
|
|
136
|
+
})
|
|
137
|
+
}),
|
|
138
|
+
/* @__PURE__ */ i("div", {
|
|
139
|
+
className: "flex justify-between items-center pt-4",
|
|
140
|
+
children: [/* @__PURE__ */ i("div", {
|
|
141
|
+
className: "text-sm text-gray-500",
|
|
142
|
+
children: [
|
|
143
|
+
"Page ",
|
|
144
|
+
l,
|
|
145
|
+
" of ",
|
|
146
|
+
f
|
|
147
|
+
]
|
|
148
|
+
}), /* @__PURE__ */ i("div", {
|
|
149
|
+
className: "flex gap-2",
|
|
150
|
+
children: [/* @__PURE__ */ r(n, {
|
|
151
|
+
href: `/cms/orders?page=${Math.max(1, l - 1)}&status=${u}`,
|
|
152
|
+
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"}`,
|
|
153
|
+
children: "Previous"
|
|
154
|
+
}), /* @__PURE__ */ r(n, {
|
|
155
|
+
href: `/cms/orders?page=${Math.min(f, l + 1)}&status=${u}`,
|
|
156
|
+
className: `px-3 py-1 border rounded text-sm ${l >= f ? "pointer-events-none opacity-50" : "hover:bg-gray-50 dark:hover:bg-slate-800"}`,
|
|
157
|
+
children: "Next"
|
|
158
|
+
})]
|
|
159
|
+
})]
|
|
160
|
+
})
|
|
161
|
+
]
|
|
162
|
+
});
|
|
97
163
|
}
|
|
98
|
-
function
|
|
99
|
-
|
|
100
|
-
|
|
164
|
+
function s({ status: e }) {
|
|
165
|
+
let t = "bg-gray-100 text-gray-700 dark:bg-slate-800 dark:text-gray-300";
|
|
166
|
+
return e === "paid" && (t = "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400"), e === "trial" && (t = "bg-cyan-100 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-300"), e === "pending" && (t = "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"), e === "failed" && (t = "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"), /* @__PURE__ */ r("span", {
|
|
167
|
+
className: `px-2 py-0.5 rounded-full text-xs font-medium capitalize ${t}`,
|
|
168
|
+
children: e
|
|
169
|
+
});
|
|
101
170
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
};
|
|
171
|
+
//#endregion
|
|
172
|
+
export { o as OrdersPage };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use
|
|
1
|
+
"use server";let e=require("@nextblock-cms/db/server");var t=20;async function n(n=1,r,i){let a=await(0,e.createClient)(),o=(n-1)*t,s=o+t-1,c=a.from(`orders`).select(`
|
|
2
2
|
*,
|
|
3
3
|
order_items (*)
|
|
4
|
-
`,{count
|
|
4
|
+
`,{count:`exact`}).order(`created_at`,{ascending:!1}).range(o,s);r&&r!==`all`&&(c=c.eq(`status`,r)),i&&(c=c.or(`id.eq.${i},user_id.eq.${i}`));let{data:l,error:u,count:d}=await c;if(u)throw console.error(`Error fetching orders:`,u),Error(`Failed to fetch orders`);let f=l||[],p=Array.from(new Set(f.map(e=>e.user_id).filter(Boolean))),m=new Map;if(p.length>0){let{data:e,error:t}=await a.from(`profiles`).select(`*`).in(`id`,p);!t&&e&&e.forEach(e=>m.set(e.id,e))}return{data:f.map(e=>({...e,customer:e.user_id?m.get(e.user_id):null})),total:d||0,totalPages:d?Math.ceil(d/t):0}}async function r(t){let n=await(0,e.createClient)(),{data:r,error:i}=await n.from(`orders`).select(`
|
|
5
5
|
*,
|
|
6
6
|
order_items (*)
|
|
7
|
-
`).eq(
|
|
7
|
+
`).eq(`id`,t).single();if(i||!r)return console.error(`Error fetching order ${t}:`,i),null;let a=r,o=null;if(a.user_id){let{data:e}=await n.from(`profiles`).select(`*`).eq(`id`,a.user_id).single();o=e}let s=a.order_items.map(e=>e.product_id).filter(Boolean),c=new Map;if(s.length>0){let{data:e}=await n.from(`products`).select(`id, title, slug, product_media(media(file_path))`).in(`id`,s);e&&e.forEach(e=>{let t=null;e.product_media&&e.product_media.length>0&&e.product_media[0].media&&(t=e.product_media[0].media.file_path),c.set(e.id,{title:e.title,slug:e.slug,image_url:t})})}let l=a.order_items.map(e=>({...e,product:e.product_id?c.get(e.product_id):null}));return{...a,order_items:l,customer:o}}exports.getOrderDetails=r,exports.getOrders=n;
|