File size: 679 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { property, sortBy } from 'lodash';
import { AUTOMATED_TRANSFER_ELIGIBILITY_UPDATE } from 'calypso/state/action-types';
import { withPersistence } from 'calypso/state/utils';

const initialState = {
	eligibilityHolds: [],
	eligibilityWarnings: [],
	lastUpdate: 0,
};

// the parent reducer will verify the schema
export default withPersistence( ( state = initialState, action ) => {
	switch ( action.type ) {
		case AUTOMATED_TRANSFER_ELIGIBILITY_UPDATE:
			return {
				eligibilityHolds: sortBy( action.eligibilityHolds ),
				eligibilityWarnings: sortBy( action.eligibilityWarnings, property( 'name' ) ),
				lastUpdate: action.lastUpdate,
			};
	}

	return state;
} );