import React, { Fragment, useEffect, useState } from 'react'; import { useHistory } from 'react-router'; import PropTypes from 'prop-types'; import { Button, Card, CardBody, CardTitle, Col, Row } from 'reactstrap'; import reduxConnect from '../../../../redux/utils/connect'; import { planRoutes } from './UserPlans'; import { allMediaTypes } from '../../../../redux/modules/appState/searchByFilters'; import { capitalize } from 'lodash'; import { convertUTCtoLocal, setDocumentData } from '../../../../common/helper'; import { translate } from 'react-i18next'; import CancellationFeedback from './CancellationFeedback'; function CurrentPlan({ actions, user, t }) { const [cancelModal, setCancelModal] = useState(false); const { restrictions } = user; const { push } = useHistory(); useEffect(() => { setDocumentData('title', 'Active Plan Details'); return () => setDocumentData('title'); // default }, []); function changePlan() { push(`/app/plans/${planRoutes.update}`); } function toggleCancelModal() { setCancelModal((prev) => !prev); } const { plans, limits, isPlanCancelled, subStartDate, subEndDate } = restrictions; const selectedMedias = []; const notSelectedMedias = []; allMediaTypes.map((v) => { if (plans[v]) { selectedMedias.push(t(`searchTab.sourceTypes.${v}`, capitalize(v))); } else { notSelectedMedias.push(t(`searchTab.sourceTypes.${v}`, capitalize(v))); } }); const isRTL = document.documentElement.dir === 'rtl'; return (
{t('plans.currentPlan.selectedMediaTypes')}
{selectedMedias.length > 0 ? selectedMedias.join(', ') : t('plans.currentPlan.none')} {notSelectedMedias.length > 0 ? ( ({t('plans.currentPlan.upgradeToGet')}:{' '} {notSelectedMedias.join(', ')}) ) : ( '' )}
{t('plans.currentPlan.selectedLicenses')}
{t('plans.currentPlan.features')}
{plans.analytics ? (
t('plans.currentPlan.analytics')
) : (
{t('plans.currentPlan.cancelWarning')}
{t('plans.currentPlan.alreadyCancelled')}