51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
|
/**
|
||
|
* @typedef {import('@woocommerce/type-defs/contexts').ShippingErrorTypes} ShippingErrorTypes
|
||
|
* @typedef {import('@woocommerce/type-defs/cart').CartShippingAddress} CartShippingAddress
|
||
|
* @typedef {import('@woocommerce/type-defs/contexts').ShippingMethodDataContext} ShippingMethodDataContext
|
||
|
*/
|
||
|
|
||
|
/**
|
||
|
* @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: '',
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* @type {ShippingMethodDataContext}
|
||
|
*/
|
||
|
export const DEFAULT_SHIPPING_CONTEXT_DATA = {
|
||
|
shippingErrorStatus: ERROR_TYPES.NONE,
|
||
|
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,
|
||
|
};
|