/* @flow */
'use strict';
import React, { Component } from 'react';
import { Notification } from '../../common/Notification';
export default class AbstractAccount extends Component {
componentDidMount() {
this.props.initAccount();
}
componentWillUpdate(newProps: any) {
this.props.updateAccount();
}
componentWillUnmount() {
this.props.disposeAccount();
}
render(state: any): any {
const props = this.props;
if (!state.checksum) {
return ();
}
const device = this.props.devices.find(d => d.checksum === state.checksum);
const discovery = props.discovery.find(d => d.checksum === device.checksum && d.coin === state.coin);
const account = props.accounts.find(a => a.checksum === state.checksum && a.index === state.accountIndex && a.coin === state.coin);
if (!account) {
if (!discovery || discovery.waitingForDevice) {
return (
);
} else if (discovery.completed) {
return (
);
} else {
return (
);
}
}
return null;
}
}