@@ -6,6 +6,7 @@ import bt, {
6
6
IGetInfoResponse ,
7
7
IGetOrderResponse
8
8
} from '@synonymdev/blocktank-client' ;
9
+ import { TFiatCurrency } from '../utils/exchange-rates' ;
9
10
10
11
export type RequestState = 'idle' | 'loading' | 'error' ;
11
12
@@ -16,16 +17,23 @@ export type TPublicPage =
16
17
| 'claim'
17
18
| 'order'
18
19
| 'orders'
20
+ | 'settings'
19
21
| 'terms'
20
22
| 'geoblocked' ;
23
+
21
24
export type TNavigationState = {
22
25
page : TPublicPage ;
23
26
orderId ?: string ;
24
27
showMenu ?: boolean ;
25
28
} ;
26
29
30
+ export type TSettingsState = {
31
+ currency : TFiatCurrency ;
32
+ } ;
33
+
27
34
export type TState = {
28
35
navigation : TNavigationState ;
36
+ settings : TSettingsState ;
29
37
info : {
30
38
state : RequestState ;
31
39
value : IGetInfoResponse ;
@@ -45,6 +53,9 @@ export const initialState: TState = {
45
53
page : 'configure' ,
46
54
showMenu : false
47
55
} ,
56
+ settings : {
57
+ currency : 'USD'
58
+ } ,
48
59
info : {
49
60
state : 'idle' ,
50
61
value : {
@@ -97,9 +108,12 @@ export const publicStore = createSlice({
97
108
setShowMenu : ( state , action : PayloadAction < boolean > ) => {
98
109
state . navigation . showMenu = action . payload ;
99
110
} ,
111
+ setCurrency : ( state , action : PayloadAction < TFiatCurrency > ) => {
112
+ state . settings . currency = action . payload ;
113
+ } ,
100
114
setOrderId : ( state , action : PayloadAction < string > ) => {
101
115
state . navigation . orderId = action . payload ;
102
- } ,
116
+ }
103
117
} ,
104
118
extraReducers : ( builder ) => {
105
119
builder
@@ -157,13 +171,14 @@ export const publicStore = createSlice({
157
171
}
158
172
} ) ;
159
173
160
- export const { navigate, setShowMenu, setOrderId } = publicStore . actions ;
174
+ export const { navigate, setShowMenu, setCurrency , setOrderId } = publicStore . actions ;
161
175
162
176
// The function below is called a selector and allows us to select a value from
163
177
// the state. Selectors can also be defined inline where they're used instead of
164
178
// in the slice file. For example: `useSelector((state: RootState) => state.counter.value)`
165
179
export const selectCurrentPage = ( state : RootState ) : TPublicPage => state . bt . navigation . page ;
166
180
export const selectShowMenu = ( state : RootState ) : boolean => ! ! state . bt . navigation . showMenu ;
181
+ export const selectCurrency = ( state : RootState ) : TFiatCurrency => state . bt . settings . currency ;
167
182
export const selectCurrentOrderId = ( state : RootState ) : string => state . bt . navigation . orderId ?? '' ;
168
183
169
184
export const selectInfo = ( state : RootState ) : IGetInfoResponse => state . bt . info . value ;
0 commit comments