@aglyn/plugins-commerce 1.31.0 → 1.33.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/README.md +4 -0
- package/package.json +13 -13
- package/src/lib/components/cart.js +35 -15
- package/src/lib/components/cart.js.map +1 -1
- package/src/lib/components/commerce-console-page.js +6 -0
- package/src/lib/components/commerce-console-page.js.map +1 -1
- package/src/lib/components/console/currencies-card.component.d.ts +21 -0
- package/src/lib/components/console/currencies-card.component.js +408 -0
- package/src/lib/components/console/currencies-card.component.js.map +1 -0
- package/src/lib/components/console/product-add-ons-fields.component.d.ts +13 -0
- package/src/lib/components/console/product-add-ons-fields.component.js +74 -2
- package/src/lib/components/console/product-add-ons-fields.component.js.map +1 -1
- package/src/lib/components/console/product-editor-dialog.component.js +42 -1
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/product-fixed-prices-fields.component.d.ts +25 -0
- package/src/lib/components/console/product-fixed-prices-fields.component.js +112 -0
- package/src/lib/components/console/product-fixed-prices-fields.component.js.map +1 -0
- package/src/lib/components/console/reservations-card.component.js +32 -15
- package/src/lib/components/console/reservations-card.component.js.map +1 -1
- package/src/lib/components/console/shipping-settings-card.component.js +337 -10
- package/src/lib/components/console/shipping-settings-card.component.js.map +1 -1
- package/src/lib/components/console/store-settings-card.component.js +1 -1
- package/src/lib/components/console/store-settings-card.component.js.map +1 -1
- package/src/lib/components/console/use-currency-setup.d.ts +20 -0
- package/src/lib/components/console/use-currency-setup.js +61 -0
- package/src/lib/components/console/use-currency-setup.js.map +1 -0
- package/src/lib/components/currency-selector.d.ts +36 -0
- package/src/lib/components/currency-selector.js +157 -0
- package/src/lib/components/currency-selector.js.map +1 -0
- package/src/lib/components/product-add-ons.d.ts +9 -1
- package/src/lib/components/product-add-ons.js +8 -4
- package/src/lib/components/product-add-ons.js.map +1 -1
- package/src/lib/components/product-choice-cards.d.ts +13 -1
- package/src/lib/components/product-choice-cards.js +5 -4
- package/src/lib/components/product-choice-cards.js.map +1 -1
- package/src/lib/components/product-detail.d.ts +8 -0
- package/src/lib/components/product-detail.js +38 -11
- package/src/lib/components/product-detail.js.map +1 -1
- package/src/lib/components/product-grid.d.ts +2 -0
- package/src/lib/components/product-grid.js +22 -9
- package/src/lib/components/product-grid.js.map +1 -1
- package/src/lib/components/related-products.js +6 -2
- package/src/lib/components/related-products.js.map +1 -1
- package/src/lib/components/shopper-currency.d.ts +108 -0
- package/src/lib/components/shopper-currency.js +262 -0
- package/src/lib/components/shopper-currency.js.map +1 -0
- package/src/lib/components/wishlist.js +7 -1
- package/src/lib/components/wishlist.js.map +1 -1
- package/src/lib/declarations.server.js +39 -0
- package/src/lib/declarations.server.js.map +1 -1
- package/src/lib/model/commerce-currency-setup.d.ts +79 -0
- package/src/lib/model/commerce-currency-setup.js +124 -0
- package/src/lib/model/commerce-currency-setup.js.map +1 -0
- package/src/lib/model/commerce-currency.d.ts +215 -0
- package/src/lib/model/commerce-currency.js +511 -0
- package/src/lib/model/commerce-currency.js.map +1 -0
- package/src/lib/model/commerce-orders.d.ts +17 -0
- package/src/lib/model/commerce-orders.js +10 -5
- package/src/lib/model/commerce-orders.js.map +1 -1
- package/src/lib/model/commerce-record-routes.js +26 -1
- package/src/lib/model/commerce-record-routes.js.map +1 -1
- package/src/lib/model/commerce-reservations.d.ts +6 -0
- package/src/lib/model/commerce-reservations.js.map +1 -1
- package/src/lib/model/commerce-shipping.d.ts +66 -11
- package/src/lib/model/commerce-shipping.js +91 -7
- package/src/lib/model/commerce-shipping.js.map +1 -1
- package/src/lib/model/commerce.d.ts +6 -0
- package/src/lib/model/commerce.js.map +1 -1
- package/src/lib/model/index.d.ts +2 -0
- package/src/lib/model/index.js +2 -0
- package/src/lib/model/index.js.map +1 -1
- package/src/lib/model/order-figures.js +9 -2
- package/src/lib/model/order-figures.js.map +1 -1
- package/src/lib/model/product-modifiers.d.ts +5 -0
- package/src/lib/model/product-modifiers.js.map +1 -1
- package/src/lib/model/store-setup-content.js +23 -2
- package/src/lib/model/store-setup-content.js.map +1 -1
- package/src/lib/server/billing-webhook.js +37 -24
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/carrier-shipping.d.ts +2 -0
- package/src/lib/server/carrier-shipping.js +8 -4
- package/src/lib/server/carrier-shipping.js.map +1 -1
- package/src/lib/server/cart-checkout.js +74 -13
- package/src/lib/server/cart-checkout.js.map +1 -1
- package/src/lib/server/cart.d.ts +12 -0
- package/src/lib/server/cart.js +50 -4
- package/src/lib/server/cart.js.map +1 -1
- package/src/lib/server/catalog.d.ts +5 -0
- package/src/lib/server/catalog.js +7 -0
- package/src/lib/server/catalog.js.map +1 -1
- package/src/lib/server/checkout.js +53 -12
- package/src/lib/server/checkout.js.map +1 -1
- package/src/lib/server/currency.d.ts +93 -0
- package/src/lib/server/currency.js +182 -0
- package/src/lib/server/currency.js.map +1 -0
- package/src/lib/server/order-notifications.js +4 -2
- package/src/lib/server/order-notifications.js.map +1 -1
- package/src/lib/server/product.d.ts +9 -0
- package/src/lib/server/product.js +12 -0
- package/src/lib/server/product.js.map +1 -1
- package/src/lib/server/refund.js +3 -3
- package/src/lib/server/refund.js.map +1 -1
- package/src/lib/server/site-chat-tools.d.ts +22 -0
- package/src/lib/server/site-chat-tools.js +369 -0
- package/src/lib/server/site-chat-tools.js.map +1 -0
- package/src/lib/server/site-chat-visitor.d.ts +24 -0
- package/src/lib/server/site-chat-visitor.js +39 -0
- package/src/lib/server/site-chat-visitor.js.map +1 -0
- package/src/lib/server/site-offers.d.ts +31 -0
- package/src/lib/server/site-offers.js +91 -0
- package/src/lib/server/site-offers.js.map +1 -0
- package/src/lib/server/stays-site-search.d.ts +20 -0
- package/src/lib/server/stays-site-search.js +78 -0
- package/src/lib/server/stays-site-search.js.map +1 -0
- package/src/lib/server.js +20 -0
- package/src/lib/server.js.map +1 -1
- package/src/lib/site-chat-tool-definitions.d.ts +26 -0
- package/src/lib/site-chat-tool-definitions.js +141 -0
- package/src/lib/site-chat-tool-definitions.js.map +1 -0
- package/src/lib/site.js +8 -0
- package/src/lib/site.js.map +1 -1
- package/src/lib/subprocessors.js +7 -0
- package/src/lib/subprocessors.js.map +1 -1
|
@@ -28,6 +28,7 @@ import { useFirestore, useUser } from "@aglyn/tenant-feature-instance";
|
|
|
28
28
|
import { useFirestoreDoc, writeGuardedBySeed } from "@aglyn/tenant-feature-instance";
|
|
29
29
|
import { pluginDocsHelp } from "@aglyn/aglyn";
|
|
30
30
|
import { heldSaveLabel, isSeedChecking, seedCheckingText, useHeldSave, useSeedEdits } from "@aglyn/tenant-feature-instance/hooks/use-seed-edits";
|
|
31
|
+
import { useCurrencySetup } from "./use-currency-setup.js";
|
|
31
32
|
/** Every country checkout can ship to, plus rest of world, for a zone. */ const ZONE_COUNTRY_OPTIONS = [
|
|
32
33
|
'*',
|
|
33
34
|
...[
|
|
@@ -69,7 +70,7 @@ function zoneCountryLabel(code) {
|
|
|
69
70
|
* that store charges no shipping and refuses nobody — and warning them would
|
|
70
71
|
* nag every store selling downloads.
|
|
71
72
|
*/ export function ShippingSettingsCard(props) {
|
|
72
|
-
var _ref, _current_zones, _current_rates, _ref1;
|
|
73
|
+
var _ref, _current_zones, _current_rates, _ref1, _current_rates1;
|
|
73
74
|
var _current_zones1;
|
|
74
75
|
const { hostId } = props;
|
|
75
76
|
const firestore = useFirestore();
|
|
@@ -122,6 +123,12 @@ function zoneCountryLabel(code) {
|
|
|
122
123
|
user
|
|
123
124
|
]);
|
|
124
125
|
const update = (patch)=>form.edit(patch);
|
|
126
|
+
/*
|
|
127
|
+
* The store's other currencies (AGL-4248), from the same settings doc, and
|
|
128
|
+
* the day's rates for the converted figure each blank field stands for.
|
|
129
|
+
*/ const { rates: fxRates } = useCurrencySetup(hostId);
|
|
130
|
+
const storeBase = CommerceModel.storeBaseCurrency(store);
|
|
131
|
+
const otherCurrencies = CommerceModel.otherStoreCurrencies(store == null ? void 0 : store.currencies, storeBase);
|
|
125
132
|
const updateZone = (index, patch)=>{
|
|
126
133
|
var _current_zones;
|
|
127
134
|
const zones = [
|
|
@@ -146,18 +153,50 @@ function zoneCountryLabel(code) {
|
|
|
146
153
|
});
|
|
147
154
|
};
|
|
148
155
|
const updateRate = (index, patch)=>{
|
|
149
|
-
var _current_rates
|
|
150
|
-
var _current_zones_, _current_zones;
|
|
156
|
+
var _current_rates;
|
|
151
157
|
const rates = [
|
|
152
158
|
...(_current_rates = current.rates) != null ? _current_rates : []
|
|
153
159
|
];
|
|
154
160
|
if (patch === null) rates.splice(index, 1);
|
|
155
|
-
else
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
+
else {
|
|
162
|
+
var _ref;
|
|
163
|
+
var _current_zones_, _current_zones;
|
|
164
|
+
const next = _extends({
|
|
165
|
+
id: Aglyn.createResourceUid(),
|
|
166
|
+
zoneId: (_ref = (_current_zones = current.zones) == null ? void 0 : (_current_zones_ = _current_zones[0]) == null ? void 0 : _current_zones_.id) != null ? _ref : '',
|
|
167
|
+
name: '',
|
|
168
|
+
kind: 'flat'
|
|
169
|
+
}, rates[index], patch);
|
|
170
|
+
// A field emptied on screen is taken off the rate, not stored as
|
|
171
|
+
// `undefined`: this Firestore client rejects the whole save on one.
|
|
172
|
+
for (const key of Object.keys(next)){
|
|
173
|
+
if (next[key] === undefined) delete next[key];
|
|
174
|
+
}
|
|
175
|
+
rates[index] = next;
|
|
176
|
+
}
|
|
177
|
+
update({
|
|
178
|
+
rates
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* One rate's price, or free-over threshold, in another currency
|
|
183
|
+
* (AGL-4248). Blank is converted from the store-currency figure, and drops
|
|
184
|
+
* the key: an emptied map is removed rather than stored as `undefined`.
|
|
185
|
+
*/ const updateRateCurrency = (index, field, code, raw)=>{
|
|
186
|
+
var _current_rates;
|
|
187
|
+
var _current_rates1;
|
|
188
|
+
const rate = (_current_rates1 = current.rates) == null ? void 0 : _current_rates1[index];
|
|
189
|
+
if (!rate) return;
|
|
190
|
+
const major = CommerceModel.parseMajorInput(raw);
|
|
191
|
+
if (major === null) return;
|
|
192
|
+
const map = CommerceModel.withCurrencyAmount(rate[field], code, major === undefined ? undefined : CommerceModel.majorToMinor(major, code));
|
|
193
|
+
const next = _extends({}, rate);
|
|
194
|
+
if (map) next[field] = map;
|
|
195
|
+
else delete next[field];
|
|
196
|
+
const rates = [
|
|
197
|
+
...(_current_rates = current.rates) != null ? _current_rates : []
|
|
198
|
+
];
|
|
199
|
+
rates[index] = next;
|
|
161
200
|
update({
|
|
162
201
|
rates
|
|
163
202
|
});
|
|
@@ -453,7 +492,15 @@ function zoneCountryLabel(code) {
|
|
|
453
492
|
}
|
|
454
493
|
}) : null
|
|
455
494
|
]
|
|
456
|
-
}) :
|
|
495
|
+
}) : null,
|
|
496
|
+
(rate.kind === 'flat' || rate.kind === 'free_over') && otherCurrencies.length ? /*#__PURE__*/ _jsx(RateCurrencyFields, {
|
|
497
|
+
rate: rate,
|
|
498
|
+
base: storeBase,
|
|
499
|
+
currencies: otherCurrencies,
|
|
500
|
+
rates: fxRates,
|
|
501
|
+
onChange: (field, code, raw)=>updateRateCurrency(index, field, code, raw)
|
|
502
|
+
}) : null,
|
|
503
|
+
rate.kind === 'carrier' || rate.kind === 'flat' || rate.kind === 'free_over' ? null : /*#__PURE__*/ _jsxs(Stack, {
|
|
457
504
|
spacing: 1,
|
|
458
505
|
sx: {
|
|
459
506
|
pl: 2
|
|
@@ -547,6 +594,12 @@ function zoneCountryLabel(code) {
|
|
|
547
594
|
children: 'Add tier'
|
|
548
595
|
})
|
|
549
596
|
]
|
|
597
|
+
}),
|
|
598
|
+
rate.kind === 'carrier' ? null : /*#__PURE__*/ _jsx(RateConditionFields, {
|
|
599
|
+
rate: rate,
|
|
600
|
+
currencies: otherCurrencies,
|
|
601
|
+
onChange: (patch)=>updateRate(index, patch),
|
|
602
|
+
onCurrencyChange: (field, code, raw)=>updateRateCurrency(index, field, code, raw)
|
|
550
603
|
})
|
|
551
604
|
]
|
|
552
605
|
}, rate.id);
|
|
@@ -613,6 +666,11 @@ function zoneCountryLabel(code) {
|
|
|
613
666
|
color: "text.secondary",
|
|
614
667
|
children: words.asks
|
|
615
668
|
}) : null,
|
|
669
|
+
((_current_rates1 = current.rates) != null ? _current_rates1 : []).some((rate)=>rate.kind !== 'carrier' && CommerceModel.rateHasConditions(rate)) ? /*#__PURE__*/ _jsx(Typography, {
|
|
670
|
+
variant: "caption",
|
|
671
|
+
color: "text.secondary",
|
|
672
|
+
children: 'Rates with conditions are offered only to orders that meet them, so the destinations above are covered for some orders. An order that meets no rate of its zone is told shipping is not available.'
|
|
673
|
+
}) : null,
|
|
616
674
|
/*#__PURE__*/ _jsx(Button, {
|
|
617
675
|
variant: "contained",
|
|
618
676
|
color: "primary",
|
|
@@ -755,5 +813,274 @@ export default ShippingSettingsCard;
|
|
|
755
813
|
]
|
|
756
814
|
});
|
|
757
815
|
}
|
|
816
|
+
/** Every condition field, cleared together when the merchant removes them (AGL-4255). */ const NO_CONDITIONS = {
|
|
817
|
+
minSubtotalCents: undefined,
|
|
818
|
+
maxSubtotalCents: undefined,
|
|
819
|
+
minSubtotalByCurrency: undefined,
|
|
820
|
+
maxSubtotalByCurrency: undefined,
|
|
821
|
+
minGrams: undefined,
|
|
822
|
+
maxGrams: undefined
|
|
823
|
+
};
|
|
824
|
+
/**
|
|
825
|
+
* A rate's conditions (AGL-4255), as Shopify sets them: offered only to
|
|
826
|
+
* carts whose order price, or whose item weight, falls between a minimum and
|
|
827
|
+
* a maximum. One basis at a time; switching clears the other's figures.
|
|
828
|
+
*/ function RateConditionFields(props) {
|
|
829
|
+
var _rate_minGrams, _rate_maxGrams;
|
|
830
|
+
const { rate, currencies, onChange, onCurrencyChange } = props;
|
|
831
|
+
const byWeight = rate.minGrams != null || rate.maxGrams != null;
|
|
832
|
+
const has = CommerceModel.rateHasConditions(rate);
|
|
833
|
+
const [adding, setAdding] = useState(null);
|
|
834
|
+
const basis = has ? byWeight ? 'weight' : 'price' : adding != null ? adding : 'price';
|
|
835
|
+
const usd = (cents)=>cents == null ? '' : String(cents / 100);
|
|
836
|
+
const cents = (raw)=>raw.trim() === '' || !Number.isFinite(Number(raw)) ? undefined : Math.max(0, Math.round(Number(raw) * 100));
|
|
837
|
+
const grams = (raw)=>raw.trim() === '' || !Number.isFinite(Number(raw)) ? undefined : Math.max(0, Math.round(Number(raw)));
|
|
838
|
+
// Emptying every figure keeps the block open while the merchant types.
|
|
839
|
+
const keep = (patch)=>{
|
|
840
|
+
setAdding(basis);
|
|
841
|
+
onChange(patch);
|
|
842
|
+
};
|
|
843
|
+
if (!has && adding === null) {
|
|
844
|
+
return /*#__PURE__*/ _jsx(Button, {
|
|
845
|
+
size: "small",
|
|
846
|
+
sx: {
|
|
847
|
+
alignSelf: 'flex-start'
|
|
848
|
+
},
|
|
849
|
+
onClick: ()=>setAdding('price'),
|
|
850
|
+
children: 'Add conditions'
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
const minMax = rate.minSubtotalCents != null && rate.maxSubtotalCents != null && rate.minSubtotalCents > rate.maxSubtotalCents ? 'The minimum is above the maximum, so no order gets this rate.' : rate.minGrams != null && rate.maxGrams != null && rate.minGrams > rate.maxGrams ? 'The minimum is above the maximum, so no order gets this rate.' : '';
|
|
854
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
855
|
+
spacing: 1,
|
|
856
|
+
sx: {
|
|
857
|
+
pl: 2
|
|
858
|
+
},
|
|
859
|
+
children: [
|
|
860
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
861
|
+
direction: "row",
|
|
862
|
+
spacing: 1,
|
|
863
|
+
sx: {
|
|
864
|
+
alignItems: 'center'
|
|
865
|
+
},
|
|
866
|
+
children: [
|
|
867
|
+
/*#__PURE__*/ _jsxs(TextField, {
|
|
868
|
+
label: "Conditions",
|
|
869
|
+
value: basis,
|
|
870
|
+
onChange: (event)=>{
|
|
871
|
+
const next = event.target.value;
|
|
872
|
+
setAdding(next);
|
|
873
|
+
if (next !== basis) onChange(NO_CONDITIONS);
|
|
874
|
+
},
|
|
875
|
+
size: "small",
|
|
876
|
+
select: true,
|
|
877
|
+
sx: {
|
|
878
|
+
width: 220
|
|
879
|
+
},
|
|
880
|
+
children: [
|
|
881
|
+
/*#__PURE__*/ _jsx(MenuItem, {
|
|
882
|
+
value: "price",
|
|
883
|
+
children: 'Based on order price'
|
|
884
|
+
}),
|
|
885
|
+
/*#__PURE__*/ _jsx(MenuItem, {
|
|
886
|
+
value: "weight",
|
|
887
|
+
children: 'Based on item weight'
|
|
888
|
+
})
|
|
889
|
+
]
|
|
890
|
+
}),
|
|
891
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
892
|
+
size: "small",
|
|
893
|
+
color: "error",
|
|
894
|
+
onClick: ()=>{
|
|
895
|
+
setAdding(null);
|
|
896
|
+
onChange(NO_CONDITIONS);
|
|
897
|
+
},
|
|
898
|
+
children: 'Remove conditions'
|
|
899
|
+
})
|
|
900
|
+
]
|
|
901
|
+
}),
|
|
902
|
+
basis === 'price' ? /*#__PURE__*/ _jsxs(Stack, {
|
|
903
|
+
direction: "row",
|
|
904
|
+
spacing: 1,
|
|
905
|
+
children: [
|
|
906
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
907
|
+
label: "Minimum order price ($)",
|
|
908
|
+
value: usd(rate.minSubtotalCents),
|
|
909
|
+
onChange: (event)=>keep({
|
|
910
|
+
minSubtotalCents: cents(event.target.value)
|
|
911
|
+
}),
|
|
912
|
+
size: "small",
|
|
913
|
+
sx: {
|
|
914
|
+
width: 200
|
|
915
|
+
},
|
|
916
|
+
slotProps: {
|
|
917
|
+
htmlInput: {
|
|
918
|
+
inputMode: 'decimal'
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
}),
|
|
922
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
923
|
+
label: "Maximum order price ($)",
|
|
924
|
+
value: usd(rate.maxSubtotalCents),
|
|
925
|
+
onChange: (event)=>keep({
|
|
926
|
+
maxSubtotalCents: cents(event.target.value)
|
|
927
|
+
}),
|
|
928
|
+
size: "small",
|
|
929
|
+
sx: {
|
|
930
|
+
width: 200
|
|
931
|
+
},
|
|
932
|
+
slotProps: {
|
|
933
|
+
htmlInput: {
|
|
934
|
+
inputMode: 'decimal'
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
})
|
|
938
|
+
]
|
|
939
|
+
}) : /*#__PURE__*/ _jsxs(Stack, {
|
|
940
|
+
direction: "row",
|
|
941
|
+
spacing: 1,
|
|
942
|
+
children: [
|
|
943
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
944
|
+
label: "Minimum weight (g)",
|
|
945
|
+
value: (_rate_minGrams = rate.minGrams) != null ? _rate_minGrams : '',
|
|
946
|
+
onChange: (event)=>keep({
|
|
947
|
+
minGrams: grams(event.target.value)
|
|
948
|
+
}),
|
|
949
|
+
size: "small",
|
|
950
|
+
sx: {
|
|
951
|
+
width: 200
|
|
952
|
+
},
|
|
953
|
+
slotProps: {
|
|
954
|
+
htmlInput: {
|
|
955
|
+
inputMode: 'numeric'
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
}),
|
|
959
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
960
|
+
label: "Maximum weight (g)",
|
|
961
|
+
value: (_rate_maxGrams = rate.maxGrams) != null ? _rate_maxGrams : '',
|
|
962
|
+
onChange: (event)=>keep({
|
|
963
|
+
maxGrams: grams(event.target.value)
|
|
964
|
+
}),
|
|
965
|
+
size: "small",
|
|
966
|
+
sx: {
|
|
967
|
+
width: 200
|
|
968
|
+
},
|
|
969
|
+
slotProps: {
|
|
970
|
+
htmlInput: {
|
|
971
|
+
inputMode: 'numeric'
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
})
|
|
975
|
+
]
|
|
976
|
+
}),
|
|
977
|
+
basis === 'price' && currencies.length ? currencies.map((entry)=>{
|
|
978
|
+
var _rate_minSubtotalByCurrency, _rate_maxSubtotalByCurrency;
|
|
979
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
980
|
+
direction: "row",
|
|
981
|
+
spacing: 1,
|
|
982
|
+
children: [
|
|
983
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
984
|
+
label: `Minimum (${entry.code})`,
|
|
985
|
+
defaultValue: CommerceModel.minorToInput((_rate_minSubtotalByCurrency = rate.minSubtotalByCurrency) == null ? void 0 : _rate_minSubtotalByCurrency[entry.code], entry.code),
|
|
986
|
+
placeholder: "Converted",
|
|
987
|
+
onBlur: (event)=>onCurrencyChange('minSubtotalByCurrency', entry.code, event.target.value),
|
|
988
|
+
size: "small",
|
|
989
|
+
sx: {
|
|
990
|
+
width: 200
|
|
991
|
+
},
|
|
992
|
+
slotProps: {
|
|
993
|
+
htmlInput: {
|
|
994
|
+
inputMode: 'decimal'
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
}, `${rate.id}-min-${entry.code}`),
|
|
998
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
999
|
+
label: `Maximum (${entry.code})`,
|
|
1000
|
+
defaultValue: CommerceModel.minorToInput((_rate_maxSubtotalByCurrency = rate.maxSubtotalByCurrency) == null ? void 0 : _rate_maxSubtotalByCurrency[entry.code], entry.code),
|
|
1001
|
+
placeholder: "Converted",
|
|
1002
|
+
onBlur: (event)=>onCurrencyChange('maxSubtotalByCurrency', entry.code, event.target.value),
|
|
1003
|
+
size: "small",
|
|
1004
|
+
sx: {
|
|
1005
|
+
width: 200
|
|
1006
|
+
},
|
|
1007
|
+
slotProps: {
|
|
1008
|
+
htmlInput: {
|
|
1009
|
+
inputMode: 'decimal'
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
}, `${rate.id}-max-${entry.code}`)
|
|
1013
|
+
]
|
|
1014
|
+
}, entry.code);
|
|
1015
|
+
}) : null,
|
|
1016
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
1017
|
+
variant: "caption",
|
|
1018
|
+
color: minMax ? 'error' : 'text.secondary',
|
|
1019
|
+
children: minMax || (basis === 'price' ? 'Checkout offers this rate only when the order, before discounts, is within these amounts. Leave one blank for no limit.' : 'Checkout offers this rate only when the items weigh within these amounts. Leave one blank for no limit.')
|
|
1020
|
+
})
|
|
1021
|
+
]
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* A flat or free-over rate in each other currency the store sells in
|
|
1026
|
+
* (AGL-4248). A blank field is converted at the day's rate, and shows the
|
|
1027
|
+
* converted figure as its placeholder; a typed one is charged as typed.
|
|
1028
|
+
*/ function RateCurrencyFields(props) {
|
|
1029
|
+
const { rate, base, currencies, rates, onChange } = props;
|
|
1030
|
+
const converted = (minor, entry)=>minor == null ? '' : CommerceModel.minorToInput(CommerceModel.amountMinorIn(minor, base, entry, rates), entry.code);
|
|
1031
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
1032
|
+
spacing: 1,
|
|
1033
|
+
sx: {
|
|
1034
|
+
pl: 2
|
|
1035
|
+
},
|
|
1036
|
+
children: [
|
|
1037
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
1038
|
+
variant: "caption",
|
|
1039
|
+
color: "text.secondary",
|
|
1040
|
+
children: 'In other currencies. Leave one blank to convert it from the price above.'
|
|
1041
|
+
}),
|
|
1042
|
+
currencies.map((entry)=>{
|
|
1043
|
+
var _rate_amountCents;
|
|
1044
|
+
var _rate_amountsByCurrency, _rate_freeOverByCurrency;
|
|
1045
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
1046
|
+
direction: "row",
|
|
1047
|
+
spacing: 1,
|
|
1048
|
+
children: [
|
|
1049
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
1050
|
+
label: `Price (${entry.code})`,
|
|
1051
|
+
defaultValue: CommerceModel.minorToInput((_rate_amountsByCurrency = rate.amountsByCurrency) == null ? void 0 : _rate_amountsByCurrency[entry.code], entry.code),
|
|
1052
|
+
placeholder: converted((_rate_amountCents = rate.amountCents) != null ? _rate_amountCents : 0, entry),
|
|
1053
|
+
onBlur: (event)=>onChange('amountsByCurrency', entry.code, event.target.value),
|
|
1054
|
+
size: "small",
|
|
1055
|
+
sx: {
|
|
1056
|
+
width: 140
|
|
1057
|
+
},
|
|
1058
|
+
slotProps: {
|
|
1059
|
+
htmlInput: {
|
|
1060
|
+
inputMode: 'decimal'
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
}, `${rate.id}-amount-${entry.code}`),
|
|
1064
|
+
rate.kind === 'free_over' ? /*#__PURE__*/ _jsx(TextField, {
|
|
1065
|
+
label: `Free at subtotal (${entry.code})`,
|
|
1066
|
+
defaultValue: CommerceModel.minorToInput((_rate_freeOverByCurrency = rate.freeOverByCurrency) == null ? void 0 : _rate_freeOverByCurrency[entry.code], entry.code),
|
|
1067
|
+
placeholder: converted(rate.freeOverCents, entry),
|
|
1068
|
+
onBlur: (event)=>onChange('freeOverByCurrency', entry.code, event.target.value),
|
|
1069
|
+
size: "small",
|
|
1070
|
+
sx: {
|
|
1071
|
+
width: 190
|
|
1072
|
+
},
|
|
1073
|
+
slotProps: {
|
|
1074
|
+
htmlInput: {
|
|
1075
|
+
inputMode: 'decimal'
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
}, `${rate.id}-free-${entry.code}`) : null
|
|
1079
|
+
]
|
|
1080
|
+
}, entry.code);
|
|
1081
|
+
})
|
|
1082
|
+
]
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
758
1085
|
|
|
759
1086
|
//# sourceMappingURL=shipping-settings-card.component.js.map
|