import {fromJS} from 'immutable'

let facials = [500, 200, 100, 50, 20, 10, 5,
  2, 1, 0.5, 0.2, 0.1, 0.05, 0.02, 0.01]
let items  = []
facials.forEach(facial => {
  items.push({
    facial,
    count: 0
  })
})

const INITIAL_STATE = fromJS({items})

export default function reducer(state = INITIAL_STATE, action) {
  switch (action.type) {
  case 'SET_ITEM_COUNT':
    const facial = action.facial
    const count = action.count
    
    const ind = state.get('items').findIndex(it => {
      return it.get('facial') === facial
    })
    
    return state.setIn(['items', ind, 'count'], count)
    
  default:
    return state
  }
}

@@ -31,13 +31,19 @@
 e'%0A%0A
-let f
+const billF
 acia
@@ -76,20 +76,39 @@
 0, 10, 5
-,%0A  
+%5D%0Aconst coinFacials = %5B
 2, 1, 0.
@@ -154,17 +154,119 @@
 s  = %5B%5D%0A
-f
+billFacials.forEach(facial =%3E %7B%0A  items.push(%7B%0A    facial,%0A    count: 0,%0A    type: 'BILL'%0A  %7D)%0A%7D)%0AcoinF
 acials.f
@@ -323,16 +323,34 @@
 count: 0
+,%0A    type: 'COIN'
 %0A  %7D)%0A%7D)

add type: 'BILL'|'COIN'