import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { observer } from 'mobx-react'; import { defineMessages, intlShape } from 'react-intl'; import { serviceLimitStore } from '../../../features/serviceLimit'; import Button from '../../ui/Button'; import { RESTRICTION_TYPES } from '../../../models/Service'; const messages = defineMessages({ headlineServiceLimit: { id: 'service.restrictedHandler.serviceLimit.headline', defaultMessage: '!!!You have reached your service limit.', }, textServiceLimit: { id: 'service.restrictedHandler.serviceLimit.text', defaultMessage: '!!!Please upgrade your account to use more than {count} services.', }, headlineCustomUrl: { id: 'service.restrictedHandler.customUrl.headline', defaultMessage: '!!!Franz Professional Plan required', }, textCustomUrl: { id: 'service.restrictedHandler.customUrl.text', defaultMessage: '!!!Please upgrade to the Franz Professional plan to use custom urls & self hosted services.', }, action: { id: 'service.restrictedHandler.action', defaultMessage: '!!!Upgrade Account', }, }); export default @observer class ServiceRestricted extends Component { static propTypes = { name: PropTypes.string.isRequired, upgrade: PropTypes.func.isRequired, type: PropTypes.number.isRequired, }; static contextTypes = { intl: intlShape, }; countdownInterval = null; countdownIntervalTimeout = 1000; render() { const { name, upgrade, type, } = this.props; const { intl } = this.context; return (
{type === RESTRICTION_TYPES.SERVICE_LIMIT && ( <>

{intl.formatMessage(messages.headlineServiceLimit)}

{intl.formatMessage(messages.textServiceLimit, { count: serviceLimitStore.serviceLimit })}

)} {type === RESTRICTION_TYPES.CUSTOM_URL && ( <>

{intl.formatMessage(messages.headlineCustomUrl)}

{intl.formatMessage(messages.textCustomUrl)}

)}
); } }