woocommerce-paypal-payments/modules/ppcp-settings/resources/js/data/onboarding/selectors.js

25 lines
537 B
JavaScript
Raw Normal View History

2024-11-18 16:25:57 +01:00
import { STORE_KEY } from './constants';
const EMPTY_OBJ = Object.freeze( {} );
2024-11-18 16:25:57 +01:00
const getState = ( state ) => {
if ( ! state ) {
return EMPTY_OBJ;
}
2024-11-18 16:25:57 +01:00
return state[ STORE_KEY ] || EMPTY_OBJ;
};
export const getPersistentData = ( state ) => {
2024-11-18 16:25:57 +01:00
return getState( state ).data || EMPTY_OBJ;
};
export const getTransientData = ( state ) => {
2024-11-18 16:25:57 +01:00
const { data, flags, ...transientState } = getState( state );
return transientState || EMPTY_OBJ;
2024-10-22 18:56:37 +02:00
};
export const getFlags = ( state ) => {
2024-11-18 16:25:57 +01:00
return getState( state ).flags || EMPTY_OBJ;
};