-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.js
More file actions
29 lines (26 loc) · 805 Bytes
/
api.js
File metadata and controls
29 lines (26 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import map from 'lodash/map';
// APIModule
import { Module } from '../utils/APIModule';
import actions from './actions';
export const init = new Module('init', [
{
name: 'base',
method: 'GET',
url: 'timetable/base',
afterSuccess: (dispatch, json) => {
const infrastructureID = map(json.infrastructures, (infrastructure, key) => (key))[0];
const roomID = map(json.infrastructures[infrastructureID].rooms, (room, key) => (key))[0];
const iDs = [infrastructureID, roomID];
dispatch(actions.setInitialIDs(iDs));
},
},
{
name: 'getCalendarByRoom',
method: 'GET',
url: 'timetable/room/:id',
afterSuccess: () => (null),
}]);
export default {
base: init.actions.base.request,
getCalendarByRoom: init.actions.getCalendarByRoom.request,
};