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',
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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,
|
|
|
|
};
|