diff --git a/web/cashtab/src/components/App.js b/web/cashtab/src/components/App.js --- a/web/cashtab/src/components/App.js +++ b/web/cashtab/src/components/App.js @@ -249,7 +249,11 @@ - + { +const CreateTokenForm = ({ + BCH, + getRestUrl, + createToken, + disabled, + passLoadingStatus, +}) => { const { wallet } = React.useContext(WalletContext); - //const { getBCH, getRestUrl, createToken } = useBCH(); - // New Token Name const [newTokenName, setNewTokenName] = useState(''); const [newTokenNameIsValid, setNewTokenNameIsValid] = useState(null); @@ -108,11 +110,8 @@ // Modal settings const [showConfirmCreateToken, setShowConfirmCreateToken] = useState(false); - // Token creation loading - const [genesisLoading, setGenesisLoading] = useState(false); - const createPreviewedToken = async () => { - setGenesisLoading(true); + passLoadingStatus(true); // If data is for some reason not valid here, bail out if (!tokenGenesisDataIsValid) { return; @@ -153,7 +152,7 @@ }); } catch (e) { // Set loading to false here as well, as balance may not change depending on where error occured in try loop - setGenesisLoading(false); + passLoadingStatus(false); let message; if (!e.error && !e.message) { @@ -184,6 +183,8 @@ } // Hide the modal setShowConfirmCreateToken(false); + // Stop spinner + passLoadingStatus(false); }; return ( <> @@ -208,165 +209,170 @@
<> - - - - -
+ + + + - - - handleNewTokenNameInput(e) - } - /> - - - - handleNewTokenTickerInput(e) - } - /> - - + handleNewTokenNameInput(e) } - > - - handleNewTokenDecimalsInput(e) - } - /> - - + + + + handleNewTokenTickerInput(e) } - help={ - newTokenInitialQtyIsValid === - null || - newTokenInitialQtyIsValid - ? '' - : 'Token supply must be greater than 0 and less than 100,000,000,000. Token supply decimal places cannot exceed token decimal places.' + /> + + + + handleNewTokenDecimalsInput(e) } - > - - handleNewTokenInitialQtyInput(e) - } - /> - - + + + + handleNewTokenInitialQtyInput(e) } - help={ - newTokenDocumentUrlIsValid === - null || - newTokenDocumentUrlIsValid - ? '' - : 'Document URL cannot exceed 68 characters' + /> + + + + handleNewTokenDocumentUrlInput(e) } - > - - handleNewTokenDocumentUrlInput( - e, - ) - } - /> - - - - setShowConfirmCreateToken(true)} - disabled={!tokenGenesisDataIsValid} - > - -  Create Token - -
-
-
+ /> + + + + setShowConfirmCreateToken(true)} + disabled={!tokenGenesisDataIsValid} + > + +  Create Token + + + ); }; +/* +passLoadingStatus must receive a default prop that is a function +in order to pass the rendering unit test in CreateTokenForm.test.js + +status => {console.log(status)} is an arbitrary stub function +*/ + +CreateTokenForm.defaultProps = { + passLoadingStatus: status => { + console.log(status); + }, +}; + export default CreateTokenForm; diff --git a/web/cashtab/src/components/Tokens/Tokens.js b/web/cashtab/src/components/Tokens/Tokens.js --- a/web/cashtab/src/components/Tokens/Tokens.js +++ b/web/cashtab/src/components/Tokens/Tokens.js @@ -10,7 +10,7 @@ import { BalanceHeaderFiat } from '@components/Common/BalanceHeaderFiat'; import { ZeroBalanceHeader, AlertMsg } from '@components/Common/Atoms'; -const Tokens = ({ jestBCH }) => { +const Tokens = ({ jestBCH, passLoadingStatus }) => { /* Dev note @@ -78,6 +78,7 @@ getRestUrl={getRestUrl} createToken={createToken} disabled={balances.totalBalanceInSatoshis < currency.dustSats} + passLoadingStatus={passLoadingStatus} /> {balances.totalBalanceInSatoshis < currency.dustSats && ( @@ -115,4 +116,17 @@ ); }; +/* +passLoadingStatus must receive a default prop that is a function +in order to pass the rendering unit test in Tokens.test.js + +status => {console.log(status)} is an arbitrary stub function +*/ + +Tokens.defaultProps = { + passLoadingStatus: status => { + console.log(status); + }, +}; + export default Tokens; diff --git a/web/cashtab/src/components/Tokens/__tests__/__snapshots__/CreateTokenForm.test.js.snap b/web/cashtab/src/components/Tokens/__tests__/__snapshots__/CreateTokenForm.test.js.snap --- a/web/cashtab/src/components/Tokens/__tests__/__snapshots__/CreateTokenForm.test.js.snap +++ b/web/cashtab/src/components/Tokens/__tests__/__snapshots__/CreateTokenForm.test.js.snap @@ -1,54 +1,46 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://goo.gl/fbAQLP @generated exports[`Wallet with BCH balances and tokens and state field 1`] = `
-
- -
+ + + + Create Token
diff --git a/web/cashtab/src/components/Tokens/__tests__/__snapshots__/Tokens.test.js.snap b/web/cashtab/src/components/Tokens/__tests__/__snapshots__/Tokens.test.js.snap --- a/web/cashtab/src/components/Tokens/__tests__/__snapshots__/Tokens.test.js.snap +++ b/web/cashtab/src/components/Tokens/__tests__/__snapshots__/Tokens.test.js.snap @@ -17,53 +17,45 @@ XEC ,
-
- -
+ + + + Create Token
, @@ -105,53 +97,45 @@ XEC ,
-
- -
+ + + + Create Token
, @@ -194,53 +178,45 @@ USD ,
-
- -
+ + + + Create Token
, @@ -299,53 +275,45 @@ XEC ,
-
- -
+ + + + Create Token
, @@ -387,53 +355,45 @@ XEC ,
-
- -
+ + + + Create Token
,