import { createContainerModule } from 'redux-with-domain' ; import reportDomain , { ReportItem } from '../../../domain/report' ; export const kSelectedReportIdChangeEmitName = 'setSelectedReportId' ; export default createContainerModule ( 'workbook/reportList' , { initialState : { } , selectors : { getReports : state => { const list = reportDomain . entities . reportList . select ( ) || [ ] ; return list ; } , getSelectedReportId : ( state , { pageSelectors } = { } ) => { return pageSelectors . getSelectedReportId ( ) ; } } , effects : ( { actions , selectors , sagaEffects : { call , put , select } , enhancer : { emit , syncPut } } ) => ( { * init ( ) { const reportList = yield select ( selectors . getReports ) ; if ( reportList && reportList . length > 0 ) { yield syncPut ( actions . setSelectedReportId ( reportList [ 0 ] . id ) ) ; } } , * setSelectedReportId ( { payload } ) { yield emit ( { name : kSelectedReportIdChangeEmitName , payload : payload } ) ; } } ) } ) ;