import DeviceManager, { getDefaultAccount } from '../DeviceManager'; import React, { Component } from 'react'; import { Spin, List, message } from 'antd'; import { Link } from 'react-router-dom'; class ManageDevices extends Component { constructor(props) { super(props); this.state = { loading: true, instance: null, devices: [] } } async componentDidMount() { try { let instance = await DeviceManager; let deviceIds = (await instance.getDevicesByOwner(getDefaultAccount())).map(el => el.toNumber()); let devicePromises = []; for (let deviceId of deviceIds) { let devicePromise = instance.devices(deviceId); devicePromises.push(devicePromise); } let devices = await Promise.all(devicePromises); this.setState({ instance, devices, deviceIds, loading: false }); } catch (error) { console.log(error); message.error(error.message); } } render() { const { devices, loading } = this.state; return (
{devices.length > 0 && !loading &&

Below you can find your devices. Click to see more details and manage.

( }*/ title={{`Device ID ${this.state.deviceIds[index]}`}} description={`Identifier ${device[1]}`} /> )} />
} {devices.length === 0 && !loading &&

You don't have any devices registered.

}
) } } export default ManageDevices;