/* @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.deviceState) {
return ();
}
const device = this.props.devices.find(d => d.state === state.deviceState);
if (!device) {
return (Device with state {state.deviceState} not found);
}
const discovery = props.discovery.find(d => d.deviceState === device.state && d.network === state.network);
const account = props.accounts.find(a => a.deviceState === state.deviceState && a.index === state.accountIndex && a.network === state.network);
if (!account) {
if (!discovery || discovery.waitingForDevice) {
return (
);
} else if (discovery.completed) {
return (
);
} else {
return (
);
}
}
return null;
}
}