import React from 'react'; import PropTypes from 'prop-types'; import { Table } from 'react-bootstrap'; import { translate as __ } from 'foremanReact/common/I18n'; import subscriptionAttributes from './SubscriptionAttributes'; const SubscriptionDetailInfo = ({ subscriptionDetails }) => { const subscriptionLimits = (subDetails) => { const limits = []; if (subDetails.sockets) { limits.push(__('Sockets: %s').replace('%s', subDetails.sockets)); } if (subDetails.cores) { limits.push(__('Cores: %s').replace('%s', subDetails.cores)); } if (subDetails.ram) { limits.push(__('RAM: %s GB').replace('%s', subDetails.ram)); } if (limits.length > 0) { return limits.join(', '); } return ''; }; const subscriptionDetailValue = (subDetails, key) => (subDetails[key] == null ? '' : String(subDetails[key])); const formatInstanceBased = (subDetails) => { if (subDetails.instance_multiplier == null || subDetails.instance_multiplier === '' || subDetails.instance_multiplier === 0) { return __('No'); } return __('Yes'); }; return (

{__('Subscription Info')}

{Object.keys(subscriptionAttributes).map(key => ( ))}
{__(subscriptionAttributes[key])} {subscriptionDetailValue(subscriptionDetails, key)}
{__('Limits')} {subscriptionLimits(subscriptionDetails)}
{__('Instance-based')} {formatInstanceBased(subscriptionDetails)}
); }; SubscriptionDetailInfo.propTypes = { subscriptionDetails: PropTypes.shape({}).isRequired, }; export default SubscriptionDetailInfo;