ttk-app-core
Version:
enterprise develop framework
38 lines (32 loc) • 1.49 kB
JavaScript
import { Map , fromJS} from 'immutable'
import { reducer as MetaReducer } from 'edf-meta-engine'
import config from './config'
import { getInitState } from './data'
class reducer {
constructor(option) {
this.metaReducer = option.metaReducer
this.config = config.current
}
init = (state, option) => {
const initState = getInitState()
if (option) {
initState.data = option
}
return this.metaReducer.init(state, initState)
}
load = (state, option) => {
state = this.metaReducer.sf(state, 'data.form.estimatedNegativeRate', fromJS(option.estimatedNegativeRate))
state = this.metaReducer.sf(state, 'data.form.estimatedStressAddTax', fromJS(option.estimatedStressAddTax))
state = this.metaReducer.sf(state, 'data.form.taxTotal', fromJS(option.taxTotal))
state = this.metaReducer.sf(state, 'data.form.invoiceSum', fromJS(option.invoiceSum))
state = this.metaReducer.sf(state, 'data.form.list', fromJS(option.list))
state = this.metaReducer.sf(state, 'data.form.taxInclusiveAmountTotal', fromJS(option.taxInclusiveAmountTotal))
state = this.metaReducer.sf(state, 'data.form.textDisplay', true)
return state
}
}
export default function creator(option) {
const metaReducer = new MetaReducer(option),
o = new reducer({ ...option, metaReducer })
return { ...metaReducer, ...o }
}