import _ from 'lodash';
import { message } from 'antd';
import { createReducer } from '../../../util';
import types from '../../types';
import initialState from './swift_state';
import objectAssign from 'object-assign';

export default createReducer(initialState, {
    
    [`${types.SWIFT_INIT_TREE_VALUE}`]: (state,{tree})=>{
        return objectAssign({},state,{swift_message_tree:tree})
    },
    [`${types.SWIFT_UPDATE_TREE_VALUE}`]: (state)=>{
        // let str = JSON.stringify(state)
        // return JSON.parse(str)
        return objectAssign({},state,{swift_message_tree:{...state.swift_message_tree}})
    },
    [`${types.SWIFT_STORE_TEMPLATE}`]: (state)=>state,
    [`${types.SWIFT_STORE_MESSAGE}`]: (state)=>state,
    [`${types.SWIFT_UPDATE_RCV_BIC}`]: (state,{rcv_bic_info})=>{
        return objectAssign({},state,{rcv_bic_info})
    },
    [`${types.SWIFT_UPDATE_SND_BIC}`]: (state,{snd_bic_info})=>{
        return objectAssign({},state,{snd_bic_info})
    }    ,
    [`${types.SWIFT_UPDATE_SWIFT_MESSAGE}`]: (state,{swift_message})=>{
        return objectAssign({},state,{swift_message})
    },


})