import { observable , action , runInAction } from 'mobx' ; import api from '../api/host' ; import { IOverview , IOverviewQuery } from '../interfaces' ; import moment from 'moment' ; class OverViewStore { @ observable overviews : ( IOverview ) [ ] ; constructor ( ) { this . overviews = [ ] ; } @ action async getOverview ( query ) { const { data : res } = await api . getOverview ( query ) ; runInAction ( ( ) => { this . overviews = res . data . map ( item => { item . date = moment ( item . date ) . format ( 'YY-MM-DD' ) ; return item ; } ) ; } ) ; return res ; } } export default OverViewStore ;