@@ -55,10 +55,7 @@ const StakeWithdrawButton: React.FC<IActionButton> = ({ amount, parsedAmount, ac
5555 const theme = useTheme ( ) ;
5656 const [ isPopupOpen , setIsPopupOpen ] = useState ( false ) ;
5757 const [ isSuccess , setIsSuccess ] = useState ( false ) ;
58- const [ popupStepsState , setPopupStepsState ] = useState < {
59- items : [ _TimelineItem1 , ..._TimelineItem1 [ ] ] ;
60- current : number ;
61- } > ( ) ;
58+ const [ popupStepsState , setPopupStepsState ] = useState < [ _TimelineItem1 , ..._TimelineItem1 [ ] ] > ( ) ;
6259
6360 const { data : courtDetails } = useCourtDetails ( id ) ;
6461 const { data : balance } = useReadPnkBalanceOf ( {
@@ -140,67 +137,62 @@ const StakeWithdrawButton: React.FC<IActionButton> = ({ amount, parsedAmount, ac
140137 const requestData = config ?. request ?? setStakeConfig ?. request ;
141138
142139 if ( requestData && publicClient ) {
143- setPopupStepsState ( {
144- items : getStakeSteps (
140+ setPopupStepsState (
141+ getStakeSteps (
145142 isWithdraw ? StakeSteps . WithdrawInitiate : StakeSteps . StakeInitiate ,
146143 amount ,
147144 theme ,
148145 approvalHash
149- ) ,
150- current : 1 ,
151- } ) ;
146+ )
147+ ) ;
152148
153149 setStake ( requestData )
154150 . then ( async ( hash ) => {
155- setPopupStepsState ( {
156- items : getStakeSteps (
151+ setPopupStepsState (
152+ getStakeSteps (
157153 isWithdraw ? StakeSteps . WithdrawPending : StakeSteps . StakePending ,
158154 amount ,
159155 theme ,
160156 approvalHash ,
161157 hash
162- ) ,
163- current : 1 ,
164- } ) ;
158+ )
159+ ) ;
165160 await publicClient . waitForTransactionReceipt ( { hash, confirmations : 2 } ) . then ( ( res : TransactionReceipt ) => {
166161 const status = res . status === "success" ;
167162 if ( status ) {
168- setPopupStepsState ( {
169- items : getStakeSteps (
163+ setPopupStepsState (
164+ getStakeSteps (
170165 isWithdraw ? StakeSteps . WithdrawConfirmed : StakeSteps . StakeConfirmed ,
171166 amount ,
172167 theme ,
173168 approvalHash ,
174169 hash
175- ) ,
176- current : 1 ,
177- } ) ;
170+ )
171+ ) ;
178172 setIsSuccess ( true ) ;
179173 } else
180- setPopupStepsState ( {
181- items : getStakeSteps (
174+ setPopupStepsState (
175+ getStakeSteps (
182176 isWithdraw ? StakeSteps . WithdrawFailed : StakeSteps . StakeFailed ,
183177 amount ,
184178 theme ,
185179 approvalHash ,
186180 hash
187- ) ,
188- current : 1 ,
189- } ) ;
181+ )
182+ ) ;
190183 } ) ;
191184 } )
192185 . catch ( ( err ) => {
193- setPopupStepsState ( {
194- items : getStakeSteps (
186+ setPopupStepsState (
187+ getStakeSteps (
195188 isWithdraw ? StakeSteps . WithdrawFailed : StakeSteps . StakeFailed ,
196189 amount ,
197190 theme ,
198191 approvalHash ,
199192 undefined ,
200193 err
201- ) ,
202- current : 1 ,
203- } ) ;
194+ )
195+ ) ;
204196 } ) ;
205197 }
206198 } ,
@@ -210,17 +202,11 @@ const StakeWithdrawButton: React.FC<IActionButton> = ({ amount, parsedAmount, ac
210202 const handleClick = useCallback ( ( ) => {
211203 setIsPopupOpen ( true ) ;
212204 if ( ActionType . allowance && isAllowance && increaseAllowanceConfig && publicClient ) {
213- setPopupStepsState ( {
214- items : getStakeSteps ( StakeSteps . ApproveInitiate , amount , theme ) ,
215- current : 0 ,
216- } ) ;
205+ setPopupStepsState ( getStakeSteps ( StakeSteps . ApproveInitiate , amount , theme ) ) ;
217206
218207 increaseAllowance ( increaseAllowanceConfig . request )
219208 . then ( async ( hash ) => {
220- setPopupStepsState ( {
221- items : getStakeSteps ( StakeSteps . ApprovePending , amount , theme , hash ) ,
222- current : 0 ,
223- } ) ;
209+ setPopupStepsState ( getStakeSteps ( StakeSteps . ApprovePending , amount , theme , hash ) ) ;
224210
225211 await publicClient
226212 . waitForTransactionReceipt ( { hash, confirmations : 2 } )
@@ -231,18 +217,11 @@ const StakeWithdrawButton: React.FC<IActionButton> = ({ amount, parsedAmount, ac
231217 const refetchData = await refetchSetStake ( ) ;
232218
233219 handleStake ( refetchData . data , hash ) ;
234- } else
235- setPopupStepsState ( {
236- items : getStakeSteps ( StakeSteps . ApproveFailed , amount , theme , hash ) ,
237- current : 0 ,
238- } ) ;
220+ } else setPopupStepsState ( getStakeSteps ( StakeSteps . ApproveFailed , amount , theme , hash ) ) ;
239221 } ) ;
240222 } )
241223 . catch ( ( err ) => {
242- setPopupStepsState ( {
243- items : getStakeSteps ( StakeSteps . ApproveFailed , amount , theme , undefined , undefined , err ) ,
244- current : 0 ,
245- } ) ;
224+ setPopupStepsState ( getStakeSteps ( StakeSteps . ApproveFailed , amount , theme , undefined , undefined , err ) ) ;
246225 } ) ;
247226 } else {
248227 handleStake ( ) ;
0 commit comments