2024-11-18 18:58:54 +01:00
|
|
|
/**
|
|
|
|
* Selectors: Extract specific pieces of state from the store.
|
|
|
|
*
|
|
|
|
* These functions provide a consistent interface for accessing store data.
|
|
|
|
* They allow components to retrieve data without knowing the store structure.
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
*/
|
|
|
|
|
|
|
|
const EMPTY_OBJ = Object.freeze( {} );
|
|
|
|
|
2024-11-20 17:21:09 +01:00
|
|
|
const getState = ( state ) => state || EMPTY_OBJ;
|
2024-11-18 18:58:54 +01:00
|
|
|
|
2024-11-20 17:21:09 +01:00
|
|
|
export const persistentData = ( state ) => {
|
2024-11-18 18:58:54 +01:00
|
|
|
return getState( state ).data || EMPTY_OBJ;
|
|
|
|
};
|
|
|
|
|
2024-11-20 17:21:09 +01:00
|
|
|
export const transientData = ( state ) => {
|
2025-01-08 16:52:21 +01:00
|
|
|
const {
|
|
|
|
data,
|
|
|
|
merchant,
|
|
|
|
features,
|
|
|
|
wooSettings,
|
|
|
|
webhooks,
|
|
|
|
...transientState
|
|
|
|
} = getState( state );
|
2024-11-18 18:58:54 +01:00
|
|
|
return transientState || EMPTY_OBJ;
|
|
|
|
};
|
2024-12-03 15:24:49 -04:00
|
|
|
|
2024-12-05 18:55:56 +01:00
|
|
|
export const getActivityList = ( state ) => {
|
|
|
|
const { activities = new Map() } = state;
|
|
|
|
return Object.fromEntries( activities );
|
|
|
|
};
|
|
|
|
|
2024-12-06 19:11:17 +01:00
|
|
|
export const merchant = ( state ) => {
|
|
|
|
return getState( state ).merchant || EMPTY_OBJ;
|
|
|
|
};
|
|
|
|
|
2025-01-08 16:50:38 +01:00
|
|
|
export const features = ( state ) => {
|
|
|
|
return getState( state ).features || EMPTY_OBJ;
|
|
|
|
};
|
|
|
|
|
2024-12-03 15:24:49 -04:00
|
|
|
export const wooSettings = ( state ) => {
|
|
|
|
return getState( state ).wooSettings || EMPTY_OBJ;
|
|
|
|
};
|
2024-12-18 07:00:47 +01:00
|
|
|
|
|
|
|
export const webhooks = ( state ) => {
|
|
|
|
return getState( state ).webhooks || EMPTY_OBJ;
|
|
|
|
};
|