More robust import #2885
This commit is contained in:
parent
134622ea3a
commit
09ec0c1f2f
@ -142,21 +142,25 @@ class Addresses extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderValidation = (content) => {
|
renderValidation = (content) => {
|
||||||
let addresses;
|
const error = {
|
||||||
|
|
||||||
try {
|
|
||||||
addresses = JSON.parse(content);
|
|
||||||
} catch (e) {
|
|
||||||
return {
|
|
||||||
error: 'The provided file is invalid...'
|
error: 'The provided file is invalid...'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const addresses = JSON.parse(content);
|
||||||
|
|
||||||
|
if (!addresses || Object.keys(addresses).length === 0) {
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
const body = Object.values(addresses).map((address, index) => (
|
const body = Object
|
||||||
|
.values(addresses)
|
||||||
|
.filter((account) => account && account.address)
|
||||||
|
.map((account, index) => (
|
||||||
<Summary
|
<Summary
|
||||||
key={ index }
|
key={ index }
|
||||||
account={ address }
|
account={ account }
|
||||||
name={ address.name }
|
name={ account.name }
|
||||||
noLink
|
noLink
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
@ -166,6 +170,7 @@ class Addresses extends Component {
|
|||||||
{ body }
|
{ body }
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
} catch (e) { return error; }
|
||||||
}
|
}
|
||||||
|
|
||||||
onImport = (content) => {
|
onImport = (content) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user