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 ) => {
|
2024-12-04 12:18:19 +01:00
|
|
|
const { data, wooSettings, ...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-03 15:24:49 -04:00
|
|
|
export const wooSettings = ( state ) => {
|
|
|
|
return getState( state ).wooSettings || EMPTY_OBJ;
|
|
|
|
};
|