Repository navigation
Expand file tree
/
Copy pathapp.js
More file actions
65 lines (60 loc) · 1.76 KB
/
Copy pathapp.js
File metadata and controls
65 lines (60 loc) · 1.76 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const askDay = require('./prompts').day.ask;
const askPositions = require('./prompts').positions.ask;
const askSummaries = require('./prompts').summaries.ask;
const askStandUpConfirmation = require('./prompts').standUpConfirmation.ask;
const printSaveConfirmation = require('./prompts').saveConfirmation.print;
const listStaffMembers = require('./http').staffMember.list;
const createDay = require('./http').day.create;
const bulkCreatePositions = require('./http').position.bulkCreate;
const bulkCreateSummaries = require('./http').summary.bulkCreate;
const standUp = {
date: '',
positions: [],
summaries: []
};
askDay()
.then(date => {
standUp.date = date;
return listStaffMembers();
})
.then(response => {
let staffMembers = response.body._embedded.staffMembers;
staffMembers = staffMembers.map(staffMember => {
delete staffMember._links;
return staffMember;
});
return staffMembers;
})
.then(staffMembers => {
console.log('Please select staff members in the order in which they stood.');
return askPositions(staffMembers);
})
.then(positions => {
standUp.positions = positions;
console.log('Please select staff members in the order in which they spoke.');
return askSummaries(positions);
})
.then(summaries => {
standUp.summaries = summaries;
return askStandUpConfirmation(standUp);
})
.then(stick => {
if (stick) {
return createDay(standUp.date);
} else {
process.exit();
}
})
.then(dayID => {
standUp.dayID = dayID;
return bulkCreatePositions(standUp.positions, standUp.dayID);
})
.then(positionIDs => {
standUp.positionIDs = positionIDs;
return bulkCreateSummaries(standUp.summaries, standUp.dayID);
})
.then(summaryIDs => {
standUp.summaryIDs = summaryIDs;
printSaveConfirmation(standUp);
})
.catch(err => console.log(err));