@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.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from '@emotion/react/jsx-runtime';
|
|
2
2
|
import { useController, get as get$1, set as set$2, useWatch, useFormState, useForm } from 'react-hook-form';
|
|
3
3
|
import { useTranslation, Trans, initReactI18next, I18nextProvider } from 'react-i18next';
|
|
4
|
-
import { Typography, FormField, FieldMessageType, Input, Checkbox, Icon, Divider, Link, Select as Select$1, Next, Option, Button, Switch as Switch$1, Textarea, ButtonVariant, InlineNotification, NotificationType, ButtonColor, Grid, GridChild, Tag, TagColor,
|
|
4
|
+
import { Typography, FormField, FieldMessageType, Input, Checkbox, Icon, Divider, Link, Select as Select$1, Next, Option, Button, Switch as Switch$1, Textarea, ButtonVariant, InlineNotification, NotificationType, ButtonColor, Grid, GridChild, Tag, TagColor, Skeleton, SkeletonAnimation, SkeletonVariant, SkeletonBackgroundColor, IconSize, Stepper, Step, Spinner, SpinnerSize, ChipList, Chip, ButtonSize, Table, TableBody, TableBaseRow, TableBodyCell, TableHeader, TableHeaderCell, useToggle as useToggle$1, Popover, DropdownOptionList, BottomSheet, GigerConfigProvider, EmotionReset, FontsLoader } from '@packlink/giger';
|
|
5
5
|
import axios from 'axios';
|
|
6
|
-
import { logger, ShipEngineProvider,
|
|
6
|
+
import { logger, ShipEngineProvider, useAddFunds, useGetCarrierById, useUpdateAutoFunding, useGetAutoFundingConfiguration, useListCarriers, useConnectCarrier, useListWarehouses, useUpdateWarehouse, useCreateWarehouse, useDeleteWarehouse, useValidateAddresses, useUpdateSalesOrderShipment, useParseAddress, useListCustomPackageTypes, useCalculateRates, useCreateLabel, useListSalesOrderShipments, useCreateSalesOrderShipment, useGetAccountSettings, useListSalesOrders, useGetSalesOrder, useListOrderSources, useRefreshOrderSource, useGetSalesOrderShipment, useListLabels, useGetLabel, useVoidLabel } from '@shipengine/react';
|
|
7
7
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
import * as React from 'react';
|
|
@@ -18,6 +18,7 @@ import { createPortal } from 'react-dom';
|
|
|
18
18
|
import { isValidPhoneNumber } from 'libphonenumber-js/min';
|
|
19
19
|
import cardValidator from 'card-validator';
|
|
20
20
|
import { encode } from 'js-base64';
|
|
21
|
+
import { useIsMutating } from 'react-query';
|
|
21
22
|
import { stringify, COMMENT, rulesheet, middleware, RULESET, combine, match as match$1, serialize, copy, replace as replace$4, WEBKIT as WEBKIT$1, MOZ, MS, KEYFRAMES, DECLARATION, compile, dealloc, alloc, hash, charat, strlen, indexof, next, token, from, peek, delimit, slice, position, prefixer as prefixer$1 } from 'stylis';
|
|
22
23
|
import i18n from 'i18next';
|
|
23
24
|
import languageDetector from 'i18next-browser-languagedetector';
|
|
@@ -2009,7 +2010,7 @@ const getRateRequiresAcknowledgement = serviceCode => {
|
|
|
2009
2010
|
return false;
|
|
2010
2011
|
}
|
|
2011
2012
|
};
|
|
2012
|
-
const getTotalRateAmount = rateCosts => calculateTotal(...Object.values(rateCosts));
|
|
2013
|
+
const getTotalRateAmount = (rateCosts = {}) => calculateTotal(...Object.values(rateCosts));
|
|
2013
2014
|
|
|
2014
2015
|
var anObject$9 = anObject$f;
|
|
2015
2016
|
|
|
@@ -3331,6 +3332,7 @@ const createFieldController = (options = {}) => function FieldController(_a) {
|
|
|
3331
3332
|
displayErrors = true,
|
|
3332
3333
|
displayLabel = true,
|
|
3333
3334
|
errors: errorsProp,
|
|
3335
|
+
hint,
|
|
3334
3336
|
inputOnly,
|
|
3335
3337
|
isOptional,
|
|
3336
3338
|
label,
|
|
@@ -3341,7 +3343,7 @@ const createFieldController = (options = {}) => function FieldController(_a) {
|
|
|
3341
3343
|
shouldUnregister,
|
|
3342
3344
|
subLabel
|
|
3343
3345
|
} = _a,
|
|
3344
|
-
formInputProps = __rest(_a, ["children", "control", "defaultValue", "displayErrors", "displayLabel", "errors", "inputOnly", "isOptional", "label", "labelWeight", "name", "nativeLabel", "rules", "shouldUnregister", "subLabel"]);
|
|
3346
|
+
formInputProps = __rest(_a, ["children", "control", "defaultValue", "displayErrors", "displayLabel", "errors", "hint", "inputOnly", "isOptional", "label", "labelWeight", "name", "nativeLabel", "rules", "shouldUnregister", "subLabel"]);
|
|
3345
3347
|
const {
|
|
3346
3348
|
field,
|
|
3347
3349
|
fieldState
|
|
@@ -3417,6 +3419,9 @@ const createFieldController = (options = {}) => function FieldController(_a) {
|
|
|
3417
3419
|
message: displayErrors && mergedErrorMessages.length > 0 ? {
|
|
3418
3420
|
content: mergedErrorMessages.join(", "),
|
|
3419
3421
|
type: FieldMessageType.ERROR
|
|
3422
|
+
} : hint ? {
|
|
3423
|
+
content: hint,
|
|
3424
|
+
type: FieldMessageType.HINT
|
|
3420
3425
|
} : undefined
|
|
3421
3426
|
}, {
|
|
3422
3427
|
children: input
|
|
@@ -21971,9 +21976,10 @@ const SubmitButton = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function SubmitB
|
|
|
21971
21976
|
children,
|
|
21972
21977
|
control,
|
|
21973
21978
|
disabled,
|
|
21979
|
+
isLoading,
|
|
21974
21980
|
requireDirty
|
|
21975
21981
|
} = _a,
|
|
21976
|
-
props = __rest(_a, ["alwaysRequireValidity", "children", "control", "disabled", "requireDirty"]);
|
|
21982
|
+
props = __rest(_a, ["alwaysRequireValidity", "children", "control", "disabled", "isLoading", "requireDirty"]);
|
|
21977
21983
|
const {
|
|
21978
21984
|
isDirty,
|
|
21979
21985
|
isValid,
|
|
@@ -21987,7 +21993,7 @@ const SubmitButton = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function SubmitB
|
|
|
21987
21993
|
disabled: disabled || !isDirty && requireDirty || !isValid && (alwaysRequireValidity || isSubmitted) || isSubmitting,
|
|
21988
21994
|
formNoValidate // Bypass all browser validations on form inputs
|
|
21989
21995
|
: true,
|
|
21990
|
-
isLoading: isSubmitting,
|
|
21996
|
+
isLoading: isLoading || isSubmitting,
|
|
21991
21997
|
ref: forwardedRef,
|
|
21992
21998
|
type: "submit"
|
|
21993
21999
|
}, props, {
|
|
@@ -24190,390 +24196,6 @@ const CustomsItemForm = ({
|
|
|
24190
24196
|
}));
|
|
24191
24197
|
};
|
|
24192
24198
|
|
|
24193
|
-
const Loader = props => {
|
|
24194
|
-
return jsx("div", Object.assign({
|
|
24195
|
-
css: {
|
|
24196
|
-
alignItems: "center",
|
|
24197
|
-
display: "flex",
|
|
24198
|
-
flexDirection: "column",
|
|
24199
|
-
height: "100%",
|
|
24200
|
-
justifyContent: "center",
|
|
24201
|
-
textAlign: "center",
|
|
24202
|
-
width: "100%"
|
|
24203
|
-
}
|
|
24204
|
-
}, {
|
|
24205
|
-
children: jsx(Spinner, Object.assign({}, props, {
|
|
24206
|
-
size: SpinnerSize.SIZE_LARGE
|
|
24207
|
-
}))
|
|
24208
|
-
}));
|
|
24209
|
-
};
|
|
24210
|
-
|
|
24211
|
-
const styles$8 = createStyles({
|
|
24212
|
-
form: theme => ({
|
|
24213
|
-
backgroundColor: theme.palette.gray.megaLight,
|
|
24214
|
-
display: "flex",
|
|
24215
|
-
flexDirection: "column",
|
|
24216
|
-
gap: theme.spacing(2),
|
|
24217
|
-
padding: theme.spacing(2)
|
|
24218
|
-
})
|
|
24219
|
-
});
|
|
24220
|
-
|
|
24221
|
-
const autoFundingSchema = z.object({
|
|
24222
|
-
isEnabled: z.boolean(),
|
|
24223
|
-
lowBalancePurchaseThreshold: moneySchema.extend({
|
|
24224
|
-
amount: z.number().min(25)
|
|
24225
|
-
}),
|
|
24226
|
-
maximumPurchasesPerDay: z.number().min(1),
|
|
24227
|
-
purchaseAmount: moneySchema.extend({
|
|
24228
|
-
amount: z.number().min(10).max(10000)
|
|
24229
|
-
})
|
|
24230
|
-
});
|
|
24231
|
-
|
|
24232
|
-
/**
|
|
24233
|
-
* This form that allows users to enable or disable auto funding, and
|
|
24234
|
-
* configure auto funding settings in ShipEngine API.
|
|
24235
|
-
*/
|
|
24236
|
-
const AutoFundingForm = ({
|
|
24237
|
-
defaultValues,
|
|
24238
|
-
errorMessage,
|
|
24239
|
-
hasError,
|
|
24240
|
-
isInteger,
|
|
24241
|
-
isLoading,
|
|
24242
|
-
onSubmit,
|
|
24243
|
-
onToggle
|
|
24244
|
-
}) => {
|
|
24245
|
-
const {
|
|
24246
|
-
t
|
|
24247
|
-
} = useTranslation();
|
|
24248
|
-
// const [showForm, toggleShowForm] = useReducer((n) => !n, false); May still need this in a subsequent PR
|
|
24249
|
-
const form = useForm({
|
|
24250
|
-
defaultValues: defaultValues,
|
|
24251
|
-
resolver: validationResolver(autoFundingSchema)
|
|
24252
|
-
});
|
|
24253
|
-
const {
|
|
24254
|
-
isDirty
|
|
24255
|
-
} = form.formState;
|
|
24256
|
-
const watchIsEnabled = form.watch("isEnabled");
|
|
24257
|
-
const handleSubmit = form.handleSubmit(values => __awaiter(void 0, void 0, void 0, function* () {
|
|
24258
|
-
yield onSubmit(values);
|
|
24259
|
-
}));
|
|
24260
|
-
if (isLoading) return jsx(Loader, {
|
|
24261
|
-
message: t("manage-funding:autoFunding.isLoading")
|
|
24262
|
-
});
|
|
24263
|
-
return jsxs(Fragment, {
|
|
24264
|
-
children: [jsx(Switch, {
|
|
24265
|
-
defaultChecked: defaultValues === null || defaultValues === void 0 ? void 0 : defaultValues.isEnabled,
|
|
24266
|
-
label: t("manage-funding:autoFunding.addFundsAutomatically"),
|
|
24267
|
-
name: "isEnabled",
|
|
24268
|
-
onChange: evt => {
|
|
24269
|
-
form.reset(Object.assign(Object.assign({}, form.getValues()), {
|
|
24270
|
-
isEnabled: evt.target.checked
|
|
24271
|
-
}));
|
|
24272
|
-
onToggle(evt.target.checked);
|
|
24273
|
-
},
|
|
24274
|
-
value: true
|
|
24275
|
-
}), watchIsEnabled && jsxs("form", Object.assign({
|
|
24276
|
-
css: styles$8.form,
|
|
24277
|
-
id: "auto-funding-form",
|
|
24278
|
-
onSubmit: formLogger.capture(handleSubmit)
|
|
24279
|
-
}, {
|
|
24280
|
-
children: [jsx(MoneyInput, {
|
|
24281
|
-
control: form.control,
|
|
24282
|
-
disabled: !watchIsEnabled,
|
|
24283
|
-
label: t("manage-funding:autoFunding.purchaseAmount"),
|
|
24284
|
-
name: "purchaseAmount",
|
|
24285
|
-
showCurrencySymbol: true
|
|
24286
|
-
}), jsx(MoneyInput, {
|
|
24287
|
-
control: form.control,
|
|
24288
|
-
disabled: !watchIsEnabled,
|
|
24289
|
-
label: t("manage-funding:autoFunding.lowBalancePurchaseThreshold"),
|
|
24290
|
-
name: "lowBalancePurchaseThreshold",
|
|
24291
|
-
showCurrencySymbol: true
|
|
24292
|
-
}), jsx(NumberInput, {
|
|
24293
|
-
control: form.control,
|
|
24294
|
-
disabled: !watchIsEnabled,
|
|
24295
|
-
label: t("manage-funding:autoFunding.maximumPurchasesPerDay"),
|
|
24296
|
-
name: "maximumPurchasesPerDay"
|
|
24297
|
-
}), jsxs(ButtonGroup, Object.assign({
|
|
24298
|
-
justify: "end"
|
|
24299
|
-
}, {
|
|
24300
|
-
children: [jsx(Button, Object.assign({
|
|
24301
|
-
disabled: !isDirty,
|
|
24302
|
-
onClick: () => form.reset(),
|
|
24303
|
-
variant: ButtonVariant.TEXT
|
|
24304
|
-
}, {
|
|
24305
|
-
children: t("actions.cancel")
|
|
24306
|
-
})), jsx(SubmitButton, Object.assign({
|
|
24307
|
-
control: form.control,
|
|
24308
|
-
"data-testid": "autoFunding.submit",
|
|
24309
|
-
disabled: !watchIsEnabled,
|
|
24310
|
-
requireDirty: true,
|
|
24311
|
-
variant: ButtonVariant.OUTLINED
|
|
24312
|
-
}, {
|
|
24313
|
-
children: t("manage-funding:actions.saveRule")
|
|
24314
|
-
}))]
|
|
24315
|
-
}))]
|
|
24316
|
-
})), hasError && errorMessage && jsxs(Fragment, {
|
|
24317
|
-
children: [jsx(Spacer, {}), jsx(InlineNotification, Object.assign({
|
|
24318
|
-
title: t("manage-funding:autoFunding.error.title"),
|
|
24319
|
-
type: NotificationType.ERROR
|
|
24320
|
-
}, {
|
|
24321
|
-
children: errorMessage
|
|
24322
|
-
})), jsx(Spacer, {})]
|
|
24323
|
-
})]
|
|
24324
|
-
});
|
|
24325
|
-
};
|
|
24326
|
-
|
|
24327
|
-
const manualFundingSchema = z.object({
|
|
24328
|
-
funds: moneySchema.extend({
|
|
24329
|
-
amount: z.number().min(10)
|
|
24330
|
-
})
|
|
24331
|
-
});
|
|
24332
|
-
|
|
24333
|
-
const ManualFundingForm = ({
|
|
24334
|
-
currentBalance,
|
|
24335
|
-
errorMessage,
|
|
24336
|
-
formId,
|
|
24337
|
-
hasError,
|
|
24338
|
-
isLoading,
|
|
24339
|
-
onCancel,
|
|
24340
|
-
onSubmit,
|
|
24341
|
-
portalRef,
|
|
24342
|
-
requiredAmount
|
|
24343
|
-
}) => {
|
|
24344
|
-
var _a;
|
|
24345
|
-
const {
|
|
24346
|
-
t
|
|
24347
|
-
} = useTranslation();
|
|
24348
|
-
const fundingRecommendations = useMemo(() => ["$20", "$50", "$100", t("manage-funding:actions.other")], [t]);
|
|
24349
|
-
const suggestedAmount = Math.max(requiredAmount !== null && requiredAmount !== void 0 ? requiredAmount : 0, 10);
|
|
24350
|
-
const [selectedFundingAmountIndex, setSelectedFundingAmountIndex] = useState(requiredAmount ? 3 : 0);
|
|
24351
|
-
const [showFormInput, toggleShowFormInput] = useToggle(!!requiredAmount);
|
|
24352
|
-
const getSelectedFundingValue = value => {
|
|
24353
|
-
return Number(value.replace(/[^0-9.-]+/g, ""));
|
|
24354
|
-
};
|
|
24355
|
-
const form = useForm({
|
|
24356
|
-
defaultValues: {
|
|
24357
|
-
funds: {
|
|
24358
|
-
amount: suggestedAmount,
|
|
24359
|
-
currency: SE.Currency.USD
|
|
24360
|
-
}
|
|
24361
|
-
},
|
|
24362
|
-
resolver: validationResolver(manualFundingSchema)
|
|
24363
|
-
});
|
|
24364
|
-
const resultingBalance = currentBalance + ((_a = form.watch("funds").amount) !== null && _a !== void 0 ? _a : 0);
|
|
24365
|
-
const formInterface = jsxs("section", Object.assign({
|
|
24366
|
-
css: theme => ({
|
|
24367
|
-
backgroundColor: theme.palette.gray.megaLight,
|
|
24368
|
-
padding: theme.spacing(2)
|
|
24369
|
-
})
|
|
24370
|
-
}, {
|
|
24371
|
-
children: [jsx(Typography, Object.assign({
|
|
24372
|
-
bold: true
|
|
24373
|
-
}, {
|
|
24374
|
-
children: t("manage-funding:addFunds")
|
|
24375
|
-
})), jsx(Spacer, {
|
|
24376
|
-
multiplier: 2
|
|
24377
|
-
}), jsx(ChipList, Object.assign({
|
|
24378
|
-
onChange: idx => {
|
|
24379
|
-
setSelectedFundingAmountIndex(idx);
|
|
24380
|
-
if (idx === fundingRecommendations.length - 1) {
|
|
24381
|
-
toggleShowFormInput(true);
|
|
24382
|
-
return;
|
|
24383
|
-
} else {
|
|
24384
|
-
toggleShowFormInput(false);
|
|
24385
|
-
form.reset({
|
|
24386
|
-
funds: {
|
|
24387
|
-
amount: getSelectedFundingValue(fundingRecommendations[idx]),
|
|
24388
|
-
currency: SE.Currency.USD
|
|
24389
|
-
}
|
|
24390
|
-
});
|
|
24391
|
-
}
|
|
24392
|
-
}
|
|
24393
|
-
}, {
|
|
24394
|
-
children: fundingRecommendations.map((item, idx) => jsx(Chip, Object.assign({
|
|
24395
|
-
css: theme => ({
|
|
24396
|
-
backgroundColor: idx !== selectedFundingAmountIndex ? theme.palette.white : theme.palette.primary.main,
|
|
24397
|
-
color: idx !== selectedFundingAmountIndex ? theme.palette.gray.main : theme.palette.white
|
|
24398
|
-
}),
|
|
24399
|
-
isSelected: idx === selectedFundingAmountIndex
|
|
24400
|
-
}, {
|
|
24401
|
-
children: item
|
|
24402
|
-
}), idx))
|
|
24403
|
-
})), jsx(Spacer, {
|
|
24404
|
-
multiplier: 1
|
|
24405
|
-
}), showFormInput && jsxs(Fragment, {
|
|
24406
|
-
children: [jsx(MoneyInput, {
|
|
24407
|
-
control: form.control,
|
|
24408
|
-
defaultValue: {
|
|
24409
|
-
amount: undefined,
|
|
24410
|
-
currency: SE.Currency.USD
|
|
24411
|
-
},
|
|
24412
|
-
label: t("manage-funding:otp.labels.amount"),
|
|
24413
|
-
name: "funds",
|
|
24414
|
-
placeholder: "Amount",
|
|
24415
|
-
showCurrencySymbol: true,
|
|
24416
|
-
subLabel: "Minimum purchase $10.00"
|
|
24417
|
-
}), jsxs(FieldLabel, Object.assign({
|
|
24418
|
-
label: t("manage-funding:otp.labels.resultingBalance")
|
|
24419
|
-
}, {
|
|
24420
|
-
children: [jsx(Typography, Object.assign({
|
|
24421
|
-
variant: "body1"
|
|
24422
|
-
}, {
|
|
24423
|
-
children: formatMoney({
|
|
24424
|
-
amount: resultingBalance,
|
|
24425
|
-
currency: SE.Currency.USD
|
|
24426
|
-
})
|
|
24427
|
-
})), jsx(Spacer, {})]
|
|
24428
|
-
}))]
|
|
24429
|
-
}), jsxs(ButtonGroup, Object.assign({
|
|
24430
|
-
justify: "end"
|
|
24431
|
-
}, {
|
|
24432
|
-
children: [jsx(Button, Object.assign({
|
|
24433
|
-
onClick: onCancel,
|
|
24434
|
-
variant: ButtonVariant.TEXT
|
|
24435
|
-
}, {
|
|
24436
|
-
children: t("actions.cancel")
|
|
24437
|
-
})), jsx(SubmitButton, Object.assign({
|
|
24438
|
-
control: form.control,
|
|
24439
|
-
form: formId,
|
|
24440
|
-
variant: ButtonVariant.OUTLINED
|
|
24441
|
-
}, {
|
|
24442
|
-
children: t(formId ? "actions.purchase" : "manage-funding:actions.addNow")
|
|
24443
|
-
}))]
|
|
24444
|
-
}))]
|
|
24445
|
-
}));
|
|
24446
|
-
if (isLoading) return jsx(Loader, {
|
|
24447
|
-
message: t("manage-funding:otp.isLoading")
|
|
24448
|
-
});
|
|
24449
|
-
return jsxs(Fragment, {
|
|
24450
|
-
children: [jsx("form", Object.assign({
|
|
24451
|
-
id: formId,
|
|
24452
|
-
onSubmit: formLogger.capture(form.handleSubmit(onSubmit))
|
|
24453
|
-
}, {
|
|
24454
|
-
children: portalRef !== undefined ?
|
|
24455
|
-
// Nested form in a well
|
|
24456
|
-
jsx(Portal, Object.assign({
|
|
24457
|
-
target: portalRef
|
|
24458
|
-
}, {
|
|
24459
|
-
children: jsx("section", Object.assign({
|
|
24460
|
-
css: theme => ({
|
|
24461
|
-
backgroundColor: theme.palette.gray.megaLight,
|
|
24462
|
-
padding: theme.spacing(2)
|
|
24463
|
-
})
|
|
24464
|
-
}, {
|
|
24465
|
-
children: formInterface
|
|
24466
|
-
}))
|
|
24467
|
-
})) :
|
|
24468
|
-
// Standalone form
|
|
24469
|
-
formInterface
|
|
24470
|
-
})), hasError && errorMessage && jsxs(Fragment, {
|
|
24471
|
-
children: [jsx(Spacer, {}), jsx(InlineNotification, Object.assign({
|
|
24472
|
-
title: t("manage-funding:otp.error.title"),
|
|
24473
|
-
type: NotificationType.ERROR
|
|
24474
|
-
}, {
|
|
24475
|
-
children: errorMessage
|
|
24476
|
-
})), jsx(Spacer, {})]
|
|
24477
|
-
})]
|
|
24478
|
-
});
|
|
24479
|
-
};
|
|
24480
|
-
|
|
24481
|
-
const styles$7 = createStyles({
|
|
24482
|
-
addFundsButton: theme => ({
|
|
24483
|
-
alignItems: "center",
|
|
24484
|
-
display: "flex",
|
|
24485
|
-
gap: theme.spacing(1)
|
|
24486
|
-
}),
|
|
24487
|
-
balanceText: theme => ({
|
|
24488
|
-
color: theme.palette.success.main
|
|
24489
|
-
}),
|
|
24490
|
-
header: theme => ({
|
|
24491
|
-
display: "flex",
|
|
24492
|
-
gap: theme.spacing(2),
|
|
24493
|
-
justifyContent: "space-between"
|
|
24494
|
-
}),
|
|
24495
|
-
negativeBalanceText: theme => ({
|
|
24496
|
-
color: theme.palette.error.main
|
|
24497
|
-
})
|
|
24498
|
-
});
|
|
24499
|
-
|
|
24500
|
-
const FundingMethods = ({
|
|
24501
|
-
addFundsErrorMessage,
|
|
24502
|
-
autoFundingData,
|
|
24503
|
-
autoFundingErrorMessage,
|
|
24504
|
-
fundingMethod,
|
|
24505
|
-
hasAutoFundingError,
|
|
24506
|
-
hasManualFundingError,
|
|
24507
|
-
isAutoFundingLoading,
|
|
24508
|
-
isManualFundingLoading,
|
|
24509
|
-
manualFundingCurrentBalance,
|
|
24510
|
-
manualFundingRequiredAmount,
|
|
24511
|
-
onSubmitAutoFunding,
|
|
24512
|
-
onSubmitManualFunding,
|
|
24513
|
-
onToggleAutoFunding
|
|
24514
|
-
}) => {
|
|
24515
|
-
const {
|
|
24516
|
-
t
|
|
24517
|
-
} = useTranslation();
|
|
24518
|
-
const [showFundingMethods, toggleShowFundingMethods] = useToggle(false);
|
|
24519
|
-
return jsxs(Fragment, {
|
|
24520
|
-
children: [jsxs("div", Object.assign({
|
|
24521
|
-
css: styles$7.header
|
|
24522
|
-
}, {
|
|
24523
|
-
children: [jsxs("div", {
|
|
24524
|
-
children: [jsx(Typography, Object.assign({
|
|
24525
|
-
variant: "body1"
|
|
24526
|
-
}, {
|
|
24527
|
-
children: t("manage-funding:currentBalance")
|
|
24528
|
-
})), jsx(Typography, Object.assign({
|
|
24529
|
-
bold: true,
|
|
24530
|
-
css: manualFundingCurrentBalance >= 0 ? styles$7.balanceText : styles$7.negativeBalanceText,
|
|
24531
|
-
variant: "body1"
|
|
24532
|
-
}, {
|
|
24533
|
-
children: formatMoney({
|
|
24534
|
-
amount: manualFundingCurrentBalance,
|
|
24535
|
-
currency: SE.Currency.USD
|
|
24536
|
-
})
|
|
24537
|
-
}))]
|
|
24538
|
-
}), jsxs(Link, Object.assign({
|
|
24539
|
-
bold: true,
|
|
24540
|
-
css: styles$7.addFundsButton,
|
|
24541
|
-
onClick: toggleShowFundingMethods,
|
|
24542
|
-
size: ButtonSize.MEDIUM
|
|
24543
|
-
}, {
|
|
24544
|
-
children: [t("manage-funding:addFunds"), jsx(Icon, {
|
|
24545
|
-
name: IconNames.ADD,
|
|
24546
|
-
size: IconSize.SIZE_MEDIUM,
|
|
24547
|
-
title: "Add Funds"
|
|
24548
|
-
})]
|
|
24549
|
-
}))]
|
|
24550
|
-
})), jsx(Spacer, {}), jsx("div", Object.assign({
|
|
24551
|
-
css: theme => Object.assign(Object.assign({}, !showFundingMethods && {
|
|
24552
|
-
display: "none"
|
|
24553
|
-
}), {
|
|
24554
|
-
marginBottom: theme.spacing(2)
|
|
24555
|
-
})
|
|
24556
|
-
}, {
|
|
24557
|
-
children: ["manual", "both"].includes(fundingMethod) && jsx(ManualFundingForm, {
|
|
24558
|
-
currentBalance: manualFundingCurrentBalance,
|
|
24559
|
-
errorMessage: addFundsErrorMessage,
|
|
24560
|
-
hasError: hasManualFundingError,
|
|
24561
|
-
isLoading: isManualFundingLoading,
|
|
24562
|
-
onCancel: toggleShowFundingMethods,
|
|
24563
|
-
onSubmit: onSubmitManualFunding,
|
|
24564
|
-
requiredAmount: manualFundingRequiredAmount
|
|
24565
|
-
})
|
|
24566
|
-
})), ["auto", "both"].includes(fundingMethod) && jsx(AutoFundingForm, {
|
|
24567
|
-
defaultValues: autoFundingData,
|
|
24568
|
-
errorMessage: autoFundingErrorMessage,
|
|
24569
|
-
hasError: hasAutoFundingError,
|
|
24570
|
-
isLoading: isAutoFundingLoading,
|
|
24571
|
-
onSubmit: onSubmitAutoFunding,
|
|
24572
|
-
onToggle: onToggleAutoFunding
|
|
24573
|
-
})]
|
|
24574
|
-
});
|
|
24575
|
-
};
|
|
24576
|
-
|
|
24577
24199
|
const Label = ({
|
|
24578
24200
|
label,
|
|
24579
24201
|
onClickVoid,
|
|
@@ -24713,7 +24335,7 @@ const LandingPageForm = ({
|
|
|
24713
24335
|
}));
|
|
24714
24336
|
};
|
|
24715
24337
|
|
|
24716
|
-
const styles$
|
|
24338
|
+
const styles$8 = createStyles({
|
|
24717
24339
|
container: theme => ({
|
|
24718
24340
|
padding: theme.spacing(2)
|
|
24719
24341
|
}),
|
|
@@ -24734,11 +24356,11 @@ const LandingPage = ({
|
|
|
24734
24356
|
t
|
|
24735
24357
|
} = useTranslation();
|
|
24736
24358
|
return jsxs("div", Object.assign({
|
|
24737
|
-
css: styles$
|
|
24359
|
+
css: styles$8.container,
|
|
24738
24360
|
"data-testid": "landing-page"
|
|
24739
24361
|
}, {
|
|
24740
24362
|
children: [jsxs("div", Object.assign({
|
|
24741
|
-
css: styles$
|
|
24363
|
+
css: styles$8.header
|
|
24742
24364
|
}, {
|
|
24743
24365
|
children: [jsx(Typography, Object.assign({
|
|
24744
24366
|
variant: "heading4"
|
|
@@ -24756,7 +24378,7 @@ const LandingPage = ({
|
|
|
24756
24378
|
})), jsx(LandingPageForm, {
|
|
24757
24379
|
onSubmit: onSubmit
|
|
24758
24380
|
}), jsxs("div", Object.assign({
|
|
24759
|
-
css: styles$
|
|
24381
|
+
css: styles$8.header
|
|
24760
24382
|
}, {
|
|
24761
24383
|
children: [jsx(Spacer, {
|
|
24762
24384
|
multiplier: 6
|
|
@@ -24767,7 +24389,7 @@ const LandingPage = ({
|
|
|
24767
24389
|
})), jsx(Spacer, {
|
|
24768
24390
|
multiplier: 2
|
|
24769
24391
|
}), jsx(Typography, Object.assign({
|
|
24770
|
-
css: styles$
|
|
24392
|
+
css: styles$8.description,
|
|
24771
24393
|
variant: "body1"
|
|
24772
24394
|
}, {
|
|
24773
24395
|
children: t("onboarding:landing.description")
|
|
@@ -24848,7 +24470,7 @@ const Accordion = _a => {
|
|
|
24848
24470
|
});
|
|
24849
24471
|
};
|
|
24850
24472
|
|
|
24851
|
-
const styles$
|
|
24473
|
+
const styles$7 = createStyles({
|
|
24852
24474
|
carrierTypography: theme => ({
|
|
24853
24475
|
color: theme.palette.black
|
|
24854
24476
|
}),
|
|
@@ -24933,13 +24555,13 @@ const ListCarriersRow = ({
|
|
|
24933
24555
|
setIsSubmitting(false);
|
|
24934
24556
|
});
|
|
24935
24557
|
return jsxs("div", Object.assign({
|
|
24936
|
-
css: styles$
|
|
24558
|
+
css: styles$7.container
|
|
24937
24559
|
}, {
|
|
24938
24560
|
children: [jsxs("div", Object.assign({
|
|
24939
|
-
css: styles$
|
|
24561
|
+
css: styles$7.rowContainer
|
|
24940
24562
|
}, {
|
|
24941
24563
|
children: [jsxs("div", Object.assign({
|
|
24942
|
-
css: styles$
|
|
24564
|
+
css: styles$7.logoContainer
|
|
24943
24565
|
}, {
|
|
24944
24566
|
children: [jsx("div", {
|
|
24945
24567
|
children: jsx("img", {
|
|
@@ -24976,7 +24598,7 @@ const ListCarriersRow = ({
|
|
|
24976
24598
|
}));
|
|
24977
24599
|
};
|
|
24978
24600
|
|
|
24979
|
-
const styles$
|
|
24601
|
+
const styles$6 = createStyles({
|
|
24980
24602
|
listContainer: theme => ({
|
|
24981
24603
|
"& > li:not(:last-of-type)": {
|
|
24982
24604
|
borderBottom: `1px solid ${theme.palette.gray.light}`
|
|
@@ -25023,7 +24645,7 @@ const ListCarriers$1 = ({
|
|
|
25023
24645
|
children: t("list-carriers:headers.accountCarriers")
|
|
25024
24646
|
}))
|
|
25025
24647
|
}), jsx("ul", Object.assign({
|
|
25026
|
-
css: styles$
|
|
24648
|
+
css: styles$6.listContainer
|
|
25027
24649
|
}, {
|
|
25028
24650
|
children: isLoading ? jsxs(Fragment, {
|
|
25029
24651
|
children: [jsx(LoadingSkeletonRow, {}), jsx(LoadingSkeletonRow, {}), jsx(LoadingSkeletonRow, {})]
|
|
@@ -25044,10 +24666,10 @@ const ListCarriers$1 = ({
|
|
|
25044
24666
|
};
|
|
25045
24667
|
const LoadingSkeletonRow = () => {
|
|
25046
24668
|
return jsxs("div", Object.assign({
|
|
25047
|
-
css: styles$
|
|
24669
|
+
css: styles$6.skeletonRow
|
|
25048
24670
|
}, {
|
|
25049
24671
|
children: [jsxs("div", Object.assign({
|
|
25050
|
-
css: styles$
|
|
24672
|
+
css: styles$6.skeletonLogoContainer
|
|
25051
24673
|
}, {
|
|
25052
24674
|
children: [jsx(Skeleton, {
|
|
25053
24675
|
animation: SkeletonAnimation.WAVE,
|
|
@@ -25071,7 +24693,7 @@ const LoadingSkeletonRow = () => {
|
|
|
25071
24693
|
}));
|
|
25072
24694
|
};
|
|
25073
24695
|
|
|
25074
|
-
const styles$
|
|
24696
|
+
const styles$5 = createStyles({
|
|
25075
24697
|
body: theme => ({
|
|
25076
24698
|
borderTop: `1px solid ${theme.palette.gray.light}`,
|
|
25077
24699
|
color: theme.palette.black,
|
|
@@ -25122,14 +24744,14 @@ const SettingsCard = ({
|
|
|
25122
24744
|
verticallyAligned
|
|
25123
24745
|
}) => {
|
|
25124
24746
|
return jsxs("div", Object.assign({
|
|
25125
|
-
css: verticallyAligned ? styles$
|
|
24747
|
+
css: verticallyAligned ? styles$5.verticalContainer : styles$5.container,
|
|
25126
24748
|
"data-testid": "settingsCard"
|
|
25127
24749
|
}, {
|
|
25128
24750
|
children: [jsxs("div", Object.assign({
|
|
25129
|
-
css: styles$
|
|
24751
|
+
css: styles$5.header
|
|
25130
24752
|
}, {
|
|
25131
24753
|
children: [jsxs("div", Object.assign({
|
|
25132
|
-
css: styles$
|
|
24754
|
+
css: styles$5.title
|
|
25133
24755
|
}, {
|
|
25134
24756
|
children: [typeof title === "string" ? jsx(Typography, Object.assign({
|
|
25135
24757
|
variant: "subtitle2"
|
|
@@ -25164,7 +24786,7 @@ const SettingsCard = ({
|
|
|
25164
24786
|
}))
|
|
25165
24787
|
}))]
|
|
25166
24788
|
})), children && jsx("div", Object.assign({
|
|
25167
|
-
css: styles$
|
|
24789
|
+
css: styles$5.body
|
|
25168
24790
|
}, {
|
|
25169
24791
|
children: jsxs("div", {
|
|
25170
24792
|
children: [children, accessoryAction && jsx(ButtonGroup, Object.assign({
|
|
@@ -25281,7 +24903,7 @@ const warehouseSchema = z.discriminatedUnion("returnToAddressIsDifferent", [z.ob
|
|
|
25281
24903
|
});
|
|
25282
24904
|
});
|
|
25283
24905
|
|
|
25284
|
-
const styles$
|
|
24906
|
+
const styles$4 = createStyles({
|
|
25285
24907
|
header: {
|
|
25286
24908
|
textAlign: "center"
|
|
25287
24909
|
},
|
|
@@ -25333,12 +24955,12 @@ const WarehouseForm = ({
|
|
|
25333
24955
|
}
|
|
25334
24956
|
}));
|
|
25335
24957
|
return jsxs("div", Object.assign({
|
|
25336
|
-
css: _isOnboarding ? styles$
|
|
24958
|
+
css: _isOnboarding ? styles$4.onboardingWell : styles$4.well,
|
|
25337
24959
|
"data-testid": "warehouse-form"
|
|
25338
24960
|
}, {
|
|
25339
24961
|
children: [_isOnboarding && jsxs(Fragment, {
|
|
25340
24962
|
children: [jsxs("div", Object.assign({
|
|
25341
|
-
css: styles$
|
|
24963
|
+
css: styles$4.header
|
|
25342
24964
|
}, {
|
|
25343
24965
|
children: [jsx(Typography, Object.assign({
|
|
25344
24966
|
variant: "heading4"
|
|
@@ -26727,7 +26349,7 @@ const EditWalletAddressForm = ({
|
|
|
26727
26349
|
}));
|
|
26728
26350
|
};
|
|
26729
26351
|
|
|
26730
|
-
const styles$
|
|
26352
|
+
const styles$3 = createStyles({
|
|
26731
26353
|
grid: theme => ({
|
|
26732
26354
|
margin: theme.spacing(4)
|
|
26733
26355
|
}),
|
|
@@ -26775,21 +26397,21 @@ const WalletForm = ({
|
|
|
26775
26397
|
onSubmit: formLogger.capture(handleSubmit)
|
|
26776
26398
|
}, {
|
|
26777
26399
|
children: jsxs(Grid, Object.assign({
|
|
26778
|
-
css: styles$
|
|
26400
|
+
css: styles$3.grid,
|
|
26779
26401
|
noPadding: true
|
|
26780
26402
|
}, {
|
|
26781
26403
|
children: [jsx(GridChild, Object.assign({
|
|
26782
26404
|
colSpan: 12
|
|
26783
26405
|
}, {
|
|
26784
26406
|
children: jsx(Typography, Object.assign({
|
|
26785
|
-
css: styles$
|
|
26407
|
+
css: styles$3.heading,
|
|
26786
26408
|
variant: "heading4"
|
|
26787
26409
|
}, {
|
|
26788
26410
|
children: t("register-wallet:sections.billing.title")
|
|
26789
26411
|
}))
|
|
26790
26412
|
})), jsx(GridChild, Object.assign({
|
|
26791
26413
|
colSpan: 12,
|
|
26792
|
-
css: styles$
|
|
26414
|
+
css: styles$3.subtitle
|
|
26793
26415
|
}, {
|
|
26794
26416
|
children: jsx(Typography, Object.assign({
|
|
26795
26417
|
variant: "subtitle1"
|
|
@@ -26811,7 +26433,7 @@ const WalletForm = ({
|
|
|
26811
26433
|
colSpan: 12
|
|
26812
26434
|
}, {
|
|
26813
26435
|
children: jsx(Typography, Object.assign({
|
|
26814
|
-
css: styles$
|
|
26436
|
+
css: styles$3.subtitle,
|
|
26815
26437
|
variant: "subtitle1"
|
|
26816
26438
|
}, {
|
|
26817
26439
|
children: t("register-wallet:sections.billing.addressSubTitle")
|
|
@@ -26878,7 +26500,7 @@ const WalletForm = ({
|
|
|
26878
26500
|
}));
|
|
26879
26501
|
};
|
|
26880
26502
|
|
|
26881
|
-
const styles = createStyles({
|
|
26503
|
+
const styles$2 = createStyles({
|
|
26882
26504
|
lastStep: {
|
|
26883
26505
|
"& > span::first-of-type": {
|
|
26884
26506
|
"::after": {
|
|
@@ -27092,16 +26714,16 @@ const Onboarding$1 = ({
|
|
|
27092
26714
|
currentStep: currentStep
|
|
27093
26715
|
}, {
|
|
27094
26716
|
children: [jsx(Step, {
|
|
27095
|
-
css: styles.step,
|
|
26717
|
+
css: styles$2.step,
|
|
27096
26718
|
label: t("onboarding:steps.login")
|
|
27097
26719
|
}), jsx(Step, {
|
|
27098
|
-
css: styles.step,
|
|
26720
|
+
css: styles$2.step,
|
|
27099
26721
|
label: t("onboarding:steps.carriers")
|
|
27100
26722
|
}), jsx(Step, {
|
|
27101
|
-
css: styles.step,
|
|
26723
|
+
css: styles$2.step,
|
|
27102
26724
|
label: t("onboarding:steps.addresses")
|
|
27103
26725
|
}), jsx(Step, {
|
|
27104
|
-
css: styles.lastStep,
|
|
26726
|
+
css: styles$2.lastStep,
|
|
27105
26727
|
label: t("onboarding:steps.payment")
|
|
27106
26728
|
})]
|
|
27107
26729
|
})), renderStep()]
|
|
@@ -27173,6 +26795,549 @@ const Cube = _a => {
|
|
|
27173
26795
|
}));
|
|
27174
26796
|
};
|
|
27175
26797
|
|
|
26798
|
+
/**
|
|
26799
|
+
* A drop-in replacement for the `<form>` tag that allows nested forms.
|
|
26800
|
+
*
|
|
26801
|
+
* Via portals, the <form> tag is mounted as a sibling of the app root. The form's
|
|
26802
|
+
* interface is then mounted back at the point of use.
|
|
26803
|
+
*/
|
|
26804
|
+
const FormPortal = ({
|
|
26805
|
+
css,
|
|
26806
|
+
children,
|
|
26807
|
+
id,
|
|
26808
|
+
onSubmit,
|
|
26809
|
+
variant
|
|
26810
|
+
}) => {
|
|
26811
|
+
const rootTarget = useRootPortal();
|
|
26812
|
+
const [interfaceTarget, setInterfaceTarget] = useState(null);
|
|
26813
|
+
const onMountInterfaceTarget = useCallback(element => {
|
|
26814
|
+
if (element) setInterfaceTarget(element);
|
|
26815
|
+
}, []);
|
|
26816
|
+
const formStyle = [variant === "well" && (theme => ({
|
|
26817
|
+
backgroundColor: theme.palette.gray.ultraLight,
|
|
26818
|
+
padding: theme.spacing(2)
|
|
26819
|
+
})), css];
|
|
26820
|
+
return jsxs(Fragment, {
|
|
26821
|
+
children: [jsx(Portal, Object.assign({
|
|
26822
|
+
target: rootTarget
|
|
26823
|
+
}, {
|
|
26824
|
+
children: jsx("form", Object.assign({
|
|
26825
|
+
id: id,
|
|
26826
|
+
onSubmit: onSubmit
|
|
26827
|
+
}, {
|
|
26828
|
+
children: jsx(Portal, Object.assign({
|
|
26829
|
+
target: interfaceTarget
|
|
26830
|
+
}, {
|
|
26831
|
+
children: children
|
|
26832
|
+
}))
|
|
26833
|
+
}))
|
|
26834
|
+
})), jsx("section", {
|
|
26835
|
+
css: formStyle,
|
|
26836
|
+
id: id + "-interface",
|
|
26837
|
+
ref: onMountInterfaceTarget
|
|
26838
|
+
})]
|
|
26839
|
+
});
|
|
26840
|
+
};
|
|
26841
|
+
|
|
26842
|
+
const Loader = props => {
|
|
26843
|
+
return jsx("div", Object.assign({
|
|
26844
|
+
css: {
|
|
26845
|
+
alignItems: "center",
|
|
26846
|
+
display: "flex",
|
|
26847
|
+
flexDirection: "column",
|
|
26848
|
+
height: "100%",
|
|
26849
|
+
justifyContent: "center",
|
|
26850
|
+
textAlign: "center",
|
|
26851
|
+
width: "100%"
|
|
26852
|
+
}
|
|
26853
|
+
}, {
|
|
26854
|
+
children: jsx(Spinner, Object.assign({}, props, {
|
|
26855
|
+
size: SpinnerSize.SIZE_LARGE
|
|
26856
|
+
}))
|
|
26857
|
+
}));
|
|
26858
|
+
};
|
|
26859
|
+
|
|
26860
|
+
const getStyles$2 = ({
|
|
26861
|
+
isDisabled,
|
|
26862
|
+
isSelected
|
|
26863
|
+
} = {}) => createStyles({
|
|
26864
|
+
chip: theme => [isSelected ? {
|
|
26865
|
+
backgroundColor: theme.palette.secondary.ultraLight,
|
|
26866
|
+
color: theme.palette.secondary.main
|
|
26867
|
+
} : {
|
|
26868
|
+
backgroundColor: theme.palette.white,
|
|
26869
|
+
color: theme.palette.gray.main
|
|
26870
|
+
},
|
|
26871
|
+
// TODO [LMNT-663] - Giger's Chip component needs support added for an isDisabled prop
|
|
26872
|
+
isDisabled && {
|
|
26873
|
+
backgroundColor: theme.palette.gray.light,
|
|
26874
|
+
cursor: "none",
|
|
26875
|
+
pointerEvents: "none"
|
|
26876
|
+
}],
|
|
26877
|
+
chipList: theme => ({
|
|
26878
|
+
gap: theme.spacing(1)
|
|
26879
|
+
}),
|
|
26880
|
+
fundsInput: theme => ({
|
|
26881
|
+
maxWidth: theme.spacing(24)
|
|
26882
|
+
})
|
|
26883
|
+
});
|
|
26884
|
+
|
|
26885
|
+
const getAddFundsSchema = (minimumAmount = 10) => z.object({
|
|
26886
|
+
funds: moneySchema.extend({
|
|
26887
|
+
amount: z.number().min(minimumAmount)
|
|
26888
|
+
})
|
|
26889
|
+
}).transform(data => data.funds);
|
|
26890
|
+
|
|
26891
|
+
/**
|
|
26892
|
+
* Form for adding funds to a carrier's account.
|
|
26893
|
+
*
|
|
26894
|
+
* If a render child is provided, external control is assumed and the cancel / submit buttons are hidden.
|
|
26895
|
+
*/
|
|
26896
|
+
const AddFundsForm = ({
|
|
26897
|
+
carrierId,
|
|
26898
|
+
children,
|
|
26899
|
+
onCancel,
|
|
26900
|
+
onSuccess,
|
|
26901
|
+
minimumAmount: _minimumAmount = 0
|
|
26902
|
+
}) => {
|
|
26903
|
+
const {
|
|
26904
|
+
t
|
|
26905
|
+
} = useTranslation();
|
|
26906
|
+
const addFunds = useAddFunds(carrierId);
|
|
26907
|
+
const carrier = useGetCarrierById(carrierId);
|
|
26908
|
+
const chips = [{
|
|
26909
|
+
label: "$20",
|
|
26910
|
+
value: 20
|
|
26911
|
+
}, {
|
|
26912
|
+
label: "$50",
|
|
26913
|
+
value: 50
|
|
26914
|
+
}, {
|
|
26915
|
+
label: "$100",
|
|
26916
|
+
value: 100
|
|
26917
|
+
}, {
|
|
26918
|
+
label: t("manage-funding:addFunds.custom"),
|
|
26919
|
+
value: "custom"
|
|
26920
|
+
}];
|
|
26921
|
+
const [selectedChip, setSelectedChip] = useState(_minimumAmount > 0 ? chips[3] : chips[0]);
|
|
26922
|
+
_minimumAmount = Math.max(_minimumAmount, 10);
|
|
26923
|
+
const form = useForm({
|
|
26924
|
+
defaultValues: {
|
|
26925
|
+
funds: {
|
|
26926
|
+
amount: selectedChip.value === "custom" ? _minimumAmount : selectedChip.value,
|
|
26927
|
+
currency: SE.Currency.USD
|
|
26928
|
+
}
|
|
26929
|
+
},
|
|
26930
|
+
resolver: validationResolver(getAddFundsSchema(_minimumAmount))
|
|
26931
|
+
});
|
|
26932
|
+
const {
|
|
26933
|
+
isSubmitted,
|
|
26934
|
+
isValid
|
|
26935
|
+
} = form.formState;
|
|
26936
|
+
const watchAmount = form.watch("funds").amount;
|
|
26937
|
+
const formId = "add-funds-form";
|
|
26938
|
+
const handleSubmit = formLogger.capture(form.handleSubmit(values => {
|
|
26939
|
+
const payload = values;
|
|
26940
|
+
addFunds.mutate(payload, {
|
|
26941
|
+
onSuccess: () => onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess()
|
|
26942
|
+
});
|
|
26943
|
+
}));
|
|
26944
|
+
if (carrier.isLoading) return jsx(Loader, {
|
|
26945
|
+
message: t("loading.carrier")
|
|
26946
|
+
});
|
|
26947
|
+
if (!carrier.data) throw new Error("errorMessages.unableToLoad.carrier");
|
|
26948
|
+
const balance = carrier.data.balance;
|
|
26949
|
+
if (balance === undefined) return jsx(InlineNotification, Object.assign({
|
|
26950
|
+
type: NotificationType.ERROR
|
|
26951
|
+
}, {
|
|
26952
|
+
children: t("manage-funding:errors.unableToFindBalance")
|
|
26953
|
+
}));
|
|
26954
|
+
return jsxs(Fragment, {
|
|
26955
|
+
children: [jsxs(FormPortal, Object.assign({
|
|
26956
|
+
id: formId,
|
|
26957
|
+
onSubmit: handleSubmit,
|
|
26958
|
+
variant: "well"
|
|
26959
|
+
}, {
|
|
26960
|
+
children: [jsx(Typography, Object.assign({
|
|
26961
|
+
bold: true
|
|
26962
|
+
}, {
|
|
26963
|
+
children: t("manage-funding:actions.addFunds")
|
|
26964
|
+
})), jsx(Spacer, {
|
|
26965
|
+
multiplier: 2
|
|
26966
|
+
}), jsx(ChipList, Object.assign({
|
|
26967
|
+
css: getStyles$2().chipList,
|
|
26968
|
+
onChange: idx => {
|
|
26969
|
+
const chip = chips[idx];
|
|
26970
|
+
setSelectedChip(chip);
|
|
26971
|
+
if (chip.value !== "custom") {
|
|
26972
|
+
form.reset({
|
|
26973
|
+
funds: {
|
|
26974
|
+
amount: chip.value,
|
|
26975
|
+
currency: SE.Currency.USD
|
|
26976
|
+
}
|
|
26977
|
+
});
|
|
26978
|
+
}
|
|
26979
|
+
}
|
|
26980
|
+
}, {
|
|
26981
|
+
children: chips.map(chip => jsx(Chip, Object.assign({
|
|
26982
|
+
css: getStyles$2({
|
|
26983
|
+
isDisabled: chip.value < _minimumAmount,
|
|
26984
|
+
isSelected: chip.value === selectedChip.value
|
|
26985
|
+
}).chip,
|
|
26986
|
+
isSelected: chip.value === selectedChip.value
|
|
26987
|
+
}, {
|
|
26988
|
+
children: jsx(Typography, Object.assign({
|
|
26989
|
+
variant: "small"
|
|
26990
|
+
}, {
|
|
26991
|
+
children: chip.label
|
|
26992
|
+
}))
|
|
26993
|
+
}), chip.label))
|
|
26994
|
+
})), selectedChip.value === "custom" && jsxs(Fragment, {
|
|
26995
|
+
children: [jsx(Spacer, {
|
|
26996
|
+
multiplier: 1
|
|
26997
|
+
}), jsx(MoneyInput, {
|
|
26998
|
+
control: form.control,
|
|
26999
|
+
css: getStyles$2().fundsInput,
|
|
27000
|
+
defaultValue: {
|
|
27001
|
+
amount: undefined,
|
|
27002
|
+
currency: SE.Currency.USD
|
|
27003
|
+
},
|
|
27004
|
+
form: formId,
|
|
27005
|
+
hint: t("manage-funding:addFunds.minimumPurchaseAmount"),
|
|
27006
|
+
label: t("manage-funding:addFunds.labels.amount"),
|
|
27007
|
+
name: "funds",
|
|
27008
|
+
nativeLabel: true,
|
|
27009
|
+
showCurrencySymbol: true
|
|
27010
|
+
})]
|
|
27011
|
+
}), !children && jsxs(Fragment, {
|
|
27012
|
+
children: [jsx(Spacer, {
|
|
27013
|
+
multiplier: selectedChip.value !== "custom" ? 1.5 : 1
|
|
27014
|
+
}), jsxs(ButtonGroup, Object.assign({
|
|
27015
|
+
justify: "end"
|
|
27016
|
+
}, {
|
|
27017
|
+
children: [onCancel && jsx(Button, Object.assign({
|
|
27018
|
+
onClick: onCancel,
|
|
27019
|
+
variant: ButtonVariant.TEXT
|
|
27020
|
+
}, {
|
|
27021
|
+
children: t("actions.cancel")
|
|
27022
|
+
})), jsx(SubmitButton, Object.assign({
|
|
27023
|
+
control: form.control,
|
|
27024
|
+
form: formId,
|
|
27025
|
+
isLoading: addFunds.isLoading,
|
|
27026
|
+
variant: ButtonVariant.OUTLINED
|
|
27027
|
+
}, {
|
|
27028
|
+
children: t("manage-funding:actions.addNow")
|
|
27029
|
+
}))]
|
|
27030
|
+
}))]
|
|
27031
|
+
})]
|
|
27032
|
+
})), addFunds.error && jsxs(Fragment, {
|
|
27033
|
+
children: [jsx(Spacer, {
|
|
27034
|
+
multiplier: 1
|
|
27035
|
+
}), jsx(InlineNotification, Object.assign({
|
|
27036
|
+
title: t("manage-funding:addFunds.error.title"),
|
|
27037
|
+
type: NotificationType.ERROR
|
|
27038
|
+
}, {
|
|
27039
|
+
children: addFunds.error[0].message
|
|
27040
|
+
}))]
|
|
27041
|
+
}), children === null || children === void 0 ? void 0 : children({
|
|
27042
|
+
isCustomAmount: selectedChip.value === "custom",
|
|
27043
|
+
isSubmitted,
|
|
27044
|
+
isSubmitting: addFunds.isLoading,
|
|
27045
|
+
isValid,
|
|
27046
|
+
selectedAmount: watchAmount,
|
|
27047
|
+
submit: handleSubmit
|
|
27048
|
+
})]
|
|
27049
|
+
});
|
|
27050
|
+
};
|
|
27051
|
+
|
|
27052
|
+
const InlineLabel = ({
|
|
27053
|
+
children,
|
|
27054
|
+
label
|
|
27055
|
+
}) => jsxs("div", Object.assign({
|
|
27056
|
+
css: theme => ({
|
|
27057
|
+
alignItems: "center",
|
|
27058
|
+
display: "flex",
|
|
27059
|
+
gap: theme.spacing(1)
|
|
27060
|
+
})
|
|
27061
|
+
}, {
|
|
27062
|
+
children: [jsx(Typography, {
|
|
27063
|
+
children: label
|
|
27064
|
+
}), children]
|
|
27065
|
+
}));
|
|
27066
|
+
|
|
27067
|
+
const getStyles$1 = balance => createStyles({
|
|
27068
|
+
balanceText: theme => ({
|
|
27069
|
+
color: balance === undefined ? theme.palette.alert.main : balance >= 0 ? theme.palette.secondary.dark : theme.palette.error.main
|
|
27070
|
+
})
|
|
27071
|
+
});
|
|
27072
|
+
|
|
27073
|
+
const CarrierBalance = ({
|
|
27074
|
+
carrierId
|
|
27075
|
+
}) => {
|
|
27076
|
+
const {
|
|
27077
|
+
t
|
|
27078
|
+
} = useTranslation();
|
|
27079
|
+
const {
|
|
27080
|
+
data: carrier,
|
|
27081
|
+
isLoading: isLoadingCarrier,
|
|
27082
|
+
isRefetching: isRefetchingCarrier
|
|
27083
|
+
} = useGetCarrierById(carrierId);
|
|
27084
|
+
const balance = carrier === null || carrier === void 0 ? void 0 : carrier.balance;
|
|
27085
|
+
return jsx(InlineLabel, Object.assign({
|
|
27086
|
+
label: t("manage-funding:currentBalance")
|
|
27087
|
+
}, {
|
|
27088
|
+
children: isLoadingCarrier || isRefetchingCarrier ? jsx(Spinner, {}) : jsx(Typography, Object.assign({
|
|
27089
|
+
bold: true,
|
|
27090
|
+
css: getStyles$1(balance).balanceText
|
|
27091
|
+
}, {
|
|
27092
|
+
children: balance === undefined ? t("manage-funding:errors.balanceUnknown") : formatMoney({
|
|
27093
|
+
amount: balance,
|
|
27094
|
+
currency: SE.Currency.USD
|
|
27095
|
+
})
|
|
27096
|
+
}))
|
|
27097
|
+
}));
|
|
27098
|
+
};
|
|
27099
|
+
|
|
27100
|
+
const icons = {
|
|
27101
|
+
add: IconNames.ADD,
|
|
27102
|
+
download: IconNames.DOWNLOAD
|
|
27103
|
+
};
|
|
27104
|
+
const LinkAction = _a => {
|
|
27105
|
+
var {
|
|
27106
|
+
css,
|
|
27107
|
+
icon,
|
|
27108
|
+
isDisabled,
|
|
27109
|
+
isLoading,
|
|
27110
|
+
title
|
|
27111
|
+
} = _a,
|
|
27112
|
+
props = __rest(_a, ["css", "icon", "isDisabled", "isLoading", "title"]);
|
|
27113
|
+
return jsx(Link, Object.assign({}, props, {
|
|
27114
|
+
bold: true,
|
|
27115
|
+
css: theme => [{
|
|
27116
|
+
alignItems: "center",
|
|
27117
|
+
display: "flex",
|
|
27118
|
+
gap: theme.spacing(1)
|
|
27119
|
+
},
|
|
27120
|
+
// TODO [LMNT-663] - Giger's Link component does not render isDisabled state unless isButton is true
|
|
27121
|
+
(isDisabled || isLoading) && {
|
|
27122
|
+
color: theme.palette.gray.main,
|
|
27123
|
+
cursor: "none",
|
|
27124
|
+
pointerEvents: "none"
|
|
27125
|
+
}, css],
|
|
27126
|
+
isDisabled: isDisabled,
|
|
27127
|
+
size: ButtonSize.MEDIUM
|
|
27128
|
+
}, {
|
|
27129
|
+
children: isLoading ? jsx(Spinner, {}) : jsxs(Fragment, {
|
|
27130
|
+
children: [title, icon && jsx(Icon, {
|
|
27131
|
+
name: icons[icon],
|
|
27132
|
+
size: IconSize.SIZE_MEDIUM,
|
|
27133
|
+
title: title
|
|
27134
|
+
})]
|
|
27135
|
+
})
|
|
27136
|
+
}));
|
|
27137
|
+
};
|
|
27138
|
+
|
|
27139
|
+
const Spread = ({
|
|
27140
|
+
children
|
|
27141
|
+
}) => jsx("div", Object.assign({
|
|
27142
|
+
css: theme => ({
|
|
27143
|
+
display: "flex",
|
|
27144
|
+
gap: theme.spacing(2),
|
|
27145
|
+
justifyContent: "space-between"
|
|
27146
|
+
})
|
|
27147
|
+
}, {
|
|
27148
|
+
children: children
|
|
27149
|
+
}));
|
|
27150
|
+
|
|
27151
|
+
const getStyles = isCustomAmount => createStyles({
|
|
27152
|
+
balanceText: theme => ({
|
|
27153
|
+
color: theme.palette.secondary.dark
|
|
27154
|
+
}),
|
|
27155
|
+
container: theme => ({
|
|
27156
|
+
padding: theme.spacing(3)
|
|
27157
|
+
}),
|
|
27158
|
+
formExtension: theme => ({
|
|
27159
|
+
backgroundColor: theme.palette.gray.ultraLight,
|
|
27160
|
+
display: "flex",
|
|
27161
|
+
flexDirection: "column",
|
|
27162
|
+
gap: theme.spacing(1),
|
|
27163
|
+
// Negative margin is to compensate for the padding on AddFundsForm, since we want this
|
|
27164
|
+
// section to seemlessly extend the form's well.
|
|
27165
|
+
marginTop: theme.spacing(isCustomAmount ? -1.5 : -1),
|
|
27166
|
+
padding: theme.spacing(2),
|
|
27167
|
+
paddingTop: 0
|
|
27168
|
+
}),
|
|
27169
|
+
saveRateButton: {
|
|
27170
|
+
whiteSpace: "nowrap"
|
|
27171
|
+
}
|
|
27172
|
+
});
|
|
27173
|
+
|
|
27174
|
+
/**
|
|
27175
|
+
* Fund and Purchase handles the label purchase submission UX, ensuring that a user
|
|
27176
|
+
* has the necessary funds available and can add them if not. It allows a single button
|
|
27177
|
+
* to submit the funding form followed by the purchase form.
|
|
27178
|
+
*/
|
|
27179
|
+
const FundAndPurchase = ({
|
|
27180
|
+
carrierId,
|
|
27181
|
+
className,
|
|
27182
|
+
disabled,
|
|
27183
|
+
isFundingRequired,
|
|
27184
|
+
onSave,
|
|
27185
|
+
purchaseAmount,
|
|
27186
|
+
onPurchase
|
|
27187
|
+
}) => {
|
|
27188
|
+
const {
|
|
27189
|
+
t
|
|
27190
|
+
} = useTranslation();
|
|
27191
|
+
const [isAddFundsFormOpen, setIsAddFundsFormOpen] = useState(false);
|
|
27192
|
+
const {
|
|
27193
|
+
data: carrier,
|
|
27194
|
+
isLoading: isLoadingCarrier
|
|
27195
|
+
} = useGetCarrierById(carrierId);
|
|
27196
|
+
const isAddingFunds = !!useIsMutating({
|
|
27197
|
+
mutationKey: ["useAddFunds"]
|
|
27198
|
+
});
|
|
27199
|
+
const isCreatingLabel = !!useIsMutating({
|
|
27200
|
+
mutationKey: ["useCreateLabel"]
|
|
27201
|
+
});
|
|
27202
|
+
const [isSavingRate, setIsSavingRate] = useState(false);
|
|
27203
|
+
const handleSaveRate = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
27204
|
+
setIsSavingRate(true);
|
|
27205
|
+
yield onSave();
|
|
27206
|
+
setIsSavingRate(false);
|
|
27207
|
+
});
|
|
27208
|
+
// Automatically open the Add Funds form if the carrier's balance is insufficient.
|
|
27209
|
+
useEffect(() => {
|
|
27210
|
+
if (isFundingRequired && (carrier === null || carrier === void 0 ? void 0 : carrier.balance) !== undefined && carrier.balance < purchaseAmount) setIsAddFundsFormOpen(true);
|
|
27211
|
+
}, [carrier === null || carrier === void 0 ? void 0 : carrier.balance, isFundingRequired, purchaseAmount]);
|
|
27212
|
+
const renderActionButtons = (addFundsForm = {}) => jsxs(ButtonGroup, Object.assign({
|
|
27213
|
+
justify: "end"
|
|
27214
|
+
}, {
|
|
27215
|
+
children: [jsx(Button, Object.assign({
|
|
27216
|
+
bold: false,
|
|
27217
|
+
css: getStyles().saveRateButton,
|
|
27218
|
+
disabled: disabled || !carrierId || isAddingFunds || isCreatingLabel,
|
|
27219
|
+
isLoading: isSavingRate,
|
|
27220
|
+
onClick: handleSaveRate,
|
|
27221
|
+
variant: ButtonVariant.OUTLINED
|
|
27222
|
+
}, {
|
|
27223
|
+
children: t("purchase-label:actions.saveRate")
|
|
27224
|
+
})), jsx(Button, Object.assign({
|
|
27225
|
+
"data-testid": "submit-fund-and-purchase",
|
|
27226
|
+
disabled: disabled || !carrierId || isFundingRequired && isAddFundsFormOpen && addFundsForm.isSubmitted && !addFundsForm.isValid,
|
|
27227
|
+
isLoading: addFundsForm.isSubmitting || isAddingFunds || isCreatingLabel,
|
|
27228
|
+
onClick: isAddFundsFormOpen ? addFundsForm.submit : onPurchase
|
|
27229
|
+
}, {
|
|
27230
|
+
children: isAddFundsFormOpen ? t("manage-funding:actions.addFundsAndPurchase") : t("purchase-label:actions.purchaseNow")
|
|
27231
|
+
}))]
|
|
27232
|
+
}));
|
|
27233
|
+
if (!isFundingRequired) return jsx("div", Object.assign({
|
|
27234
|
+
className: className,
|
|
27235
|
+
css: getStyles().container
|
|
27236
|
+
}, {
|
|
27237
|
+
children: renderActionButtons()
|
|
27238
|
+
}));
|
|
27239
|
+
if (isLoadingCarrier) return jsx(Loader, {
|
|
27240
|
+
message: t("loading.carrier")
|
|
27241
|
+
});
|
|
27242
|
+
if (!carrier || !carrierId) throw new Error("errorMessages.unableToLoad.carrier");
|
|
27243
|
+
const balance = carrier.balance;
|
|
27244
|
+
const handleAddFundsSuccess = () => {
|
|
27245
|
+
setIsAddFundsFormOpen(false);
|
|
27246
|
+
onPurchase();
|
|
27247
|
+
};
|
|
27248
|
+
return jsxs("div", Object.assign({
|
|
27249
|
+
className: className,
|
|
27250
|
+
css: getStyles().container
|
|
27251
|
+
}, {
|
|
27252
|
+
children: [jsxs(Spread, {
|
|
27253
|
+
children: [jsx(CarrierBalance, {
|
|
27254
|
+
carrierId: carrierId
|
|
27255
|
+
}), jsx(LinkAction, {
|
|
27256
|
+
icon: "add",
|
|
27257
|
+
isDisabled: isAddFundsFormOpen || isAddingFunds || isCreatingLabel,
|
|
27258
|
+
onClick: () => setIsAddFundsFormOpen(true),
|
|
27259
|
+
title: t("manage-funding:actions.addFunds")
|
|
27260
|
+
})]
|
|
27261
|
+
}), jsx(Spacer, {
|
|
27262
|
+
multiplier: 2
|
|
27263
|
+
}), balance < purchaseAmount && jsxs(Fragment, {
|
|
27264
|
+
children: [jsx(InlineNotification, Object.assign({
|
|
27265
|
+
title: t(`manage-funding:fundAndPurchase.${balance < 0 ? "negativeBalanceTitle" : "insufficientFundsTitle"}`),
|
|
27266
|
+
type: NotificationType.ALERT
|
|
27267
|
+
}, {
|
|
27268
|
+
children: t(`manage-funding:fundAndPurchase.${balance < 0 ? "negativeBalance" : "insufficientFunds"}`)
|
|
27269
|
+
})), jsx(Spacer, {
|
|
27270
|
+
multiplier: 2
|
|
27271
|
+
})]
|
|
27272
|
+
}), isAddFundsFormOpen ? jsx(AddFundsForm, Object.assign({
|
|
27273
|
+
carrierId: carrierId,
|
|
27274
|
+
minimumAmount: purchaseAmount - balance,
|
|
27275
|
+
onSuccess: handleAddFundsSuccess
|
|
27276
|
+
}, {
|
|
27277
|
+
children: addFundsForm => {
|
|
27278
|
+
var _a, _b;
|
|
27279
|
+
return jsxs(Fragment, {
|
|
27280
|
+
children: [jsxs("section", Object.assign({
|
|
27281
|
+
css: getStyles(addFundsForm.isCustomAmount).formExtension
|
|
27282
|
+
}, {
|
|
27283
|
+
children: [jsx(InlineLabel, Object.assign({
|
|
27284
|
+
label: t("manage-funding:fundAndPurchase.newBalance")
|
|
27285
|
+
}, {
|
|
27286
|
+
children: jsx(Typography, Object.assign({
|
|
27287
|
+
css: getStyles().balanceText
|
|
27288
|
+
}, {
|
|
27289
|
+
children: formatMoney({
|
|
27290
|
+
amount: balance + ((_a = addFundsForm.selectedAmount) !== null && _a !== void 0 ? _a : 0),
|
|
27291
|
+
currency: SE.Currency.USD
|
|
27292
|
+
})
|
|
27293
|
+
}))
|
|
27294
|
+
})), jsx(InlineLabel, Object.assign({
|
|
27295
|
+
label: t("manage-funding:fundAndPurchase.finalBalance")
|
|
27296
|
+
}, {
|
|
27297
|
+
children: jsx(Typography, Object.assign({
|
|
27298
|
+
css: getStyles().balanceText
|
|
27299
|
+
}, {
|
|
27300
|
+
children: formatMoney({
|
|
27301
|
+
amount: balance + ((_b = addFundsForm.selectedAmount) !== null && _b !== void 0 ? _b : 0) - purchaseAmount,
|
|
27302
|
+
currency: SE.Currency.USD
|
|
27303
|
+
})
|
|
27304
|
+
}))
|
|
27305
|
+
})), balance >= purchaseAmount && jsx(ButtonGroup, Object.assign({
|
|
27306
|
+
justify: "end"
|
|
27307
|
+
}, {
|
|
27308
|
+
children: jsx(Button, Object.assign({
|
|
27309
|
+
onClick: () => setIsAddFundsFormOpen(false),
|
|
27310
|
+
variant: ButtonVariant.TEXT
|
|
27311
|
+
}, {
|
|
27312
|
+
children: t("actions.cancel")
|
|
27313
|
+
}))
|
|
27314
|
+
}))]
|
|
27315
|
+
})), jsx(Spacer, {
|
|
27316
|
+
multiplier: 2
|
|
27317
|
+
}), renderActionButtons(addFundsForm)]
|
|
27318
|
+
});
|
|
27319
|
+
}
|
|
27320
|
+
})) : renderActionButtons()]
|
|
27321
|
+
}));
|
|
27322
|
+
};
|
|
27323
|
+
|
|
27324
|
+
const styles$1 = createStyles({
|
|
27325
|
+
fundAndPurchase: theme => ({
|
|
27326
|
+
borderTop: `1px solid ${theme.palette.gray.ultraLight}`
|
|
27327
|
+
}),
|
|
27328
|
+
ratesInterstitial: {
|
|
27329
|
+
alignItems: "center",
|
|
27330
|
+
display: "flex",
|
|
27331
|
+
flexDirection: "column",
|
|
27332
|
+
justifyContent: "center",
|
|
27333
|
+
textAlign: "center"
|
|
27334
|
+
},
|
|
27335
|
+
showMoreOrLessRatesButton: {
|
|
27336
|
+
alignItems: "center",
|
|
27337
|
+
display: "flex"
|
|
27338
|
+
}
|
|
27339
|
+
});
|
|
27340
|
+
|
|
27176
27341
|
const rateSchema = z.object({
|
|
27177
27342
|
rate: z.object({
|
|
27178
27343
|
isAcknowledged: z.boolean().refine(v => v === true, "purchase-label:schemaErrors.needToAcknowledge"),
|
|
@@ -27201,7 +27366,7 @@ const RateForm = ({
|
|
|
27201
27366
|
}, features !== null && features !== void 0 ? features : {});
|
|
27202
27367
|
const {
|
|
27203
27368
|
t
|
|
27204
|
-
} = useTranslation(
|
|
27369
|
+
} = useTranslation();
|
|
27205
27370
|
const rateFormScrollToRef = useRef(null);
|
|
27206
27371
|
const [showHiddenRates, setShowHiddenRates] = useState(false);
|
|
27207
27372
|
const form = useForm({
|
|
@@ -27214,16 +27379,13 @@ const RateForm = ({
|
|
|
27214
27379
|
mode: "onChange",
|
|
27215
27380
|
resolver: validationResolver(rateSchema)
|
|
27216
27381
|
});
|
|
27217
|
-
const {
|
|
27218
|
-
isDirty
|
|
27219
|
-
} = form.formState;
|
|
27220
27382
|
const {
|
|
27221
27383
|
rateId: selectedRateId
|
|
27222
27384
|
} = form.watch("rate");
|
|
27223
|
-
const handleSubmit = form.handleSubmit(values => __awaiter(void 0, void 0, void 0, function* () {
|
|
27385
|
+
const handleSubmit = formLogger.capture(form.handleSubmit(values => __awaiter(void 0, void 0, void 0, function* () {
|
|
27224
27386
|
const rateId = values;
|
|
27225
27387
|
yield onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(rateId);
|
|
27226
|
-
}));
|
|
27388
|
+
})));
|
|
27227
27389
|
const rateOptions = useRateOptions(rates, carriers, shipment, features.enableGlobalPostFiltering
|
|
27228
27390
|
// TODO: LMNT-677: fix RecommendedRate logic
|
|
27229
27391
|
// {
|
|
@@ -27245,13 +27407,10 @@ const RateForm = ({
|
|
|
27245
27407
|
);
|
|
27246
27408
|
|
|
27247
27409
|
const selectedRate = useMemo(() => rateOptions === null || rateOptions === void 0 ? void 0 : rateOptions.find(r => r.rateId === selectedRateId), [rateOptions, selectedRateId]);
|
|
27248
|
-
const [isRateSaving, setIsRateSaving] = useState(false);
|
|
27249
27410
|
const handleSaveRate = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
27250
27411
|
const isValid = yield form.trigger();
|
|
27251
27412
|
if (!isValid) return;
|
|
27252
|
-
setIsRateSaving(true);
|
|
27253
27413
|
if (selectedRate) yield onSave === null || onSave === void 0 ? void 0 : onSave(selectedRate);
|
|
27254
|
-
setIsRateSaving(false);
|
|
27255
27414
|
// sets the form to not be dirty, so that Save is disabled
|
|
27256
27415
|
form.reset(form.getValues());
|
|
27257
27416
|
}), [form, onSave, selectedRate]);
|
|
@@ -27280,15 +27439,6 @@ const RateForm = ({
|
|
|
27280
27439
|
}, 0);
|
|
27281
27440
|
}
|
|
27282
27441
|
}, [form, rateOptions, errors === null || errors === void 0 ? void 0 : errors.length]);
|
|
27283
|
-
const formatFundingAmount = selectedRate => {
|
|
27284
|
-
var _a;
|
|
27285
|
-
const totalRateAmount = getTotalRateAmount(selectedRate);
|
|
27286
|
-
const walletBalance = (_a = selectedRate.balance) !== null && _a !== void 0 ? _a : 0;
|
|
27287
|
-
return formatMoney({
|
|
27288
|
-
amount: Math.max(totalRateAmount - walletBalance, 0),
|
|
27289
|
-
currency: SE.Currency.USD
|
|
27290
|
-
});
|
|
27291
|
-
};
|
|
27292
27442
|
return jsxs("form", Object.assign({
|
|
27293
27443
|
id: "rate-form",
|
|
27294
27444
|
onSubmit: handleSubmit,
|
|
@@ -27310,10 +27460,7 @@ const RateForm = ({
|
|
|
27310
27460
|
onClick: onSelectRate,
|
|
27311
27461
|
options: showHiddenRates ? rateOptions : filteredRateOptions
|
|
27312
27462
|
}), rateOptions.some(option => option.requiresAcknowledgement) && rateOptions.length > 5 && jsx(Link, Object.assign({
|
|
27313
|
-
css:
|
|
27314
|
-
alignItems: "center",
|
|
27315
|
-
display: "flex"
|
|
27316
|
-
},
|
|
27463
|
+
css: styles$1.showMoreOrLessRatesButton,
|
|
27317
27464
|
onClick: () => {
|
|
27318
27465
|
var _a;
|
|
27319
27466
|
setShowHiddenRates(!showHiddenRates);
|
|
@@ -27331,86 +27478,36 @@ const RateForm = ({
|
|
|
27331
27478
|
variant: "body1"
|
|
27332
27479
|
}, {
|
|
27333
27480
|
children: showHiddenRates ? t("purchase-label:actions.showFewerRates") : t("purchase-label:actions.showMoreRates")
|
|
27334
|
-
}))
|
|
27335
|
-
}))]
|
|
27336
|
-
}) : !isLoading && errors && !!errors.length ? null : jsxs("article", Object.assign({
|
|
27337
|
-
css:
|
|
27338
|
-
|
|
27339
|
-
display: "flex",
|
|
27340
|
-
flexDirection: "column",
|
|
27341
|
-
justifyContent: "center",
|
|
27342
|
-
textAlign: "center"
|
|
27343
|
-
},
|
|
27344
|
-
role: "presentation"
|
|
27345
|
-
}, {
|
|
27346
|
-
children: [jsx(Cube, {
|
|
27347
|
-
animate: isLoading
|
|
27348
|
-
}), jsx(Spacer, {}), isLoading ? t("purchase-label:loading.calculatingRates") : t("purchase-label:cta.addPackageDetails")]
|
|
27349
|
-
})), !isLoading && (errors && !!errors.length && rateOptions.length === 0 || !!(labelErrors === null || labelErrors === void 0 ? void 0 : labelErrors.length)) && jsxs(Fragment, {
|
|
27350
|
-
children: [jsx(Spacer, {}), jsxs(InlineNotification, Object.assign({
|
|
27351
|
-
title: t("errorTypes.rateInvalid"),
|
|
27352
|
-
type: NotificationType.ERROR
|
|
27353
|
-
}, {
|
|
27354
|
-
children: [errors === null || errors === void 0 ? void 0 : errors.map(e => t(encode(e.message), {
|
|
27355
|
-
defaultValue: e.message.includes("No rates are available for service_codes") ? t("common:errorMessages.noRatesAvailable") : e.message
|
|
27356
|
-
})).join(" "), labelErrors === null || labelErrors === void 0 ? void 0 : labelErrors.map(e => t(encode(e.message), {
|
|
27357
|
-
defaultValue: e.message.replace(/Exception with code [\w\d]+; module [\d]+, category [\d]+, item [\d]+/g, "")
|
|
27358
|
-
}))]
|
|
27359
|
-
}))]
|
|
27360
|
-
})]
|
|
27361
|
-
})), jsxs(BottomSheet, Object.assign({
|
|
27362
|
-
alwaysVisible: true,
|
|
27363
|
-
css: theme => ({
|
|
27364
|
-
borderTop: `1px solid ${theme.palette.gray.ultraLight}`,
|
|
27365
|
-
boxShadow: "none",
|
|
27366
|
-
position: "static"
|
|
27367
|
-
})
|
|
27368
|
-
}, {
|
|
27369
|
-
children: [typeof (selectedRate === null || selectedRate === void 0 ? void 0 : selectedRate.balance) === "number" && selectedRate.requiresFundedAmount && jsxs(Fragment, {
|
|
27370
|
-
children: [jsx(Typography, Object.assign({
|
|
27371
|
-
variant: "body1"
|
|
27372
|
-
}, {
|
|
27373
|
-
children: t("purchase-label:balance.currentBalance")
|
|
27374
|
-
})), jsx(Typography, Object.assign({
|
|
27375
|
-
color: selectedRate.balance < 0 ? "error.main" : undefined
|
|
27376
|
-
}, {
|
|
27377
|
-
children: ` ${formatMoney({
|
|
27378
|
-
amount: selectedRate.balance,
|
|
27379
|
-
currency: SE.Currency.USD
|
|
27380
|
-
})}`
|
|
27381
|
-
})), jsx(Spacer, {
|
|
27382
|
-
multiplier: 2
|
|
27383
|
-
})]
|
|
27384
|
-
}), jsx("div", Object.assign({
|
|
27385
|
-
"data-testid": "actions"
|
|
27481
|
+
}))
|
|
27482
|
+
}))]
|
|
27483
|
+
}) : !isLoading && errors && !!errors.length ? null : jsxs("article", Object.assign({
|
|
27484
|
+
css: styles$1.ratesInterstitial,
|
|
27485
|
+
role: "presentation"
|
|
27386
27486
|
}, {
|
|
27387
|
-
children:
|
|
27388
|
-
|
|
27487
|
+
children: [jsx(Cube, {
|
|
27488
|
+
animate: isLoading
|
|
27489
|
+
}), jsx(Spacer, {}), isLoading ? t("purchase-label:loading.calculatingRates") : t("purchase-label:cta.addPackageDetails")]
|
|
27490
|
+
})), !isLoading && (errors && !!errors.length && rateOptions.length === 0 || !!(labelErrors === null || labelErrors === void 0 ? void 0 : labelErrors.length)) && jsxs(Fragment, {
|
|
27491
|
+
children: [jsx(Spacer, {}), jsxs(InlineNotification, Object.assign({
|
|
27492
|
+
title: t("errorTypes.rateInvalid"),
|
|
27493
|
+
type: NotificationType.ERROR
|
|
27389
27494
|
}, {
|
|
27390
|
-
children: [
|
|
27391
|
-
|
|
27392
|
-
|
|
27393
|
-
|
|
27394
|
-
},
|
|
27395
|
-
disabled: !isDirty || disabled,
|
|
27396
|
-
isLoading: isRateSaving,
|
|
27397
|
-
onClick: handleSaveRate,
|
|
27398
|
-
variant: ButtonVariant.OUTLINED
|
|
27399
|
-
}, {
|
|
27400
|
-
children: t("purchase-label:actions.saveRate")
|
|
27401
|
-
})), jsx(SubmitButton, Object.assign({
|
|
27402
|
-
alwaysRequireValidity: true,
|
|
27403
|
-
control: form.control,
|
|
27404
|
-
"data-testid": "purchaseLabel",
|
|
27405
|
-
disabled: !selectedRate || disabled,
|
|
27406
|
-
form: "rate-form",
|
|
27407
|
-
isFullWidth: true
|
|
27408
|
-
}, {
|
|
27409
|
-
children: (selectedRate === null || selectedRate === void 0 ? void 0 : selectedRate.balance) ? `${t("purchase-label:actions.purchaseNow")} - ${formatFundingAmount(selectedRate)}` : t("purchase-label:actions.purchaseNow")
|
|
27495
|
+
children: [errors === null || errors === void 0 ? void 0 : errors.map(e => t(encode(e.message), {
|
|
27496
|
+
defaultValue: e.message.includes("No rates are available for service_codes") ? t("common:errorMessages.noRatesAvailable") : e.message
|
|
27497
|
+
})).join(" "), labelErrors === null || labelErrors === void 0 ? void 0 : labelErrors.map(e => t(encode(e.message), {
|
|
27498
|
+
defaultValue: e.message.replace(/Exception with code [\w\d]+; module [\d]+, category [\d]+, item [\d]+/g, "")
|
|
27410
27499
|
}))]
|
|
27411
|
-
}))
|
|
27412
|
-
})
|
|
27413
|
-
}))
|
|
27500
|
+
}))]
|
|
27501
|
+
})]
|
|
27502
|
+
})), jsx(FundAndPurchase, {
|
|
27503
|
+
carrierId: selectedRate === null || selectedRate === void 0 ? void 0 : selectedRate.carrierId,
|
|
27504
|
+
css: styles$1.fundAndPurchase,
|
|
27505
|
+
disabled: disabled,
|
|
27506
|
+
isFundingRequired: (selectedRate === null || selectedRate === void 0 ? void 0 : selectedRate.balance) !== undefined && !!selectedRate.requiresFundedAmount,
|
|
27507
|
+
onPurchase: handleSubmit,
|
|
27508
|
+
onSave: handleSaveRate,
|
|
27509
|
+
purchaseAmount: getTotalRateAmount(selectedRate)
|
|
27510
|
+
})]
|
|
27414
27511
|
}));
|
|
27415
27512
|
};
|
|
27416
27513
|
|
|
@@ -28960,7 +29057,6 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
28960
29057
|
CarrierTermsForm: CarrierTermsForm,
|
|
28961
29058
|
CustomsItemForm: CustomsItemForm,
|
|
28962
29059
|
getCustomsItemFormSchema: getCustomsItemFormSchema,
|
|
28963
|
-
FundingMethods: FundingMethods,
|
|
28964
29060
|
Label: Label,
|
|
28965
29061
|
LandingPage: LandingPage,
|
|
28966
29062
|
ListCarriers: ListCarriers$1,
|
|
@@ -28974,12 +29070,141 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
28974
29070
|
WarehouseForm: WarehouseForm,
|
|
28975
29071
|
VoidLabel: VoidLabel$1,
|
|
28976
29072
|
WalletForm: WalletForm,
|
|
28977
|
-
styles: styles$
|
|
29073
|
+
styles: styles$3,
|
|
28978
29074
|
billingAddressSchema: billingAddressSchema,
|
|
28979
29075
|
walletSchema: walletSchema,
|
|
28980
29076
|
BillingFields: BillingFields
|
|
28981
29077
|
});
|
|
28982
29078
|
|
|
29079
|
+
const styles = createStyles({
|
|
29080
|
+
form: theme => ({
|
|
29081
|
+
backgroundColor: theme.palette.gray.megaLight,
|
|
29082
|
+
display: "flex",
|
|
29083
|
+
flexDirection: "column",
|
|
29084
|
+
gap: theme.spacing(2),
|
|
29085
|
+
padding: theme.spacing(2)
|
|
29086
|
+
})
|
|
29087
|
+
});
|
|
29088
|
+
|
|
29089
|
+
const autoFundingSchema = z.object({
|
|
29090
|
+
isEnabled: z.boolean(),
|
|
29091
|
+
lowBalancePurchaseThreshold: moneySchema.extend({
|
|
29092
|
+
amount: z.number().min(25)
|
|
29093
|
+
}),
|
|
29094
|
+
maximumPurchasesPerDay: z.number().min(1),
|
|
29095
|
+
purchaseAmount: moneySchema.extend({
|
|
29096
|
+
amount: z.number().min(10).max(10000)
|
|
29097
|
+
})
|
|
29098
|
+
});
|
|
29099
|
+
|
|
29100
|
+
/**
|
|
29101
|
+
* This form that allows users to enable or disable auto funding, and
|
|
29102
|
+
* configure auto funding settings in ShipEngine API.
|
|
29103
|
+
*/
|
|
29104
|
+
const AutoFundingForm = ({
|
|
29105
|
+
carrierId
|
|
29106
|
+
}) => {
|
|
29107
|
+
const {
|
|
29108
|
+
t
|
|
29109
|
+
} = useTranslation();
|
|
29110
|
+
const updateAutoFunding = useUpdateAutoFunding(carrierId);
|
|
29111
|
+
const autoFundingConfiguration = useGetAutoFundingConfiguration();
|
|
29112
|
+
const form = useForm({
|
|
29113
|
+
// TODO - [LMNT-663] We should probably make a hydration effect for autoFundingConfiguration.data
|
|
29114
|
+
defaultValues: autoFundingConfiguration.data,
|
|
29115
|
+
resolver: validationResolver(autoFundingSchema)
|
|
29116
|
+
});
|
|
29117
|
+
const {
|
|
29118
|
+
isDirty
|
|
29119
|
+
} = form.formState;
|
|
29120
|
+
const watchIsEnabled = form.watch("isEnabled");
|
|
29121
|
+
const handleSubmit = formLogger.capture(form.handleSubmit(values => {
|
|
29122
|
+
const payload = values;
|
|
29123
|
+
updateAutoFunding.mutate(payload, {
|
|
29124
|
+
onSuccess: () => autoFundingConfiguration.refetch()
|
|
29125
|
+
});
|
|
29126
|
+
}));
|
|
29127
|
+
const handleToggle = isEnabled => {
|
|
29128
|
+
form.reset(values => Object.assign(Object.assign({}, values), {
|
|
29129
|
+
isEnabled
|
|
29130
|
+
}));
|
|
29131
|
+
if (autoFundingConfiguration.data) {
|
|
29132
|
+
updateAutoFunding.mutate(Object.assign(Object.assign({}, autoFundingConfiguration.data), {
|
|
29133
|
+
isEnabled
|
|
29134
|
+
}), {
|
|
29135
|
+
onSuccess: x => autoFundingConfiguration.refetch()
|
|
29136
|
+
});
|
|
29137
|
+
} else {
|
|
29138
|
+
// TODO - [LMNT-663] Should this throw?
|
|
29139
|
+
logger.error("Toggling auto-funding failed because autoFundingData is undefined.");
|
|
29140
|
+
}
|
|
29141
|
+
};
|
|
29142
|
+
if (autoFundingConfiguration.isLoading) return jsx(Loader, {
|
|
29143
|
+
message: t("manage-funding:autoFunding.isLoading")
|
|
29144
|
+
});
|
|
29145
|
+
return jsxs(Fragment, {
|
|
29146
|
+
children: [jsx(Switch, {
|
|
29147
|
+
defaultChecked: false,
|
|
29148
|
+
// defaultChecked={autoFundingConfiguration.data?.isEnabled}
|
|
29149
|
+
label: t("manage-funding:autoFunding.addFundsAutomatically"),
|
|
29150
|
+
name: "isEnabled",
|
|
29151
|
+
onChange: e => handleToggle(e.target.checked),
|
|
29152
|
+
value: true
|
|
29153
|
+
}), watchIsEnabled && jsxs("form", Object.assign({
|
|
29154
|
+
css: styles.form,
|
|
29155
|
+
id: "auto-funding-form",
|
|
29156
|
+
onSubmit: handleSubmit
|
|
29157
|
+
}, {
|
|
29158
|
+
children: [jsx(MoneyInput, {
|
|
29159
|
+
control: form.control,
|
|
29160
|
+
disabled: !watchIsEnabled,
|
|
29161
|
+
label: t("manage-funding:autoFunding.purchaseAmount"),
|
|
29162
|
+
name: "purchaseAmount",
|
|
29163
|
+
showCurrencySymbol: true
|
|
29164
|
+
}), jsx(MoneyInput, {
|
|
29165
|
+
control: form.control,
|
|
29166
|
+
disabled: !watchIsEnabled,
|
|
29167
|
+
label: t("manage-funding:autoFunding.lowBalancePurchaseThreshold"),
|
|
29168
|
+
name: "lowBalancePurchaseThreshold",
|
|
29169
|
+
showCurrencySymbol: true
|
|
29170
|
+
}), jsx(NumberInput, {
|
|
29171
|
+
control: form.control,
|
|
29172
|
+
disabled: !watchIsEnabled,
|
|
29173
|
+
isInteger: true,
|
|
29174
|
+
label: t("manage-funding:autoFunding.maximumPurchasesPerDay"),
|
|
29175
|
+
name: "maximumPurchasesPerDay"
|
|
29176
|
+
}), jsxs(ButtonGroup, Object.assign({
|
|
29177
|
+
justify: "end"
|
|
29178
|
+
}, {
|
|
29179
|
+
children: [jsx(Button, Object.assign({
|
|
29180
|
+
disabled: !isDirty,
|
|
29181
|
+
onClick: () => form.reset(),
|
|
29182
|
+
variant: ButtonVariant.TEXT
|
|
29183
|
+
}, {
|
|
29184
|
+
children: t("actions.cancel")
|
|
29185
|
+
})), jsx(SubmitButton, Object.assign({
|
|
29186
|
+
control: form.control,
|
|
29187
|
+
"data-testid": "submit-auto-funding",
|
|
29188
|
+
disabled: !watchIsEnabled,
|
|
29189
|
+
requireDirty: true,
|
|
29190
|
+
variant: ButtonVariant.OUTLINED
|
|
29191
|
+
}, {
|
|
29192
|
+
children: t("manage-funding:actions.saveRule")
|
|
29193
|
+
}))]
|
|
29194
|
+
}))]
|
|
29195
|
+
})), autoFundingConfiguration.error && jsxs(Fragment, {
|
|
29196
|
+
children: [jsx(Spacer, {
|
|
29197
|
+
multiplier: 1
|
|
29198
|
+
}), jsx(InlineNotification, Object.assign({
|
|
29199
|
+
title: t("manage-funding:autoFunding.error.title"),
|
|
29200
|
+
type: NotificationType.ERROR
|
|
29201
|
+
}, {
|
|
29202
|
+
children: autoFundingConfiguration.error[0].message
|
|
29203
|
+
}))]
|
|
29204
|
+
})]
|
|
29205
|
+
});
|
|
29206
|
+
};
|
|
29207
|
+
|
|
28983
29208
|
/**
|
|
28984
29209
|
* Captures errors thrown within an Element, logs them and displays a fallback component
|
|
28985
29210
|
*
|
|
@@ -29043,49 +29268,82 @@ class ErrorBoundary extends React.Component {
|
|
|
29043
29268
|
}
|
|
29044
29269
|
}
|
|
29045
29270
|
|
|
29271
|
+
const ManageFunding = ({
|
|
29272
|
+
carrierId
|
|
29273
|
+
}) => {
|
|
29274
|
+
const {
|
|
29275
|
+
t
|
|
29276
|
+
} = useTranslation();
|
|
29277
|
+
const {
|
|
29278
|
+
isLoading: isLoadingCarrier
|
|
29279
|
+
} = useGetCarrierById(carrierId);
|
|
29280
|
+
const [isAddFundsFormOpen, setIsAddFundsFormOpen] = useState(false);
|
|
29281
|
+
if (isLoadingCarrier) return jsx(Loader, {
|
|
29282
|
+
message: t("loading.carrier")
|
|
29283
|
+
});
|
|
29284
|
+
return jsxs("section", {
|
|
29285
|
+
children: [jsxs(Spread, {
|
|
29286
|
+
children: [jsx(CarrierBalance, {
|
|
29287
|
+
carrierId: carrierId
|
|
29288
|
+
}), jsx(LinkAction, {
|
|
29289
|
+
icon: "add",
|
|
29290
|
+
isDisabled: isAddFundsFormOpen,
|
|
29291
|
+
onClick: () => setIsAddFundsFormOpen(true),
|
|
29292
|
+
title: t("manage-funding:actions.addFunds")
|
|
29293
|
+
})]
|
|
29294
|
+
}), isAddFundsFormOpen && jsxs(Fragment, {
|
|
29295
|
+
children: [jsx(Spacer, {
|
|
29296
|
+
multiplier: 2
|
|
29297
|
+
}), jsx(AddFundsForm, {
|
|
29298
|
+
carrierId: carrierId,
|
|
29299
|
+
onCancel: () => setIsAddFundsFormOpen(false)
|
|
29300
|
+
})]
|
|
29301
|
+
}), jsx(Spacer, {
|
|
29302
|
+
multiplier: 2
|
|
29303
|
+
})]
|
|
29304
|
+
});
|
|
29305
|
+
};
|
|
29306
|
+
|
|
29046
29307
|
/**
|
|
29047
|
-
*
|
|
29308
|
+
* For relevant notes about Storybook stories
|
|
29048
29309
|
*
|
|
29049
|
-
*
|
|
29050
|
-
* interface is then mounted back at the point of use.
|
|
29310
|
+
* Stopgap until we setup https://storybook.js.org/addons/@storybook/addon-docs
|
|
29051
29311
|
*/
|
|
29052
|
-
const
|
|
29053
|
-
css,
|
|
29312
|
+
const StoryNotes = ({
|
|
29054
29313
|
children,
|
|
29055
|
-
|
|
29056
|
-
|
|
29057
|
-
|
|
29058
|
-
|
|
29059
|
-
|
|
29060
|
-
|
|
29061
|
-
|
|
29062
|
-
|
|
29063
|
-
|
|
29064
|
-
|
|
29065
|
-
|
|
29066
|
-
|
|
29067
|
-
})), css];
|
|
29068
|
-
return jsxs(Fragment, {
|
|
29069
|
-
children: [jsx(Portal, Object.assign({
|
|
29070
|
-
target: rootTarget
|
|
29314
|
+
notes
|
|
29315
|
+
}) => jsxs(Fragment, {
|
|
29316
|
+
children: [jsxs("div", Object.assign({
|
|
29317
|
+
css: () => ({
|
|
29318
|
+
backgroundColor: "lightsteelblue",
|
|
29319
|
+
marginBottom: "16px",
|
|
29320
|
+
padding: "16px",
|
|
29321
|
+
paddingLeft: "32px"
|
|
29322
|
+
})
|
|
29323
|
+
}, {
|
|
29324
|
+
children: [jsx(Typography, Object.assign({
|
|
29325
|
+
variant: "heading5"
|
|
29071
29326
|
}, {
|
|
29072
|
-
children:
|
|
29073
|
-
|
|
29074
|
-
|
|
29075
|
-
|
|
29076
|
-
|
|
29077
|
-
|
|
29078
|
-
|
|
29079
|
-
|
|
29080
|
-
|
|
29081
|
-
|
|
29082
|
-
|
|
29083
|
-
|
|
29084
|
-
|
|
29085
|
-
|
|
29086
|
-
|
|
29087
|
-
|
|
29088
|
-
|
|
29327
|
+
children: "Story notes:"
|
|
29328
|
+
})), jsx("ul", Object.assign({
|
|
29329
|
+
css: theme => ({
|
|
29330
|
+
"> li": {
|
|
29331
|
+
marginTop: theme.spacing(1)
|
|
29332
|
+
}
|
|
29333
|
+
})
|
|
29334
|
+
}, {
|
|
29335
|
+
children: notes.map(n => jsx("li", {
|
|
29336
|
+
children: n
|
|
29337
|
+
}, n))
|
|
29338
|
+
}))]
|
|
29339
|
+
})), jsx("hr", {
|
|
29340
|
+
css: () => ({
|
|
29341
|
+
backgroundColor: "transparent",
|
|
29342
|
+
borderTop: "1px dotted lightgrey",
|
|
29343
|
+
marginBottom: "16px"
|
|
29344
|
+
})
|
|
29345
|
+
}), children]
|
|
29346
|
+
});
|
|
29089
29347
|
|
|
29090
29348
|
var $$2 = _export;
|
|
29091
29349
|
var uncurryThis = functionUncurryThisClause;
|
|
@@ -30092,6 +30350,7 @@ var common = {
|
|
|
30092
30350
|
invalidNameOrCompany: "Recipient name and company name (if provided) must have two characters in first and last name.",
|
|
30093
30351
|
noWarehouses: "You must have an active warehouse in order to use this feature",
|
|
30094
30352
|
unableToLoad: {
|
|
30353
|
+
carrier: "Unable to load carrier",
|
|
30095
30354
|
carriers: "Unable to load carriers",
|
|
30096
30355
|
salesOrder: "Unable to load order",
|
|
30097
30356
|
shipment: "Unable to load shipment",
|
|
@@ -30118,6 +30377,7 @@ var common = {
|
|
|
30118
30377
|
thirdParty: "Third Party"
|
|
30119
30378
|
},
|
|
30120
30379
|
loading: {
|
|
30380
|
+
carrier: "Loading carrier...",
|
|
30121
30381
|
carriers: "Loading carriers...",
|
|
30122
30382
|
data: "Loading...",
|
|
30123
30383
|
importingSalesOrder: "Importing order...",
|
|
@@ -30214,11 +30474,11 @@ var listCarriers = {
|
|
|
30214
30474
|
var manageFunding = {
|
|
30215
30475
|
"manage-funding": {
|
|
30216
30476
|
actions: {
|
|
30477
|
+
addFunds: "Add Funds",
|
|
30478
|
+
addFundsAndPurchase: "Add Funds & Purchase",
|
|
30217
30479
|
addNow: "Add Now",
|
|
30218
|
-
saveRule: "Save Rule"
|
|
30219
|
-
other: "Other..."
|
|
30480
|
+
saveRule: "Save Rule"
|
|
30220
30481
|
},
|
|
30221
|
-
addFunds: "Add Funds",
|
|
30222
30482
|
autoFunding: {
|
|
30223
30483
|
addFundsAutomatically: "Add Funds Automatically",
|
|
30224
30484
|
error: {
|
|
@@ -30231,20 +30491,31 @@ var manageFunding = {
|
|
|
30231
30491
|
maximumPurchasesPerDay: "Maximum Purchases Per Day",
|
|
30232
30492
|
purchaseAmount: "Purchase Amount"
|
|
30233
30493
|
},
|
|
30234
|
-
|
|
30235
|
-
|
|
30494
|
+
addFunds: {
|
|
30495
|
+
custom: "Custom...",
|
|
30236
30496
|
error: {
|
|
30237
30497
|
title: "Manual-Funding Error",
|
|
30238
30498
|
message: "An error occurred while trying add funds to your ShipEngine wallet."
|
|
30239
30499
|
},
|
|
30240
30500
|
isLoading: "Adding funds to your ShipEngine wallet...",
|
|
30241
30501
|
labels: {
|
|
30242
|
-
amount: "Amount"
|
|
30243
|
-
currentBalance: "Current Balance",
|
|
30244
|
-
resultingBalance: "Resulting Balance"
|
|
30502
|
+
amount: "Amount"
|
|
30245
30503
|
},
|
|
30246
30504
|
minimumPurchaseAmount: "Minimum Purchase $10.00"
|
|
30247
30505
|
},
|
|
30506
|
+
fundAndPurchase: {
|
|
30507
|
+
finalBalance: "Final balance after payment:",
|
|
30508
|
+
insufficientFunds: "Add funds below to purchase label.",
|
|
30509
|
+
insufficientFundsTitle: "Not enough money in your account",
|
|
30510
|
+
negativeBalance: "You will be charged this amount in addition to the label cost.",
|
|
30511
|
+
negativeBalanceTitle: "Negative balance (due to adjustments)",
|
|
30512
|
+
newBalance: "New balance after adding funds:"
|
|
30513
|
+
},
|
|
30514
|
+
errors: {
|
|
30515
|
+
balanceUnknown: "Unknown",
|
|
30516
|
+
unableToFindBalance: "There was a problem retrieving your balance. Please try again later."
|
|
30517
|
+
},
|
|
30518
|
+
currentBalance: "Current balance:",
|
|
30248
30519
|
maximumBalanceAmount: "Balance may not exceed $10,000.00"
|
|
30249
30520
|
}
|
|
30250
30521
|
};
|
|
@@ -30753,16 +31024,84 @@ const ListCarriers = () => {
|
|
|
30753
31024
|
}
|
|
30754
31025
|
yield refetchCarriers();
|
|
30755
31026
|
});
|
|
30756
|
-
// TODO: How to pass two sets of errors and isLoading, possible example is to join errors like in RateForm and ShipmentForm.
|
|
30757
|
-
return jsx(ListCarriers$1, {
|
|
30758
|
-
carriers: carriersConnectedStatus,
|
|
30759
|
-
isLoading: isLoading,
|
|
30760
|
-
onRegisterCarrier: handleRegistration,
|
|
30761
|
-
registerCarrierErrors: registerCarrierErrors
|
|
31027
|
+
// TODO: How to pass two sets of errors and isLoading, possible example is to join errors like in RateForm and ShipmentForm.
|
|
31028
|
+
return jsx(ListCarriers$1, {
|
|
31029
|
+
carriers: carriersConnectedStatus,
|
|
31030
|
+
isLoading: isLoading,
|
|
31031
|
+
onRegisterCarrier: handleRegistration,
|
|
31032
|
+
registerCarrierErrors: registerCarrierErrors
|
|
31033
|
+
});
|
|
31034
|
+
};
|
|
31035
|
+
|
|
31036
|
+
const Element$5 = registerElement("list-carriers", ListCarriers);
|
|
31037
|
+
|
|
31038
|
+
const ManageWarehouses = () => {
|
|
31039
|
+
const {
|
|
31040
|
+
t
|
|
31041
|
+
} = useTranslation();
|
|
31042
|
+
const {
|
|
31043
|
+
data: warehouses,
|
|
31044
|
+
error: listWarehouseErrors,
|
|
31045
|
+
isLoading: isLoadingWarehouses,
|
|
31046
|
+
refetch: refreshListWarehouses
|
|
31047
|
+
} = useListWarehouses();
|
|
31048
|
+
const {
|
|
31049
|
+
error: updateWarehouseErrors,
|
|
31050
|
+
mutateAsync: updateWarehouse
|
|
31051
|
+
} = useUpdateWarehouse();
|
|
31052
|
+
const {
|
|
31053
|
+
error: createWarehouseErrors,
|
|
31054
|
+
mutateAsync: createWarehouse
|
|
31055
|
+
} = useCreateWarehouse();
|
|
31056
|
+
const {
|
|
31057
|
+
error: deleteWarehouseErrors,
|
|
31058
|
+
mutateAsync: deleteWarehouse
|
|
31059
|
+
} = useDeleteWarehouse();
|
|
31060
|
+
const handleDeleteWarehouse = warehouseId => __awaiter(void 0, void 0, void 0, function* () {
|
|
31061
|
+
yield deleteWarehouse({
|
|
31062
|
+
warehouseId
|
|
31063
|
+
});
|
|
31064
|
+
void refreshListWarehouses();
|
|
31065
|
+
});
|
|
31066
|
+
const handleSubmitAddNewWarehouse = payload => __awaiter(void 0, void 0, void 0, function* () {
|
|
31067
|
+
const result = yield createWarehouse(payload);
|
|
31068
|
+
if (result) void refreshListWarehouses();
|
|
31069
|
+
});
|
|
31070
|
+
const handleSubmitEditWarehouse = (payload, warehouseId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31071
|
+
yield updateWarehouse({
|
|
31072
|
+
name: payload.name,
|
|
31073
|
+
originAddress: payload.originAddress,
|
|
31074
|
+
returnAddress: payload.returnAddress,
|
|
31075
|
+
warehouseId: warehouseId
|
|
31076
|
+
});
|
|
31077
|
+
void refreshListWarehouses();
|
|
31078
|
+
});
|
|
31079
|
+
const handleSetDefault = (payload, warehouseId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31080
|
+
yield updateWarehouse(Object.assign(Object.assign({}, payload), {
|
|
31081
|
+
isDefault: true,
|
|
31082
|
+
warehouseId
|
|
31083
|
+
}));
|
|
31084
|
+
void refreshListWarehouses();
|
|
31085
|
+
});
|
|
31086
|
+
if (isLoadingWarehouses) return jsx(Loader, {
|
|
31087
|
+
message: t("loading.warehouses")
|
|
31088
|
+
});
|
|
31089
|
+
if (!warehouses) {
|
|
31090
|
+
if (listWarehouseErrors) throw new Error(listWarehouseErrors.map(e => e.message).join(", "));
|
|
31091
|
+
throw new Error("errorMessages.unableToLoad.warehouses");
|
|
31092
|
+
}
|
|
31093
|
+
const errors = [...(updateWarehouseErrors !== null && updateWarehouseErrors !== void 0 ? updateWarehouseErrors : []), ...(createWarehouseErrors !== null && createWarehouseErrors !== void 0 ? createWarehouseErrors : []), ...(deleteWarehouseErrors !== null && deleteWarehouseErrors !== void 0 ? deleteWarehouseErrors : [])];
|
|
31094
|
+
return jsx(ManageWarehouses$1, {
|
|
31095
|
+
errors: errors,
|
|
31096
|
+
onAdd: handleSubmitAddNewWarehouse,
|
|
31097
|
+
onDelete: handleDeleteWarehouse,
|
|
31098
|
+
onEdit: handleSubmitEditWarehouse,
|
|
31099
|
+
onSetDefault: handleSetDefault,
|
|
31100
|
+
warehouses: warehouses
|
|
30762
31101
|
});
|
|
30763
31102
|
};
|
|
30764
31103
|
|
|
30765
|
-
const Element$
|
|
31104
|
+
const Element$4 = registerElement("manage-warehouses", ManageWarehouses);
|
|
30766
31105
|
|
|
30767
31106
|
const useAddress = ({
|
|
30768
31107
|
compatibleCountryCodes,
|
|
@@ -31368,196 +31707,6 @@ const ConfigureShipment = _a => {
|
|
|
31368
31707
|
});
|
|
31369
31708
|
};
|
|
31370
31709
|
|
|
31371
|
-
const ManageFunding = ({
|
|
31372
|
-
carrierId,
|
|
31373
|
-
fundingMethod,
|
|
31374
|
-
requiredAmount
|
|
31375
|
-
}) => {
|
|
31376
|
-
// const { data: carriersData, loading, error } = useListCarriers();
|
|
31377
|
-
var _a, _b;
|
|
31378
|
-
const {
|
|
31379
|
-
data: addFundsData,
|
|
31380
|
-
error: addFundsErrors,
|
|
31381
|
-
mutateAsync: addFunds,
|
|
31382
|
-
isLoading: isAddFundsLoading,
|
|
31383
|
-
reset: addFundsRefresh
|
|
31384
|
-
} = useAddFunds();
|
|
31385
|
-
const {
|
|
31386
|
-
data: autoFundingData,
|
|
31387
|
-
error: autoFundingErrors,
|
|
31388
|
-
isLoading: isAutoFundingLoading,
|
|
31389
|
-
refetch: refreshAutoFundingConfiguration
|
|
31390
|
-
} = useGetAutoFundingConfiguration();
|
|
31391
|
-
const {
|
|
31392
|
-
mutateAsync: configureAutoFunding
|
|
31393
|
-
} = useUpdateAutoFunding();
|
|
31394
|
-
const handleSubmitManualFunding = payload => __awaiter(void 0, void 0, void 0, function* () {
|
|
31395
|
-
const result = yield addFunds({
|
|
31396
|
-
amount: payload.funds,
|
|
31397
|
-
carrierId
|
|
31398
|
-
});
|
|
31399
|
-
if (result) void addFundsRefresh();
|
|
31400
|
-
});
|
|
31401
|
-
const handleSubmitAutoFunding = payload => __awaiter(void 0, void 0, void 0, function* () {
|
|
31402
|
-
const result = yield configureAutoFunding(Object.assign({
|
|
31403
|
-
carrierId
|
|
31404
|
-
}, payload));
|
|
31405
|
-
if (result) void refreshAutoFundingConfiguration();
|
|
31406
|
-
});
|
|
31407
|
-
const handleToggleAutoFunding = isEnabled => __awaiter(void 0, void 0, void 0, function* () {
|
|
31408
|
-
if (autoFundingData) {
|
|
31409
|
-
const result = yield configureAutoFunding(Object.assign(Object.assign({}, autoFundingData), {
|
|
31410
|
-
carrierId,
|
|
31411
|
-
isEnabled
|
|
31412
|
-
}));
|
|
31413
|
-
if (result) void refreshAutoFundingConfiguration();
|
|
31414
|
-
} else {
|
|
31415
|
-
console.error("Toggling auto-funding failed because autoFundingData is undefined.");
|
|
31416
|
-
}
|
|
31417
|
-
});
|
|
31418
|
-
return jsx(FundingMethods, {
|
|
31419
|
-
autoFundingData: autoFundingData,
|
|
31420
|
-
autoFundingErrorMessage: autoFundingErrors ? (_a = autoFundingErrors[0]) === null || _a === void 0 ? void 0 : _a.message : undefined,
|
|
31421
|
-
fundingMethod: fundingMethod !== null && fundingMethod !== void 0 ? fundingMethod : "both",
|
|
31422
|
-
hasAutoFundingError: !!(autoFundingErrors === null || autoFundingErrors === void 0 ? void 0 : autoFundingErrors.length),
|
|
31423
|
-
hasManualFundingError: !!(addFundsErrors === null || addFundsErrors === void 0 ? void 0 : addFundsErrors.length),
|
|
31424
|
-
isAutoFundingLoading: isAutoFundingLoading,
|
|
31425
|
-
isManualFundingLoading: isAddFundsLoading,
|
|
31426
|
-
manualFundingCurrentBalance: (_b = addFundsData === null || addFundsData === void 0 ? void 0 : addFundsData.balance.amount) !== null && _b !== void 0 ? _b : 0,
|
|
31427
|
-
manualFundingRequiredAmount: requiredAmount,
|
|
31428
|
-
onSubmitAutoFunding: handleSubmitAutoFunding,
|
|
31429
|
-
onSubmitManualFunding: handleSubmitManualFunding,
|
|
31430
|
-
onToggleAutoFunding: handleToggleAutoFunding
|
|
31431
|
-
});
|
|
31432
|
-
};
|
|
31433
|
-
|
|
31434
|
-
const ManageWarehouses = () => {
|
|
31435
|
-
const {
|
|
31436
|
-
t
|
|
31437
|
-
} = useTranslation();
|
|
31438
|
-
const {
|
|
31439
|
-
data: warehouses,
|
|
31440
|
-
error: listWarehouseErrors,
|
|
31441
|
-
isLoading: isLoadingWarehouses,
|
|
31442
|
-
refetch: refreshListWarehouses
|
|
31443
|
-
} = useListWarehouses();
|
|
31444
|
-
const {
|
|
31445
|
-
error: updateWarehouseErrors,
|
|
31446
|
-
mutateAsync: updateWarehouse
|
|
31447
|
-
} = useUpdateWarehouse();
|
|
31448
|
-
const {
|
|
31449
|
-
error: createWarehouseErrors,
|
|
31450
|
-
mutateAsync: createWarehouse
|
|
31451
|
-
} = useCreateWarehouse();
|
|
31452
|
-
const {
|
|
31453
|
-
error: deleteWarehouseErrors,
|
|
31454
|
-
mutateAsync: deleteWarehouse
|
|
31455
|
-
} = useDeleteWarehouse();
|
|
31456
|
-
const handleDeleteWarehouse = warehouseId => __awaiter(void 0, void 0, void 0, function* () {
|
|
31457
|
-
yield deleteWarehouse({
|
|
31458
|
-
warehouseId
|
|
31459
|
-
});
|
|
31460
|
-
void refreshListWarehouses();
|
|
31461
|
-
});
|
|
31462
|
-
const handleSubmitAddNewWarehouse = payload => __awaiter(void 0, void 0, void 0, function* () {
|
|
31463
|
-
const result = yield createWarehouse(payload);
|
|
31464
|
-
if (result) void refreshListWarehouses();
|
|
31465
|
-
});
|
|
31466
|
-
const handleSubmitEditWarehouse = (payload, warehouseId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31467
|
-
yield updateWarehouse({
|
|
31468
|
-
name: payload.name,
|
|
31469
|
-
originAddress: payload.originAddress,
|
|
31470
|
-
returnAddress: payload.returnAddress,
|
|
31471
|
-
warehouseId: warehouseId
|
|
31472
|
-
});
|
|
31473
|
-
void refreshListWarehouses();
|
|
31474
|
-
});
|
|
31475
|
-
const handleSetDefault = (payload, warehouseId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31476
|
-
yield updateWarehouse(Object.assign(Object.assign({}, payload), {
|
|
31477
|
-
isDefault: true,
|
|
31478
|
-
warehouseId
|
|
31479
|
-
}));
|
|
31480
|
-
void refreshListWarehouses();
|
|
31481
|
-
});
|
|
31482
|
-
if (isLoadingWarehouses) return jsx(Loader, {
|
|
31483
|
-
message: t("loading.warehouses")
|
|
31484
|
-
});
|
|
31485
|
-
if (!warehouses) {
|
|
31486
|
-
if (listWarehouseErrors) throw new Error(listWarehouseErrors.map(e => e.message).join(", "));
|
|
31487
|
-
throw new Error("errorMessages.unableToLoad.warehouses");
|
|
31488
|
-
}
|
|
31489
|
-
const errors = [...(updateWarehouseErrors !== null && updateWarehouseErrors !== void 0 ? updateWarehouseErrors : []), ...(createWarehouseErrors !== null && createWarehouseErrors !== void 0 ? createWarehouseErrors : []), ...(deleteWarehouseErrors !== null && deleteWarehouseErrors !== void 0 ? deleteWarehouseErrors : [])];
|
|
31490
|
-
return jsx(ManageWarehouses$1, {
|
|
31491
|
-
errors: errors,
|
|
31492
|
-
onAdd: handleSubmitAddNewWarehouse,
|
|
31493
|
-
onDelete: handleDeleteWarehouse,
|
|
31494
|
-
onEdit: handleSubmitEditWarehouse,
|
|
31495
|
-
onSetDefault: handleSetDefault,
|
|
31496
|
-
warehouses: warehouses
|
|
31497
|
-
});
|
|
31498
|
-
};
|
|
31499
|
-
|
|
31500
|
-
const Onboarding = ({
|
|
31501
|
-
onCompleteOnboarding
|
|
31502
|
-
}) => {
|
|
31503
|
-
const {
|
|
31504
|
-
t
|
|
31505
|
-
} = useTranslation(["common", "register-wallet"]);
|
|
31506
|
-
const {
|
|
31507
|
-
data: warehouses,
|
|
31508
|
-
refetch: refetchWarehouses
|
|
31509
|
-
} = useListWarehouses();
|
|
31510
|
-
const {
|
|
31511
|
-
mutateAsync: createWarehouse
|
|
31512
|
-
} = useCreateWarehouse();
|
|
31513
|
-
const {
|
|
31514
|
-
data: carriers,
|
|
31515
|
-
refetch: refetchCarriers
|
|
31516
|
-
} = useListCarriers();
|
|
31517
|
-
const {
|
|
31518
|
-
error: registerStampsCarrierErrors,
|
|
31519
|
-
mutateAsync: registerStampsCarrier
|
|
31520
|
-
} = useConnectCarrier();
|
|
31521
|
-
const {
|
|
31522
|
-
error: registerUpsCarrierErrors,
|
|
31523
|
-
mutateAsync: registerUpsCarrier,
|
|
31524
|
-
isLoading: isLoadingUps
|
|
31525
|
-
} = useConnectCarrier();
|
|
31526
|
-
const {
|
|
31527
|
-
error: registerDhlCarrierErrors,
|
|
31528
|
-
mutateAsync: registerDhlCarrier,
|
|
31529
|
-
isLoading: isLoadingDhl
|
|
31530
|
-
} = useConnectCarrier();
|
|
31531
|
-
const onWarehouseCreated = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
31532
|
-
yield refetchWarehouses();
|
|
31533
|
-
}), [refetchWarehouses]);
|
|
31534
|
-
const onCarrierCreated = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
31535
|
-
yield refetchCarriers();
|
|
31536
|
-
}), [refetchCarriers]);
|
|
31537
|
-
if (!carriers) return jsx(Loader, {
|
|
31538
|
-
message: t("loading.carriers")
|
|
31539
|
-
});
|
|
31540
|
-
if (!warehouses) return jsx(Loader, {
|
|
31541
|
-
message: t("loading.warehouses")
|
|
31542
|
-
});
|
|
31543
|
-
return jsx(Onboarding$1, {
|
|
31544
|
-
carriers: carriers,
|
|
31545
|
-
createWarehouse: createWarehouse,
|
|
31546
|
-
isLoadingDhl: isLoadingDhl,
|
|
31547
|
-
isLoadingUps: isLoadingUps,
|
|
31548
|
-
onCarrierCreated: onCarrierCreated,
|
|
31549
|
-
onCompleteOnboarding: onCompleteOnboarding,
|
|
31550
|
-
onWarehouseCreated: onWarehouseCreated,
|
|
31551
|
-
registerDhlCarrier: registerDhlCarrier,
|
|
31552
|
-
registerDhlCarrierErrors: registerDhlCarrierErrors,
|
|
31553
|
-
registerStampsCarrier: registerStampsCarrier,
|
|
31554
|
-
registerStampsCarrierErrors: registerStampsCarrierErrors,
|
|
31555
|
-
registerUpsCarrier: registerUpsCarrier,
|
|
31556
|
-
registerUpsCarrierErrors: registerUpsCarrierErrors,
|
|
31557
|
-
warehouses: warehouses
|
|
31558
|
-
});
|
|
31559
|
-
};
|
|
31560
|
-
|
|
31561
31710
|
const usePendingShipment = ({
|
|
31562
31711
|
onLoad,
|
|
31563
31712
|
salesOrder,
|
|
@@ -31750,6 +31899,69 @@ const SalesOrder = _a => {
|
|
|
31750
31899
|
}));
|
|
31751
31900
|
};
|
|
31752
31901
|
|
|
31902
|
+
const Element$3 = registerElement("purchase-label", SalesOrder);
|
|
31903
|
+
|
|
31904
|
+
const Onboarding = ({
|
|
31905
|
+
onCompleteOnboarding
|
|
31906
|
+
}) => {
|
|
31907
|
+
const {
|
|
31908
|
+
t
|
|
31909
|
+
} = useTranslation(["common", "register-wallet"]);
|
|
31910
|
+
const {
|
|
31911
|
+
data: warehouses,
|
|
31912
|
+
refetch: refetchWarehouses
|
|
31913
|
+
} = useListWarehouses();
|
|
31914
|
+
const {
|
|
31915
|
+
mutateAsync: createWarehouse
|
|
31916
|
+
} = useCreateWarehouse();
|
|
31917
|
+
const {
|
|
31918
|
+
data: carriers,
|
|
31919
|
+
refetch: refetchCarriers
|
|
31920
|
+
} = useListCarriers();
|
|
31921
|
+
const {
|
|
31922
|
+
error: registerStampsCarrierErrors,
|
|
31923
|
+
mutateAsync: registerStampsCarrier
|
|
31924
|
+
} = useConnectCarrier();
|
|
31925
|
+
const {
|
|
31926
|
+
error: registerUpsCarrierErrors,
|
|
31927
|
+
mutateAsync: registerUpsCarrier,
|
|
31928
|
+
isLoading: isLoadingUps
|
|
31929
|
+
} = useConnectCarrier();
|
|
31930
|
+
const {
|
|
31931
|
+
error: registerDhlCarrierErrors,
|
|
31932
|
+
mutateAsync: registerDhlCarrier,
|
|
31933
|
+
isLoading: isLoadingDhl
|
|
31934
|
+
} = useConnectCarrier();
|
|
31935
|
+
const onWarehouseCreated = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
31936
|
+
yield refetchWarehouses();
|
|
31937
|
+
}), [refetchWarehouses]);
|
|
31938
|
+
const onCarrierCreated = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
31939
|
+
yield refetchCarriers();
|
|
31940
|
+
}), [refetchCarriers]);
|
|
31941
|
+
if (!carriers) return jsx(Loader, {
|
|
31942
|
+
message: t("loading.carriers")
|
|
31943
|
+
});
|
|
31944
|
+
if (!warehouses) return jsx(Loader, {
|
|
31945
|
+
message: t("loading.warehouses")
|
|
31946
|
+
});
|
|
31947
|
+
return jsx(Onboarding$1, {
|
|
31948
|
+
carriers: carriers,
|
|
31949
|
+
createWarehouse: createWarehouse,
|
|
31950
|
+
isLoadingDhl: isLoadingDhl,
|
|
31951
|
+
isLoadingUps: isLoadingUps,
|
|
31952
|
+
onCarrierCreated: onCarrierCreated,
|
|
31953
|
+
onCompleteOnboarding: onCompleteOnboarding,
|
|
31954
|
+
onWarehouseCreated: onWarehouseCreated,
|
|
31955
|
+
registerDhlCarrier: registerDhlCarrier,
|
|
31956
|
+
registerDhlCarrierErrors: registerDhlCarrierErrors,
|
|
31957
|
+
registerStampsCarrier: registerStampsCarrier,
|
|
31958
|
+
registerStampsCarrierErrors: registerStampsCarrierErrors,
|
|
31959
|
+
registerUpsCarrier: registerUpsCarrier,
|
|
31960
|
+
registerUpsCarrierErrors: registerUpsCarrierErrors,
|
|
31961
|
+
warehouses: warehouses
|
|
31962
|
+
});
|
|
31963
|
+
};
|
|
31964
|
+
|
|
31753
31965
|
const Shipment = ({
|
|
31754
31966
|
features,
|
|
31755
31967
|
onClickPrintLabel,
|
|
@@ -31818,12 +32030,6 @@ const VoidLabel = ({
|
|
|
31818
32030
|
});
|
|
31819
32031
|
};
|
|
31820
32032
|
|
|
31821
|
-
const Element$5 = registerElement("manage-funding", ManageFunding);
|
|
31822
|
-
|
|
31823
|
-
const Element$4 = registerElement("manage-warehouses", ManageWarehouses);
|
|
31824
|
-
|
|
31825
|
-
const Element$3 = registerElement("purchase-label", SalesOrder);
|
|
31826
|
-
|
|
31827
32033
|
const Element$2 = registerElement("onboarding", Onboarding);
|
|
31828
32034
|
|
|
31829
32035
|
const Element$1 = registerElement("view-shipment", Shipment);
|
|
@@ -32512,5 +32718,35 @@ const renderWithProviders = component => {
|
|
|
32512
32718
|
})
|
|
32513
32719
|
});
|
|
32514
32720
|
};
|
|
32721
|
+
/**
|
|
32722
|
+
* Wraps the test with all of the usual Shipengine / Giger / i18 / etc providers that a full, registered "Element" would have.
|
|
32723
|
+
* This allows components to simulate usage in an Element via `decorators: [withAllProviders]`
|
|
32724
|
+
**/
|
|
32725
|
+
const renderWithAllProviders = component => {
|
|
32726
|
+
const theme = createTheme(BrandName.FALLBACK);
|
|
32727
|
+
return render(component, {
|
|
32728
|
+
wrapper: ({
|
|
32729
|
+
children
|
|
32730
|
+
}) => jsx(ShipEngineProvider, Object.assign({
|
|
32731
|
+
baseURL: "/api",
|
|
32732
|
+
getToken: () => {
|
|
32733
|
+
var _a;
|
|
32734
|
+
return (_a = process.env.STORYBOOK_TOKEN) !== null && _a !== void 0 ? _a : "none";
|
|
32735
|
+
}
|
|
32736
|
+
}, {
|
|
32737
|
+
children: jsx(RootPortalProvider, {
|
|
32738
|
+
children: jsx(GigerConfigProvider, Object.assign({
|
|
32739
|
+
resolveIcon: name => `<svg>${name}</svg>`
|
|
32740
|
+
}, {
|
|
32741
|
+
children: jsx(ThemeProvider, Object.assign({
|
|
32742
|
+
theme: deserialize(theme)
|
|
32743
|
+
}, {
|
|
32744
|
+
children: children
|
|
32745
|
+
}))
|
|
32746
|
+
}))
|
|
32747
|
+
})
|
|
32748
|
+
}))
|
|
32749
|
+
});
|
|
32750
|
+
};
|
|
32515
32751
|
|
|
32516
|
-
export { Accordion, ButtonGroup, Country, Cube, ElementsContext, ElementsProvider, ErrorBoundary, ErrorFallback, fields as Field, FieldLabel, FormPortal, GigerProvider, ItemsBreakdown, Element$
|
|
32752
|
+
export { Accordion, AddFundsForm, AutoFundingForm, ButtonGroup, CarrierBalance, Country, Cube, ElementsContext, ElementsProvider, ErrorBoundary, ErrorFallback, fields as Field, FieldLabel, FormPortal, FundAndPurchase, GigerProvider, InlineLabel, ItemsBreakdown, LinkAction, Element$5 as ListCarriers, Loader, ManageFunding, Element$4 as ManageWarehouses, Element$2 as Onboarding, PageLayoutProvider, Portal, Element$3 as PurchaseLabel, RootPortalProvider, Spacer, Spread, StoryNotes, index$1 as Templates, UsState, UsaCity, Element$1 as ViewShipment, Element as VoidLabel, addressFactory, addressPreferenceFactory, addressValidationFactory, autoFundingSchema, calculateTotal, capitalizeFirstLetter, carrierFactory, carrierOptionFactory, convertDimensions, convertWeight, countries, countryCodes, createCodedErrors, createDictionary, createStyles, currencySymbol, customsItemFactory, daysAfter, downloadFactory, errorMap, euCountryCodes, extendZod, formLogger, formatCreditCardNumber, formatDate, formatFractionalWeight, formatMoney, fractionalWeightFactory, getAddFundsSchema, getCustomsFromSalesOrder, getExpirationYears, getIsCustomsRequiredForSalesOrder, getIsCustomsRequiredForShipment, getIsInternationalShipment, getPendingShipment, getRateRequiresAcknowledgement, getRequestedServices, getTotalRateAmount, isDomesticAddress, isFlatRatePackageCode, isMilitaryAddress, isNowOrInTheFuture, isPoBox, isPoBoxAddress, isString, isUnitedStatesTerritory, isUspsCarrier, labelFactory, linkedResourceFactory, moneyFactory, moneySchema, mostRecent, nextDayCutoff, omitTime, orderSourceFactory, orderSourceRefreshInfoFactory, packageFactory, phoneSchema, phoneSchemaUnvalidated, postalCodeRegex$3 as postalCodeRegex, randomDeliveryConfirmation, randomFulfillmentStatus, randomInsuranceProvider, randomOrderSourceCode, randomPaymentStatus, randomShipengineId, randomShipengineSlug, randomWeightUnit, registerElement, renderWithAllProviders, renderWithProviders, salesOrderFactory, salesOrderItemFactory, salesOrderShipmentFactory, serviceFactory, shipmentFactory, shipmentItemFactory, shipmentPackageFactory, sortByCreationDate, tristateValue, usCities, usStateCodes, usStates, useCarrierMetadata, useConfirmationOptions, useCountryCodeOptions, useCustomsContentsOptions, useCustomsNonDeliveryOptions, useElements, useExpirationMonthOptions, useInsuranceProviderOptions, useNestedForm, usePackageOptions, usePageLayout, useRateOptions, useRootPortal, useRunOnceOnTrue, useServiceCodeOptions, useShippingPresetsOptions, useStateCodeOptions, useToggle, useWarehouseOptions, validationResolver, warehouseFactory, weightFactory, weightWithUnitFactory };
|