/
xoflowDefinition.js
82 lines (71 loc) · 2.77 KB
/
xoflowDefinition.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
'use strict';
module.exports = {
flowName: 'XO flow',
secured: ['ROLE_MEMBER'],
start_state: 'updateBuyer',
states: {
view: {
memberReview: {
viewName: 'memberReview',
changeFundingSource: 'changeFundingSourceView',
changeShippingAddress: 'changeShippingAddressSubflow',
submit: { nextState: 'redirectToMerchant', onExit: 'noOpMethod' },
changeShippingAddressWithOnExit: { nextState: 'changeShippingAddressSubflow', onExit: 'noOpMethod' },
go2ChangeShippingAddressAction: 'go2ChangeShippingAddressAction',
go2firstLevelSubflow: 'firstLevelSubflow'
},
changeFundingSourceView: {
viewName: 'changeFundingSourceView',
submit: 'changeFundingSource'
},
genericPurchaseErrorState: {
viewName: 'genericPurchaseError',
submit: 'memberReview'
}
},
action: {
updateBuyer: {
success: 'memberReview'
},
// these transitions events need to be returned from your onEntry
changeFundingSource: {
success: 'memberReview',
error: 'changeFundingSourceView'
},
redirectToMerchant: {
success: 'redirectedToMerchant',
error: 'cancelToMerchant'
},
cancelToMerchant: {
success: 'redirectToMerchant'
},
go2ChangeShippingAddressAction: {
success: 'changeShippingAddressSubflow'
}
},
subflow: {
changeShippingAddressSubflow: {
// the subflow name MUST be the exact flow name in the subflow definition file
flowName: 'changeShippingAddressFlow',
transitions: {
cancelledChangeShippingAddress: 'memberReview',
addedShippingAddress: 'memberReview',
changedShippingAddress: 'memberReview',
redirectToMerchant: 'redirectToMerchant'
}
},
firstLevelSubflow: {
flowName: 'firstLevelFlow',
transitions: {
didSomething: 'memberReview'
}
}
}
},
// parent flow needs to end this subflow and then map the child end event to the parent next state
// can't put 'redirectToMerchant', 'cancelToMerchant' in there yet because of logic in framework
endStates: [ 'redirectedToMerchant', 'cancelledToMerchant'],
globalTransitions: {
genericUserError: 'genericPurchaseErrorState' // ' 'genericUserError' is a state name
}
};