2018-09-25 09:23:43 -05:00
|
|
|
|
import { ApiKeysState } from 'app/types';
|
|
|
|
|
import { Action, ActionTypes } from './actions';
|
|
|
|
|
|
2018-09-26 06:45:04 -05:00
|
|
|
|
export const initialApiKeysState: ApiKeysState = {
|
|
|
|
|
keys: [],
|
|
|
|
|
searchQuery: '',
|
2018-10-11 04:49:34 -05:00
|
|
|
|
hasFetched: false,
|
2019-11-20 05:14:57 -06:00
|
|
|
|
includeExpired: false,
|
2018-09-26 06:45:04 -05:00
|
|
|
|
};
|
2018-09-25 09:23:43 -05:00
|
|
|
|
|
|
|
|
|
export const apiKeysReducer = (state = initialApiKeysState, action: Action): ApiKeysState => {
|
|
|
|
|
switch (action.type) {
|
|
|
|
|
case ActionTypes.LoadApiKeys:
|
2018-10-11 04:49:34 -05:00
|
|
|
|
return { ...state, hasFetched: true, keys: action.payload };
|
2018-09-26 06:45:04 -05:00
|
|
|
|
case ActionTypes.SetApiKeysSearchQuery:
|
|
|
|
|
return { ...state, searchQuery: action.payload };
|
2018-09-25 09:23:43 -05:00
|
|
|
|
}
|
|
|
|
|
return state;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
apiKeys: apiKeysReducer,
|
|
|
|
|
};
|