@shipengine/elements 0.16.0 → 0.16.1
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/components/add-funds-form/add-funds-form.d.ts +22 -0
- package/components/add-funds-form/add-funds-form.styles.d.ts +6 -0
- package/components/{organisms/manual-funding-form/manual-funding-schema.d.ts → add-funds-form/add-funds-schema.d.ts} +13 -3
- package/components/add-funds-form/index.d.ts +2 -0
- package/components/auto-funding-form/auto-funding-form.d.ts +8 -0
- package/components/auto-funding-form/index.d.ts +2 -0
- package/components/carrier-balance/carrier-balance.d.ts +4 -0
- package/components/carrier-balance/carrier-balance.styles.d.ts +1 -0
- package/components/carrier-balance/index.d.ts +1 -0
- package/components/field/create-field-controller.d.ts +2 -1
- package/components/fund-and-purchase/fund-and-purchase.d.ts +15 -0
- package/components/fund-and-purchase/fund-and-purchase.styles.d.ts +1 -0
- package/components/fund-and-purchase/index.d.ts +1 -0
- package/components/index.d.ts +9 -0
- package/components/inline-label/index.d.ts +1 -0
- package/components/inline-label/inline-label.d.ts +6 -0
- package/components/link-action/index.d.ts +1 -0
- package/components/link-action/link-action.d.ts +12 -0
- package/components/manage-funding/manage-funding.d.ts +4 -0
- package/components/spread/index.d.ts +1 -0
- package/components/spread/spread.d.ts +5 -0
- package/components/story-notes/index.d.ts +1 -0
- package/components/story-notes/story-notes.d.ts +11 -0
- package/components/templates/index.d.ts +0 -1
- package/components/templates/rate-form/rate-form.styles.d.ts +1 -0
- package/elements/components/index.d.ts +0 -1
- package/elements/index.d.ts +0 -1
- package/hooks/use-nested-form.d.ts +2 -2
- package/index.cjs +1018 -771
- package/index.js +1008 -772
- package/locales/en/index.d.ts +19 -6
- package/mocks/carriers/handlers.d.ts +12 -1
- package/mocks/carriers/index.d.ts +1 -0
- package/mocks/index.d.ts +2 -0
- package/mocks/server.d.ts +2 -0
- package/mocks/warehouses/handlers.d.ts +1 -0
- package/mocks/warehouses/index.d.ts +1 -0
- package/package.json +5 -4
- package/testing/render.d.ts +5 -0
- package/utilities/rates.d.ts +1 -1
- package/components/organisms/auto-funding-form/auto-funding-form.d.ts +0 -16
- package/components/organisms/auto-funding-form/index.d.ts +0 -1
- package/components/organisms/index.d.ts +0 -2
- package/components/organisms/manual-funding-form/index.d.ts +0 -2
- package/components/organisms/manual-funding-form/manual-funding-form.d.ts +0 -18
- package/components/templates/funding-methods/funding-methods.d.ts +0 -18
- package/components/templates/funding-methods/funding-methods.styles.d.ts +0 -1
- package/components/templates/funding-methods/index.d.ts +0 -1
- package/elements/components/manage-funding/manage-funding.d.ts +0 -6
- package/elements/manage-funding.d.ts +0 -1
- package/mocks/handlers.d.ts +0 -12
- /package/components/{organisms/auto-funding-form → auto-funding-form}/auto-funding-form.styles.d.ts +0 -0
- /package/components/{organisms/auto-funding-form → auto-funding-form}/auto-funding-schema.d.ts +0 -0
- /package/{elements/components → components}/manage-funding/index.d.ts +0 -0
package/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var reactDom = require('react-dom');
|
|
|
21
21
|
var min$4 = require('libphonenumber-js/min');
|
|
22
22
|
var cardValidator = require('card-validator');
|
|
23
23
|
var jsBase64 = require('js-base64');
|
|
24
|
+
var reactQuery = require('react-query');
|
|
24
25
|
var stylis = require('stylis');
|
|
25
26
|
var i18n = require('i18next');
|
|
26
27
|
var languageDetector = require('i18next-browser-languagedetector');
|
|
@@ -2039,7 +2040,7 @@ const getRateRequiresAcknowledgement = serviceCode => {
|
|
|
2039
2040
|
return false;
|
|
2040
2041
|
}
|
|
2041
2042
|
};
|
|
2042
|
-
const getTotalRateAmount = rateCosts => calculateTotal(...Object.values(rateCosts));
|
|
2043
|
+
const getTotalRateAmount = (rateCosts = {}) => calculateTotal(...Object.values(rateCosts));
|
|
2043
2044
|
|
|
2044
2045
|
var anObject$9 = anObject$f;
|
|
2045
2046
|
|
|
@@ -3361,6 +3362,7 @@ const createFieldController = (options = {}) => function FieldController(_a) {
|
|
|
3361
3362
|
displayErrors = true,
|
|
3362
3363
|
displayLabel = true,
|
|
3363
3364
|
errors: errorsProp,
|
|
3365
|
+
hint,
|
|
3364
3366
|
inputOnly,
|
|
3365
3367
|
isOptional,
|
|
3366
3368
|
label,
|
|
@@ -3371,7 +3373,7 @@ const createFieldController = (options = {}) => function FieldController(_a) {
|
|
|
3371
3373
|
shouldUnregister,
|
|
3372
3374
|
subLabel
|
|
3373
3375
|
} = _a,
|
|
3374
|
-
formInputProps = __rest(_a, ["children", "control", "defaultValue", "displayErrors", "displayLabel", "errors", "inputOnly", "isOptional", "label", "labelWeight", "name", "nativeLabel", "rules", "shouldUnregister", "subLabel"]);
|
|
3376
|
+
formInputProps = __rest(_a, ["children", "control", "defaultValue", "displayErrors", "displayLabel", "errors", "hint", "inputOnly", "isOptional", "label", "labelWeight", "name", "nativeLabel", "rules", "shouldUnregister", "subLabel"]);
|
|
3375
3377
|
const {
|
|
3376
3378
|
field,
|
|
3377
3379
|
fieldState
|
|
@@ -3447,6 +3449,9 @@ const createFieldController = (options = {}) => function FieldController(_a) {
|
|
|
3447
3449
|
message: displayErrors && mergedErrorMessages.length > 0 ? {
|
|
3448
3450
|
content: mergedErrorMessages.join(", "),
|
|
3449
3451
|
type: giger.FieldMessageType.ERROR
|
|
3452
|
+
} : hint ? {
|
|
3453
|
+
content: hint,
|
|
3454
|
+
type: giger.FieldMessageType.HINT
|
|
3450
3455
|
} : undefined
|
|
3451
3456
|
}, {
|
|
3452
3457
|
children: input
|
|
@@ -22001,9 +22006,10 @@ const SubmitButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(func
|
|
|
22001
22006
|
children,
|
|
22002
22007
|
control,
|
|
22003
22008
|
disabled,
|
|
22009
|
+
isLoading,
|
|
22004
22010
|
requireDirty
|
|
22005
22011
|
} = _a,
|
|
22006
|
-
props = __rest(_a, ["alwaysRequireValidity", "children", "control", "disabled", "requireDirty"]);
|
|
22012
|
+
props = __rest(_a, ["alwaysRequireValidity", "children", "control", "disabled", "isLoading", "requireDirty"]);
|
|
22007
22013
|
const {
|
|
22008
22014
|
isDirty,
|
|
22009
22015
|
isValid,
|
|
@@ -22017,7 +22023,7 @@ const SubmitButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(func
|
|
|
22017
22023
|
disabled: disabled || !isDirty && requireDirty || !isValid && (alwaysRequireValidity || isSubmitted) || isSubmitting,
|
|
22018
22024
|
formNoValidate // Bypass all browser validations on form inputs
|
|
22019
22025
|
: true,
|
|
22020
|
-
isLoading: isSubmitting,
|
|
22026
|
+
isLoading: isLoading || isSubmitting,
|
|
22021
22027
|
ref: forwardedRef,
|
|
22022
22028
|
type: "submit"
|
|
22023
22029
|
}, props, {
|
|
@@ -24220,390 +24226,6 @@ const CustomsItemForm = ({
|
|
|
24220
24226
|
}));
|
|
24221
24227
|
};
|
|
24222
24228
|
|
|
24223
|
-
const Loader = props => {
|
|
24224
|
-
return jsxRuntime.jsx("div", Object.assign({
|
|
24225
|
-
css: {
|
|
24226
|
-
alignItems: "center",
|
|
24227
|
-
display: "flex",
|
|
24228
|
-
flexDirection: "column",
|
|
24229
|
-
height: "100%",
|
|
24230
|
-
justifyContent: "center",
|
|
24231
|
-
textAlign: "center",
|
|
24232
|
-
width: "100%"
|
|
24233
|
-
}
|
|
24234
|
-
}, {
|
|
24235
|
-
children: jsxRuntime.jsx(giger.Spinner, Object.assign({}, props, {
|
|
24236
|
-
size: giger.SpinnerSize.SIZE_LARGE
|
|
24237
|
-
}))
|
|
24238
|
-
}));
|
|
24239
|
-
};
|
|
24240
|
-
|
|
24241
|
-
const styles$8 = createStyles({
|
|
24242
|
-
form: theme => ({
|
|
24243
|
-
backgroundColor: theme.palette.gray.megaLight,
|
|
24244
|
-
display: "flex",
|
|
24245
|
-
flexDirection: "column",
|
|
24246
|
-
gap: theme.spacing(2),
|
|
24247
|
-
padding: theme.spacing(2)
|
|
24248
|
-
})
|
|
24249
|
-
});
|
|
24250
|
-
|
|
24251
|
-
const autoFundingSchema = zod.z.object({
|
|
24252
|
-
isEnabled: zod.z.boolean(),
|
|
24253
|
-
lowBalancePurchaseThreshold: moneySchema.extend({
|
|
24254
|
-
amount: zod.z.number().min(25)
|
|
24255
|
-
}),
|
|
24256
|
-
maximumPurchasesPerDay: zod.z.number().min(1),
|
|
24257
|
-
purchaseAmount: moneySchema.extend({
|
|
24258
|
-
amount: zod.z.number().min(10).max(10000)
|
|
24259
|
-
})
|
|
24260
|
-
});
|
|
24261
|
-
|
|
24262
|
-
/**
|
|
24263
|
-
* This form that allows users to enable or disable auto funding, and
|
|
24264
|
-
* configure auto funding settings in ShipEngine API.
|
|
24265
|
-
*/
|
|
24266
|
-
const AutoFundingForm = ({
|
|
24267
|
-
defaultValues,
|
|
24268
|
-
errorMessage,
|
|
24269
|
-
hasError,
|
|
24270
|
-
isInteger,
|
|
24271
|
-
isLoading,
|
|
24272
|
-
onSubmit,
|
|
24273
|
-
onToggle
|
|
24274
|
-
}) => {
|
|
24275
|
-
const {
|
|
24276
|
-
t
|
|
24277
|
-
} = reactI18next.useTranslation();
|
|
24278
|
-
// const [showForm, toggleShowForm] = useReducer((n) => !n, false); May still need this in a subsequent PR
|
|
24279
|
-
const form = reactHookForm.useForm({
|
|
24280
|
-
defaultValues: defaultValues,
|
|
24281
|
-
resolver: validationResolver(autoFundingSchema)
|
|
24282
|
-
});
|
|
24283
|
-
const {
|
|
24284
|
-
isDirty
|
|
24285
|
-
} = form.formState;
|
|
24286
|
-
const watchIsEnabled = form.watch("isEnabled");
|
|
24287
|
-
const handleSubmit = form.handleSubmit(values => __awaiter(void 0, void 0, void 0, function* () {
|
|
24288
|
-
yield onSubmit(values);
|
|
24289
|
-
}));
|
|
24290
|
-
if (isLoading) return jsxRuntime.jsx(Loader, {
|
|
24291
|
-
message: t("manage-funding:autoFunding.isLoading")
|
|
24292
|
-
});
|
|
24293
|
-
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
24294
|
-
children: [jsxRuntime.jsx(Switch, {
|
|
24295
|
-
defaultChecked: defaultValues === null || defaultValues === void 0 ? void 0 : defaultValues.isEnabled,
|
|
24296
|
-
label: t("manage-funding:autoFunding.addFundsAutomatically"),
|
|
24297
|
-
name: "isEnabled",
|
|
24298
|
-
onChange: evt => {
|
|
24299
|
-
form.reset(Object.assign(Object.assign({}, form.getValues()), {
|
|
24300
|
-
isEnabled: evt.target.checked
|
|
24301
|
-
}));
|
|
24302
|
-
onToggle(evt.target.checked);
|
|
24303
|
-
},
|
|
24304
|
-
value: true
|
|
24305
|
-
}), watchIsEnabled && jsxRuntime.jsxs("form", Object.assign({
|
|
24306
|
-
css: styles$8.form,
|
|
24307
|
-
id: "auto-funding-form",
|
|
24308
|
-
onSubmit: formLogger.capture(handleSubmit)
|
|
24309
|
-
}, {
|
|
24310
|
-
children: [jsxRuntime.jsx(MoneyInput, {
|
|
24311
|
-
control: form.control,
|
|
24312
|
-
disabled: !watchIsEnabled,
|
|
24313
|
-
label: t("manage-funding:autoFunding.purchaseAmount"),
|
|
24314
|
-
name: "purchaseAmount",
|
|
24315
|
-
showCurrencySymbol: true
|
|
24316
|
-
}), jsxRuntime.jsx(MoneyInput, {
|
|
24317
|
-
control: form.control,
|
|
24318
|
-
disabled: !watchIsEnabled,
|
|
24319
|
-
label: t("manage-funding:autoFunding.lowBalancePurchaseThreshold"),
|
|
24320
|
-
name: "lowBalancePurchaseThreshold",
|
|
24321
|
-
showCurrencySymbol: true
|
|
24322
|
-
}), jsxRuntime.jsx(NumberInput, {
|
|
24323
|
-
control: form.control,
|
|
24324
|
-
disabled: !watchIsEnabled,
|
|
24325
|
-
label: t("manage-funding:autoFunding.maximumPurchasesPerDay"),
|
|
24326
|
-
name: "maximumPurchasesPerDay"
|
|
24327
|
-
}), jsxRuntime.jsxs(ButtonGroup, Object.assign({
|
|
24328
|
-
justify: "end"
|
|
24329
|
-
}, {
|
|
24330
|
-
children: [jsxRuntime.jsx(giger.Button, Object.assign({
|
|
24331
|
-
disabled: !isDirty,
|
|
24332
|
-
onClick: () => form.reset(),
|
|
24333
|
-
variant: giger.ButtonVariant.TEXT
|
|
24334
|
-
}, {
|
|
24335
|
-
children: t("actions.cancel")
|
|
24336
|
-
})), jsxRuntime.jsx(SubmitButton, Object.assign({
|
|
24337
|
-
control: form.control,
|
|
24338
|
-
"data-testid": "autoFunding.submit",
|
|
24339
|
-
disabled: !watchIsEnabled,
|
|
24340
|
-
requireDirty: true,
|
|
24341
|
-
variant: giger.ButtonVariant.OUTLINED
|
|
24342
|
-
}, {
|
|
24343
|
-
children: t("manage-funding:actions.saveRule")
|
|
24344
|
-
}))]
|
|
24345
|
-
}))]
|
|
24346
|
-
})), hasError && errorMessage && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
24347
|
-
children: [jsxRuntime.jsx(Spacer, {}), jsxRuntime.jsx(giger.InlineNotification, Object.assign({
|
|
24348
|
-
title: t("manage-funding:autoFunding.error.title"),
|
|
24349
|
-
type: giger.NotificationType.ERROR
|
|
24350
|
-
}, {
|
|
24351
|
-
children: errorMessage
|
|
24352
|
-
})), jsxRuntime.jsx(Spacer, {})]
|
|
24353
|
-
})]
|
|
24354
|
-
});
|
|
24355
|
-
};
|
|
24356
|
-
|
|
24357
|
-
const manualFundingSchema = zod.z.object({
|
|
24358
|
-
funds: moneySchema.extend({
|
|
24359
|
-
amount: zod.z.number().min(10)
|
|
24360
|
-
})
|
|
24361
|
-
});
|
|
24362
|
-
|
|
24363
|
-
const ManualFundingForm = ({
|
|
24364
|
-
currentBalance,
|
|
24365
|
-
errorMessage,
|
|
24366
|
-
formId,
|
|
24367
|
-
hasError,
|
|
24368
|
-
isLoading,
|
|
24369
|
-
onCancel,
|
|
24370
|
-
onSubmit,
|
|
24371
|
-
portalRef,
|
|
24372
|
-
requiredAmount
|
|
24373
|
-
}) => {
|
|
24374
|
-
var _a;
|
|
24375
|
-
const {
|
|
24376
|
-
t
|
|
24377
|
-
} = reactI18next.useTranslation();
|
|
24378
|
-
const fundingRecommendations = React.useMemo(() => ["$20", "$50", "$100", t("manage-funding:actions.other")], [t]);
|
|
24379
|
-
const suggestedAmount = Math.max(requiredAmount !== null && requiredAmount !== void 0 ? requiredAmount : 0, 10);
|
|
24380
|
-
const [selectedFundingAmountIndex, setSelectedFundingAmountIndex] = React.useState(requiredAmount ? 3 : 0);
|
|
24381
|
-
const [showFormInput, toggleShowFormInput] = useToggle(!!requiredAmount);
|
|
24382
|
-
const getSelectedFundingValue = value => {
|
|
24383
|
-
return Number(value.replace(/[^0-9.-]+/g, ""));
|
|
24384
|
-
};
|
|
24385
|
-
const form = reactHookForm.useForm({
|
|
24386
|
-
defaultValues: {
|
|
24387
|
-
funds: {
|
|
24388
|
-
amount: suggestedAmount,
|
|
24389
|
-
currency: api.SE.Currency.USD
|
|
24390
|
-
}
|
|
24391
|
-
},
|
|
24392
|
-
resolver: validationResolver(manualFundingSchema)
|
|
24393
|
-
});
|
|
24394
|
-
const resultingBalance = currentBalance + ((_a = form.watch("funds").amount) !== null && _a !== void 0 ? _a : 0);
|
|
24395
|
-
const formInterface = jsxRuntime.jsxs("section", Object.assign({
|
|
24396
|
-
css: theme => ({
|
|
24397
|
-
backgroundColor: theme.palette.gray.megaLight,
|
|
24398
|
-
padding: theme.spacing(2)
|
|
24399
|
-
})
|
|
24400
|
-
}, {
|
|
24401
|
-
children: [jsxRuntime.jsx(giger.Typography, Object.assign({
|
|
24402
|
-
bold: true
|
|
24403
|
-
}, {
|
|
24404
|
-
children: t("manage-funding:addFunds")
|
|
24405
|
-
})), jsxRuntime.jsx(Spacer, {
|
|
24406
|
-
multiplier: 2
|
|
24407
|
-
}), jsxRuntime.jsx(giger.ChipList, Object.assign({
|
|
24408
|
-
onChange: idx => {
|
|
24409
|
-
setSelectedFundingAmountIndex(idx);
|
|
24410
|
-
if (idx === fundingRecommendations.length - 1) {
|
|
24411
|
-
toggleShowFormInput(true);
|
|
24412
|
-
return;
|
|
24413
|
-
} else {
|
|
24414
|
-
toggleShowFormInput(false);
|
|
24415
|
-
form.reset({
|
|
24416
|
-
funds: {
|
|
24417
|
-
amount: getSelectedFundingValue(fundingRecommendations[idx]),
|
|
24418
|
-
currency: api.SE.Currency.USD
|
|
24419
|
-
}
|
|
24420
|
-
});
|
|
24421
|
-
}
|
|
24422
|
-
}
|
|
24423
|
-
}, {
|
|
24424
|
-
children: fundingRecommendations.map((item, idx) => jsxRuntime.jsx(giger.Chip, Object.assign({
|
|
24425
|
-
css: theme => ({
|
|
24426
|
-
backgroundColor: idx !== selectedFundingAmountIndex ? theme.palette.white : theme.palette.primary.main,
|
|
24427
|
-
color: idx !== selectedFundingAmountIndex ? theme.palette.gray.main : theme.palette.white
|
|
24428
|
-
}),
|
|
24429
|
-
isSelected: idx === selectedFundingAmountIndex
|
|
24430
|
-
}, {
|
|
24431
|
-
children: item
|
|
24432
|
-
}), idx))
|
|
24433
|
-
})), jsxRuntime.jsx(Spacer, {
|
|
24434
|
-
multiplier: 1
|
|
24435
|
-
}), showFormInput && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
24436
|
-
children: [jsxRuntime.jsx(MoneyInput, {
|
|
24437
|
-
control: form.control,
|
|
24438
|
-
defaultValue: {
|
|
24439
|
-
amount: undefined,
|
|
24440
|
-
currency: api.SE.Currency.USD
|
|
24441
|
-
},
|
|
24442
|
-
label: t("manage-funding:otp.labels.amount"),
|
|
24443
|
-
name: "funds",
|
|
24444
|
-
placeholder: "Amount",
|
|
24445
|
-
showCurrencySymbol: true,
|
|
24446
|
-
subLabel: "Minimum purchase $10.00"
|
|
24447
|
-
}), jsxRuntime.jsxs(FieldLabel, Object.assign({
|
|
24448
|
-
label: t("manage-funding:otp.labels.resultingBalance")
|
|
24449
|
-
}, {
|
|
24450
|
-
children: [jsxRuntime.jsx(giger.Typography, Object.assign({
|
|
24451
|
-
variant: "body1"
|
|
24452
|
-
}, {
|
|
24453
|
-
children: formatMoney({
|
|
24454
|
-
amount: resultingBalance,
|
|
24455
|
-
currency: api.SE.Currency.USD
|
|
24456
|
-
})
|
|
24457
|
-
})), jsxRuntime.jsx(Spacer, {})]
|
|
24458
|
-
}))]
|
|
24459
|
-
}), jsxRuntime.jsxs(ButtonGroup, Object.assign({
|
|
24460
|
-
justify: "end"
|
|
24461
|
-
}, {
|
|
24462
|
-
children: [jsxRuntime.jsx(giger.Button, Object.assign({
|
|
24463
|
-
onClick: onCancel,
|
|
24464
|
-
variant: giger.ButtonVariant.TEXT
|
|
24465
|
-
}, {
|
|
24466
|
-
children: t("actions.cancel")
|
|
24467
|
-
})), jsxRuntime.jsx(SubmitButton, Object.assign({
|
|
24468
|
-
control: form.control,
|
|
24469
|
-
form: formId,
|
|
24470
|
-
variant: giger.ButtonVariant.OUTLINED
|
|
24471
|
-
}, {
|
|
24472
|
-
children: t(formId ? "actions.purchase" : "manage-funding:actions.addNow")
|
|
24473
|
-
}))]
|
|
24474
|
-
}))]
|
|
24475
|
-
}));
|
|
24476
|
-
if (isLoading) return jsxRuntime.jsx(Loader, {
|
|
24477
|
-
message: t("manage-funding:otp.isLoading")
|
|
24478
|
-
});
|
|
24479
|
-
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
24480
|
-
children: [jsxRuntime.jsx("form", Object.assign({
|
|
24481
|
-
id: formId,
|
|
24482
|
-
onSubmit: formLogger.capture(form.handleSubmit(onSubmit))
|
|
24483
|
-
}, {
|
|
24484
|
-
children: portalRef !== undefined ?
|
|
24485
|
-
// Nested form in a well
|
|
24486
|
-
jsxRuntime.jsx(Portal, Object.assign({
|
|
24487
|
-
target: portalRef
|
|
24488
|
-
}, {
|
|
24489
|
-
children: jsxRuntime.jsx("section", Object.assign({
|
|
24490
|
-
css: theme => ({
|
|
24491
|
-
backgroundColor: theme.palette.gray.megaLight,
|
|
24492
|
-
padding: theme.spacing(2)
|
|
24493
|
-
})
|
|
24494
|
-
}, {
|
|
24495
|
-
children: formInterface
|
|
24496
|
-
}))
|
|
24497
|
-
})) :
|
|
24498
|
-
// Standalone form
|
|
24499
|
-
formInterface
|
|
24500
|
-
})), hasError && errorMessage && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
24501
|
-
children: [jsxRuntime.jsx(Spacer, {}), jsxRuntime.jsx(giger.InlineNotification, Object.assign({
|
|
24502
|
-
title: t("manage-funding:otp.error.title"),
|
|
24503
|
-
type: giger.NotificationType.ERROR
|
|
24504
|
-
}, {
|
|
24505
|
-
children: errorMessage
|
|
24506
|
-
})), jsxRuntime.jsx(Spacer, {})]
|
|
24507
|
-
})]
|
|
24508
|
-
});
|
|
24509
|
-
};
|
|
24510
|
-
|
|
24511
|
-
const styles$7 = createStyles({
|
|
24512
|
-
addFundsButton: theme => ({
|
|
24513
|
-
alignItems: "center",
|
|
24514
|
-
display: "flex",
|
|
24515
|
-
gap: theme.spacing(1)
|
|
24516
|
-
}),
|
|
24517
|
-
balanceText: theme => ({
|
|
24518
|
-
color: theme.palette.success.main
|
|
24519
|
-
}),
|
|
24520
|
-
header: theme => ({
|
|
24521
|
-
display: "flex",
|
|
24522
|
-
gap: theme.spacing(2),
|
|
24523
|
-
justifyContent: "space-between"
|
|
24524
|
-
}),
|
|
24525
|
-
negativeBalanceText: theme => ({
|
|
24526
|
-
color: theme.palette.error.main
|
|
24527
|
-
})
|
|
24528
|
-
});
|
|
24529
|
-
|
|
24530
|
-
const FundingMethods = ({
|
|
24531
|
-
addFundsErrorMessage,
|
|
24532
|
-
autoFundingData,
|
|
24533
|
-
autoFundingErrorMessage,
|
|
24534
|
-
fundingMethod,
|
|
24535
|
-
hasAutoFundingError,
|
|
24536
|
-
hasManualFundingError,
|
|
24537
|
-
isAutoFundingLoading,
|
|
24538
|
-
isManualFundingLoading,
|
|
24539
|
-
manualFundingCurrentBalance,
|
|
24540
|
-
manualFundingRequiredAmount,
|
|
24541
|
-
onSubmitAutoFunding,
|
|
24542
|
-
onSubmitManualFunding,
|
|
24543
|
-
onToggleAutoFunding
|
|
24544
|
-
}) => {
|
|
24545
|
-
const {
|
|
24546
|
-
t
|
|
24547
|
-
} = reactI18next.useTranslation();
|
|
24548
|
-
const [showFundingMethods, toggleShowFundingMethods] = useToggle(false);
|
|
24549
|
-
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
24550
|
-
children: [jsxRuntime.jsxs("div", Object.assign({
|
|
24551
|
-
css: styles$7.header
|
|
24552
|
-
}, {
|
|
24553
|
-
children: [jsxRuntime.jsxs("div", {
|
|
24554
|
-
children: [jsxRuntime.jsx(giger.Typography, Object.assign({
|
|
24555
|
-
variant: "body1"
|
|
24556
|
-
}, {
|
|
24557
|
-
children: t("manage-funding:currentBalance")
|
|
24558
|
-
})), jsxRuntime.jsx(giger.Typography, Object.assign({
|
|
24559
|
-
bold: true,
|
|
24560
|
-
css: manualFundingCurrentBalance >= 0 ? styles$7.balanceText : styles$7.negativeBalanceText,
|
|
24561
|
-
variant: "body1"
|
|
24562
|
-
}, {
|
|
24563
|
-
children: formatMoney({
|
|
24564
|
-
amount: manualFundingCurrentBalance,
|
|
24565
|
-
currency: api.SE.Currency.USD
|
|
24566
|
-
})
|
|
24567
|
-
}))]
|
|
24568
|
-
}), jsxRuntime.jsxs(giger.Link, Object.assign({
|
|
24569
|
-
bold: true,
|
|
24570
|
-
css: styles$7.addFundsButton,
|
|
24571
|
-
onClick: toggleShowFundingMethods,
|
|
24572
|
-
size: giger.ButtonSize.MEDIUM
|
|
24573
|
-
}, {
|
|
24574
|
-
children: [t("manage-funding:addFunds"), jsxRuntime.jsx(giger.Icon, {
|
|
24575
|
-
name: brands.IconNames.ADD,
|
|
24576
|
-
size: giger.IconSize.SIZE_MEDIUM,
|
|
24577
|
-
title: "Add Funds"
|
|
24578
|
-
})]
|
|
24579
|
-
}))]
|
|
24580
|
-
})), jsxRuntime.jsx(Spacer, {}), jsxRuntime.jsx("div", Object.assign({
|
|
24581
|
-
css: theme => Object.assign(Object.assign({}, !showFundingMethods && {
|
|
24582
|
-
display: "none"
|
|
24583
|
-
}), {
|
|
24584
|
-
marginBottom: theme.spacing(2)
|
|
24585
|
-
})
|
|
24586
|
-
}, {
|
|
24587
|
-
children: ["manual", "both"].includes(fundingMethod) && jsxRuntime.jsx(ManualFundingForm, {
|
|
24588
|
-
currentBalance: manualFundingCurrentBalance,
|
|
24589
|
-
errorMessage: addFundsErrorMessage,
|
|
24590
|
-
hasError: hasManualFundingError,
|
|
24591
|
-
isLoading: isManualFundingLoading,
|
|
24592
|
-
onCancel: toggleShowFundingMethods,
|
|
24593
|
-
onSubmit: onSubmitManualFunding,
|
|
24594
|
-
requiredAmount: manualFundingRequiredAmount
|
|
24595
|
-
})
|
|
24596
|
-
})), ["auto", "both"].includes(fundingMethod) && jsxRuntime.jsx(AutoFundingForm, {
|
|
24597
|
-
defaultValues: autoFundingData,
|
|
24598
|
-
errorMessage: autoFundingErrorMessage,
|
|
24599
|
-
hasError: hasAutoFundingError,
|
|
24600
|
-
isLoading: isAutoFundingLoading,
|
|
24601
|
-
onSubmit: onSubmitAutoFunding,
|
|
24602
|
-
onToggle: onToggleAutoFunding
|
|
24603
|
-
})]
|
|
24604
|
-
});
|
|
24605
|
-
};
|
|
24606
|
-
|
|
24607
24229
|
const Label = ({
|
|
24608
24230
|
label,
|
|
24609
24231
|
onClickVoid,
|
|
@@ -24743,7 +24365,7 @@ const LandingPageForm = ({
|
|
|
24743
24365
|
}));
|
|
24744
24366
|
};
|
|
24745
24367
|
|
|
24746
|
-
const styles$
|
|
24368
|
+
const styles$8 = createStyles({
|
|
24747
24369
|
container: theme => ({
|
|
24748
24370
|
padding: theme.spacing(2)
|
|
24749
24371
|
}),
|
|
@@ -24764,11 +24386,11 @@ const LandingPage = ({
|
|
|
24764
24386
|
t
|
|
24765
24387
|
} = reactI18next.useTranslation();
|
|
24766
24388
|
return jsxRuntime.jsxs("div", Object.assign({
|
|
24767
|
-
css: styles$
|
|
24389
|
+
css: styles$8.container,
|
|
24768
24390
|
"data-testid": "landing-page"
|
|
24769
24391
|
}, {
|
|
24770
24392
|
children: [jsxRuntime.jsxs("div", Object.assign({
|
|
24771
|
-
css: styles$
|
|
24393
|
+
css: styles$8.header
|
|
24772
24394
|
}, {
|
|
24773
24395
|
children: [jsxRuntime.jsx(giger.Typography, Object.assign({
|
|
24774
24396
|
variant: "heading4"
|
|
@@ -24786,7 +24408,7 @@ const LandingPage = ({
|
|
|
24786
24408
|
})), jsxRuntime.jsx(LandingPageForm, {
|
|
24787
24409
|
onSubmit: onSubmit
|
|
24788
24410
|
}), jsxRuntime.jsxs("div", Object.assign({
|
|
24789
|
-
css: styles$
|
|
24411
|
+
css: styles$8.header
|
|
24790
24412
|
}, {
|
|
24791
24413
|
children: [jsxRuntime.jsx(Spacer, {
|
|
24792
24414
|
multiplier: 6
|
|
@@ -24797,7 +24419,7 @@ const LandingPage = ({
|
|
|
24797
24419
|
})), jsxRuntime.jsx(Spacer, {
|
|
24798
24420
|
multiplier: 2
|
|
24799
24421
|
}), jsxRuntime.jsx(giger.Typography, Object.assign({
|
|
24800
|
-
css: styles$
|
|
24422
|
+
css: styles$8.description,
|
|
24801
24423
|
variant: "body1"
|
|
24802
24424
|
}, {
|
|
24803
24425
|
children: t("onboarding:landing.description")
|
|
@@ -24878,7 +24500,7 @@ const Accordion = _a => {
|
|
|
24878
24500
|
});
|
|
24879
24501
|
};
|
|
24880
24502
|
|
|
24881
|
-
const styles$
|
|
24503
|
+
const styles$7 = createStyles({
|
|
24882
24504
|
carrierTypography: theme => ({
|
|
24883
24505
|
color: theme.palette.black
|
|
24884
24506
|
}),
|
|
@@ -24963,13 +24585,13 @@ const ListCarriersRow = ({
|
|
|
24963
24585
|
setIsSubmitting(false);
|
|
24964
24586
|
});
|
|
24965
24587
|
return jsxRuntime.jsxs("div", Object.assign({
|
|
24966
|
-
css: styles$
|
|
24588
|
+
css: styles$7.container
|
|
24967
24589
|
}, {
|
|
24968
24590
|
children: [jsxRuntime.jsxs("div", Object.assign({
|
|
24969
|
-
css: styles$
|
|
24591
|
+
css: styles$7.rowContainer
|
|
24970
24592
|
}, {
|
|
24971
24593
|
children: [jsxRuntime.jsxs("div", Object.assign({
|
|
24972
|
-
css: styles$
|
|
24594
|
+
css: styles$7.logoContainer
|
|
24973
24595
|
}, {
|
|
24974
24596
|
children: [jsxRuntime.jsx("div", {
|
|
24975
24597
|
children: jsxRuntime.jsx("img", {
|
|
@@ -25006,7 +24628,7 @@ const ListCarriersRow = ({
|
|
|
25006
24628
|
}));
|
|
25007
24629
|
};
|
|
25008
24630
|
|
|
25009
|
-
const styles$
|
|
24631
|
+
const styles$6 = createStyles({
|
|
25010
24632
|
listContainer: theme => ({
|
|
25011
24633
|
"& > li:not(:last-of-type)": {
|
|
25012
24634
|
borderBottom: `1px solid ${theme.palette.gray.light}`
|
|
@@ -25053,7 +24675,7 @@ const ListCarriers$1 = ({
|
|
|
25053
24675
|
children: t("list-carriers:headers.accountCarriers")
|
|
25054
24676
|
}))
|
|
25055
24677
|
}), jsxRuntime.jsx("ul", Object.assign({
|
|
25056
|
-
css: styles$
|
|
24678
|
+
css: styles$6.listContainer
|
|
25057
24679
|
}, {
|
|
25058
24680
|
children: isLoading ? jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
25059
24681
|
children: [jsxRuntime.jsx(LoadingSkeletonRow, {}), jsxRuntime.jsx(LoadingSkeletonRow, {}), jsxRuntime.jsx(LoadingSkeletonRow, {})]
|
|
@@ -25074,10 +24696,10 @@ const ListCarriers$1 = ({
|
|
|
25074
24696
|
};
|
|
25075
24697
|
const LoadingSkeletonRow = () => {
|
|
25076
24698
|
return jsxRuntime.jsxs("div", Object.assign({
|
|
25077
|
-
css: styles$
|
|
24699
|
+
css: styles$6.skeletonRow
|
|
25078
24700
|
}, {
|
|
25079
24701
|
children: [jsxRuntime.jsxs("div", Object.assign({
|
|
25080
|
-
css: styles$
|
|
24702
|
+
css: styles$6.skeletonLogoContainer
|
|
25081
24703
|
}, {
|
|
25082
24704
|
children: [jsxRuntime.jsx(giger.Skeleton, {
|
|
25083
24705
|
animation: giger.SkeletonAnimation.WAVE,
|
|
@@ -25101,7 +24723,7 @@ const LoadingSkeletonRow = () => {
|
|
|
25101
24723
|
}));
|
|
25102
24724
|
};
|
|
25103
24725
|
|
|
25104
|
-
const styles$
|
|
24726
|
+
const styles$5 = createStyles({
|
|
25105
24727
|
body: theme => ({
|
|
25106
24728
|
borderTop: `1px solid ${theme.palette.gray.light}`,
|
|
25107
24729
|
color: theme.palette.black,
|
|
@@ -25152,14 +24774,14 @@ const SettingsCard = ({
|
|
|
25152
24774
|
verticallyAligned
|
|
25153
24775
|
}) => {
|
|
25154
24776
|
return jsxRuntime.jsxs("div", Object.assign({
|
|
25155
|
-
css: verticallyAligned ? styles$
|
|
24777
|
+
css: verticallyAligned ? styles$5.verticalContainer : styles$5.container,
|
|
25156
24778
|
"data-testid": "settingsCard"
|
|
25157
24779
|
}, {
|
|
25158
24780
|
children: [jsxRuntime.jsxs("div", Object.assign({
|
|
25159
|
-
css: styles$
|
|
24781
|
+
css: styles$5.header
|
|
25160
24782
|
}, {
|
|
25161
24783
|
children: [jsxRuntime.jsxs("div", Object.assign({
|
|
25162
|
-
css: styles$
|
|
24784
|
+
css: styles$5.title
|
|
25163
24785
|
}, {
|
|
25164
24786
|
children: [typeof title === "string" ? jsxRuntime.jsx(giger.Typography, Object.assign({
|
|
25165
24787
|
variant: "subtitle2"
|
|
@@ -25194,7 +24816,7 @@ const SettingsCard = ({
|
|
|
25194
24816
|
}))
|
|
25195
24817
|
}))]
|
|
25196
24818
|
})), children && jsxRuntime.jsx("div", Object.assign({
|
|
25197
|
-
css: styles$
|
|
24819
|
+
css: styles$5.body
|
|
25198
24820
|
}, {
|
|
25199
24821
|
children: jsxRuntime.jsxs("div", {
|
|
25200
24822
|
children: [children, accessoryAction && jsxRuntime.jsx(ButtonGroup, Object.assign({
|
|
@@ -25311,7 +24933,7 @@ const warehouseSchema = zod.z.discriminatedUnion("returnToAddressIsDifferent", [
|
|
|
25311
24933
|
});
|
|
25312
24934
|
});
|
|
25313
24935
|
|
|
25314
|
-
const styles$
|
|
24936
|
+
const styles$4 = createStyles({
|
|
25315
24937
|
header: {
|
|
25316
24938
|
textAlign: "center"
|
|
25317
24939
|
},
|
|
@@ -25363,12 +24985,12 @@ const WarehouseForm = ({
|
|
|
25363
24985
|
}
|
|
25364
24986
|
}));
|
|
25365
24987
|
return jsxRuntime.jsxs("div", Object.assign({
|
|
25366
|
-
css: _isOnboarding ? styles$
|
|
24988
|
+
css: _isOnboarding ? styles$4.onboardingWell : styles$4.well,
|
|
25367
24989
|
"data-testid": "warehouse-form"
|
|
25368
24990
|
}, {
|
|
25369
24991
|
children: [_isOnboarding && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
25370
24992
|
children: [jsxRuntime.jsxs("div", Object.assign({
|
|
25371
|
-
css: styles$
|
|
24993
|
+
css: styles$4.header
|
|
25372
24994
|
}, {
|
|
25373
24995
|
children: [jsxRuntime.jsx(giger.Typography, Object.assign({
|
|
25374
24996
|
variant: "heading4"
|
|
@@ -26757,7 +26379,7 @@ const EditWalletAddressForm = ({
|
|
|
26757
26379
|
}));
|
|
26758
26380
|
};
|
|
26759
26381
|
|
|
26760
|
-
const styles$
|
|
26382
|
+
const styles$3 = createStyles({
|
|
26761
26383
|
grid: theme => ({
|
|
26762
26384
|
margin: theme.spacing(4)
|
|
26763
26385
|
}),
|
|
@@ -26805,21 +26427,21 @@ const WalletForm = ({
|
|
|
26805
26427
|
onSubmit: formLogger.capture(handleSubmit)
|
|
26806
26428
|
}, {
|
|
26807
26429
|
children: jsxRuntime.jsxs(giger.Grid, Object.assign({
|
|
26808
|
-
css: styles$
|
|
26430
|
+
css: styles$3.grid,
|
|
26809
26431
|
noPadding: true
|
|
26810
26432
|
}, {
|
|
26811
26433
|
children: [jsxRuntime.jsx(giger.GridChild, Object.assign({
|
|
26812
26434
|
colSpan: 12
|
|
26813
26435
|
}, {
|
|
26814
26436
|
children: jsxRuntime.jsx(giger.Typography, Object.assign({
|
|
26815
|
-
css: styles$
|
|
26437
|
+
css: styles$3.heading,
|
|
26816
26438
|
variant: "heading4"
|
|
26817
26439
|
}, {
|
|
26818
26440
|
children: t("register-wallet:sections.billing.title")
|
|
26819
26441
|
}))
|
|
26820
26442
|
})), jsxRuntime.jsx(giger.GridChild, Object.assign({
|
|
26821
26443
|
colSpan: 12,
|
|
26822
|
-
css: styles$
|
|
26444
|
+
css: styles$3.subtitle
|
|
26823
26445
|
}, {
|
|
26824
26446
|
children: jsxRuntime.jsx(giger.Typography, Object.assign({
|
|
26825
26447
|
variant: "subtitle1"
|
|
@@ -26841,7 +26463,7 @@ const WalletForm = ({
|
|
|
26841
26463
|
colSpan: 12
|
|
26842
26464
|
}, {
|
|
26843
26465
|
children: jsxRuntime.jsx(giger.Typography, Object.assign({
|
|
26844
|
-
css: styles$
|
|
26466
|
+
css: styles$3.subtitle,
|
|
26845
26467
|
variant: "subtitle1"
|
|
26846
26468
|
}, {
|
|
26847
26469
|
children: t("register-wallet:sections.billing.addressSubTitle")
|
|
@@ -26908,7 +26530,7 @@ const WalletForm = ({
|
|
|
26908
26530
|
}));
|
|
26909
26531
|
};
|
|
26910
26532
|
|
|
26911
|
-
const styles = createStyles({
|
|
26533
|
+
const styles$2 = createStyles({
|
|
26912
26534
|
lastStep: {
|
|
26913
26535
|
"& > span::first-of-type": {
|
|
26914
26536
|
"::after": {
|
|
@@ -27122,16 +26744,16 @@ const Onboarding$1 = ({
|
|
|
27122
26744
|
currentStep: currentStep
|
|
27123
26745
|
}, {
|
|
27124
26746
|
children: [jsxRuntime.jsx(giger.Step, {
|
|
27125
|
-
css: styles.step,
|
|
26747
|
+
css: styles$2.step,
|
|
27126
26748
|
label: t("onboarding:steps.login")
|
|
27127
26749
|
}), jsxRuntime.jsx(giger.Step, {
|
|
27128
|
-
css: styles.step,
|
|
26750
|
+
css: styles$2.step,
|
|
27129
26751
|
label: t("onboarding:steps.carriers")
|
|
27130
26752
|
}), jsxRuntime.jsx(giger.Step, {
|
|
27131
|
-
css: styles.step,
|
|
26753
|
+
css: styles$2.step,
|
|
27132
26754
|
label: t("onboarding:steps.addresses")
|
|
27133
26755
|
}), jsxRuntime.jsx(giger.Step, {
|
|
27134
|
-
css: styles.lastStep,
|
|
26756
|
+
css: styles$2.lastStep,
|
|
27135
26757
|
label: t("onboarding:steps.payment")
|
|
27136
26758
|
})]
|
|
27137
26759
|
})), renderStep()]
|
|
@@ -27203,6 +26825,549 @@ const Cube = _a => {
|
|
|
27203
26825
|
}));
|
|
27204
26826
|
};
|
|
27205
26827
|
|
|
26828
|
+
/**
|
|
26829
|
+
* A drop-in replacement for the `<form>` tag that allows nested forms.
|
|
26830
|
+
*
|
|
26831
|
+
* Via portals, the <form> tag is mounted as a sibling of the app root. The form's
|
|
26832
|
+
* interface is then mounted back at the point of use.
|
|
26833
|
+
*/
|
|
26834
|
+
const FormPortal = ({
|
|
26835
|
+
css,
|
|
26836
|
+
children,
|
|
26837
|
+
id,
|
|
26838
|
+
onSubmit,
|
|
26839
|
+
variant
|
|
26840
|
+
}) => {
|
|
26841
|
+
const rootTarget = useRootPortal();
|
|
26842
|
+
const [interfaceTarget, setInterfaceTarget] = React.useState(null);
|
|
26843
|
+
const onMountInterfaceTarget = React.useCallback(element => {
|
|
26844
|
+
if (element) setInterfaceTarget(element);
|
|
26845
|
+
}, []);
|
|
26846
|
+
const formStyle = [variant === "well" && (theme => ({
|
|
26847
|
+
backgroundColor: theme.palette.gray.ultraLight,
|
|
26848
|
+
padding: theme.spacing(2)
|
|
26849
|
+
})), css];
|
|
26850
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
26851
|
+
children: [jsxRuntime.jsx(Portal, Object.assign({
|
|
26852
|
+
target: rootTarget
|
|
26853
|
+
}, {
|
|
26854
|
+
children: jsxRuntime.jsx("form", Object.assign({
|
|
26855
|
+
id: id,
|
|
26856
|
+
onSubmit: onSubmit
|
|
26857
|
+
}, {
|
|
26858
|
+
children: jsxRuntime.jsx(Portal, Object.assign({
|
|
26859
|
+
target: interfaceTarget
|
|
26860
|
+
}, {
|
|
26861
|
+
children: children
|
|
26862
|
+
}))
|
|
26863
|
+
}))
|
|
26864
|
+
})), jsxRuntime.jsx("section", {
|
|
26865
|
+
css: formStyle,
|
|
26866
|
+
id: id + "-interface",
|
|
26867
|
+
ref: onMountInterfaceTarget
|
|
26868
|
+
})]
|
|
26869
|
+
});
|
|
26870
|
+
};
|
|
26871
|
+
|
|
26872
|
+
const Loader = props => {
|
|
26873
|
+
return jsxRuntime.jsx("div", Object.assign({
|
|
26874
|
+
css: {
|
|
26875
|
+
alignItems: "center",
|
|
26876
|
+
display: "flex",
|
|
26877
|
+
flexDirection: "column",
|
|
26878
|
+
height: "100%",
|
|
26879
|
+
justifyContent: "center",
|
|
26880
|
+
textAlign: "center",
|
|
26881
|
+
width: "100%"
|
|
26882
|
+
}
|
|
26883
|
+
}, {
|
|
26884
|
+
children: jsxRuntime.jsx(giger.Spinner, Object.assign({}, props, {
|
|
26885
|
+
size: giger.SpinnerSize.SIZE_LARGE
|
|
26886
|
+
}))
|
|
26887
|
+
}));
|
|
26888
|
+
};
|
|
26889
|
+
|
|
26890
|
+
const getStyles$2 = ({
|
|
26891
|
+
isDisabled,
|
|
26892
|
+
isSelected
|
|
26893
|
+
} = {}) => createStyles({
|
|
26894
|
+
chip: theme => [isSelected ? {
|
|
26895
|
+
backgroundColor: theme.palette.secondary.ultraLight,
|
|
26896
|
+
color: theme.palette.secondary.main
|
|
26897
|
+
} : {
|
|
26898
|
+
backgroundColor: theme.palette.white,
|
|
26899
|
+
color: theme.palette.gray.main
|
|
26900
|
+
},
|
|
26901
|
+
// TODO [LMNT-663] - Giger's Chip component needs support added for an isDisabled prop
|
|
26902
|
+
isDisabled && {
|
|
26903
|
+
backgroundColor: theme.palette.gray.light,
|
|
26904
|
+
cursor: "none",
|
|
26905
|
+
pointerEvents: "none"
|
|
26906
|
+
}],
|
|
26907
|
+
chipList: theme => ({
|
|
26908
|
+
gap: theme.spacing(1)
|
|
26909
|
+
}),
|
|
26910
|
+
fundsInput: theme => ({
|
|
26911
|
+
maxWidth: theme.spacing(24)
|
|
26912
|
+
})
|
|
26913
|
+
});
|
|
26914
|
+
|
|
26915
|
+
const getAddFundsSchema = (minimumAmount = 10) => zod.z.object({
|
|
26916
|
+
funds: moneySchema.extend({
|
|
26917
|
+
amount: zod.z.number().min(minimumAmount)
|
|
26918
|
+
})
|
|
26919
|
+
}).transform(data => data.funds);
|
|
26920
|
+
|
|
26921
|
+
/**
|
|
26922
|
+
* Form for adding funds to a carrier's account.
|
|
26923
|
+
*
|
|
26924
|
+
* If a render child is provided, external control is assumed and the cancel / submit buttons are hidden.
|
|
26925
|
+
*/
|
|
26926
|
+
const AddFundsForm = ({
|
|
26927
|
+
carrierId,
|
|
26928
|
+
children,
|
|
26929
|
+
onCancel,
|
|
26930
|
+
onSuccess,
|
|
26931
|
+
minimumAmount: _minimumAmount = 0
|
|
26932
|
+
}) => {
|
|
26933
|
+
const {
|
|
26934
|
+
t
|
|
26935
|
+
} = reactI18next.useTranslation();
|
|
26936
|
+
const addFunds = react.useAddFunds(carrierId);
|
|
26937
|
+
const carrier = react.useGetCarrierById(carrierId);
|
|
26938
|
+
const chips = [{
|
|
26939
|
+
label: "$20",
|
|
26940
|
+
value: 20
|
|
26941
|
+
}, {
|
|
26942
|
+
label: "$50",
|
|
26943
|
+
value: 50
|
|
26944
|
+
}, {
|
|
26945
|
+
label: "$100",
|
|
26946
|
+
value: 100
|
|
26947
|
+
}, {
|
|
26948
|
+
label: t("manage-funding:addFunds.custom"),
|
|
26949
|
+
value: "custom"
|
|
26950
|
+
}];
|
|
26951
|
+
const [selectedChip, setSelectedChip] = React.useState(_minimumAmount > 0 ? chips[3] : chips[0]);
|
|
26952
|
+
_minimumAmount = Math.max(_minimumAmount, 10);
|
|
26953
|
+
const form = reactHookForm.useForm({
|
|
26954
|
+
defaultValues: {
|
|
26955
|
+
funds: {
|
|
26956
|
+
amount: selectedChip.value === "custom" ? _minimumAmount : selectedChip.value,
|
|
26957
|
+
currency: api.SE.Currency.USD
|
|
26958
|
+
}
|
|
26959
|
+
},
|
|
26960
|
+
resolver: validationResolver(getAddFundsSchema(_minimumAmount))
|
|
26961
|
+
});
|
|
26962
|
+
const {
|
|
26963
|
+
isSubmitted,
|
|
26964
|
+
isValid
|
|
26965
|
+
} = form.formState;
|
|
26966
|
+
const watchAmount = form.watch("funds").amount;
|
|
26967
|
+
const formId = "add-funds-form";
|
|
26968
|
+
const handleSubmit = formLogger.capture(form.handleSubmit(values => {
|
|
26969
|
+
const payload = values;
|
|
26970
|
+
addFunds.mutate(payload, {
|
|
26971
|
+
onSuccess: () => onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess()
|
|
26972
|
+
});
|
|
26973
|
+
}));
|
|
26974
|
+
if (carrier.isLoading) return jsxRuntime.jsx(Loader, {
|
|
26975
|
+
message: t("loading.carrier")
|
|
26976
|
+
});
|
|
26977
|
+
if (!carrier.data) throw new Error("errorMessages.unableToLoad.carrier");
|
|
26978
|
+
const balance = carrier.data.balance;
|
|
26979
|
+
if (balance === undefined) return jsxRuntime.jsx(giger.InlineNotification, Object.assign({
|
|
26980
|
+
type: giger.NotificationType.ERROR
|
|
26981
|
+
}, {
|
|
26982
|
+
children: t("manage-funding:errors.unableToFindBalance")
|
|
26983
|
+
}));
|
|
26984
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
26985
|
+
children: [jsxRuntime.jsxs(FormPortal, Object.assign({
|
|
26986
|
+
id: formId,
|
|
26987
|
+
onSubmit: handleSubmit,
|
|
26988
|
+
variant: "well"
|
|
26989
|
+
}, {
|
|
26990
|
+
children: [jsxRuntime.jsx(giger.Typography, Object.assign({
|
|
26991
|
+
bold: true
|
|
26992
|
+
}, {
|
|
26993
|
+
children: t("manage-funding:actions.addFunds")
|
|
26994
|
+
})), jsxRuntime.jsx(Spacer, {
|
|
26995
|
+
multiplier: 2
|
|
26996
|
+
}), jsxRuntime.jsx(giger.ChipList, Object.assign({
|
|
26997
|
+
css: getStyles$2().chipList,
|
|
26998
|
+
onChange: idx => {
|
|
26999
|
+
const chip = chips[idx];
|
|
27000
|
+
setSelectedChip(chip);
|
|
27001
|
+
if (chip.value !== "custom") {
|
|
27002
|
+
form.reset({
|
|
27003
|
+
funds: {
|
|
27004
|
+
amount: chip.value,
|
|
27005
|
+
currency: api.SE.Currency.USD
|
|
27006
|
+
}
|
|
27007
|
+
});
|
|
27008
|
+
}
|
|
27009
|
+
}
|
|
27010
|
+
}, {
|
|
27011
|
+
children: chips.map(chip => jsxRuntime.jsx(giger.Chip, Object.assign({
|
|
27012
|
+
css: getStyles$2({
|
|
27013
|
+
isDisabled: chip.value < _minimumAmount,
|
|
27014
|
+
isSelected: chip.value === selectedChip.value
|
|
27015
|
+
}).chip,
|
|
27016
|
+
isSelected: chip.value === selectedChip.value
|
|
27017
|
+
}, {
|
|
27018
|
+
children: jsxRuntime.jsx(giger.Typography, Object.assign({
|
|
27019
|
+
variant: "small"
|
|
27020
|
+
}, {
|
|
27021
|
+
children: chip.label
|
|
27022
|
+
}))
|
|
27023
|
+
}), chip.label))
|
|
27024
|
+
})), selectedChip.value === "custom" && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
27025
|
+
children: [jsxRuntime.jsx(Spacer, {
|
|
27026
|
+
multiplier: 1
|
|
27027
|
+
}), jsxRuntime.jsx(MoneyInput, {
|
|
27028
|
+
control: form.control,
|
|
27029
|
+
css: getStyles$2().fundsInput,
|
|
27030
|
+
defaultValue: {
|
|
27031
|
+
amount: undefined,
|
|
27032
|
+
currency: api.SE.Currency.USD
|
|
27033
|
+
},
|
|
27034
|
+
form: formId,
|
|
27035
|
+
hint: t("manage-funding:addFunds.minimumPurchaseAmount"),
|
|
27036
|
+
label: t("manage-funding:addFunds.labels.amount"),
|
|
27037
|
+
name: "funds",
|
|
27038
|
+
nativeLabel: true,
|
|
27039
|
+
showCurrencySymbol: true
|
|
27040
|
+
})]
|
|
27041
|
+
}), !children && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
27042
|
+
children: [jsxRuntime.jsx(Spacer, {
|
|
27043
|
+
multiplier: selectedChip.value !== "custom" ? 1.5 : 1
|
|
27044
|
+
}), jsxRuntime.jsxs(ButtonGroup, Object.assign({
|
|
27045
|
+
justify: "end"
|
|
27046
|
+
}, {
|
|
27047
|
+
children: [onCancel && jsxRuntime.jsx(giger.Button, Object.assign({
|
|
27048
|
+
onClick: onCancel,
|
|
27049
|
+
variant: giger.ButtonVariant.TEXT
|
|
27050
|
+
}, {
|
|
27051
|
+
children: t("actions.cancel")
|
|
27052
|
+
})), jsxRuntime.jsx(SubmitButton, Object.assign({
|
|
27053
|
+
control: form.control,
|
|
27054
|
+
form: formId,
|
|
27055
|
+
isLoading: addFunds.isLoading,
|
|
27056
|
+
variant: giger.ButtonVariant.OUTLINED
|
|
27057
|
+
}, {
|
|
27058
|
+
children: t("manage-funding:actions.addNow")
|
|
27059
|
+
}))]
|
|
27060
|
+
}))]
|
|
27061
|
+
})]
|
|
27062
|
+
})), addFunds.error && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
27063
|
+
children: [jsxRuntime.jsx(Spacer, {
|
|
27064
|
+
multiplier: 1
|
|
27065
|
+
}), jsxRuntime.jsx(giger.InlineNotification, Object.assign({
|
|
27066
|
+
title: t("manage-funding:addFunds.error.title"),
|
|
27067
|
+
type: giger.NotificationType.ERROR
|
|
27068
|
+
}, {
|
|
27069
|
+
children: addFunds.error[0].message
|
|
27070
|
+
}))]
|
|
27071
|
+
}), children === null || children === void 0 ? void 0 : children({
|
|
27072
|
+
isCustomAmount: selectedChip.value === "custom",
|
|
27073
|
+
isSubmitted,
|
|
27074
|
+
isSubmitting: addFunds.isLoading,
|
|
27075
|
+
isValid,
|
|
27076
|
+
selectedAmount: watchAmount,
|
|
27077
|
+
submit: handleSubmit
|
|
27078
|
+
})]
|
|
27079
|
+
});
|
|
27080
|
+
};
|
|
27081
|
+
|
|
27082
|
+
const InlineLabel = ({
|
|
27083
|
+
children,
|
|
27084
|
+
label
|
|
27085
|
+
}) => jsxRuntime.jsxs("div", Object.assign({
|
|
27086
|
+
css: theme => ({
|
|
27087
|
+
alignItems: "center",
|
|
27088
|
+
display: "flex",
|
|
27089
|
+
gap: theme.spacing(1)
|
|
27090
|
+
})
|
|
27091
|
+
}, {
|
|
27092
|
+
children: [jsxRuntime.jsx(giger.Typography, {
|
|
27093
|
+
children: label
|
|
27094
|
+
}), children]
|
|
27095
|
+
}));
|
|
27096
|
+
|
|
27097
|
+
const getStyles$1 = balance => createStyles({
|
|
27098
|
+
balanceText: theme => ({
|
|
27099
|
+
color: balance === undefined ? theme.palette.alert.main : balance >= 0 ? theme.palette.secondary.dark : theme.palette.error.main
|
|
27100
|
+
})
|
|
27101
|
+
});
|
|
27102
|
+
|
|
27103
|
+
const CarrierBalance = ({
|
|
27104
|
+
carrierId
|
|
27105
|
+
}) => {
|
|
27106
|
+
const {
|
|
27107
|
+
t
|
|
27108
|
+
} = reactI18next.useTranslation();
|
|
27109
|
+
const {
|
|
27110
|
+
data: carrier,
|
|
27111
|
+
isLoading: isLoadingCarrier,
|
|
27112
|
+
isRefetching: isRefetchingCarrier
|
|
27113
|
+
} = react.useGetCarrierById(carrierId);
|
|
27114
|
+
const balance = carrier === null || carrier === void 0 ? void 0 : carrier.balance;
|
|
27115
|
+
return jsxRuntime.jsx(InlineLabel, Object.assign({
|
|
27116
|
+
label: t("manage-funding:currentBalance")
|
|
27117
|
+
}, {
|
|
27118
|
+
children: isLoadingCarrier || isRefetchingCarrier ? jsxRuntime.jsx(giger.Spinner, {}) : jsxRuntime.jsx(giger.Typography, Object.assign({
|
|
27119
|
+
bold: true,
|
|
27120
|
+
css: getStyles$1(balance).balanceText
|
|
27121
|
+
}, {
|
|
27122
|
+
children: balance === undefined ? t("manage-funding:errors.balanceUnknown") : formatMoney({
|
|
27123
|
+
amount: balance,
|
|
27124
|
+
currency: api.SE.Currency.USD
|
|
27125
|
+
})
|
|
27126
|
+
}))
|
|
27127
|
+
}));
|
|
27128
|
+
};
|
|
27129
|
+
|
|
27130
|
+
const icons = {
|
|
27131
|
+
add: brands.IconNames.ADD,
|
|
27132
|
+
download: brands.IconNames.DOWNLOAD
|
|
27133
|
+
};
|
|
27134
|
+
const LinkAction = _a => {
|
|
27135
|
+
var {
|
|
27136
|
+
css,
|
|
27137
|
+
icon,
|
|
27138
|
+
isDisabled,
|
|
27139
|
+
isLoading,
|
|
27140
|
+
title
|
|
27141
|
+
} = _a,
|
|
27142
|
+
props = __rest(_a, ["css", "icon", "isDisabled", "isLoading", "title"]);
|
|
27143
|
+
return jsxRuntime.jsx(giger.Link, Object.assign({}, props, {
|
|
27144
|
+
bold: true,
|
|
27145
|
+
css: theme => [{
|
|
27146
|
+
alignItems: "center",
|
|
27147
|
+
display: "flex",
|
|
27148
|
+
gap: theme.spacing(1)
|
|
27149
|
+
},
|
|
27150
|
+
// TODO [LMNT-663] - Giger's Link component does not render isDisabled state unless isButton is true
|
|
27151
|
+
(isDisabled || isLoading) && {
|
|
27152
|
+
color: theme.palette.gray.main,
|
|
27153
|
+
cursor: "none",
|
|
27154
|
+
pointerEvents: "none"
|
|
27155
|
+
}, css],
|
|
27156
|
+
isDisabled: isDisabled,
|
|
27157
|
+
size: giger.ButtonSize.MEDIUM
|
|
27158
|
+
}, {
|
|
27159
|
+
children: isLoading ? jsxRuntime.jsx(giger.Spinner, {}) : jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
27160
|
+
children: [title, icon && jsxRuntime.jsx(giger.Icon, {
|
|
27161
|
+
name: icons[icon],
|
|
27162
|
+
size: giger.IconSize.SIZE_MEDIUM,
|
|
27163
|
+
title: title
|
|
27164
|
+
})]
|
|
27165
|
+
})
|
|
27166
|
+
}));
|
|
27167
|
+
};
|
|
27168
|
+
|
|
27169
|
+
const Spread = ({
|
|
27170
|
+
children
|
|
27171
|
+
}) => jsxRuntime.jsx("div", Object.assign({
|
|
27172
|
+
css: theme => ({
|
|
27173
|
+
display: "flex",
|
|
27174
|
+
gap: theme.spacing(2),
|
|
27175
|
+
justifyContent: "space-between"
|
|
27176
|
+
})
|
|
27177
|
+
}, {
|
|
27178
|
+
children: children
|
|
27179
|
+
}));
|
|
27180
|
+
|
|
27181
|
+
const getStyles = isCustomAmount => createStyles({
|
|
27182
|
+
balanceText: theme => ({
|
|
27183
|
+
color: theme.palette.secondary.dark
|
|
27184
|
+
}),
|
|
27185
|
+
container: theme => ({
|
|
27186
|
+
padding: theme.spacing(3)
|
|
27187
|
+
}),
|
|
27188
|
+
formExtension: theme => ({
|
|
27189
|
+
backgroundColor: theme.palette.gray.ultraLight,
|
|
27190
|
+
display: "flex",
|
|
27191
|
+
flexDirection: "column",
|
|
27192
|
+
gap: theme.spacing(1),
|
|
27193
|
+
// Negative margin is to compensate for the padding on AddFundsForm, since we want this
|
|
27194
|
+
// section to seemlessly extend the form's well.
|
|
27195
|
+
marginTop: theme.spacing(isCustomAmount ? -1.5 : -1),
|
|
27196
|
+
padding: theme.spacing(2),
|
|
27197
|
+
paddingTop: 0
|
|
27198
|
+
}),
|
|
27199
|
+
saveRateButton: {
|
|
27200
|
+
whiteSpace: "nowrap"
|
|
27201
|
+
}
|
|
27202
|
+
});
|
|
27203
|
+
|
|
27204
|
+
/**
|
|
27205
|
+
* Fund and Purchase handles the label purchase submission UX, ensuring that a user
|
|
27206
|
+
* has the necessary funds available and can add them if not. It allows a single button
|
|
27207
|
+
* to submit the funding form followed by the purchase form.
|
|
27208
|
+
*/
|
|
27209
|
+
const FundAndPurchase = ({
|
|
27210
|
+
carrierId,
|
|
27211
|
+
className,
|
|
27212
|
+
disabled,
|
|
27213
|
+
isFundingRequired,
|
|
27214
|
+
onSave,
|
|
27215
|
+
purchaseAmount,
|
|
27216
|
+
onPurchase
|
|
27217
|
+
}) => {
|
|
27218
|
+
const {
|
|
27219
|
+
t
|
|
27220
|
+
} = reactI18next.useTranslation();
|
|
27221
|
+
const [isAddFundsFormOpen, setIsAddFundsFormOpen] = React.useState(false);
|
|
27222
|
+
const {
|
|
27223
|
+
data: carrier,
|
|
27224
|
+
isLoading: isLoadingCarrier
|
|
27225
|
+
} = react.useGetCarrierById(carrierId);
|
|
27226
|
+
const isAddingFunds = !!reactQuery.useIsMutating({
|
|
27227
|
+
mutationKey: ["useAddFunds"]
|
|
27228
|
+
});
|
|
27229
|
+
const isCreatingLabel = !!reactQuery.useIsMutating({
|
|
27230
|
+
mutationKey: ["useCreateLabel"]
|
|
27231
|
+
});
|
|
27232
|
+
const [isSavingRate, setIsSavingRate] = React.useState(false);
|
|
27233
|
+
const handleSaveRate = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
27234
|
+
setIsSavingRate(true);
|
|
27235
|
+
yield onSave();
|
|
27236
|
+
setIsSavingRate(false);
|
|
27237
|
+
});
|
|
27238
|
+
// Automatically open the Add Funds form if the carrier's balance is insufficient.
|
|
27239
|
+
React.useEffect(() => {
|
|
27240
|
+
if (isFundingRequired && (carrier === null || carrier === void 0 ? void 0 : carrier.balance) !== undefined && carrier.balance < purchaseAmount) setIsAddFundsFormOpen(true);
|
|
27241
|
+
}, [carrier === null || carrier === void 0 ? void 0 : carrier.balance, isFundingRequired, purchaseAmount]);
|
|
27242
|
+
const renderActionButtons = (addFundsForm = {}) => jsxRuntime.jsxs(ButtonGroup, Object.assign({
|
|
27243
|
+
justify: "end"
|
|
27244
|
+
}, {
|
|
27245
|
+
children: [jsxRuntime.jsx(giger.Button, Object.assign({
|
|
27246
|
+
bold: false,
|
|
27247
|
+
css: getStyles().saveRateButton,
|
|
27248
|
+
disabled: disabled || !carrierId || isAddingFunds || isCreatingLabel,
|
|
27249
|
+
isLoading: isSavingRate,
|
|
27250
|
+
onClick: handleSaveRate,
|
|
27251
|
+
variant: giger.ButtonVariant.OUTLINED
|
|
27252
|
+
}, {
|
|
27253
|
+
children: t("purchase-label:actions.saveRate")
|
|
27254
|
+
})), jsxRuntime.jsx(giger.Button, Object.assign({
|
|
27255
|
+
"data-testid": "submit-fund-and-purchase",
|
|
27256
|
+
disabled: disabled || !carrierId || isFundingRequired && isAddFundsFormOpen && addFundsForm.isSubmitted && !addFundsForm.isValid,
|
|
27257
|
+
isLoading: addFundsForm.isSubmitting || isAddingFunds || isCreatingLabel,
|
|
27258
|
+
onClick: isAddFundsFormOpen ? addFundsForm.submit : onPurchase
|
|
27259
|
+
}, {
|
|
27260
|
+
children: isAddFundsFormOpen ? t("manage-funding:actions.addFundsAndPurchase") : t("purchase-label:actions.purchaseNow")
|
|
27261
|
+
}))]
|
|
27262
|
+
}));
|
|
27263
|
+
if (!isFundingRequired) return jsxRuntime.jsx("div", Object.assign({
|
|
27264
|
+
className: className,
|
|
27265
|
+
css: getStyles().container
|
|
27266
|
+
}, {
|
|
27267
|
+
children: renderActionButtons()
|
|
27268
|
+
}));
|
|
27269
|
+
if (isLoadingCarrier) return jsxRuntime.jsx(Loader, {
|
|
27270
|
+
message: t("loading.carrier")
|
|
27271
|
+
});
|
|
27272
|
+
if (!carrier || !carrierId) throw new Error("errorMessages.unableToLoad.carrier");
|
|
27273
|
+
const balance = carrier.balance;
|
|
27274
|
+
const handleAddFundsSuccess = () => {
|
|
27275
|
+
setIsAddFundsFormOpen(false);
|
|
27276
|
+
onPurchase();
|
|
27277
|
+
};
|
|
27278
|
+
return jsxRuntime.jsxs("div", Object.assign({
|
|
27279
|
+
className: className,
|
|
27280
|
+
css: getStyles().container
|
|
27281
|
+
}, {
|
|
27282
|
+
children: [jsxRuntime.jsxs(Spread, {
|
|
27283
|
+
children: [jsxRuntime.jsx(CarrierBalance, {
|
|
27284
|
+
carrierId: carrierId
|
|
27285
|
+
}), jsxRuntime.jsx(LinkAction, {
|
|
27286
|
+
icon: "add",
|
|
27287
|
+
isDisabled: isAddFundsFormOpen || isAddingFunds || isCreatingLabel,
|
|
27288
|
+
onClick: () => setIsAddFundsFormOpen(true),
|
|
27289
|
+
title: t("manage-funding:actions.addFunds")
|
|
27290
|
+
})]
|
|
27291
|
+
}), jsxRuntime.jsx(Spacer, {
|
|
27292
|
+
multiplier: 2
|
|
27293
|
+
}), balance < purchaseAmount && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
27294
|
+
children: [jsxRuntime.jsx(giger.InlineNotification, Object.assign({
|
|
27295
|
+
title: t(`manage-funding:fundAndPurchase.${balance < 0 ? "negativeBalanceTitle" : "insufficientFundsTitle"}`),
|
|
27296
|
+
type: giger.NotificationType.ALERT
|
|
27297
|
+
}, {
|
|
27298
|
+
children: t(`manage-funding:fundAndPurchase.${balance < 0 ? "negativeBalance" : "insufficientFunds"}`)
|
|
27299
|
+
})), jsxRuntime.jsx(Spacer, {
|
|
27300
|
+
multiplier: 2
|
|
27301
|
+
})]
|
|
27302
|
+
}), isAddFundsFormOpen ? jsxRuntime.jsx(AddFundsForm, Object.assign({
|
|
27303
|
+
carrierId: carrierId,
|
|
27304
|
+
minimumAmount: purchaseAmount - balance,
|
|
27305
|
+
onSuccess: handleAddFundsSuccess
|
|
27306
|
+
}, {
|
|
27307
|
+
children: addFundsForm => {
|
|
27308
|
+
var _a, _b;
|
|
27309
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
27310
|
+
children: [jsxRuntime.jsxs("section", Object.assign({
|
|
27311
|
+
css: getStyles(addFundsForm.isCustomAmount).formExtension
|
|
27312
|
+
}, {
|
|
27313
|
+
children: [jsxRuntime.jsx(InlineLabel, Object.assign({
|
|
27314
|
+
label: t("manage-funding:fundAndPurchase.newBalance")
|
|
27315
|
+
}, {
|
|
27316
|
+
children: jsxRuntime.jsx(giger.Typography, Object.assign({
|
|
27317
|
+
css: getStyles().balanceText
|
|
27318
|
+
}, {
|
|
27319
|
+
children: formatMoney({
|
|
27320
|
+
amount: balance + ((_a = addFundsForm.selectedAmount) !== null && _a !== void 0 ? _a : 0),
|
|
27321
|
+
currency: api.SE.Currency.USD
|
|
27322
|
+
})
|
|
27323
|
+
}))
|
|
27324
|
+
})), jsxRuntime.jsx(InlineLabel, Object.assign({
|
|
27325
|
+
label: t("manage-funding:fundAndPurchase.finalBalance")
|
|
27326
|
+
}, {
|
|
27327
|
+
children: jsxRuntime.jsx(giger.Typography, Object.assign({
|
|
27328
|
+
css: getStyles().balanceText
|
|
27329
|
+
}, {
|
|
27330
|
+
children: formatMoney({
|
|
27331
|
+
amount: balance + ((_b = addFundsForm.selectedAmount) !== null && _b !== void 0 ? _b : 0) - purchaseAmount,
|
|
27332
|
+
currency: api.SE.Currency.USD
|
|
27333
|
+
})
|
|
27334
|
+
}))
|
|
27335
|
+
})), balance >= purchaseAmount && jsxRuntime.jsx(ButtonGroup, Object.assign({
|
|
27336
|
+
justify: "end"
|
|
27337
|
+
}, {
|
|
27338
|
+
children: jsxRuntime.jsx(giger.Button, Object.assign({
|
|
27339
|
+
onClick: () => setIsAddFundsFormOpen(false),
|
|
27340
|
+
variant: giger.ButtonVariant.TEXT
|
|
27341
|
+
}, {
|
|
27342
|
+
children: t("actions.cancel")
|
|
27343
|
+
}))
|
|
27344
|
+
}))]
|
|
27345
|
+
})), jsxRuntime.jsx(Spacer, {
|
|
27346
|
+
multiplier: 2
|
|
27347
|
+
}), renderActionButtons(addFundsForm)]
|
|
27348
|
+
});
|
|
27349
|
+
}
|
|
27350
|
+
})) : renderActionButtons()]
|
|
27351
|
+
}));
|
|
27352
|
+
};
|
|
27353
|
+
|
|
27354
|
+
const styles$1 = createStyles({
|
|
27355
|
+
fundAndPurchase: theme => ({
|
|
27356
|
+
borderTop: `1px solid ${theme.palette.gray.ultraLight}`
|
|
27357
|
+
}),
|
|
27358
|
+
ratesInterstitial: {
|
|
27359
|
+
alignItems: "center",
|
|
27360
|
+
display: "flex",
|
|
27361
|
+
flexDirection: "column",
|
|
27362
|
+
justifyContent: "center",
|
|
27363
|
+
textAlign: "center"
|
|
27364
|
+
},
|
|
27365
|
+
showMoreOrLessRatesButton: {
|
|
27366
|
+
alignItems: "center",
|
|
27367
|
+
display: "flex"
|
|
27368
|
+
}
|
|
27369
|
+
});
|
|
27370
|
+
|
|
27206
27371
|
const rateSchema = zod.z.object({
|
|
27207
27372
|
rate: zod.z.object({
|
|
27208
27373
|
isAcknowledged: zod.z.boolean().refine(v => v === true, "purchase-label:schemaErrors.needToAcknowledge"),
|
|
@@ -27231,7 +27396,7 @@ const RateForm = ({
|
|
|
27231
27396
|
}, features !== null && features !== void 0 ? features : {});
|
|
27232
27397
|
const {
|
|
27233
27398
|
t
|
|
27234
|
-
} = reactI18next.useTranslation(
|
|
27399
|
+
} = reactI18next.useTranslation();
|
|
27235
27400
|
const rateFormScrollToRef = React.useRef(null);
|
|
27236
27401
|
const [showHiddenRates, setShowHiddenRates] = React.useState(false);
|
|
27237
27402
|
const form = reactHookForm.useForm({
|
|
@@ -27244,16 +27409,13 @@ const RateForm = ({
|
|
|
27244
27409
|
mode: "onChange",
|
|
27245
27410
|
resolver: validationResolver(rateSchema)
|
|
27246
27411
|
});
|
|
27247
|
-
const {
|
|
27248
|
-
isDirty
|
|
27249
|
-
} = form.formState;
|
|
27250
27412
|
const {
|
|
27251
27413
|
rateId: selectedRateId
|
|
27252
27414
|
} = form.watch("rate");
|
|
27253
|
-
const handleSubmit = form.handleSubmit(values => __awaiter(void 0, void 0, void 0, function* () {
|
|
27415
|
+
const handleSubmit = formLogger.capture(form.handleSubmit(values => __awaiter(void 0, void 0, void 0, function* () {
|
|
27254
27416
|
const rateId = values;
|
|
27255
27417
|
yield onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(rateId);
|
|
27256
|
-
}));
|
|
27418
|
+
})));
|
|
27257
27419
|
const rateOptions = useRateOptions(rates, carriers, shipment, features.enableGlobalPostFiltering
|
|
27258
27420
|
// TODO: LMNT-677: fix RecommendedRate logic
|
|
27259
27421
|
// {
|
|
@@ -27275,13 +27437,10 @@ const RateForm = ({
|
|
|
27275
27437
|
);
|
|
27276
27438
|
|
|
27277
27439
|
const selectedRate = React.useMemo(() => rateOptions === null || rateOptions === void 0 ? void 0 : rateOptions.find(r => r.rateId === selectedRateId), [rateOptions, selectedRateId]);
|
|
27278
|
-
const [isRateSaving, setIsRateSaving] = React.useState(false);
|
|
27279
27440
|
const handleSaveRate = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
27280
27441
|
const isValid = yield form.trigger();
|
|
27281
27442
|
if (!isValid) return;
|
|
27282
|
-
setIsRateSaving(true);
|
|
27283
27443
|
if (selectedRate) yield onSave === null || onSave === void 0 ? void 0 : onSave(selectedRate);
|
|
27284
|
-
setIsRateSaving(false);
|
|
27285
27444
|
// sets the form to not be dirty, so that Save is disabled
|
|
27286
27445
|
form.reset(form.getValues());
|
|
27287
27446
|
}), [form, onSave, selectedRate]);
|
|
@@ -27310,15 +27469,6 @@ const RateForm = ({
|
|
|
27310
27469
|
}, 0);
|
|
27311
27470
|
}
|
|
27312
27471
|
}, [form, rateOptions, errors === null || errors === void 0 ? void 0 : errors.length]);
|
|
27313
|
-
const formatFundingAmount = selectedRate => {
|
|
27314
|
-
var _a;
|
|
27315
|
-
const totalRateAmount = getTotalRateAmount(selectedRate);
|
|
27316
|
-
const walletBalance = (_a = selectedRate.balance) !== null && _a !== void 0 ? _a : 0;
|
|
27317
|
-
return formatMoney({
|
|
27318
|
-
amount: Math.max(totalRateAmount - walletBalance, 0),
|
|
27319
|
-
currency: api.SE.Currency.USD
|
|
27320
|
-
});
|
|
27321
|
-
};
|
|
27322
27472
|
return jsxRuntime.jsxs("form", Object.assign({
|
|
27323
27473
|
id: "rate-form",
|
|
27324
27474
|
onSubmit: handleSubmit,
|
|
@@ -27340,10 +27490,7 @@ const RateForm = ({
|
|
|
27340
27490
|
onClick: onSelectRate,
|
|
27341
27491
|
options: showHiddenRates ? rateOptions : filteredRateOptions
|
|
27342
27492
|
}), rateOptions.some(option => option.requiresAcknowledgement) && rateOptions.length > 5 && jsxRuntime.jsx(giger.Link, Object.assign({
|
|
27343
|
-
css:
|
|
27344
|
-
alignItems: "center",
|
|
27345
|
-
display: "flex"
|
|
27346
|
-
},
|
|
27493
|
+
css: styles$1.showMoreOrLessRatesButton,
|
|
27347
27494
|
onClick: () => {
|
|
27348
27495
|
var _a;
|
|
27349
27496
|
setShowHiddenRates(!showHiddenRates);
|
|
@@ -27361,86 +27508,36 @@ const RateForm = ({
|
|
|
27361
27508
|
variant: "body1"
|
|
27362
27509
|
}, {
|
|
27363
27510
|
children: showHiddenRates ? t("purchase-label:actions.showFewerRates") : t("purchase-label:actions.showMoreRates")
|
|
27364
|
-
}))
|
|
27365
|
-
}))]
|
|
27366
|
-
}) : !isLoading && errors && !!errors.length ? null : jsxRuntime.jsxs("article", Object.assign({
|
|
27367
|
-
css:
|
|
27368
|
-
|
|
27369
|
-
display: "flex",
|
|
27370
|
-
flexDirection: "column",
|
|
27371
|
-
justifyContent: "center",
|
|
27372
|
-
textAlign: "center"
|
|
27373
|
-
},
|
|
27374
|
-
role: "presentation"
|
|
27375
|
-
}, {
|
|
27376
|
-
children: [jsxRuntime.jsx(Cube, {
|
|
27377
|
-
animate: isLoading
|
|
27378
|
-
}), jsxRuntime.jsx(Spacer, {}), isLoading ? t("purchase-label:loading.calculatingRates") : t("purchase-label:cta.addPackageDetails")]
|
|
27379
|
-
})), !isLoading && (errors && !!errors.length && rateOptions.length === 0 || !!(labelErrors === null || labelErrors === void 0 ? void 0 : labelErrors.length)) && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
27380
|
-
children: [jsxRuntime.jsx(Spacer, {}), jsxRuntime.jsxs(giger.InlineNotification, Object.assign({
|
|
27381
|
-
title: t("errorTypes.rateInvalid"),
|
|
27382
|
-
type: giger.NotificationType.ERROR
|
|
27383
|
-
}, {
|
|
27384
|
-
children: [errors === null || errors === void 0 ? void 0 : errors.map(e => t(jsBase64.encode(e.message), {
|
|
27385
|
-
defaultValue: e.message.includes("No rates are available for service_codes") ? t("common:errorMessages.noRatesAvailable") : e.message
|
|
27386
|
-
})).join(" "), labelErrors === null || labelErrors === void 0 ? void 0 : labelErrors.map(e => t(jsBase64.encode(e.message), {
|
|
27387
|
-
defaultValue: e.message.replace(/Exception with code [\w\d]+; module [\d]+, category [\d]+, item [\d]+/g, "")
|
|
27388
|
-
}))]
|
|
27389
|
-
}))]
|
|
27390
|
-
})]
|
|
27391
|
-
})), jsxRuntime.jsxs(giger.BottomSheet, Object.assign({
|
|
27392
|
-
alwaysVisible: true,
|
|
27393
|
-
css: theme => ({
|
|
27394
|
-
borderTop: `1px solid ${theme.palette.gray.ultraLight}`,
|
|
27395
|
-
boxShadow: "none",
|
|
27396
|
-
position: "static"
|
|
27397
|
-
})
|
|
27398
|
-
}, {
|
|
27399
|
-
children: [typeof (selectedRate === null || selectedRate === void 0 ? void 0 : selectedRate.balance) === "number" && selectedRate.requiresFundedAmount && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
27400
|
-
children: [jsxRuntime.jsx(giger.Typography, Object.assign({
|
|
27401
|
-
variant: "body1"
|
|
27402
|
-
}, {
|
|
27403
|
-
children: t("purchase-label:balance.currentBalance")
|
|
27404
|
-
})), jsxRuntime.jsx(giger.Typography, Object.assign({
|
|
27405
|
-
color: selectedRate.balance < 0 ? "error.main" : undefined
|
|
27406
|
-
}, {
|
|
27407
|
-
children: ` ${formatMoney({
|
|
27408
|
-
amount: selectedRate.balance,
|
|
27409
|
-
currency: api.SE.Currency.USD
|
|
27410
|
-
})}`
|
|
27411
|
-
})), jsxRuntime.jsx(Spacer, {
|
|
27412
|
-
multiplier: 2
|
|
27413
|
-
})]
|
|
27414
|
-
}), jsxRuntime.jsx("div", Object.assign({
|
|
27415
|
-
"data-testid": "actions"
|
|
27511
|
+
}))
|
|
27512
|
+
}))]
|
|
27513
|
+
}) : !isLoading && errors && !!errors.length ? null : jsxRuntime.jsxs("article", Object.assign({
|
|
27514
|
+
css: styles$1.ratesInterstitial,
|
|
27515
|
+
role: "presentation"
|
|
27416
27516
|
}, {
|
|
27417
|
-
children: jsxRuntime.
|
|
27418
|
-
|
|
27517
|
+
children: [jsxRuntime.jsx(Cube, {
|
|
27518
|
+
animate: isLoading
|
|
27519
|
+
}), jsxRuntime.jsx(Spacer, {}), isLoading ? t("purchase-label:loading.calculatingRates") : t("purchase-label:cta.addPackageDetails")]
|
|
27520
|
+
})), !isLoading && (errors && !!errors.length && rateOptions.length === 0 || !!(labelErrors === null || labelErrors === void 0 ? void 0 : labelErrors.length)) && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
27521
|
+
children: [jsxRuntime.jsx(Spacer, {}), jsxRuntime.jsxs(giger.InlineNotification, Object.assign({
|
|
27522
|
+
title: t("errorTypes.rateInvalid"),
|
|
27523
|
+
type: giger.NotificationType.ERROR
|
|
27419
27524
|
}, {
|
|
27420
|
-
children: [
|
|
27421
|
-
|
|
27422
|
-
|
|
27423
|
-
|
|
27424
|
-
},
|
|
27425
|
-
disabled: !isDirty || disabled,
|
|
27426
|
-
isLoading: isRateSaving,
|
|
27427
|
-
onClick: handleSaveRate,
|
|
27428
|
-
variant: giger.ButtonVariant.OUTLINED
|
|
27429
|
-
}, {
|
|
27430
|
-
children: t("purchase-label:actions.saveRate")
|
|
27431
|
-
})), jsxRuntime.jsx(SubmitButton, Object.assign({
|
|
27432
|
-
alwaysRequireValidity: true,
|
|
27433
|
-
control: form.control,
|
|
27434
|
-
"data-testid": "purchaseLabel",
|
|
27435
|
-
disabled: !selectedRate || disabled,
|
|
27436
|
-
form: "rate-form",
|
|
27437
|
-
isFullWidth: true
|
|
27438
|
-
}, {
|
|
27439
|
-
children: (selectedRate === null || selectedRate === void 0 ? void 0 : selectedRate.balance) ? `${t("purchase-label:actions.purchaseNow")} - ${formatFundingAmount(selectedRate)}` : t("purchase-label:actions.purchaseNow")
|
|
27525
|
+
children: [errors === null || errors === void 0 ? void 0 : errors.map(e => t(jsBase64.encode(e.message), {
|
|
27526
|
+
defaultValue: e.message.includes("No rates are available for service_codes") ? t("common:errorMessages.noRatesAvailable") : e.message
|
|
27527
|
+
})).join(" "), labelErrors === null || labelErrors === void 0 ? void 0 : labelErrors.map(e => t(jsBase64.encode(e.message), {
|
|
27528
|
+
defaultValue: e.message.replace(/Exception with code [\w\d]+; module [\d]+, category [\d]+, item [\d]+/g, "")
|
|
27440
27529
|
}))]
|
|
27441
|
-
}))
|
|
27442
|
-
})
|
|
27443
|
-
}))
|
|
27530
|
+
}))]
|
|
27531
|
+
})]
|
|
27532
|
+
})), jsxRuntime.jsx(FundAndPurchase, {
|
|
27533
|
+
carrierId: selectedRate === null || selectedRate === void 0 ? void 0 : selectedRate.carrierId,
|
|
27534
|
+
css: styles$1.fundAndPurchase,
|
|
27535
|
+
disabled: disabled,
|
|
27536
|
+
isFundingRequired: (selectedRate === null || selectedRate === void 0 ? void 0 : selectedRate.balance) !== undefined && !!selectedRate.requiresFundedAmount,
|
|
27537
|
+
onPurchase: handleSubmit,
|
|
27538
|
+
onSave: handleSaveRate,
|
|
27539
|
+
purchaseAmount: getTotalRateAmount(selectedRate)
|
|
27540
|
+
})]
|
|
27444
27541
|
}));
|
|
27445
27542
|
};
|
|
27446
27543
|
|
|
@@ -28990,7 +29087,6 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
28990
29087
|
CarrierTermsForm: CarrierTermsForm,
|
|
28991
29088
|
CustomsItemForm: CustomsItemForm,
|
|
28992
29089
|
getCustomsItemFormSchema: getCustomsItemFormSchema,
|
|
28993
|
-
FundingMethods: FundingMethods,
|
|
28994
29090
|
Label: Label,
|
|
28995
29091
|
LandingPage: LandingPage,
|
|
28996
29092
|
ListCarriers: ListCarriers$1,
|
|
@@ -29004,12 +29100,141 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
29004
29100
|
WarehouseForm: WarehouseForm,
|
|
29005
29101
|
VoidLabel: VoidLabel$1,
|
|
29006
29102
|
WalletForm: WalletForm,
|
|
29007
|
-
styles: styles$
|
|
29103
|
+
styles: styles$3,
|
|
29008
29104
|
billingAddressSchema: billingAddressSchema,
|
|
29009
29105
|
walletSchema: walletSchema,
|
|
29010
29106
|
BillingFields: BillingFields
|
|
29011
29107
|
});
|
|
29012
29108
|
|
|
29109
|
+
const styles = createStyles({
|
|
29110
|
+
form: theme => ({
|
|
29111
|
+
backgroundColor: theme.palette.gray.megaLight,
|
|
29112
|
+
display: "flex",
|
|
29113
|
+
flexDirection: "column",
|
|
29114
|
+
gap: theme.spacing(2),
|
|
29115
|
+
padding: theme.spacing(2)
|
|
29116
|
+
})
|
|
29117
|
+
});
|
|
29118
|
+
|
|
29119
|
+
const autoFundingSchema = zod.z.object({
|
|
29120
|
+
isEnabled: zod.z.boolean(),
|
|
29121
|
+
lowBalancePurchaseThreshold: moneySchema.extend({
|
|
29122
|
+
amount: zod.z.number().min(25)
|
|
29123
|
+
}),
|
|
29124
|
+
maximumPurchasesPerDay: zod.z.number().min(1),
|
|
29125
|
+
purchaseAmount: moneySchema.extend({
|
|
29126
|
+
amount: zod.z.number().min(10).max(10000)
|
|
29127
|
+
})
|
|
29128
|
+
});
|
|
29129
|
+
|
|
29130
|
+
/**
|
|
29131
|
+
* This form that allows users to enable or disable auto funding, and
|
|
29132
|
+
* configure auto funding settings in ShipEngine API.
|
|
29133
|
+
*/
|
|
29134
|
+
const AutoFundingForm = ({
|
|
29135
|
+
carrierId
|
|
29136
|
+
}) => {
|
|
29137
|
+
const {
|
|
29138
|
+
t
|
|
29139
|
+
} = reactI18next.useTranslation();
|
|
29140
|
+
const updateAutoFunding = react.useUpdateAutoFunding(carrierId);
|
|
29141
|
+
const autoFundingConfiguration = react.useGetAutoFundingConfiguration();
|
|
29142
|
+
const form = reactHookForm.useForm({
|
|
29143
|
+
// TODO - [LMNT-663] We should probably make a hydration effect for autoFundingConfiguration.data
|
|
29144
|
+
defaultValues: autoFundingConfiguration.data,
|
|
29145
|
+
resolver: validationResolver(autoFundingSchema)
|
|
29146
|
+
});
|
|
29147
|
+
const {
|
|
29148
|
+
isDirty
|
|
29149
|
+
} = form.formState;
|
|
29150
|
+
const watchIsEnabled = form.watch("isEnabled");
|
|
29151
|
+
const handleSubmit = formLogger.capture(form.handleSubmit(values => {
|
|
29152
|
+
const payload = values;
|
|
29153
|
+
updateAutoFunding.mutate(payload, {
|
|
29154
|
+
onSuccess: () => autoFundingConfiguration.refetch()
|
|
29155
|
+
});
|
|
29156
|
+
}));
|
|
29157
|
+
const handleToggle = isEnabled => {
|
|
29158
|
+
form.reset(values => Object.assign(Object.assign({}, values), {
|
|
29159
|
+
isEnabled
|
|
29160
|
+
}));
|
|
29161
|
+
if (autoFundingConfiguration.data) {
|
|
29162
|
+
updateAutoFunding.mutate(Object.assign(Object.assign({}, autoFundingConfiguration.data), {
|
|
29163
|
+
isEnabled
|
|
29164
|
+
}), {
|
|
29165
|
+
onSuccess: x => autoFundingConfiguration.refetch()
|
|
29166
|
+
});
|
|
29167
|
+
} else {
|
|
29168
|
+
// TODO - [LMNT-663] Should this throw?
|
|
29169
|
+
react.logger.error("Toggling auto-funding failed because autoFundingData is undefined.");
|
|
29170
|
+
}
|
|
29171
|
+
};
|
|
29172
|
+
if (autoFundingConfiguration.isLoading) return jsxRuntime.jsx(Loader, {
|
|
29173
|
+
message: t("manage-funding:autoFunding.isLoading")
|
|
29174
|
+
});
|
|
29175
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
29176
|
+
children: [jsxRuntime.jsx(Switch, {
|
|
29177
|
+
defaultChecked: false,
|
|
29178
|
+
// defaultChecked={autoFundingConfiguration.data?.isEnabled}
|
|
29179
|
+
label: t("manage-funding:autoFunding.addFundsAutomatically"),
|
|
29180
|
+
name: "isEnabled",
|
|
29181
|
+
onChange: e => handleToggle(e.target.checked),
|
|
29182
|
+
value: true
|
|
29183
|
+
}), watchIsEnabled && jsxRuntime.jsxs("form", Object.assign({
|
|
29184
|
+
css: styles.form,
|
|
29185
|
+
id: "auto-funding-form",
|
|
29186
|
+
onSubmit: handleSubmit
|
|
29187
|
+
}, {
|
|
29188
|
+
children: [jsxRuntime.jsx(MoneyInput, {
|
|
29189
|
+
control: form.control,
|
|
29190
|
+
disabled: !watchIsEnabled,
|
|
29191
|
+
label: t("manage-funding:autoFunding.purchaseAmount"),
|
|
29192
|
+
name: "purchaseAmount",
|
|
29193
|
+
showCurrencySymbol: true
|
|
29194
|
+
}), jsxRuntime.jsx(MoneyInput, {
|
|
29195
|
+
control: form.control,
|
|
29196
|
+
disabled: !watchIsEnabled,
|
|
29197
|
+
label: t("manage-funding:autoFunding.lowBalancePurchaseThreshold"),
|
|
29198
|
+
name: "lowBalancePurchaseThreshold",
|
|
29199
|
+
showCurrencySymbol: true
|
|
29200
|
+
}), jsxRuntime.jsx(NumberInput, {
|
|
29201
|
+
control: form.control,
|
|
29202
|
+
disabled: !watchIsEnabled,
|
|
29203
|
+
isInteger: true,
|
|
29204
|
+
label: t("manage-funding:autoFunding.maximumPurchasesPerDay"),
|
|
29205
|
+
name: "maximumPurchasesPerDay"
|
|
29206
|
+
}), jsxRuntime.jsxs(ButtonGroup, Object.assign({
|
|
29207
|
+
justify: "end"
|
|
29208
|
+
}, {
|
|
29209
|
+
children: [jsxRuntime.jsx(giger.Button, Object.assign({
|
|
29210
|
+
disabled: !isDirty,
|
|
29211
|
+
onClick: () => form.reset(),
|
|
29212
|
+
variant: giger.ButtonVariant.TEXT
|
|
29213
|
+
}, {
|
|
29214
|
+
children: t("actions.cancel")
|
|
29215
|
+
})), jsxRuntime.jsx(SubmitButton, Object.assign({
|
|
29216
|
+
control: form.control,
|
|
29217
|
+
"data-testid": "submit-auto-funding",
|
|
29218
|
+
disabled: !watchIsEnabled,
|
|
29219
|
+
requireDirty: true,
|
|
29220
|
+
variant: giger.ButtonVariant.OUTLINED
|
|
29221
|
+
}, {
|
|
29222
|
+
children: t("manage-funding:actions.saveRule")
|
|
29223
|
+
}))]
|
|
29224
|
+
}))]
|
|
29225
|
+
})), autoFundingConfiguration.error && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
29226
|
+
children: [jsxRuntime.jsx(Spacer, {
|
|
29227
|
+
multiplier: 1
|
|
29228
|
+
}), jsxRuntime.jsx(giger.InlineNotification, Object.assign({
|
|
29229
|
+
title: t("manage-funding:autoFunding.error.title"),
|
|
29230
|
+
type: giger.NotificationType.ERROR
|
|
29231
|
+
}, {
|
|
29232
|
+
children: autoFundingConfiguration.error[0].message
|
|
29233
|
+
}))]
|
|
29234
|
+
})]
|
|
29235
|
+
});
|
|
29236
|
+
};
|
|
29237
|
+
|
|
29013
29238
|
/**
|
|
29014
29239
|
* Captures errors thrown within an Element, logs them and displays a fallback component
|
|
29015
29240
|
*
|
|
@@ -29073,49 +29298,82 @@ class ErrorBoundary extends React__namespace.Component {
|
|
|
29073
29298
|
}
|
|
29074
29299
|
}
|
|
29075
29300
|
|
|
29301
|
+
const ManageFunding = ({
|
|
29302
|
+
carrierId
|
|
29303
|
+
}) => {
|
|
29304
|
+
const {
|
|
29305
|
+
t
|
|
29306
|
+
} = reactI18next.useTranslation();
|
|
29307
|
+
const {
|
|
29308
|
+
isLoading: isLoadingCarrier
|
|
29309
|
+
} = react.useGetCarrierById(carrierId);
|
|
29310
|
+
const [isAddFundsFormOpen, setIsAddFundsFormOpen] = React.useState(false);
|
|
29311
|
+
if (isLoadingCarrier) return jsxRuntime.jsx(Loader, {
|
|
29312
|
+
message: t("loading.carrier")
|
|
29313
|
+
});
|
|
29314
|
+
return jsxRuntime.jsxs("section", {
|
|
29315
|
+
children: [jsxRuntime.jsxs(Spread, {
|
|
29316
|
+
children: [jsxRuntime.jsx(CarrierBalance, {
|
|
29317
|
+
carrierId: carrierId
|
|
29318
|
+
}), jsxRuntime.jsx(LinkAction, {
|
|
29319
|
+
icon: "add",
|
|
29320
|
+
isDisabled: isAddFundsFormOpen,
|
|
29321
|
+
onClick: () => setIsAddFundsFormOpen(true),
|
|
29322
|
+
title: t("manage-funding:actions.addFunds")
|
|
29323
|
+
})]
|
|
29324
|
+
}), isAddFundsFormOpen && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
29325
|
+
children: [jsxRuntime.jsx(Spacer, {
|
|
29326
|
+
multiplier: 2
|
|
29327
|
+
}), jsxRuntime.jsx(AddFundsForm, {
|
|
29328
|
+
carrierId: carrierId,
|
|
29329
|
+
onCancel: () => setIsAddFundsFormOpen(false)
|
|
29330
|
+
})]
|
|
29331
|
+
}), jsxRuntime.jsx(Spacer, {
|
|
29332
|
+
multiplier: 2
|
|
29333
|
+
})]
|
|
29334
|
+
});
|
|
29335
|
+
};
|
|
29336
|
+
|
|
29076
29337
|
/**
|
|
29077
|
-
*
|
|
29338
|
+
* For relevant notes about Storybook stories
|
|
29078
29339
|
*
|
|
29079
|
-
*
|
|
29080
|
-
* interface is then mounted back at the point of use.
|
|
29340
|
+
* Stopgap until we setup https://storybook.js.org/addons/@storybook/addon-docs
|
|
29081
29341
|
*/
|
|
29082
|
-
const
|
|
29083
|
-
css,
|
|
29342
|
+
const StoryNotes = ({
|
|
29084
29343
|
children,
|
|
29085
|
-
|
|
29086
|
-
|
|
29087
|
-
|
|
29088
|
-
|
|
29089
|
-
|
|
29090
|
-
|
|
29091
|
-
|
|
29092
|
-
|
|
29093
|
-
|
|
29094
|
-
|
|
29095
|
-
|
|
29096
|
-
|
|
29097
|
-
})), css];
|
|
29098
|
-
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
29099
|
-
children: [jsxRuntime.jsx(Portal, Object.assign({
|
|
29100
|
-
target: rootTarget
|
|
29344
|
+
notes
|
|
29345
|
+
}) => jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
29346
|
+
children: [jsxRuntime.jsxs("div", Object.assign({
|
|
29347
|
+
css: () => ({
|
|
29348
|
+
backgroundColor: "lightsteelblue",
|
|
29349
|
+
marginBottom: "16px",
|
|
29350
|
+
padding: "16px",
|
|
29351
|
+
paddingLeft: "32px"
|
|
29352
|
+
})
|
|
29353
|
+
}, {
|
|
29354
|
+
children: [jsxRuntime.jsx(giger.Typography, Object.assign({
|
|
29355
|
+
variant: "heading5"
|
|
29101
29356
|
}, {
|
|
29102
|
-
children:
|
|
29103
|
-
|
|
29104
|
-
|
|
29105
|
-
|
|
29106
|
-
|
|
29107
|
-
|
|
29108
|
-
|
|
29109
|
-
|
|
29110
|
-
|
|
29111
|
-
|
|
29112
|
-
|
|
29113
|
-
|
|
29114
|
-
|
|
29115
|
-
|
|
29116
|
-
|
|
29117
|
-
|
|
29118
|
-
|
|
29357
|
+
children: "Story notes:"
|
|
29358
|
+
})), jsxRuntime.jsx("ul", Object.assign({
|
|
29359
|
+
css: theme => ({
|
|
29360
|
+
"> li": {
|
|
29361
|
+
marginTop: theme.spacing(1)
|
|
29362
|
+
}
|
|
29363
|
+
})
|
|
29364
|
+
}, {
|
|
29365
|
+
children: notes.map(n => jsxRuntime.jsx("li", {
|
|
29366
|
+
children: n
|
|
29367
|
+
}, n))
|
|
29368
|
+
}))]
|
|
29369
|
+
})), jsxRuntime.jsx("hr", {
|
|
29370
|
+
css: () => ({
|
|
29371
|
+
backgroundColor: "transparent",
|
|
29372
|
+
borderTop: "1px dotted lightgrey",
|
|
29373
|
+
marginBottom: "16px"
|
|
29374
|
+
})
|
|
29375
|
+
}), children]
|
|
29376
|
+
});
|
|
29119
29377
|
|
|
29120
29378
|
var $$2 = _export;
|
|
29121
29379
|
var uncurryThis = functionUncurryThisClause;
|
|
@@ -30122,6 +30380,7 @@ var common = {
|
|
|
30122
30380
|
invalidNameOrCompany: "Recipient name and company name (if provided) must have two characters in first and last name.",
|
|
30123
30381
|
noWarehouses: "You must have an active warehouse in order to use this feature",
|
|
30124
30382
|
unableToLoad: {
|
|
30383
|
+
carrier: "Unable to load carrier",
|
|
30125
30384
|
carriers: "Unable to load carriers",
|
|
30126
30385
|
salesOrder: "Unable to load order",
|
|
30127
30386
|
shipment: "Unable to load shipment",
|
|
@@ -30148,6 +30407,7 @@ var common = {
|
|
|
30148
30407
|
thirdParty: "Third Party"
|
|
30149
30408
|
},
|
|
30150
30409
|
loading: {
|
|
30410
|
+
carrier: "Loading carrier...",
|
|
30151
30411
|
carriers: "Loading carriers...",
|
|
30152
30412
|
data: "Loading...",
|
|
30153
30413
|
importingSalesOrder: "Importing order...",
|
|
@@ -30244,11 +30504,11 @@ var listCarriers = {
|
|
|
30244
30504
|
var manageFunding = {
|
|
30245
30505
|
"manage-funding": {
|
|
30246
30506
|
actions: {
|
|
30507
|
+
addFunds: "Add Funds",
|
|
30508
|
+
addFundsAndPurchase: "Add Funds & Purchase",
|
|
30247
30509
|
addNow: "Add Now",
|
|
30248
|
-
saveRule: "Save Rule"
|
|
30249
|
-
other: "Other..."
|
|
30510
|
+
saveRule: "Save Rule"
|
|
30250
30511
|
},
|
|
30251
|
-
addFunds: "Add Funds",
|
|
30252
30512
|
autoFunding: {
|
|
30253
30513
|
addFundsAutomatically: "Add Funds Automatically",
|
|
30254
30514
|
error: {
|
|
@@ -30261,20 +30521,31 @@ var manageFunding = {
|
|
|
30261
30521
|
maximumPurchasesPerDay: "Maximum Purchases Per Day",
|
|
30262
30522
|
purchaseAmount: "Purchase Amount"
|
|
30263
30523
|
},
|
|
30264
|
-
|
|
30265
|
-
|
|
30524
|
+
addFunds: {
|
|
30525
|
+
custom: "Custom...",
|
|
30266
30526
|
error: {
|
|
30267
30527
|
title: "Manual-Funding Error",
|
|
30268
30528
|
message: "An error occurred while trying add funds to your ShipEngine wallet."
|
|
30269
30529
|
},
|
|
30270
30530
|
isLoading: "Adding funds to your ShipEngine wallet...",
|
|
30271
30531
|
labels: {
|
|
30272
|
-
amount: "Amount"
|
|
30273
|
-
currentBalance: "Current Balance",
|
|
30274
|
-
resultingBalance: "Resulting Balance"
|
|
30532
|
+
amount: "Amount"
|
|
30275
30533
|
},
|
|
30276
30534
|
minimumPurchaseAmount: "Minimum Purchase $10.00"
|
|
30277
30535
|
},
|
|
30536
|
+
fundAndPurchase: {
|
|
30537
|
+
finalBalance: "Final balance after payment:",
|
|
30538
|
+
insufficientFunds: "Add funds below to purchase label.",
|
|
30539
|
+
insufficientFundsTitle: "Not enough money in your account",
|
|
30540
|
+
negativeBalance: "You will be charged this amount in addition to the label cost.",
|
|
30541
|
+
negativeBalanceTitle: "Negative balance (due to adjustments)",
|
|
30542
|
+
newBalance: "New balance after adding funds:"
|
|
30543
|
+
},
|
|
30544
|
+
errors: {
|
|
30545
|
+
balanceUnknown: "Unknown",
|
|
30546
|
+
unableToFindBalance: "There was a problem retrieving your balance. Please try again later."
|
|
30547
|
+
},
|
|
30548
|
+
currentBalance: "Current balance:",
|
|
30278
30549
|
maximumBalanceAmount: "Balance may not exceed $10,000.00"
|
|
30279
30550
|
}
|
|
30280
30551
|
};
|
|
@@ -30783,16 +31054,84 @@ const ListCarriers = () => {
|
|
|
30783
31054
|
}
|
|
30784
31055
|
yield refetchCarriers();
|
|
30785
31056
|
});
|
|
30786
|
-
// TODO: How to pass two sets of errors and isLoading, possible example is to join errors like in RateForm and ShipmentForm.
|
|
30787
|
-
return jsxRuntime.jsx(ListCarriers$1, {
|
|
30788
|
-
carriers: carriersConnectedStatus,
|
|
30789
|
-
isLoading: isLoading,
|
|
30790
|
-
onRegisterCarrier: handleRegistration,
|
|
30791
|
-
registerCarrierErrors: registerCarrierErrors
|
|
31057
|
+
// TODO: How to pass two sets of errors and isLoading, possible example is to join errors like in RateForm and ShipmentForm.
|
|
31058
|
+
return jsxRuntime.jsx(ListCarriers$1, {
|
|
31059
|
+
carriers: carriersConnectedStatus,
|
|
31060
|
+
isLoading: isLoading,
|
|
31061
|
+
onRegisterCarrier: handleRegistration,
|
|
31062
|
+
registerCarrierErrors: registerCarrierErrors
|
|
31063
|
+
});
|
|
31064
|
+
};
|
|
31065
|
+
|
|
31066
|
+
const Element$5 = registerElement("list-carriers", ListCarriers);
|
|
31067
|
+
|
|
31068
|
+
const ManageWarehouses = () => {
|
|
31069
|
+
const {
|
|
31070
|
+
t
|
|
31071
|
+
} = reactI18next.useTranslation();
|
|
31072
|
+
const {
|
|
31073
|
+
data: warehouses,
|
|
31074
|
+
error: listWarehouseErrors,
|
|
31075
|
+
isLoading: isLoadingWarehouses,
|
|
31076
|
+
refetch: refreshListWarehouses
|
|
31077
|
+
} = react.useListWarehouses();
|
|
31078
|
+
const {
|
|
31079
|
+
error: updateWarehouseErrors,
|
|
31080
|
+
mutateAsync: updateWarehouse
|
|
31081
|
+
} = react.useUpdateWarehouse();
|
|
31082
|
+
const {
|
|
31083
|
+
error: createWarehouseErrors,
|
|
31084
|
+
mutateAsync: createWarehouse
|
|
31085
|
+
} = react.useCreateWarehouse();
|
|
31086
|
+
const {
|
|
31087
|
+
error: deleteWarehouseErrors,
|
|
31088
|
+
mutateAsync: deleteWarehouse
|
|
31089
|
+
} = react.useDeleteWarehouse();
|
|
31090
|
+
const handleDeleteWarehouse = warehouseId => __awaiter(void 0, void 0, void 0, function* () {
|
|
31091
|
+
yield deleteWarehouse({
|
|
31092
|
+
warehouseId
|
|
31093
|
+
});
|
|
31094
|
+
void refreshListWarehouses();
|
|
31095
|
+
});
|
|
31096
|
+
const handleSubmitAddNewWarehouse = payload => __awaiter(void 0, void 0, void 0, function* () {
|
|
31097
|
+
const result = yield createWarehouse(payload);
|
|
31098
|
+
if (result) void refreshListWarehouses();
|
|
31099
|
+
});
|
|
31100
|
+
const handleSubmitEditWarehouse = (payload, warehouseId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31101
|
+
yield updateWarehouse({
|
|
31102
|
+
name: payload.name,
|
|
31103
|
+
originAddress: payload.originAddress,
|
|
31104
|
+
returnAddress: payload.returnAddress,
|
|
31105
|
+
warehouseId: warehouseId
|
|
31106
|
+
});
|
|
31107
|
+
void refreshListWarehouses();
|
|
31108
|
+
});
|
|
31109
|
+
const handleSetDefault = (payload, warehouseId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31110
|
+
yield updateWarehouse(Object.assign(Object.assign({}, payload), {
|
|
31111
|
+
isDefault: true,
|
|
31112
|
+
warehouseId
|
|
31113
|
+
}));
|
|
31114
|
+
void refreshListWarehouses();
|
|
31115
|
+
});
|
|
31116
|
+
if (isLoadingWarehouses) return jsxRuntime.jsx(Loader, {
|
|
31117
|
+
message: t("loading.warehouses")
|
|
31118
|
+
});
|
|
31119
|
+
if (!warehouses) {
|
|
31120
|
+
if (listWarehouseErrors) throw new Error(listWarehouseErrors.map(e => e.message).join(", "));
|
|
31121
|
+
throw new Error("errorMessages.unableToLoad.warehouses");
|
|
31122
|
+
}
|
|
31123
|
+
const errors = [...(updateWarehouseErrors !== null && updateWarehouseErrors !== void 0 ? updateWarehouseErrors : []), ...(createWarehouseErrors !== null && createWarehouseErrors !== void 0 ? createWarehouseErrors : []), ...(deleteWarehouseErrors !== null && deleteWarehouseErrors !== void 0 ? deleteWarehouseErrors : [])];
|
|
31124
|
+
return jsxRuntime.jsx(ManageWarehouses$1, {
|
|
31125
|
+
errors: errors,
|
|
31126
|
+
onAdd: handleSubmitAddNewWarehouse,
|
|
31127
|
+
onDelete: handleDeleteWarehouse,
|
|
31128
|
+
onEdit: handleSubmitEditWarehouse,
|
|
31129
|
+
onSetDefault: handleSetDefault,
|
|
31130
|
+
warehouses: warehouses
|
|
30792
31131
|
});
|
|
30793
31132
|
};
|
|
30794
31133
|
|
|
30795
|
-
const Element$
|
|
31134
|
+
const Element$4 = registerElement("manage-warehouses", ManageWarehouses);
|
|
30796
31135
|
|
|
30797
31136
|
const useAddress = ({
|
|
30798
31137
|
compatibleCountryCodes,
|
|
@@ -31398,196 +31737,6 @@ const ConfigureShipment = _a => {
|
|
|
31398
31737
|
});
|
|
31399
31738
|
};
|
|
31400
31739
|
|
|
31401
|
-
const ManageFunding = ({
|
|
31402
|
-
carrierId,
|
|
31403
|
-
fundingMethod,
|
|
31404
|
-
requiredAmount
|
|
31405
|
-
}) => {
|
|
31406
|
-
// const { data: carriersData, loading, error } = useListCarriers();
|
|
31407
|
-
var _a, _b;
|
|
31408
|
-
const {
|
|
31409
|
-
data: addFundsData,
|
|
31410
|
-
error: addFundsErrors,
|
|
31411
|
-
mutateAsync: addFunds,
|
|
31412
|
-
isLoading: isAddFundsLoading,
|
|
31413
|
-
reset: addFundsRefresh
|
|
31414
|
-
} = react.useAddFunds();
|
|
31415
|
-
const {
|
|
31416
|
-
data: autoFundingData,
|
|
31417
|
-
error: autoFundingErrors,
|
|
31418
|
-
isLoading: isAutoFundingLoading,
|
|
31419
|
-
refetch: refreshAutoFundingConfiguration
|
|
31420
|
-
} = react.useGetAutoFundingConfiguration();
|
|
31421
|
-
const {
|
|
31422
|
-
mutateAsync: configureAutoFunding
|
|
31423
|
-
} = react.useUpdateAutoFunding();
|
|
31424
|
-
const handleSubmitManualFunding = payload => __awaiter(void 0, void 0, void 0, function* () {
|
|
31425
|
-
const result = yield addFunds({
|
|
31426
|
-
amount: payload.funds,
|
|
31427
|
-
carrierId
|
|
31428
|
-
});
|
|
31429
|
-
if (result) void addFundsRefresh();
|
|
31430
|
-
});
|
|
31431
|
-
const handleSubmitAutoFunding = payload => __awaiter(void 0, void 0, void 0, function* () {
|
|
31432
|
-
const result = yield configureAutoFunding(Object.assign({
|
|
31433
|
-
carrierId
|
|
31434
|
-
}, payload));
|
|
31435
|
-
if (result) void refreshAutoFundingConfiguration();
|
|
31436
|
-
});
|
|
31437
|
-
const handleToggleAutoFunding = isEnabled => __awaiter(void 0, void 0, void 0, function* () {
|
|
31438
|
-
if (autoFundingData) {
|
|
31439
|
-
const result = yield configureAutoFunding(Object.assign(Object.assign({}, autoFundingData), {
|
|
31440
|
-
carrierId,
|
|
31441
|
-
isEnabled
|
|
31442
|
-
}));
|
|
31443
|
-
if (result) void refreshAutoFundingConfiguration();
|
|
31444
|
-
} else {
|
|
31445
|
-
console.error("Toggling auto-funding failed because autoFundingData is undefined.");
|
|
31446
|
-
}
|
|
31447
|
-
});
|
|
31448
|
-
return jsxRuntime.jsx(FundingMethods, {
|
|
31449
|
-
autoFundingData: autoFundingData,
|
|
31450
|
-
autoFundingErrorMessage: autoFundingErrors ? (_a = autoFundingErrors[0]) === null || _a === void 0 ? void 0 : _a.message : undefined,
|
|
31451
|
-
fundingMethod: fundingMethod !== null && fundingMethod !== void 0 ? fundingMethod : "both",
|
|
31452
|
-
hasAutoFundingError: !!(autoFundingErrors === null || autoFundingErrors === void 0 ? void 0 : autoFundingErrors.length),
|
|
31453
|
-
hasManualFundingError: !!(addFundsErrors === null || addFundsErrors === void 0 ? void 0 : addFundsErrors.length),
|
|
31454
|
-
isAutoFundingLoading: isAutoFundingLoading,
|
|
31455
|
-
isManualFundingLoading: isAddFundsLoading,
|
|
31456
|
-
manualFundingCurrentBalance: (_b = addFundsData === null || addFundsData === void 0 ? void 0 : addFundsData.balance.amount) !== null && _b !== void 0 ? _b : 0,
|
|
31457
|
-
manualFundingRequiredAmount: requiredAmount,
|
|
31458
|
-
onSubmitAutoFunding: handleSubmitAutoFunding,
|
|
31459
|
-
onSubmitManualFunding: handleSubmitManualFunding,
|
|
31460
|
-
onToggleAutoFunding: handleToggleAutoFunding
|
|
31461
|
-
});
|
|
31462
|
-
};
|
|
31463
|
-
|
|
31464
|
-
const ManageWarehouses = () => {
|
|
31465
|
-
const {
|
|
31466
|
-
t
|
|
31467
|
-
} = reactI18next.useTranslation();
|
|
31468
|
-
const {
|
|
31469
|
-
data: warehouses,
|
|
31470
|
-
error: listWarehouseErrors,
|
|
31471
|
-
isLoading: isLoadingWarehouses,
|
|
31472
|
-
refetch: refreshListWarehouses
|
|
31473
|
-
} = react.useListWarehouses();
|
|
31474
|
-
const {
|
|
31475
|
-
error: updateWarehouseErrors,
|
|
31476
|
-
mutateAsync: updateWarehouse
|
|
31477
|
-
} = react.useUpdateWarehouse();
|
|
31478
|
-
const {
|
|
31479
|
-
error: createWarehouseErrors,
|
|
31480
|
-
mutateAsync: createWarehouse
|
|
31481
|
-
} = react.useCreateWarehouse();
|
|
31482
|
-
const {
|
|
31483
|
-
error: deleteWarehouseErrors,
|
|
31484
|
-
mutateAsync: deleteWarehouse
|
|
31485
|
-
} = react.useDeleteWarehouse();
|
|
31486
|
-
const handleDeleteWarehouse = warehouseId => __awaiter(void 0, void 0, void 0, function* () {
|
|
31487
|
-
yield deleteWarehouse({
|
|
31488
|
-
warehouseId
|
|
31489
|
-
});
|
|
31490
|
-
void refreshListWarehouses();
|
|
31491
|
-
});
|
|
31492
|
-
const handleSubmitAddNewWarehouse = payload => __awaiter(void 0, void 0, void 0, function* () {
|
|
31493
|
-
const result = yield createWarehouse(payload);
|
|
31494
|
-
if (result) void refreshListWarehouses();
|
|
31495
|
-
});
|
|
31496
|
-
const handleSubmitEditWarehouse = (payload, warehouseId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31497
|
-
yield updateWarehouse({
|
|
31498
|
-
name: payload.name,
|
|
31499
|
-
originAddress: payload.originAddress,
|
|
31500
|
-
returnAddress: payload.returnAddress,
|
|
31501
|
-
warehouseId: warehouseId
|
|
31502
|
-
});
|
|
31503
|
-
void refreshListWarehouses();
|
|
31504
|
-
});
|
|
31505
|
-
const handleSetDefault = (payload, warehouseId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31506
|
-
yield updateWarehouse(Object.assign(Object.assign({}, payload), {
|
|
31507
|
-
isDefault: true,
|
|
31508
|
-
warehouseId
|
|
31509
|
-
}));
|
|
31510
|
-
void refreshListWarehouses();
|
|
31511
|
-
});
|
|
31512
|
-
if (isLoadingWarehouses) return jsxRuntime.jsx(Loader, {
|
|
31513
|
-
message: t("loading.warehouses")
|
|
31514
|
-
});
|
|
31515
|
-
if (!warehouses) {
|
|
31516
|
-
if (listWarehouseErrors) throw new Error(listWarehouseErrors.map(e => e.message).join(", "));
|
|
31517
|
-
throw new Error("errorMessages.unableToLoad.warehouses");
|
|
31518
|
-
}
|
|
31519
|
-
const errors = [...(updateWarehouseErrors !== null && updateWarehouseErrors !== void 0 ? updateWarehouseErrors : []), ...(createWarehouseErrors !== null && createWarehouseErrors !== void 0 ? createWarehouseErrors : []), ...(deleteWarehouseErrors !== null && deleteWarehouseErrors !== void 0 ? deleteWarehouseErrors : [])];
|
|
31520
|
-
return jsxRuntime.jsx(ManageWarehouses$1, {
|
|
31521
|
-
errors: errors,
|
|
31522
|
-
onAdd: handleSubmitAddNewWarehouse,
|
|
31523
|
-
onDelete: handleDeleteWarehouse,
|
|
31524
|
-
onEdit: handleSubmitEditWarehouse,
|
|
31525
|
-
onSetDefault: handleSetDefault,
|
|
31526
|
-
warehouses: warehouses
|
|
31527
|
-
});
|
|
31528
|
-
};
|
|
31529
|
-
|
|
31530
|
-
const Onboarding = ({
|
|
31531
|
-
onCompleteOnboarding
|
|
31532
|
-
}) => {
|
|
31533
|
-
const {
|
|
31534
|
-
t
|
|
31535
|
-
} = reactI18next.useTranslation(["common", "register-wallet"]);
|
|
31536
|
-
const {
|
|
31537
|
-
data: warehouses,
|
|
31538
|
-
refetch: refetchWarehouses
|
|
31539
|
-
} = react.useListWarehouses();
|
|
31540
|
-
const {
|
|
31541
|
-
mutateAsync: createWarehouse
|
|
31542
|
-
} = react.useCreateWarehouse();
|
|
31543
|
-
const {
|
|
31544
|
-
data: carriers,
|
|
31545
|
-
refetch: refetchCarriers
|
|
31546
|
-
} = react.useListCarriers();
|
|
31547
|
-
const {
|
|
31548
|
-
error: registerStampsCarrierErrors,
|
|
31549
|
-
mutateAsync: registerStampsCarrier
|
|
31550
|
-
} = react.useConnectCarrier();
|
|
31551
|
-
const {
|
|
31552
|
-
error: registerUpsCarrierErrors,
|
|
31553
|
-
mutateAsync: registerUpsCarrier,
|
|
31554
|
-
isLoading: isLoadingUps
|
|
31555
|
-
} = react.useConnectCarrier();
|
|
31556
|
-
const {
|
|
31557
|
-
error: registerDhlCarrierErrors,
|
|
31558
|
-
mutateAsync: registerDhlCarrier,
|
|
31559
|
-
isLoading: isLoadingDhl
|
|
31560
|
-
} = react.useConnectCarrier();
|
|
31561
|
-
const onWarehouseCreated = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
31562
|
-
yield refetchWarehouses();
|
|
31563
|
-
}), [refetchWarehouses]);
|
|
31564
|
-
const onCarrierCreated = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
31565
|
-
yield refetchCarriers();
|
|
31566
|
-
}), [refetchCarriers]);
|
|
31567
|
-
if (!carriers) return jsxRuntime.jsx(Loader, {
|
|
31568
|
-
message: t("loading.carriers")
|
|
31569
|
-
});
|
|
31570
|
-
if (!warehouses) return jsxRuntime.jsx(Loader, {
|
|
31571
|
-
message: t("loading.warehouses")
|
|
31572
|
-
});
|
|
31573
|
-
return jsxRuntime.jsx(Onboarding$1, {
|
|
31574
|
-
carriers: carriers,
|
|
31575
|
-
createWarehouse: createWarehouse,
|
|
31576
|
-
isLoadingDhl: isLoadingDhl,
|
|
31577
|
-
isLoadingUps: isLoadingUps,
|
|
31578
|
-
onCarrierCreated: onCarrierCreated,
|
|
31579
|
-
onCompleteOnboarding: onCompleteOnboarding,
|
|
31580
|
-
onWarehouseCreated: onWarehouseCreated,
|
|
31581
|
-
registerDhlCarrier: registerDhlCarrier,
|
|
31582
|
-
registerDhlCarrierErrors: registerDhlCarrierErrors,
|
|
31583
|
-
registerStampsCarrier: registerStampsCarrier,
|
|
31584
|
-
registerStampsCarrierErrors: registerStampsCarrierErrors,
|
|
31585
|
-
registerUpsCarrier: registerUpsCarrier,
|
|
31586
|
-
registerUpsCarrierErrors: registerUpsCarrierErrors,
|
|
31587
|
-
warehouses: warehouses
|
|
31588
|
-
});
|
|
31589
|
-
};
|
|
31590
|
-
|
|
31591
31740
|
const usePendingShipment = ({
|
|
31592
31741
|
onLoad,
|
|
31593
31742
|
salesOrder,
|
|
@@ -31780,6 +31929,69 @@ const SalesOrder = _a => {
|
|
|
31780
31929
|
}));
|
|
31781
31930
|
};
|
|
31782
31931
|
|
|
31932
|
+
const Element$3 = registerElement("purchase-label", SalesOrder);
|
|
31933
|
+
|
|
31934
|
+
const Onboarding = ({
|
|
31935
|
+
onCompleteOnboarding
|
|
31936
|
+
}) => {
|
|
31937
|
+
const {
|
|
31938
|
+
t
|
|
31939
|
+
} = reactI18next.useTranslation(["common", "register-wallet"]);
|
|
31940
|
+
const {
|
|
31941
|
+
data: warehouses,
|
|
31942
|
+
refetch: refetchWarehouses
|
|
31943
|
+
} = react.useListWarehouses();
|
|
31944
|
+
const {
|
|
31945
|
+
mutateAsync: createWarehouse
|
|
31946
|
+
} = react.useCreateWarehouse();
|
|
31947
|
+
const {
|
|
31948
|
+
data: carriers,
|
|
31949
|
+
refetch: refetchCarriers
|
|
31950
|
+
} = react.useListCarriers();
|
|
31951
|
+
const {
|
|
31952
|
+
error: registerStampsCarrierErrors,
|
|
31953
|
+
mutateAsync: registerStampsCarrier
|
|
31954
|
+
} = react.useConnectCarrier();
|
|
31955
|
+
const {
|
|
31956
|
+
error: registerUpsCarrierErrors,
|
|
31957
|
+
mutateAsync: registerUpsCarrier,
|
|
31958
|
+
isLoading: isLoadingUps
|
|
31959
|
+
} = react.useConnectCarrier();
|
|
31960
|
+
const {
|
|
31961
|
+
error: registerDhlCarrierErrors,
|
|
31962
|
+
mutateAsync: registerDhlCarrier,
|
|
31963
|
+
isLoading: isLoadingDhl
|
|
31964
|
+
} = react.useConnectCarrier();
|
|
31965
|
+
const onWarehouseCreated = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
31966
|
+
yield refetchWarehouses();
|
|
31967
|
+
}), [refetchWarehouses]);
|
|
31968
|
+
const onCarrierCreated = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
31969
|
+
yield refetchCarriers();
|
|
31970
|
+
}), [refetchCarriers]);
|
|
31971
|
+
if (!carriers) return jsxRuntime.jsx(Loader, {
|
|
31972
|
+
message: t("loading.carriers")
|
|
31973
|
+
});
|
|
31974
|
+
if (!warehouses) return jsxRuntime.jsx(Loader, {
|
|
31975
|
+
message: t("loading.warehouses")
|
|
31976
|
+
});
|
|
31977
|
+
return jsxRuntime.jsx(Onboarding$1, {
|
|
31978
|
+
carriers: carriers,
|
|
31979
|
+
createWarehouse: createWarehouse,
|
|
31980
|
+
isLoadingDhl: isLoadingDhl,
|
|
31981
|
+
isLoadingUps: isLoadingUps,
|
|
31982
|
+
onCarrierCreated: onCarrierCreated,
|
|
31983
|
+
onCompleteOnboarding: onCompleteOnboarding,
|
|
31984
|
+
onWarehouseCreated: onWarehouseCreated,
|
|
31985
|
+
registerDhlCarrier: registerDhlCarrier,
|
|
31986
|
+
registerDhlCarrierErrors: registerDhlCarrierErrors,
|
|
31987
|
+
registerStampsCarrier: registerStampsCarrier,
|
|
31988
|
+
registerStampsCarrierErrors: registerStampsCarrierErrors,
|
|
31989
|
+
registerUpsCarrier: registerUpsCarrier,
|
|
31990
|
+
registerUpsCarrierErrors: registerUpsCarrierErrors,
|
|
31991
|
+
warehouses: warehouses
|
|
31992
|
+
});
|
|
31993
|
+
};
|
|
31994
|
+
|
|
31783
31995
|
const Shipment = ({
|
|
31784
31996
|
features,
|
|
31785
31997
|
onClickPrintLabel,
|
|
@@ -31848,12 +32060,6 @@ const VoidLabel = ({
|
|
|
31848
32060
|
});
|
|
31849
32061
|
};
|
|
31850
32062
|
|
|
31851
|
-
const Element$5 = registerElement("manage-funding", ManageFunding);
|
|
31852
|
-
|
|
31853
|
-
const Element$4 = registerElement("manage-warehouses", ManageWarehouses);
|
|
31854
|
-
|
|
31855
|
-
const Element$3 = registerElement("purchase-label", SalesOrder);
|
|
31856
|
-
|
|
31857
32063
|
const Element$2 = registerElement("onboarding", Onboarding);
|
|
31858
32064
|
|
|
31859
32065
|
const Element$1 = registerElement("view-shipment", Shipment);
|
|
@@ -32542,9 +32748,42 @@ const renderWithProviders = component => {
|
|
|
32542
32748
|
})
|
|
32543
32749
|
});
|
|
32544
32750
|
};
|
|
32751
|
+
/**
|
|
32752
|
+
* Wraps the test with all of the usual Shipengine / Giger / i18 / etc providers that a full, registered "Element" would have.
|
|
32753
|
+
* This allows components to simulate usage in an Element via `decorators: [withAllProviders]`
|
|
32754
|
+
**/
|
|
32755
|
+
const renderWithAllProviders = component => {
|
|
32756
|
+
const theme = brands.createTheme(brands.BrandName.FALLBACK);
|
|
32757
|
+
return react$2.render(component, {
|
|
32758
|
+
wrapper: ({
|
|
32759
|
+
children
|
|
32760
|
+
}) => jsxRuntime.jsx(react.ShipEngineProvider, Object.assign({
|
|
32761
|
+
baseURL: "/api",
|
|
32762
|
+
getToken: () => {
|
|
32763
|
+
var _a;
|
|
32764
|
+
return (_a = process.env.STORYBOOK_TOKEN) !== null && _a !== void 0 ? _a : "none";
|
|
32765
|
+
}
|
|
32766
|
+
}, {
|
|
32767
|
+
children: jsxRuntime.jsx(RootPortalProvider, {
|
|
32768
|
+
children: jsxRuntime.jsx(giger.GigerConfigProvider, Object.assign({
|
|
32769
|
+
resolveIcon: name => `<svg>${name}</svg>`
|
|
32770
|
+
}, {
|
|
32771
|
+
children: jsxRuntime.jsx(react$1.ThemeProvider, Object.assign({
|
|
32772
|
+
theme: brands.deserialize(theme)
|
|
32773
|
+
}, {
|
|
32774
|
+
children: children
|
|
32775
|
+
}))
|
|
32776
|
+
}))
|
|
32777
|
+
})
|
|
32778
|
+
}))
|
|
32779
|
+
});
|
|
32780
|
+
};
|
|
32545
32781
|
|
|
32546
32782
|
exports.Accordion = Accordion;
|
|
32783
|
+
exports.AddFundsForm = AddFundsForm;
|
|
32784
|
+
exports.AutoFundingForm = AutoFundingForm;
|
|
32547
32785
|
exports.ButtonGroup = ButtonGroup;
|
|
32786
|
+
exports.CarrierBalance = CarrierBalance;
|
|
32548
32787
|
exports.Country = Country;
|
|
32549
32788
|
exports.Cube = Cube;
|
|
32550
32789
|
exports.ElementsContext = ElementsContext;
|
|
@@ -32554,11 +32793,14 @@ exports.ErrorFallback = ErrorFallback;
|
|
|
32554
32793
|
exports.Field = fields;
|
|
32555
32794
|
exports.FieldLabel = FieldLabel;
|
|
32556
32795
|
exports.FormPortal = FormPortal;
|
|
32796
|
+
exports.FundAndPurchase = FundAndPurchase;
|
|
32557
32797
|
exports.GigerProvider = GigerProvider;
|
|
32798
|
+
exports.InlineLabel = InlineLabel;
|
|
32558
32799
|
exports.ItemsBreakdown = ItemsBreakdown;
|
|
32559
|
-
exports.
|
|
32800
|
+
exports.LinkAction = LinkAction;
|
|
32801
|
+
exports.ListCarriers = Element$5;
|
|
32560
32802
|
exports.Loader = Loader;
|
|
32561
|
-
exports.ManageFunding =
|
|
32803
|
+
exports.ManageFunding = ManageFunding;
|
|
32562
32804
|
exports.ManageWarehouses = Element$4;
|
|
32563
32805
|
exports.Onboarding = Element$2;
|
|
32564
32806
|
exports.PageLayoutProvider = PageLayoutProvider;
|
|
@@ -32566,6 +32808,8 @@ exports.Portal = Portal;
|
|
|
32566
32808
|
exports.PurchaseLabel = Element$3;
|
|
32567
32809
|
exports.RootPortalProvider = RootPortalProvider;
|
|
32568
32810
|
exports.Spacer = Spacer;
|
|
32811
|
+
exports.Spread = Spread;
|
|
32812
|
+
exports.StoryNotes = StoryNotes;
|
|
32569
32813
|
exports.Templates = index$1;
|
|
32570
32814
|
exports.UsState = UsState;
|
|
32571
32815
|
exports.UsaCity = UsaCity;
|
|
@@ -32574,6 +32818,7 @@ exports.VoidLabel = Element;
|
|
|
32574
32818
|
exports.addressFactory = addressFactory;
|
|
32575
32819
|
exports.addressPreferenceFactory = addressPreferenceFactory;
|
|
32576
32820
|
exports.addressValidationFactory = addressValidationFactory;
|
|
32821
|
+
exports.autoFundingSchema = autoFundingSchema;
|
|
32577
32822
|
exports.calculateTotal = calculateTotal;
|
|
32578
32823
|
exports.capitalizeFirstLetter = capitalizeFirstLetter;
|
|
32579
32824
|
exports.carrierFactory = carrierFactory;
|
|
@@ -32598,6 +32843,7 @@ exports.formatDate = formatDate;
|
|
|
32598
32843
|
exports.formatFractionalWeight = formatFractionalWeight;
|
|
32599
32844
|
exports.formatMoney = formatMoney;
|
|
32600
32845
|
exports.fractionalWeightFactory = fractionalWeightFactory;
|
|
32846
|
+
exports.getAddFundsSchema = getAddFundsSchema;
|
|
32601
32847
|
exports.getCustomsFromSalesOrder = getCustomsFromSalesOrder;
|
|
32602
32848
|
exports.getExpirationYears = getExpirationYears;
|
|
32603
32849
|
exports.getIsCustomsRequiredForSalesOrder = getIsCustomsRequiredForSalesOrder;
|
|
@@ -32638,6 +32884,7 @@ exports.randomShipengineId = randomShipengineId;
|
|
|
32638
32884
|
exports.randomShipengineSlug = randomShipengineSlug;
|
|
32639
32885
|
exports.randomWeightUnit = randomWeightUnit;
|
|
32640
32886
|
exports.registerElement = registerElement;
|
|
32887
|
+
exports.renderWithAllProviders = renderWithAllProviders;
|
|
32641
32888
|
exports.renderWithProviders = renderWithProviders;
|
|
32642
32889
|
exports.salesOrderFactory = salesOrderFactory;
|
|
32643
32890
|
exports.salesOrderItemFactory = salesOrderItemFactory;
|