Add empty msgs warning
This commit is contained in:
@@ -96,33 +96,39 @@ const CreateTxForm = ({ router, senderAddress, accountOnChain }: CreateTxFormPro
|
||||
return (
|
||||
<StackableContainer lessPadding>
|
||||
<h2>Create New Transaction</h2>
|
||||
{msgTypes.map((msgType, index) => (
|
||||
<MsgForm
|
||||
key={msgKeys[index]}
|
||||
msgType={msgType}
|
||||
senderAddress={senderAddress}
|
||||
setMsgGetter={(msgGetter) => {
|
||||
msgGetters.current = [
|
||||
...msgGetters.current.slice(0, index),
|
||||
msgGetter,
|
||||
...msgGetters.current.slice(index + 1),
|
||||
];
|
||||
}}
|
||||
deleteMsg={() => {
|
||||
msgGetters.current.splice(index, 1);
|
||||
setMsgKeys((oldMsgKeys) => [
|
||||
...oldMsgKeys.slice(0, index),
|
||||
...oldMsgKeys.slice(index + 1),
|
||||
]);
|
||||
setMsgTypes((oldMsgTypes) => {
|
||||
const newMsgTypes: MsgTypeUrl[] = oldMsgTypes.slice();
|
||||
newMsgTypes.splice(index, 1);
|
||||
setGasLimit(gasOfTx(newMsgTypes));
|
||||
return newMsgTypes;
|
||||
});
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
{msgTypes.length ? (
|
||||
msgTypes.map((msgType, index) => (
|
||||
<MsgForm
|
||||
key={msgKeys[index]}
|
||||
msgType={msgType}
|
||||
senderAddress={senderAddress}
|
||||
setMsgGetter={(msgGetter) => {
|
||||
msgGetters.current = [
|
||||
...msgGetters.current.slice(0, index),
|
||||
msgGetter,
|
||||
...msgGetters.current.slice(index + 1),
|
||||
];
|
||||
}}
|
||||
deleteMsg={() => {
|
||||
msgGetters.current.splice(index, 1);
|
||||
setMsgKeys((oldMsgKeys) => [
|
||||
...oldMsgKeys.slice(0, index),
|
||||
...oldMsgKeys.slice(index + 1),
|
||||
]);
|
||||
setMsgTypes((oldMsgTypes) => {
|
||||
const newMsgTypes: MsgTypeUrl[] = oldMsgTypes.slice();
|
||||
newMsgTypes.splice(index, 1);
|
||||
setGasLimit(gasOfTx(newMsgTypes));
|
||||
return newMsgTypes;
|
||||
});
|
||||
}}
|
||||
/>
|
||||
))
|
||||
) : (
|
||||
<StackableContainer lessMargin lessPadding>
|
||||
<p className="empty-msg-warning">Add at least one message to this transaction</p>
|
||||
</StackableContainer>
|
||||
)}
|
||||
<div className="form-item">
|
||||
<Input
|
||||
type="number"
|
||||
@@ -188,6 +194,10 @@ const CreateTxForm = ({ router, senderAddress, accountOnChain }: CreateTxFormPro
|
||||
p {
|
||||
margin-top: 15px;
|
||||
}
|
||||
.empty-msg-warning {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
}
|
||||
.form-item {
|
||||
margin-top: 1.5em;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user