import {
  getDashboards as getDashboardsAJAX,
  updateDashboard as updateDashboardAJAX,
} from 'src/dashboards/apis'

export function loadDashboards(dashboards, dashboardID) {
  return {
    type: 'LOAD_DASHBOARDS',
    payload: {
      dashboards,
      dashboardID,
    },
  }
}

export function setDashboard(dashboardID) {
  return {
    type: 'SET_DASHBOARD',
    payload: {
      dashboardID,
    },
  }
}

export function setTimeRange(timeRange) {
  return {
    type: 'SET_DASHBOARD_TIME_RANGE',
    payload: {
      timeRange,
    },
  }
}

export function setEditMode(isEditMode) {
  return {
    type: 'SET_EDIT_MODE',
    payload: {
      isEditMode,
    },
  }
}

export function getDashboards(dashboardID) {
  return (dispatch) => {
    getDashboardsAJAX().then(({data: {dashboards}}) => {
      dispatch(loadDashboards(dashboards, dashboardID))
    });
  }
}

export function putDashboard(dashboard) {
  return (dispatch) => {
    updateDashboardAJAX(dashboard).then(({data}) => {
      dispatch(updateDashboard(data))
    })
  }
}

export function updateDashboard(dashboard) {
  return {
    type: 'UPDATE_DASHBOARD',
    payload: {
      dashboard,
    },
  }
}

@@ -119,24 +119,21 @@
 %0Aexport 
-function
+const
  loadDas
@@ -131,32 +131,35 @@
 t loadDashboards
+ = 
 (dashboards, das
@@ -164,39 +164,30 @@
 ashboardID) 
-%7B%0A  return 
+=%3E (
 %7B%0A
-  
   type: 'LOA
@@ -201,18 +201,16 @@
 OARDS',%0A
-  
   payloa
@@ -210,34 +210,32 @@
  payload: %7B%0A    
-  
 dashboards,%0A    
@@ -230,26 +230,24 @@
 boards,%0A    
- 
- 
 dashboardID,
@@ -243,36 +243,31 @@
 ashboardID,%0A
-  
   %7D,%0A
-  %7D%0A
 %7D
+)
 %0A%0Aexport fun
@@ -259,32 +259,29 @@
 %0A%7D)%0A%0Aexport 
-function
+const
  setDashboar
@@ -273,32 +273,35 @@
 nst setDashboard
+ = 
 (dashboardID) %7B%0A
@@ -298,31 +298,22 @@
 oardID) 
-%7B%0A  return %7B%0A  
+=%3E (%7B%0A
   type: 
@@ -323,34 +323,32 @@
 T_DASHBOARD',%0A  
- 
- 
 payload: %7B%0A     
@@ -334,34 +334,32 @@
 ',%0A  payload: %7B%0A
-  
     dashboardID,
@@ -357,34 +357,29 @@
 hboardID,%0A  
- 
- 
 %7D,%0A
-  %7D%0A
 %7D
+)
 %0A%0Aexport fun
@@ -371,32 +371,29 @@
 %0A%7D)%0A%0Aexport 
-function
+const
  setTimeRang
@@ -393,16 +393,19 @@
 imeRange
+ = 
 (timeRan
@@ -408,33 +408,24 @@
 eRange) 
-%7B%0A  return 
+=%3E (
 %7B%0A  
- 
- 
 type: 'S
@@ -446,26 +446,24 @@
 IME_RANGE',%0A
-  
   payload: %7B
@@ -467,18 +467,16 @@
 : %7B%0A    
- 
- 
 timeRang
@@ -478,28 +478,23 @@
 eRange,%0A
-  
   %7D,%0A
-  %7D%0A
 %7D
+)
 %0A%0Aexport
@@ -494,24 +494,21 @@
 %0Aexport 
-function
+const
  setEdit
@@ -511,16 +511,19 @@
 EditMode
+ = 
 (isEditM
@@ -527,33 +527,24 @@
 itMode) 
-%7B%0A  return 
+=%3E (
 %7B%0A  
- 
- 
 type: 'S
@@ -558,18 +558,16 @@
 _MODE',%0A
-  
   payloa
@@ -575,18 +575,16 @@
 : %7B%0A    
- 
- 
 isEditMo
@@ -589,26 +589,162 @@
 Mode,%0A  
-  %7D
+%7D,%0A%7D)%0A%0Aexport const updateDashboard = (dashboard) =%3E (%7B%0A  type: 'UPDATE_DASHBOARD',%0A  payload: %7B%0A    dashboard
 ,%0A  %7D
+,
 %0A%7D
+)%0A%0A%0A// Async Action Creators
 %0A%0Aexport
@@ -744,24 +744,21 @@
 %0Aexport 
-function
+const
  getDash
@@ -755,32 +755,35 @@
 st getDashboards
+ = 
 (dashboardID) %7B%0A
@@ -780,26 +780,18 @@
 oardID) 
-%7B%0A  return
+=%3E
  (dispat
@@ -799,18 +799,16 @@
 h) =%3E %7B%0A
-  
   getDas
@@ -850,34 +850,32 @@
 rds%7D%7D) =%3E %7B%0A    
-  
 dispatch(loadDas
@@ -912,19 +912,12 @@
 D))%0A
-  
   %7D)
-;%0A  %7D
 %0A%7D%0A%0A
@@ -923,24 +923,21 @@
 %0Aexport 
-function
+const
  putDash
@@ -933,32 +933,35 @@
 nst putDashboard
+ = 
 (dashboard) %7B%0A  
@@ -956,26 +956,18 @@
 hboard) 
-%7B%0A  return
+=%3E
  (dispat
@@ -975,18 +975,16 @@
 h) =%3E %7B%0A
-  
   update
@@ -1031,18 +1031,16 @@
 %3E %7B%0A    
- 
- 
 dispatch
@@ -1069,147 +1069,9 @@
 )%0A  
-  %7D)%0A  %7D%0A%7D%0A%0Aexport function updateDashboard(dashboard) %7B%0A  return %7B%0A    type: 'UPDATE_DASHBOARD',%0A    payload: %7B%0A      dashboard,%0A    %7D,%0A  
 %7D
+)
 %0A%7D%0A

Use implicit returns for dashboard action creators