'use strict';
import React from 'react';
export default class SendingStep extends React.Component {
constructor (props) {
super(props);
this.state = {
loading: true,
success: null
};
}
componentDidMount () {
this.props.sendConfig().then(() => {
this.setState({ loading: false, success: true });
}).catch(() => {
this.setState({ loading: false, success: false });
});
}
render () {
return (
{(() => {
if (this.state.loading) {
return (
Loading
Sending configuration...
);
} else {
if (this.state.success) {
return (
The configuration was sent. Your device will reboot.
);
} else {
return (
There was an error while sending the configuration. Please retry.
);
}
}
})()}
);
}
}
if (process.env.NODE_ENV !== 'production') { // for Preact
SendingStep.propTypes = {
sendConfig: React.PropTypes.func.isRequired
};
}