@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,175 +1,134 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { revalidatePath as
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use server";
|
|
2
|
+
import { copyProductFromLanguage as e, getProduct as t, getProducts as n } from "../../../product-actions.es.js";
|
|
3
|
+
import { syncFreemiusProductsToSupabase as r, syncSingleFreemiusProduct as i } from "../../../providers/freemius.es.js";
|
|
4
|
+
import { createClient as a, getServiceRoleSupabaseClient as o } from "@nextblock-cms/db/server";
|
|
5
|
+
import { revalidatePath as s } from "next/cache";
|
|
6
|
+
//#region libs/ecommerce/src/lib/pages/cms/products/actions.ts
|
|
7
|
+
async function c(e) {
|
|
8
|
+
let t = a(), { data: r, count: i, error: o } = await await n(t, {
|
|
9
|
+
...e,
|
|
10
|
+
status: "all"
|
|
11
|
+
});
|
|
12
|
+
if (o) throw Error(o.message);
|
|
13
|
+
return {
|
|
14
|
+
data: r,
|
|
15
|
+
count: i
|
|
16
|
+
};
|
|
10
17
|
}
|
|
11
|
-
async function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
async function l(e) {
|
|
19
|
+
let n = a(), { data: r, error: i } = await t(n, e);
|
|
20
|
+
if (i) throw Error(i.message);
|
|
21
|
+
return r;
|
|
15
22
|
}
|
|
16
|
-
async function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
async function u() {
|
|
24
|
+
try {
|
|
25
|
+
let e = await r();
|
|
26
|
+
return s("/cms/products", "page"), {
|
|
27
|
+
success: !0,
|
|
28
|
+
data: e
|
|
29
|
+
};
|
|
30
|
+
} catch (e) {
|
|
31
|
+
return { error: e.message || "Failed to sync with Freemius" };
|
|
32
|
+
}
|
|
23
33
|
}
|
|
24
|
-
async function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
async function d(e) {
|
|
35
|
+
try {
|
|
36
|
+
let t = await i(e);
|
|
37
|
+
return s("/cms/products", "page"), s("/cms/products/[id]/edit", "page"), {
|
|
38
|
+
success: !0,
|
|
39
|
+
data: t
|
|
40
|
+
};
|
|
41
|
+
} catch (e) {
|
|
42
|
+
return { error: e.message || "Failed to sync product with Freemius" };
|
|
43
|
+
}
|
|
31
44
|
}
|
|
32
|
-
async function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
45
|
+
async function f(t, n) {
|
|
46
|
+
try {
|
|
47
|
+
let r = a();
|
|
48
|
+
return await e(r, t, n), s("/cms/products"), s(`/cms/products/${t}/edit`), { success: !0 };
|
|
49
|
+
} catch (e) {
|
|
50
|
+
return {
|
|
51
|
+
success: !1,
|
|
52
|
+
error: e.message || "Failed to copy product content"
|
|
53
|
+
};
|
|
54
|
+
}
|
|
39
55
|
}
|
|
40
|
-
async function
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
56
|
+
async function p(e) {
|
|
57
|
+
let { data: t, error: n } = await a().from("products").select("id, title, language_id, slug").eq("translation_group_id", e);
|
|
58
|
+
if (n) throw Error(n.message);
|
|
59
|
+
return t;
|
|
44
60
|
}
|
|
45
|
-
async function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
id,
|
|
53
|
-
attribute_id,
|
|
54
|
-
value,
|
|
55
|
-
slug,
|
|
56
|
-
sort_order,
|
|
57
|
-
value_translations
|
|
58
|
-
)
|
|
59
|
-
`);
|
|
60
|
-
if (a)
|
|
61
|
-
throw new Error(a.message);
|
|
62
|
-
return (t || []).map((e) => ({
|
|
63
|
-
...e,
|
|
64
|
-
product_attribute_terms: (e.product_attribute_terms || []).sort(
|
|
65
|
-
(s, u) => (s.sort_order ?? Number.MAX_SAFE_INTEGER) - (u.sort_order ?? Number.MAX_SAFE_INTEGER) || s.value.localeCompare(u.value)
|
|
66
|
-
)
|
|
67
|
-
})).sort((e, s) => e.name.localeCompare(s.name));
|
|
61
|
+
async function m() {
|
|
62
|
+
let { data: e, error: t } = await o().from("product_attributes").select("\n id,\n name,\n name_translations,\n slug,\n product_attribute_terms (\n id,\n attribute_id,\n value,\n slug,\n sort_order,\n value_translations\n )\n ");
|
|
63
|
+
if (t) throw Error(t.message);
|
|
64
|
+
return (e || []).map((e) => ({
|
|
65
|
+
...e,
|
|
66
|
+
product_attribute_terms: (e.product_attribute_terms || []).sort((e, t) => (e.sort_order ?? 2 ** 53 - 1) - (t.sort_order ?? 2 ** 53 - 1) || e.value.localeCompare(t.value))
|
|
67
|
+
})).sort((e, t) => e.name.localeCompare(t.name));
|
|
68
68
|
}
|
|
69
|
-
async function
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
title,
|
|
74
|
-
freemius_pricing (
|
|
75
|
-
id,
|
|
76
|
-
license_quota,
|
|
77
|
-
api_monthly_price,
|
|
78
|
-
api_annual_price,
|
|
79
|
-
api_lifetime_price,
|
|
80
|
-
override_monthly_price,
|
|
81
|
-
override_annual_price,
|
|
82
|
-
override_lifetime_price,
|
|
83
|
-
is_active
|
|
84
|
-
)
|
|
85
|
-
`).eq("product_id", r);
|
|
86
|
-
if (e) throw new Error(e.message);
|
|
87
|
-
return a;
|
|
69
|
+
async function h(e) {
|
|
70
|
+
let { data: t, error: n } = await a().from("freemius_plans").select("\n id,\n name,\n title,\n freemius_pricing (\n id,\n license_quota,\n api_monthly_price,\n api_annual_price,\n api_lifetime_price,\n override_monthly_price,\n override_annual_price,\n override_lifetime_price,\n is_active\n )\n ").eq("product_id", e);
|
|
71
|
+
if (n) throw Error(n.message);
|
|
72
|
+
return t;
|
|
88
73
|
}
|
|
89
|
-
async function
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
74
|
+
async function g(e, t) {
|
|
75
|
+
let { error: n } = await a().from("freemius_pricing").update({
|
|
76
|
+
...t,
|
|
77
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
78
|
+
}).eq("id", e);
|
|
79
|
+
return n ? {
|
|
80
|
+
success: !1,
|
|
81
|
+
error: n.message
|
|
82
|
+
} : (s("/cms/products"), { success: !0 });
|
|
95
83
|
}
|
|
96
|
-
async function
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
)
|
|
118
|
-
`).in("product_id", e);
|
|
119
|
-
if (u) throw new Error(u.message);
|
|
120
|
-
return (s || []).map((n) => ({
|
|
121
|
-
id: n.id,
|
|
122
|
-
name: n.name,
|
|
123
|
-
title: n.title,
|
|
124
|
-
pricing: (n.freemius_pricing || []).filter((i) => i.is_active !== !1).map((i) => ({
|
|
125
|
-
id: i.id,
|
|
126
|
-
license_quota: i.license_quota,
|
|
127
|
-
monthly_price: i.override_monthly_price ?? i.api_monthly_price,
|
|
128
|
-
annual_price: i.override_annual_price ?? i.api_annual_price,
|
|
129
|
-
lifetime_price: i.override_lifetime_price ?? i.api_lifetime_price,
|
|
130
|
-
is_active: i.is_active
|
|
131
|
-
}))
|
|
132
|
-
}));
|
|
84
|
+
async function _(e) {
|
|
85
|
+
let t = a(), { data: n } = await t.from("products").select("translation_group_id").eq("id", e).maybeSingle(), r = [e];
|
|
86
|
+
if (n?.translation_group_id) {
|
|
87
|
+
let { data: e } = await t.from("products").select("id").eq("translation_group_id", n.translation_group_id);
|
|
88
|
+
e && e.length > 0 && (r = e.map((e) => e.id));
|
|
89
|
+
}
|
|
90
|
+
let { data: i, error: o } = await t.from("freemius_plans").select("\n id,\n name,\n title,\n freemius_pricing (\n id,\n license_quota,\n api_monthly_price,\n api_annual_price,\n api_lifetime_price,\n override_monthly_price,\n override_annual_price,\n override_lifetime_price,\n is_active\n )\n ").in("product_id", r);
|
|
91
|
+
if (o) throw Error(o.message);
|
|
92
|
+
return (i || []).map((e) => ({
|
|
93
|
+
id: e.id,
|
|
94
|
+
name: e.name,
|
|
95
|
+
title: e.title,
|
|
96
|
+
pricing: (e.freemius_pricing || []).filter((e) => e.is_active !== !1).map((e) => ({
|
|
97
|
+
id: e.id,
|
|
98
|
+
license_quota: e.license_quota,
|
|
99
|
+
monthly_price: e.override_monthly_price ?? e.api_monthly_price,
|
|
100
|
+
annual_price: e.override_annual_price ?? e.api_annual_price,
|
|
101
|
+
lifetime_price: e.override_lifetime_price ?? e.api_lifetime_price,
|
|
102
|
+
is_active: e.is_active
|
|
103
|
+
}))
|
|
104
|
+
}));
|
|
133
105
|
}
|
|
134
|
-
async function
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
106
|
+
async function v() {
|
|
107
|
+
let { data: e, error: t } = await a().from("categories").select("id, name, slug, description, created_at, name_translations, description_translations, product_categories(count)").order("name", { ascending: !0 });
|
|
108
|
+
if (t) throw Error(t.message);
|
|
109
|
+
return (e || []).map((e) => {
|
|
110
|
+
let t = e.product_categories?.[0]?.count ?? e.product_categories?.count ?? 0;
|
|
111
|
+
return {
|
|
112
|
+
id: e.id,
|
|
113
|
+
name: e.name,
|
|
114
|
+
slug: e.slug,
|
|
115
|
+
description: e.description ?? "",
|
|
116
|
+
created_at: e.created_at,
|
|
117
|
+
productCount: Number(t),
|
|
118
|
+
name_translations: e.name_translations || {},
|
|
119
|
+
description_translations: e.description_translations || {}
|
|
120
|
+
};
|
|
121
|
+
});
|
|
150
122
|
}
|
|
151
|
-
async function
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
123
|
+
async function y(e) {
|
|
124
|
+
let { data: t, error: n } = await a().from("categories").select("id, name, slug, description, created_at").eq("slug", e).maybeSingle();
|
|
125
|
+
if (n) throw Error(n.message);
|
|
126
|
+
return t;
|
|
155
127
|
}
|
|
156
|
-
async function
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
128
|
+
async function b(e) {
|
|
129
|
+
let { data: t, error: n } = await a().from("product_categories").select("category:categories(id, name, slug, description, name_translations, description_translations, created_at)").eq("product_id", e);
|
|
130
|
+
if (n) throw Error(n.message);
|
|
131
|
+
return (t || []).map((e) => e.category).filter(Boolean);
|
|
160
132
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
B as getCategoriesWithCount,
|
|
164
|
-
G as getCategoryBySlug,
|
|
165
|
-
A as getFreemiusPricingByProductId,
|
|
166
|
-
C as getGlobalProductAttributes,
|
|
167
|
-
P as getProduct,
|
|
168
|
-
I as getProductCategories,
|
|
169
|
-
q as getProductTranslations,
|
|
170
|
-
v as getProducts,
|
|
171
|
-
T as getPublicFreemiusPricing,
|
|
172
|
-
E as triggerFreemiusSync,
|
|
173
|
-
F as triggerSingleProductSync,
|
|
174
|
-
N as updateFreemiusOverride
|
|
175
|
-
};
|
|
133
|
+
//#endregion
|
|
134
|
+
export { f as copyProductFromLanguageAction, v as getCategoriesWithCount, y as getCategoryBySlug, h as getFreemiusPricingByProductId, m as getGlobalProductAttributes, l as getProduct, b as getProductCategories, p as getProductTranslations, c as getProducts, _ as getPublicFreemiusPricing, u as triggerFreemiusSync, d as triggerSingleProductSync, g as updateFreemiusOverride };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("../../../../../_virtual/_rolldown/runtime.cjs.js"),t=require("../actions.cjs.js"),n=require("../server-actions.cjs.js"),r=require("./components/AttributeManager.cjs.js");let i=require("next/link");i=e.__toESM(i,1);let a=require("lucide-react"),o=require("react/jsx-runtime"),s=require("@nextblock-cms/db/server"),c=require("@nextblock-cms/ui");async function l(){let[e,l]=await Promise.all([t.getGlobalProductAttributes(),(0,s.getActiveLanguagesServerSide)()]),u=(e||[]).map(e=>({id:e.id,name:e.name,name_translations:e.name_translations||{},slug:e.slug,terms:(e.product_attribute_terms||[]).map(e=>({...e,value_translations:e.value_translations||{}}))}));return(0,o.jsxs)(`div`,{className:`space-y-8 w-full max-w-[1200px] mx-auto px-6 py-8`,children:[(0,o.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:(0,o.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,o.jsx)(c.Button,{variant:`outline`,size:`icon`,asChild:!0,children:(0,o.jsx)(i.default,{href:`/cms/products`,children:(0,o.jsx)(a.ArrowLeft,{className:`h-4 w-4`})})}),(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Global Attribute Management`}),(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Define reusable attributes and terms for variation-based physical products.`})]})]})}),(0,o.jsx)(r.AttributeManager,{attributes:u,createAttributeAction:n.createProductAttributeAction,deleteAttributeAction:n.deleteProductAttributeAction,createTermAction:n.createProductAttributeTermAction,deleteTermAction:n.deleteProductAttributeTermAction,reorderTermsAction:n.reorderProductAttributeTermsAction,updateTranslationsAction:n.updateProductAttributeTranslationsAction,languages:l})]})}exports.AttributeManagementPage=l;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function AttributeManagementPage(): Promise<import(
|
|
1
|
+
export declare function AttributeManagementPage(): Promise<import('react').JSX.Element>;
|
|
@@ -1,48 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
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
|
-
|
|
1
|
+
import { getGlobalProductAttributes as e } from "../actions.es.js";
|
|
2
|
+
import { createProductAttributeAction as t, createProductAttributeTermAction as n, deleteProductAttributeAction as r, deleteProductAttributeTermAction as i, reorderProductAttributeTermsAction as a, updateProductAttributeTranslationsAction as o } from "../server-actions.es.js";
|
|
3
|
+
import { AttributeManager as s } from "./components/AttributeManager.es.js";
|
|
4
|
+
import c from "next/link";
|
|
5
|
+
import { ArrowLeft as l } from "lucide-react";
|
|
6
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
7
|
+
import { getActiveLanguagesServerSide as f } from "@nextblock-cms/db/server";
|
|
8
|
+
import { Button as p } from "@nextblock-cms/ui";
|
|
9
|
+
//#region libs/ecommerce/src/lib/pages/cms/products/attributes/AttributeManagementPage.tsx
|
|
10
|
+
async function m() {
|
|
11
|
+
let [m, h] = await Promise.all([e(), f()]), g = (m || []).map((e) => ({
|
|
12
|
+
id: e.id,
|
|
13
|
+
name: e.name,
|
|
14
|
+
name_translations: e.name_translations || {},
|
|
15
|
+
slug: e.slug,
|
|
16
|
+
terms: (e.product_attribute_terms || []).map((e) => ({
|
|
17
|
+
...e,
|
|
18
|
+
value_translations: e.value_translations || {}
|
|
19
|
+
}))
|
|
20
|
+
}));
|
|
21
|
+
return /* @__PURE__ */ d("div", {
|
|
22
|
+
className: "space-y-8 w-full max-w-[1200px] mx-auto px-6 py-8",
|
|
23
|
+
children: [/* @__PURE__ */ u("div", {
|
|
24
|
+
className: "flex flex-wrap items-center justify-between gap-4",
|
|
25
|
+
children: /* @__PURE__ */ d("div", {
|
|
26
|
+
className: "flex items-center gap-3",
|
|
27
|
+
children: [/* @__PURE__ */ u(p, {
|
|
28
|
+
variant: "outline",
|
|
29
|
+
size: "icon",
|
|
30
|
+
asChild: !0,
|
|
31
|
+
children: /* @__PURE__ */ u(c, {
|
|
32
|
+
href: "/cms/products",
|
|
33
|
+
children: /* @__PURE__ */ u(l, { className: "h-4 w-4" })
|
|
34
|
+
})
|
|
35
|
+
}), /* @__PURE__ */ d("div", { children: [/* @__PURE__ */ u("h1", {
|
|
36
|
+
className: "text-2xl font-bold",
|
|
37
|
+
children: "Global Attribute Management"
|
|
38
|
+
}), /* @__PURE__ */ u("p", {
|
|
39
|
+
className: "text-sm text-muted-foreground",
|
|
40
|
+
children: "Define reusable attributes and terms for variation-based physical products."
|
|
41
|
+
})] })]
|
|
42
|
+
})
|
|
43
|
+
}), /* @__PURE__ */ u(s, {
|
|
44
|
+
attributes: g,
|
|
45
|
+
createAttributeAction: t,
|
|
46
|
+
deleteAttributeAction: r,
|
|
47
|
+
createTermAction: n,
|
|
48
|
+
deleteTermAction: i,
|
|
49
|
+
reorderTermsAction: a,
|
|
50
|
+
updateTranslationsAction: o,
|
|
51
|
+
languages: h
|
|
52
|
+
})]
|
|
53
|
+
});
|
|
45
54
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
};
|
|
55
|
+
//#endregion
|
|
56
|
+
export { m as AttributeManagementPage };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use
|
|
1
|
+
"use client";let e=require("react"),t=require("lucide-react"),n=require("react/jsx-runtime"),r=require("next/navigation"),i=require("@nextblock-cms/ui");function a({attributes:a,languages:o,createAttributeAction:s,deleteAttributeAction:c,createTermAction:l,deleteTermAction:u,reorderTermsAction:d,updateTranslationsAction:f}){let p=(0,r.useRouter)(),[m,h]=(0,e.useState)(``),[g,_]=(0,e.useState)(null),[v,y]=(0,e.useState)(null),[b,x]=(0,e.useState)(null),[S,C]=(0,e.useState)(null),[w,T]=(0,e.useState)({}),[E,D]=(0,e.useState)(()=>a.reduce((e,t)=>(e[t.id]=t.name_translations||{},e),{})),[O,k]=(0,e.useState)(()=>a.reduce((e,t)=>{for(let n of t.terms)e[n.id]=n.value_translations||{};return e},{})),A=o.filter(e=>!e.is_default),j=async e=>{e.preventDefault();let t=await s({name:m});if(!t.success){alert(t.error||`Failed to create attribute.`);return}h(``),p.refresh()},M=async(e,t)=>{e.preventDefault(),_(t);let n=await l({attributeId:t,value:w[t]||``});if(_(null),!n.success){alert(n.error||`Failed to create term.`);return}T(e=>({...e,[t]:``})),p.refresh()},N=async e=>{if(!window.confirm(`Delete this attribute and all of its terms?`))return;let t=await c(e);if(!t.success){alert(t.error||`Failed to delete attribute.`);return}p.refresh()},P=async e=>{y(e);let t=await u(e);if(y(null),!t.success){alert(t.error||`Failed to delete term.`);return}p.refresh()},F=async(e,t,n)=>{let r=e.terms.findIndex(e=>e.id===t),i=r+n;if(r===-1||i<0||i>=e.terms.length)return;let a=[...e.terms],[o]=a.splice(r,1);a.splice(i,0,o),x(e.id);let s=await d({attributeId:e.id,orderedTermIds:a.map(e=>e.id)});if(x(null),!s.success){alert(s.error||`Failed to reorder terms.`);return}p.refresh()},I=async e=>{C(e.id);let t=await f({attributeId:e.id,nameTranslations:E[e.id]||{},termTranslations:e.terms.map(e=>({termId:e.id,valueTranslations:O[e.id]||{}}))});if(C(null),!t.success){alert(t.error||`Failed to save translations.`);return}p.refresh()};return(0,n.jsxs)(`div`,{className:`space-y-6`,children:[(0,n.jsx)(`form`,{onSubmit:j,className:`rounded-lg border bg-card p-6 shadow-sm`,children:(0,n.jsxs)(`div`,{className:`flex flex-wrap items-end gap-4`,children:[(0,n.jsxs)(`div`,{className:`flex-1 min-w-[220px] space-y-2`,children:[(0,n.jsx)(i.Label,{htmlFor:`attribute-name`,children:`New Attribute`}),(0,n.jsx)(i.Input,{id:`attribute-name`,value:m,onChange:e=>h(e.target.value),placeholder:`Material, Size, Color...`})]}),(0,n.jsxs)(i.Button,{type:`submit`,disabled:!m.trim(),children:[(0,n.jsx)(t.Plus,{className:`mr-2 h-4 w-4`}),`Create Attribute`]})]})}),a.length===0?(0,n.jsx)(`div`,{className:`rounded-lg border border-dashed p-6 text-sm text-muted-foreground`,children:`No global attributes have been created yet.`}):(0,n.jsx)(`div`,{className:`grid gap-6`,children:a.map(e=>(0,n.jsxs)(`div`,{className:`rounded-lg border bg-card p-6 shadow-sm`,children:[(0,n.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,n.jsxs)(`div`,{children:[(0,n.jsx)(`h2`,{className:`text-lg font-semibold`,children:e.name}),(0,n.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.slug})]}),(0,n.jsx)(i.Button,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>N(e.id),className:`text-muted-foreground hover:text-destructive`,children:(0,n.jsx)(t.Trash2,{className:`h-4 w-4`})})]}),(0,n.jsx)(`div`,{className:`mt-4 space-y-2`,children:e.terms.map((r,a)=>(0,n.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border bg-muted/20 px-3 py-2`,children:[(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(i.Badge,{variant:`secondary`,className:`py-1.5`,children:r.value}),(0,n.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Position `,a+1]})]}),(0,n.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,n.jsx)(i.Button,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>F(e,r.id,-1),disabled:a===0||b===e.id,children:(0,n.jsx)(t.ChevronUp,{className:`h-4 w-4`})}),(0,n.jsx)(i.Button,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>F(e,r.id,1),disabled:a===e.terms.length-1||b===e.id,children:(0,n.jsx)(t.ChevronDown,{className:`h-4 w-4`})}),(0,n.jsx)(i.Button,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>P(r.id),className:`h-8 w-8 text-muted-foreground hover:text-destructive`,disabled:v===r.id,children:(0,n.jsx)(t.Trash2,{className:`h-4 w-4`})})]})]},r.id))}),(0,n.jsxs)(`form`,{onSubmit:t=>M(t,e.id),className:`mt-6 flex flex-wrap items-end gap-3`,children:[(0,n.jsxs)(`div`,{className:`flex-1 min-w-[220px] space-y-2`,children:[(0,n.jsx)(i.Label,{htmlFor:`term-input-${e.id}`,children:`Add Term`}),(0,n.jsx)(i.Input,{id:`term-input-${e.id}`,value:w[e.id]||``,onChange:t=>T(n=>({...n,[e.id]:t.target.value})),placeholder:`Add a term for ${e.name}`})]}),(0,n.jsxs)(i.Button,{type:`submit`,variant:`outline`,disabled:!w[e.id]?.trim()||g===e.id,children:[(0,n.jsx)(t.Plus,{className:`mr-2 h-4 w-4`}),g===e.id?`Saving...`:`Add Term`]})]}),A.length>0&&(0,n.jsxs)(`div`,{className:`mt-6 border-t pt-6 space-y-4`,children:[(0,n.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,n.jsxs)(`div`,{children:[(0,n.jsx)(`h3`,{className:`font-medium`,children:`Translations`}),(0,n.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Translate the attribute label and each term for every active site language.`})]}),(0,n.jsx)(i.Button,{type:`button`,variant:`outline`,onClick:()=>I(e),disabled:S===e.id,children:S===e.id?`Saving...`:`Save Translations`})]}),(0,n.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:A.map(t=>(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsxs)(i.Label,{htmlFor:`attribute-translation-${e.id}-${t.code}`,children:[`Attribute Name (`,t.name,`)`]}),(0,n.jsx)(i.Input,{id:`attribute-translation-${e.id}-${t.code}`,value:E[e.id]?.[t.code]||``,onChange:n=>D(r=>({...r,[e.id]:{...r[e.id]||{},[t.code]:n.target.value}})),placeholder:e.name})]},`${e.id}-${t.code}`))}),(0,n.jsx)(`div`,{className:`space-y-3`,children:e.terms.map(e=>(0,n.jsxs)(`div`,{className:`rounded-lg border p-4 space-y-3`,children:[(0,n.jsxs)(`div`,{children:[(0,n.jsx)(`p`,{className:`font-medium`,children:e.value}),(0,n.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Translate this term for each language.`})]}),(0,n.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:A.map(t=>(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(i.Label,{htmlFor:`term-translation-${e.id}-${t.code}`,children:t.name}),(0,n.jsx)(i.Input,{id:`term-translation-${e.id}-${t.code}`,value:O[e.id]?.[t.code]||``,onChange:n=>k(r=>({...r,[e.id]:{...r[e.id]||{},[t.code]:n.target.value}})),placeholder:e.value})]},`${e.id}-${t.code}`))})]},`translations-${e.id}`))})]})]},e.id))})]})}exports.AttributeManager=a;
|
|
@@ -46,5 +46,5 @@ interface AttributeManagerProps {
|
|
|
46
46
|
error?: string;
|
|
47
47
|
}>;
|
|
48
48
|
}
|
|
49
|
-
export declare function AttributeManager({ attributes, languages, createAttributeAction, deleteAttributeAction, createTermAction, deleteTermAction, reorderTermsAction, updateTranslationsAction, }: AttributeManagerProps): import(
|
|
49
|
+
export declare function AttributeManager({ attributes, languages, createAttributeAction, deleteAttributeAction, createTermAction, deleteTermAction, reorderTermsAction, updateTranslationsAction, }: AttributeManagerProps): import('react').JSX.Element;
|
|
50
50
|
export {};
|