@@ -50,16 +50,16 @@ const CreateCertificate = () => {
5050 const [ openModal , setOpenModal ] = useState ( false ) ;
5151 const [ disableCertify , setDisableCertify ] = useState ( false ) ;
5252 const [ certificationPrice , setCertificationPrice ] = useState ( 0 ) ;
53+ const [ performTransaction , setPerformTransaction ] = useState ( true ) ;
5354
5455 // to run only once initially
5556 useEffect ( ( ) => {
5657 fetchData . get ( '/profile/current/balance' ) . then ( response => {
5758 const availableProfileBalance : number = response . data
5859 fetchData . get ( '/run/' + uuid + '/details' ) . then ( res => {
5960 const runDetails : Run = res . data
60- if ( ( availableProfileBalance - runDetails . certificationPrice ) < 0 ) {
61- setCertificationPrice ( runDetails . certificationPrice ) ;
62- }
61+ setCertificationPrice ( runDetails . certificationPrice ) ;
62+ setPerformTransaction ( ( availableProfileBalance > 0 && ( availableProfileBalance - runDetails . certificationPrice ) < 0 ) ? true : false )
6363 } )
6464 } )
6565 // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -127,7 +127,7 @@ const CreateCertificate = () => {
127127 const triggerGetCertificate = async ( ) => {
128128 setCertifying ( true ) ;
129129 setShowError ( "" )
130- if ( certificationPrice ) {
130+ if ( performTransaction ) {
131131 triggerTransactionFromWallet ( certificationPrice )
132132 } else {
133133 triggerSubmitCertificate ( )
@@ -206,7 +206,7 @@ const CreateCertificate = () => {
206206 { certified || disableCertify ? null : ( < Button
207207 displayStyle = "gradient"
208208 onClick = { ( ) => triggerGetCertificate ( ) }
209- buttonLabel = { "Purchase a Certificate (" + ( certificationPrice / 1000000 ) . toString ( ) + " ADA)" }
209+ buttonLabel = { "Purchase a Certificate" + ( certificationPrice ? " (" + ( certificationPrice / 1000000 ) . toString ( ) + " ADA)" : null ) }
210210 showLoader = { certifying }
211211 /> ) }
212212 { transactionId ? (
0 commit comments