@@ -6,13 +6,18 @@ import {
6
6
MenuItem ,
7
7
MenuItemProps ,
8
8
Typography ,
9
+ withStyles ,
9
10
} from "@material-ui/core" ;
10
- import classNames from 'classnames'
11
- import React , { FunctionComponent , useCallback } from "react" ;
11
+ import { GatewaySession } from "@renproject/ren-tx" ;
12
+ import classNames from "classnames" ;
13
+ import React , { FunctionComponent , useCallback , useState } from "react" ;
14
+ import {
15
+ ActionButton ,
16
+ ActionButtonWrapper ,
17
+ } from "../../../components/buttons/Buttons" ;
12
18
import { CircleIcon } from "../../../components/icons/IconHelpers" ;
13
19
import {
14
20
AddIcon ,
15
- BitcoinIcon ,
16
21
CustomSvgIconComponent ,
17
22
DeleteIcon ,
18
23
TxSettingsIcon ,
@@ -83,44 +88,120 @@ const useTransactionMenuStyles = makeStyles((theme) => ({
83
88
type TransactionMenuProps = {
84
89
open : boolean ;
85
90
onClose : ( ) => void ;
91
+ onDeleteTx : ( ) => void ;
92
+ tx : GatewaySession ;
86
93
} ;
87
94
88
95
export const TransactionMenu : FunctionComponent < TransactionMenuProps > = ( {
89
96
open,
90
97
onClose,
98
+ onDeleteTx,
99
+ tx,
91
100
} ) => {
92
101
const styles = useTransactionMenuStyles ( ) ;
93
102
const handleClose = useCallback ( ( ) => {
94
103
if ( onClose ) {
95
104
onClose ( ) ;
96
105
}
97
106
} , [ onClose ] ) ;
107
+ const [ confirmOpen , setConfirmOpen ] = useState ( false ) ;
108
+ const handleConfirmClose = useCallback ( ( ) => {
109
+ setConfirmOpen ( false ) ;
110
+ } , [ ] ) ;
111
+ const handleDeleteWithConfirm = useCallback ( ( ) => {
112
+ setConfirmOpen ( true ) ;
113
+ } , [ ] ) ;
114
+
98
115
return (
99
- < NestedDrawer open = { open } onClose = { handleClose } className = { styles . root } >
100
- < BridgeModalTitle className = { styles . modalTitle } onClose = { handleClose } >
101
- < ListItemIcon className = { styles . titleIconWrapper } >
102
- < CircleIcon Icon = { TxSettingsIcon } fontSize = "small" variant = "solid" />
103
- </ ListItemIcon >
104
- < Typography variant = "inherit" > Transaction Menu</ Typography >
105
- </ BridgeModalTitle >
106
- < div className = { styles . menuItems } >
107
- < TransactionMenuItem Icon = { AddIcon } disabled >
108
- Insert/update transaction
109
- </ TransactionMenuItem >
110
- < TransactionMenuItem Icon = { DeleteIcon } >
111
- Delete transaction
112
- </ TransactionMenuItem >
113
- </ div >
114
- < PaperContent paddingVariant = "medium" className = { styles . transferId } >
115
- < Typography variant = "inherit" >
116
- Transfer ID: TODO: CRIT: add here
116
+ < >
117
+ < NestedDrawer open = { open } onClose = { handleClose } className = { styles . root } >
118
+ < BridgeModalTitle className = { styles . modalTitle } onClose = { handleClose } >
119
+ < ListItemIcon className = { styles . titleIconWrapper } >
120
+ < CircleIcon
121
+ Icon = { TxSettingsIcon }
122
+ fontSize = "small"
123
+ variant = "solid"
124
+ />
125
+ </ ListItemIcon >
126
+ < Typography variant = "inherit" > Transaction Menu</ Typography >
127
+ </ BridgeModalTitle >
128
+ < div className = { styles . menuItems } >
129
+ < TransactionMenuItem Icon = { AddIcon } disabled >
130
+ Insert/update transaction
131
+ </ TransactionMenuItem >
132
+ < TransactionMenuItem
133
+ Icon = { DeleteIcon }
134
+ onClick = { handleDeleteWithConfirm }
135
+ >
136
+ Delete transaction
137
+ </ TransactionMenuItem >
138
+ </ div >
139
+ < PaperContent paddingVariant = "medium" className = { styles . transferId } >
140
+ < Typography variant = "inherit" > Transfer ID: { tx . id } </ Typography >
141
+ </ PaperContent >
142
+ < Divider />
143
+ < PaperContent bottomPadding topPadding paddingVariant = "medium" >
144
+ < Button variant = "outlined" size = "small" disabled >
145
+ Report an Issue
146
+ </ Button >
147
+ </ PaperContent >
148
+ </ NestedDrawer >
149
+ < ConfirmTransactionDeletion
150
+ open = { confirmOpen }
151
+ onClose = { handleConfirmClose }
152
+ onDeleteTx = { onDeleteTx }
153
+ />
154
+ </ >
155
+ ) ;
156
+ } ;
157
+
158
+ type ConfirmTransactionDeletionProps = {
159
+ open : boolean ;
160
+ onClose : ( ) => void ;
161
+ onDeleteTx : ( ) => void ;
162
+ } ;
163
+
164
+ const RedButton = withStyles ( ( theme ) => ( {
165
+ root : {
166
+ color : theme . palette . error . main ,
167
+ } ,
168
+ } ) ) ( Button ) ;
169
+
170
+ export const ConfirmTransactionDeletion : FunctionComponent < ConfirmTransactionDeletionProps > = ( {
171
+ open,
172
+ onClose,
173
+ onDeleteTx,
174
+ } ) => {
175
+ return (
176
+ < NestedDrawer title = "Delete a Transaction" open = { open } onClose = { onClose } >
177
+ < PaperContent topPadding >
178
+ < Typography variant = "h5" align = "center" gutterBottom >
179
+ Are you sure?
180
+ </ Typography >
181
+ < Typography
182
+ variant = "body2"
183
+ align = "center"
184
+ color = "textSecondary"
185
+ gutterBottom
186
+ >
187
+ If you have already sent your assets you will lose them forever if you
188
+ remove the transaction.
117
189
</ Typography >
118
190
</ PaperContent >
119
- < Divider />
120
- < PaperContent bottomPadding topPadding paddingVariant = "medium" >
121
- < Button variant = "outlined" size = "small" >
122
- Report an Issue
123
- </ Button >
191
+ < PaperContent bottomPadding >
192
+ < ActionButtonWrapper >
193
+ < RedButton
194
+ variant = "text"
195
+ color = "inherit"
196
+ startIcon = { < DeleteIcon /> }
197
+ onClick = { onDeleteTx }
198
+ >
199
+ Remove Transaction
200
+ </ RedButton >
201
+ </ ActionButtonWrapper >
202
+ < ActionButtonWrapper >
203
+ < ActionButton onClick = { onClose } > Cancel</ ActionButton >
204
+ </ ActionButtonWrapper >
124
205
</ PaperContent >
125
206
</ NestedDrawer >
126
207
) ;
0 commit comments