File size: 566 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { combineReducers } from '@wordpress/data';
import type { Action } from './actions';
import type { CurrentUser } from './types';
import type { Reducer } from 'redux';

export const currentUser: Reducer< CurrentUser | null | undefined, Action > = ( state, action ) => {
	switch ( action.type ) {
		case 'RECEIVE_CURRENT_USER':
			return action.currentUser;
		case 'RECEIVE_CURRENT_USER_FAILED':
			return null;
	}
	return state;
};

const reducer = combineReducers( { currentUser } );
export type State = ReturnType< typeof reducer >;

export default reducer;