-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsample_flow.js
234 lines (195 loc) · 6.24 KB
/
sample_flow.js
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/**
* FLOW DEFINITION
*
* 1 ----- 2 ----- 3 ----- 4 ----- 5 ----- 6 ----- 7
* \ 2a / \ 3a / \ 4a / \ 5a / \ --- 7a ---- 8 ----- 9 ----- 10
*
*/
/* 1 - HOME */
function displayHomeMenu() {
return render({
content: `Menu
${datasetToList(home)}`,
dataset: home
})
}
var home = [
null,
{ title: "Request a shipment", confirm: displaySenders },
{ title: "Check shipment status" },
{ title: "Repeat recent jobs" },
{ title: "Register new user or location" },
{ title: "Help / Other services" },
]
/* 2 - SENDERS */
function displaySenders() {
return render({
content: `Enter sender
${datasetToList(senders)}`,
dataset: senders
})
}
var senders = [
null,
{ title: "Me", confirm: displayPickupLocations },
{ title: "Doreen Gashuga", confirm: displayPickupLocations },
{ title: "Pacific Tuyishime", confirm: displayPickupLocations },
{ title: "Angelique Kantengwa", confirm: displayPickupLocations },
{ title: "Viola Dub", confirm: displayPickupLocations },
{ title: "Manuel Arzuah", confirm: displayPickupLocations },
{ title: "Someone else", confirm: displayArbitrarySender },
]
/* 2a alternative path - ARBITRARY SENDER NUMBER */
function displayArbitrarySender() {
return render({
content: "Enter sender phone number",
dataset: displayPickupLocations,
status: "answerStandby"
})
}
/* 3 - PICK UP LOCATIONS */
function displayPickupLocations() {
return render({
content: `Enter pickup location
${datasetToList(pickUpLocations)}`,
dataset: pickUpLocations
})
}
var pickUpLocations = [
null,
{ title: "Saved location 1", confirm: displayReceivers },
{ title: "Saved location 2", confirm: displayReceivers },
{ title: "Saved location 3", confirm: displayReceivers },
{ title: "Find public location near me", confirm: displayArbitraryPickupLocationCode },
{ title: "Enter a location code", confirm: displayArbitraryPickupLocationCode },
{ title: "MTN branch code", confirm: displayArbitraryPickupLocationCode },
]
/* 3a alternative path - ARBITRARY PICK UP LOCATION CODE */
function displayArbitraryPickupLocationCode() {
return render({
content: "Enter pickup location code",
dataset: displayReceivers,
status: "answerStandby"
})
}
/* 4 - RECEIVERS */
function displayReceivers() {
return render({
content: `Enter receiver
${datasetToList(receivers)}`,
dataset: receivers
})
}
var receivers = [
null,
{ title: "Me", confirm: displayDropOffLocations },
{ title: "Doreen Gashuga", confirm: displayDropOffLocations },
{ title: "Pacific Tuyishime", confirm: displayDropOffLocations },
{ title: "Angelique Kantengwa", confirm: displayDropOffLocations },
{ title: "Viola Dub", confirm: displayDropOffLocations },
{ title: "Manuel Arzuah", confirm: displayDropOffLocations },
{ title: "Someone else", confirm: displayArbitraryReceiver },
]
/* 4a alternative path - ARBITRARY RECEIVER */
function displayArbitraryReceiver() {
return render({
content: "Enter receiver phone number",
dataset: displayDropOffLocations,
status: "answerStandby"
})
}
/* 5 - DROP OFF LOCATIONS */
function displayDropOffLocations() {
return render({
content: `Enter drop off location
${datasetToList(dropOffLocations)}`,
dataset: dropOffLocations
})
}
var dropOffLocations = [
null,
{ title: "Saved location 1", confirm: displayGoods },
{ title: "Saved location 2", confirm: displayGoods },
{ title: "Saved location 3", confirm: displayGoods },
{ title: "Find public location near me", confirm: displayArbitraryDropOffLocationCode },
{ title: "Enter a location code", confirm: displayArbitraryDropOffLocationCode },
{ title: "MTN branch code", confirm: displayArbitraryDropOffLocationCode },
]
/* 5a alternative path - ARBITRARY DROP OFF LOCATION */
function displayArbitraryDropOffLocationCode() {
return render({
content: "Enter drop off location code",
dataset: displayGoods,
status: "answerStandby"
})
}
/* 6 - GOODS */
function displayGoods() {
return render({
content: `Select what's being shipped
${datasetToList(goods)}`,
dataset: goods
})
}
var goods = [
null,
{ title: "Loose goods", confirm: displayThanksWithCallInfo, },
{ title: "Packaged goods", confirm: displaySelectPackagingType, },
{ title: "Livestock", confirm: displayThanksWithCallInfo, },
{ title: "Unusual shapes", confirm: displayThanksWithCallInfo, },
]
/* 7 - THANKS WITH CALL INFO (FINAL) */
function displayThanksWithCallInfo() {
return render({
content: `Thank you for requesting a shipment.
We will call you shortly to confirm what will be shipped and provide a quote.`,
status: "final"
})
}
/* 7 alternative path - SELECT PACKAGE TYPE */
function displaySelectPackagingType() {
return render({
content: `Select packaging type
${datasetToList(packagingType)}`,
dataset: packagingType,
})
}
var packagingType = [
null,
{ title: "20kg sack", confirm: displaySelectPackageQuantity },
{ title: "Small crate", confirm: displaySelectPackageQuantity },
{ title: "Large crate", confirm: displaySelectPackageQuantity },
]
/* 8 - SELECT PACKAGE QUANTITY */
function displaySelectPackageQuantity() {
return render({
content: "Select quantity of packages",
dataset: displaySelectDeliveryDate,
status: "answerStandby"
})
}
/* 9 - SELECT DELIVERY DATE */
function displaySelectDeliveryDate() {
return render({
content: `Choose date and time
${datasetToList(deliveryDates)}`,
dataset: deliveryDates,
})
}
var deliveryDates = [
null,
{ title: "24/06/2020 AM: R₣ 2,000", confirm: displayThanksWithSmsInfo },
{ title: "24/06/2020 PM: R₣ 1,800", confirm: displayThanksWithSmsInfo },
{ title: "25/06/2020 AM: R₣ 1,500", confirm: displayThanksWithSmsInfo },
{ title: "25/06/2020 PM: R₣ 1,500", confirm: displayThanksWithSmsInfo },
{ title: "26/06/2020 AM: R₣ 1,200", confirm: displayThanksWithSmsInfo },
{ title: "26/06/2020 PM: R₣ 1,200", confirm: displayThanksWithSmsInfo },
]
/* 10 - THANKS WITH SMS INFO (FINAL) */
function displayThanksWithSmsInfo() {
return render({
content: `Thank you for requesting a shipment.
You will receive a SMS to confirm your booking once the other party has confirmed they can make/accept delivery.`,
status: 'final'
})
}