2020-03-10 13:39:21 +00:00
|
|
|
/**
|
|
|
|
* @typedef {import('@woocommerce/type-defs/contexts').ShippingErrorTypes} ShippingErrorTypes
|
|
|
|
* @typedef {import('@woocommerce/type-defs/cart').CartShippingAddress} CartShippingAddress
|
2020-03-26 13:31:09 +00:00
|
|
|
* @typedef {import('@woocommerce/type-defs/contexts').ShippingDataContext} ShippingDataContext
|
2020-03-10 13:39:21 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @type {ShippingErrorTypes}
|
|
|
|
*/
|
|
|
|
export const ERROR_TYPES = {
|
|
|
|
NONE: 'none',
|
|
|
|
INVALID_ADDRESS: 'invalid_address',
|
|
|
|
UNKNOWN: 'unknown_error',
|
|
|
|
};
|
|
|
|
|
2020-05-14 23:55:22 +00:00
|
|
|
export const shippingErrorCodes = {
|
|
|
|
INVALID_COUNTRY: 'woocommerce_rest_cart_shipping_rates_invalid_country',
|
|
|
|
MISSING_COUNTRY: 'woocommerce_rest_cart_shipping_rates_missing_country',
|
|
|
|
INVALID_STATE: 'woocommerce_rest_cart_shipping_rates_invalid_state',
|
|
|
|
};
|
|
|
|
|
2020-03-10 13:39:21 +00:00
|
|
|
/**
|
|
|
|
* @type {CartShippingAddress}
|
|
|
|
*/
|
|
|
|
export const DEFAULT_SHIPPING_ADDRESS = {
|
|
|
|
first_name: '',
|
|
|
|
last_name: '',
|
|
|
|
company: '',
|
|
|
|
address_1: '',
|
|
|
|
address_2: '',
|
|
|
|
city: '',
|
|
|
|
state: '',
|
|
|
|
postcode: '',
|
|
|
|
country: '',
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2020-03-26 13:31:09 +00:00
|
|
|
* @type {ShippingDataContext}
|
2020-03-10 13:39:21 +00:00
|
|
|
*/
|
|
|
|
export const DEFAULT_SHIPPING_CONTEXT_DATA = {
|
2020-04-06 20:36:19 +00:00
|
|
|
shippingErrorStatus: {
|
|
|
|
isPristine: true,
|
|
|
|
isValid: false,
|
|
|
|
hasInvalidAddress: false,
|
|
|
|
hasError: false,
|
|
|
|
},
|
2020-03-10 13:39:21 +00:00
|
|
|
dispatchErrorStatus: () => null,
|
|
|
|
shippingErrorTypes: ERROR_TYPES,
|
|
|
|
shippingRates: [],
|
|
|
|
setShippingRates: () => null,
|
|
|
|
shippingRatesLoading: false,
|
|
|
|
selectedRates: [],
|
|
|
|
setSelectedRates: () => null,
|
|
|
|
shippingAddress: DEFAULT_SHIPPING_ADDRESS,
|
|
|
|
setShippingAddress: () => null,
|
|
|
|
onShippingRateSuccess: () => null,
|
|
|
|
onShippingRateFail: () => null,
|
|
|
|
onShippingRateSelectSuccess: () => null,
|
|
|
|
onShippingRateSelectFail: () => null,
|
|
|
|
needsShipping: false,
|
|
|
|
};
|