-
Notifications
You must be signed in to change notification settings - Fork 504
/
reducers.js
executable file
·125 lines (121 loc) · 3.95 KB
/
reducers.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
import { assoc } from 'ramda'
import * as AT from './actionTypes.js'
import Remote from '../../../remote'
const INITIAL_STATE = {
kyc: Remote.NotAsked,
mediums: Remote.NotAsked,
nextAddress: null,
profile: Remote.NotAsked,
quote: Remote.NotAsked,
rateQuote: Remote.NotAsked,
subscriptions: Remote.NotAsked,
trade: Remote.NotAsked,
trades: Remote.NotAsked
}
const coinifyReducer = (state = INITIAL_STATE, action) => {
const { type, payload } = action
switch (type) {
case AT.COINIFY_FETCH_PROFILE_LOADING: {
return assoc('profile', Remote.Loading, state)
}
case AT.COINIFY_FETCH_PROFILE_SUCCESS: {
return assoc('profile', Remote.Success(payload), state)
}
case AT.COINIFY_FETCH_PROFILE_FAILURE: {
return assoc('profile', Remote.Failure(payload), state)
}
case AT.COINIFY_FETCH_QUOTE_LOADING: {
return assoc('quote', Remote.Loading, state)
}
case AT.COINIFY_FETCH_QUOTE_SUCCESS: {
return assoc('quote', Remote.Success(payload), state)
}
case AT.COINIFY_FETCH_QUOTE_FAILURE: {
return assoc('quote', Remote.Failure(payload), state)
}
case AT.COINIFY_FETCH_RATE_QUOTE_LOADING: {
return assoc('rateQuote', Remote.Loading, state)
}
case AT.COINIFY_FETCH_RATE_QUOTE_SUCCESS: {
return assoc('rateQuote', Remote.Success(payload), state)
}
case AT.COINIFY_FETCH_RATE_QUOTE_FAILURE: {
return assoc('rateQuote', Remote.Failure(payload), state)
}
case AT.COINIFY_FETCH_TRADES_LOADING: {
return assoc('trades', Remote.Loading, state)
}
case AT.COINIFY_FETCH_TRADES_SUCCESS: {
return assoc('trades', Remote.Success(payload), state)
}
case AT.COINIFY_FETCH_TRADES_FAILURE: {
return assoc('trades', Remote.Failure(payload), state)
}
case AT.COINIFY_FETCH_SUBSCRIPTIONS_LOADING: {
return assoc('subscriptions', Remote.Loading, state)
}
case AT.COINIFY_FETCH_SUBSCRIPTIONS_SUCCESS: {
return assoc('subscriptions', Remote.Success(payload), state)
}
case AT.COINIFY_FETCH_SUBSCRIPTIONS_FAILURE: {
return assoc('subscriptions', Remote.Failure(payload), state)
}
case AT.HANDLE_TRADE_LOADING: {
return assoc('trade', Remote.Loading, state)
}
case AT.HANDLE_TRADE_SUCCESS: {
return assoc('trade', Remote.Success(payload), state)
}
case AT.HANDLE_TRADE_FAILURE: {
return assoc('trade', Remote.Failure(payload), state)
}
case AT.SET_PROFILE_SUCCESS: {
return assoc('profile', Remote.Success(payload), state)
}
case AT.SET_PROFILE_FAILURE: {
return assoc('profile', Remote.Failure(payload), state)
}
case AT.COINIFY_SIGNUP_SUCCESS: {
return assoc('profile', Remote.Success(payload), state)
}
case AT.COINIFY_SIGNUP_FAILURE: {
return assoc('profile', Remote.Failure(payload), state)
}
case AT.SET_NEXT_ADDRESS: {
return assoc('nextAddress', payload, state)
}
case AT.RESET_PROFILE: {
return assoc('profile', Remote.NotAsked)
}
case AT.GET_DELEGATE_TOKEN_SUCCESS: {
return assoc('delegateToken', payload, state)
}
case AT.COINIFY_SET_TOKEN: {
return assoc('offlineToken', payload.token, state)
}
case AT.COINIFY_GET_PAYMENT_MEDIUMS_LOADING: {
return assoc('mediums', Remote.Loading, state)
}
case AT.COINIFY_GET_PAYMENT_MEDIUMS_SUCCESS: {
return assoc('mediums', Remote.Success(payload), state)
}
case AT.COINIFY_GET_PAYMENT_MEDIUMS_FAILURE: {
return assoc('mediums', Remote.Failure(payload), state)
}
case AT.COINIFY_SET_BANK_ACCOUNT: {
return assoc('account', payload, state)
}
case AT.GET_KYC_LOADING: {
return assoc('kyc', Remote.Loading, state)
}
case AT.GET_KYC_SUCCESS: {
return assoc('kyc', Remote.Success(payload), state)
}
case AT.GET_KYC_FAILURE: {
return assoc('kyc', Remote.Failure(payload), state)
}
default:
return state
}
}
export default coinifyReducer