Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 3x 3x 3x 3x 51x 153x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 51x 44x 51x | import { CheckoutSelectors, CustomError } from '@bigcommerce/checkout-sdk'; import { createSelector } from 'reselect'; import { EMPTY_ARRAY } from '../common/utility'; import getCheckoutStepStatuses from './getCheckoutStepStatuses'; import { WithCheckoutProps } from './Checkout'; import { CheckoutContextProps } from './CheckoutContext'; export default function mapToCheckoutProps( { checkoutService, checkoutState }: CheckoutContextProps ): WithCheckoutProps { const { data, errors, statuses } = checkoutState; const { promotions = EMPTY_ARRAY } = data.getCheckout() || {}; const submitOrderError = errors.getSubmitOrderError() as CustomError; const { checkoutSettings: { guestCheckoutEnabled: isGuestEnabled = false, features = {}, } = {}, links: { loginLink: loginUrl = '', createAccountLink: createAccountUrl = '', } = {}, } = data.getConfig() || {}; const subscribeToConsignmentsSelector = createSelector( ({ checkoutService: { subscribe} }: CheckoutContextProps) => subscribe, subscribe => (subscriber: (state: CheckoutSelectors) => void) => { return subscribe(subscriber, ({ data: { getConsignments } }) => getConsignments()); } ); return { billingAddress: data.getBillingAddress(), cart: data.getCart(), clearError: checkoutService.clearError, consignments: data.getConsignments(), hasCartChanged: submitOrderError && submitOrderError.type === 'cart_changed', // TODO: Need to clear the error once it's displayed isGuestEnabled, isLoadingCheckout: statuses.isLoadingCheckout(), isPending: statuses.isPending(), loadCheckout: checkoutService.loadCheckout, loginUrl, createAccountUrl, canCreateAccountInCheckout: features['CHECKOUT-4941.account_creation_in_checkout'], promotions, subscribeToConsignments: subscribeToConsignmentsSelector({ checkoutService, checkoutState }), steps: data.getCheckout() ? getCheckoutStepStatuses(checkoutState) : EMPTY_ARRAY, }; } |