11import { match } from 'ts-pattern'
22
3+ import { formatSNT } from '../../../utils/currency'
4+
35import type { VaultState } from '../../_hooks/useVaultStateMachine'
46
57export type ActionStatusState =
@@ -18,6 +20,7 @@ export type ActionStatusContent = {
1820export function useActionStatusContent (
1921 state : VaultState
2022) : ActionStatusContent | null {
23+ console . log ( state )
2124 return (
2225 match < VaultState , ActionStatusContent | null > ( state )
2326 // SIWE flow
@@ -65,7 +68,7 @@ export function useActionStatusContent(
6568 title : 'Increase token allowance' ,
6669 description : 'Please sign the message in your wallet.' ,
6770 state : 'pending' ,
68- showCloseButton : true ,
71+ showCloseButton : false ,
6972 } ) )
7073 . with ( { type : 'increaseAllowance' , step : 'processing' } , ( ) => ( {
7174 title : 'Increasing token allowance' ,
@@ -87,15 +90,15 @@ export function useActionStatusContent(
8790 step : 'initialize' ,
8891 } ,
8992 state => ( {
90- title : `Ready to stake ${ state . amount || '0' } SNT ` ,
93+ title : `Ready to stake ${ formatSNT ( state . amount ?? 0 , { includeSymbol : true } ) } ` ,
9194 description : 'Please sign the message in your wallet.' ,
9295 state : 'pending' ,
9396 showCloseButton : true ,
9497 } )
9598 )
9699
97100 . with ( { type : 'staking' , step : 'processing' } , state => ( {
98- title : `Staking ${ state . amount || '0' } SNT ` ,
101+ title : `Staking ${ formatSNT ( state . amount ?? 0 , { includeSymbol : true } ) } ` ,
99102 description : 'Wait a moment...' ,
100103 state : 'processing' ,
101104 showCloseButton : false ,
@@ -107,6 +110,52 @@ export function useActionStatusContent(
107110 showCloseButton : true ,
108111 } ) )
109112
113+ // Withdraw flow
114+ . with (
115+ {
116+ type : 'withdraw' ,
117+ step : 'initialize' ,
118+ } ,
119+ state => ( {
120+ title : `Ready to withdraw ${ formatSNT ( state . amount ?? 0 , { includeSymbol : true } ) } ` ,
121+ description : 'Please sign the message in your wallet.' ,
122+ state : 'pending' ,
123+ showCloseButton : true ,
124+ } )
125+ )
126+ . with ( { type : 'withdraw' , step : 'processing' } , state => ( {
127+ title : `Withdrawing ${ formatSNT ( state . amount ?? 0 , { includeSymbol : true } ) } ` ,
128+ description : 'Wait a moment...' ,
129+ state : 'processing' ,
130+ showCloseButton : false ,
131+ } ) )
132+ . with ( { type : 'withdraw' , step : 'rejected' } , ( ) => ( {
133+ title : 'Request was rejected' ,
134+ description : 'Request was rejected by user' ,
135+ state : 'error' ,
136+ showCloseButton : true ,
137+ } ) )
138+
139+ // Lock flow
140+ . with ( { type : 'lock' , step : 'initialize' } , ( ) => ( {
141+ title : 'Ready to lock vault' ,
142+ description : 'Please sign the message in your wallet.' ,
143+ state : 'pending' ,
144+ showCloseButton : true ,
145+ } ) )
146+ . with ( { type : 'lock' , step : 'processing' } , ( ) => ( {
147+ title : 'Locking vault' ,
148+ description : 'Wait a moment...' ,
149+ state : 'processing' ,
150+ showCloseButton : false ,
151+ } ) )
152+ . with ( { type : 'lock' , step : 'rejected' } , ( ) => ( {
153+ title : 'Request was rejected' ,
154+ description : 'Request was rejected by user' ,
155+ state : 'error' ,
156+ showCloseButton : true ,
157+ } ) )
158+
110159 // Success
111160 . with ( { type : 'success' } , ( ) => ( {
112161 title : 'Success!' ,
0 commit comments