export const enhanceWithLocationCounts = ( action, getState ) => { const siteId = getSelectedSiteId( getState() ); if ( siteId !== null ) { const locations = getGoogleMyBusinessLocations( getState(), siteId ); const verifiedLocationCount = locations.filter( location => get( location, 'meta.state.isVerified', false ) ).length; return merge( action, { meta: { analytics: [ { payload: { properties: { location_count: locations.length, verified_location_count: verifiedLocationCount, }, }, }, ], }, } ); } return action; };
state => { const siteId = getSelectedSiteId( state ); const locations = getGoogleMyBusinessLocations( state, siteId ); return { locations, siteId, siteSlug: getSelectedSiteSlug( state ), }; },