github.com/wfusion/gofusion@v1.1.14/common/infra/asynq/asynqmon/ui/src/reducers/redisInfoReducer.ts (about) 1 import { 2 GET_REDIS_INFO_BEGIN, 3 GET_REDIS_INFO_ERROR, 4 GET_REDIS_INFO_SUCCESS, 5 RedisInfoActionTypes, 6 } from "../actions/redisInfoActions"; 7 import { QueueLocation, RedisInfo } from "../api"; 8 9 interface RedisInfoState { 10 loading: boolean; 11 error: string; 12 address: string; 13 data: RedisInfo | null; 14 rawData: string | null; 15 cluster: boolean; 16 rawClusterNodes: string | null; 17 queueLocations: QueueLocation[] | null; 18 } 19 20 const initialState: RedisInfoState = { 21 loading: false, 22 error: "", 23 address: "", 24 data: null, 25 rawData: null, 26 cluster: false, 27 rawClusterNodes: null, 28 queueLocations: null, 29 }; 30 31 export default function redisInfoReducer( 32 state = initialState, 33 action: RedisInfoActionTypes 34 ): RedisInfoState { 35 switch (action.type) { 36 case GET_REDIS_INFO_BEGIN: 37 return { 38 ...state, 39 loading: true, 40 }; 41 42 case GET_REDIS_INFO_ERROR: 43 return { 44 ...state, 45 loading: false, 46 error: action.error, 47 }; 48 49 case GET_REDIS_INFO_SUCCESS: 50 return { 51 loading: false, 52 error: "", 53 address: action.payload.address, 54 data: action.payload.info, 55 rawData: action.payload.raw_info, 56 cluster: action.payload.cluster, 57 rawClusterNodes: action.payload.raw_cluster_nodes, 58 queueLocations: action.payload.queue_locations, 59 }; 60 61 default: 62 return state; 63 } 64 }