import React, { Component, Fragment } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import { Trans, withNamespaces } from 'react-i18next'; import Form from './Form'; import Leases from './Leases'; import Card from '../../ui/Card'; class Dhcp extends Component { handleFormSubmit = (values) => { this.props.setDhcpConfig(values); }; handleRefresh = () => { this.props.findActiveDhcp(); } getToggleDhcpButton = () => { const { config } = this.props.dhcp; const buttonText = config.enabled ? 'dhcp_disable' : 'dhcp_enable'; const buttonClass = config.enabled ? 'btn-gray' : 'btn-success'; return ( this.props.toggleDhcp(config)}> {buttonText} ); } render() { const { t, dhcp } = this.props; const statusButtonClass = classnames({ 'btn btn-primary btn-standart': true, 'btn btn-primary btn-standart btn-loading': dhcp.processingStatus, }); return ( {!dhcp.processing && {this.getToggleDhcpButton()} refresh_status {dhcp.active && !dhcp.active.found && dhcp_not_found } } {!dhcp.processing && dhcp.config.enabled && } ); } } Dhcp.propTypes = { dhcp: PropTypes.object, toggleDhcp: PropTypes.func, getDhcpStatus: PropTypes.func, setDhcpConfig: PropTypes.func, findActiveDhcp: PropTypes.func, handleSubmit: PropTypes.func, t: PropTypes.func, }; export default withNamespaces()(Dhcp);