UNPKG

@omegabigdata/honoplay-redux-helper

Version:
148 lines (139 loc) 3.25 kB
import { FETCHING_TENANT_LIST, FETCH_TENANT_LIST_SUCCESS, FETCH_TENANT_LIST_FAILED, FETCHING_TENANT, FETCH_TENANT_SUCCESS, FETCH_TENANT_FAILED, UPDATING_TENANT, UPDATE_TENANT_SUCCESS, UPDATE_TENANT_FAILED, CREATING_TENANT, CREATE_TENANT_SUCCESS, CREATE_TENANT_FAILED } from '../helpers/ActionTypes/Tenant'; const TENANT_LIST_INITIAL_STATE = { isTenantListLoading: false, tenants: null, errorTenantList: null }; const TENANT_INITIAL_STATE = { isTenantLoading: false, tenant: null, errorTenant: null }; const CREATE_TENANT_INITIAL_STATE = { isCreateTenantLoading: false, newTenant: null, errorCreateTenant: null }; const UPDATE_TENANT_INITIAL_STATE = { isUpdateTenantLoading: false, updatedTenant: null, errorUpdateTenant: null }; export const tenantListReducers = ( state = TENANT_LIST_INITIAL_STATE, action ) => { switch (action.type) { case FETCHING_TENANT_LIST: return { ...state, isTenantListLoading: true, errorTenantList: null }; case FETCH_TENANT_LIST_SUCCESS: return { ...state, isTenantListLoading: false, tenants: action.data }; case FETCH_TENANT_LIST_FAILED: return { ...state, isTenantListLoading: false, errorTenantList: action.data.error }; default: return state; } }; export const tenantReducers = (state = TENANT_INITIAL_STATE, action) => { switch (action.type) { case FETCHING_TENANT: return { ...state, isTenantLoading: true, errorTenant: null }; case FETCH_TENANT_SUCCESS: return { ...state, isTenantLoading: false, tenant: action.data }; case FETCH_TENANT_FAILED: return { ...state, isTenantLoading: false, errorTenant: action.data.error }; default: return state; } }; export const createTenantReducers = ( state = CREATE_TENANT_INITIAL_STATE, action ) => { switch (action.type) { case CREATING_TENANT: return { ...state, isCreateTenantLoading: true, errorCreateTenant: null }; case CREATE_TENANT_SUCCESS: return { ...state, isCreateTenantLoading: false, newTenant: action.data }; case CREATE_TENANT_FAILED: return { ...state, isCreateTenantLoading: false, errorCreateTenant: action.data.error }; default: return state; } }; export const updateTenantReducers = ( state = UPDATE_TENANT_INITIAL_STATE, action ) => { switch (action.type) { case UPDATING_TENANT: return { ...state, isUpdateTenantLoading: true, errorUpdateTenant: null }; case UPDATE_TENANT_SUCCESS: return { ...state, isUpdateTenantLoading: false, updatedTenant: action.data }; case UPDATE_TENANT_FAILED: return { ...state, isUpdateTenantLoading: false, errorUpdateTenant: action.data.error }; default: return state; } };