Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 4 additions & 16 deletions src/utils/JsonTextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,14 @@ const JsonTextArea = ({ onConvert }: JsonTextAreaProps) => {
throw Error('Empty Json Object')
}
setIsValidJson(true);
onConvert(value)
} catch (error) {
setIsValidJson(false);
}
};

const handleSubmit = (event: any) => {
event.preventDefault();
if (isValidJson) {
// Handle the submission of valid JSON data
onConvert(jsonText)
} else {
// alert('The JSON is invalid. Please correct it before submitting.');
}
};

return (
<form onSubmit={handleSubmit}>
<form>
<textarea
value={jsonText}
onChange={handleJsonChange}
Expand All @@ -43,12 +34,9 @@ const JsonTextArea = ({ onConvert }: JsonTextAreaProps) => {
cols={100}
style={{ fontFamily: 'monospace' }}
/>
<div>
<div style={{ margin: '8px' }}>
{jsonText && !isValidJson && <span style={{ color: 'red' }}>Invalid JSON format!</span>}
</div>
<button type="submit" disabled={!isValidJson}>
Convert to Hook Tx
</button>
</form>
);
};
Expand All @@ -66,4 +54,4 @@ export default JsonTextArea;
"value": "100000000000"
}
}
*/
*/