Web: PortalSettings: Payments: Added check for nonProfit.

This commit is contained in:
Tatiana Lopaeva 2023-04-03 12:03:21 +03:00
parent ac48208d40
commit c88c6da4b5
3 changed files with 98 additions and 71 deletions

View File

@ -81,26 +81,28 @@ const StyledBody = styled.div`
}
`;
const PaymentContainer = ({
isFreeTariff,
isGracePeriod,
theme,
isNotPaidPeriod,
payerEmail,
user,
isPaidPeriod,
currencySymbol,
startValue,
currentTariffPlanTitle,
tariffPlanTitle,
expandArticle,
gracePeriodEndDate,
delayDaysCount,
const PaymentContainer = (props) => {
const {
isFreeTariff,
isGracePeriod,
theme,
isNotPaidPeriod,
payerEmail,
user,
isPaidPeriod,
currencySymbol,
startValue,
currentTariffPlanTitle,
tariffPlanTitle,
expandArticle,
gracePeriodEndDate,
delayDaysCount,
isAlreadyPaid,
paymentDate,
t,
}) => {
isAlreadyPaid,
paymentDate,
t,
isNonProfit,
} = props;
const renderTooltip = () => {
return (
<>
@ -164,6 +166,8 @@ const PaymentContainer = ({
};
const planSuggestion = () => {
if (isNonProfit) return;
if (isFreeTariff) {
return (
<Text
@ -228,6 +232,41 @@ const PaymentContainer = ({
return;
};
const planDescription = () => {
if (isFreeTariff || isNonProfit) return;
if (isGracePeriod)
return (
<Text noSelect fontSize={"14px"} lineHeight={"16px"}>
<Trans t={t} i18nKey="GracePeriodActivatedInfo" ns="Payments">
Grace period activated
<strong>
from {{ fromDate: paymentDate }} to
{{ byDate: gracePeriodEndDate }}
</strong>
(days remaining: {{ delayDaysCount }})
</Trans>{" "}
<Text as="span" fontSize="14px" lineHeight="16px">
{t("GracePeriodActivatedDescription")}
</Text>
</Text>
);
if (isPaidPeriod)
return (
<Text
noSelect
fontSize={"14px"}
lineHeight={"16px"}
className="payment-info_managers-price"
>
<Trans t={t} i18nKey="BusinessFinalDateInfo" ns="Payments">
{{ finalDate: paymentDate }}
</Trans>
</Text>
);
};
const isPayer = user.email === payerEmail;
const isFreeAfterPaidPeriod = isFreeTariff && payerEmail?.length !== 0;
@ -244,7 +283,7 @@ const PaymentContainer = ({
? expiredTitleSubscriptionWarning()
: currentPlanTitle()}
{isAlreadyPaid && (
{!isNonProfit && isAlreadyPaid && (
<PayerInformationContainer
isPayer={isPayer}
isFreeAfterPaidPeriod={isFreeAfterPaidPeriod}
@ -254,59 +293,37 @@ const PaymentContainer = ({
<CurrentTariffContainer />
{planSuggestion()}
{planDescription()}
{isGracePeriod && (
<Text noSelect fontSize={"14px"} lineHeight={"16px"}>
<Trans t={t} i18nKey="GracePeriodActivatedInfo" ns="Payments">
Grace period activated
<strong>
from {{ fromDate: paymentDate }} to
{{ byDate: gracePeriodEndDate }}
</strong>
(days remaining: {{ delayDaysCount }})
</Trans>{" "}
<Text as="span" fontSize="14px" lineHeight="16px">
{t("GracePeriodActivatedDescription")}
</Text>
</Text>
)}
{!isNonProfit &&
!isGracePeriod &&
!isNotPaidPeriod &&
!isFreeAfterPaidPeriod && (
<div className="payment-info_wrapper">
<Text
noSelect
fontWeight={600}
fontSize={"14px"}
className="payment-info_managers-price"
>
<Trans t={t} i18nKey="PerUserMonth" ns="Common">
From {{ currencySymbol }}
{{ price: startValue }} per admin/power user /month
</Trans>
</Text>
{isPaidPeriod && !isFreeTariff && (
<Text
noSelect
fontSize={"14px"}
lineHeight={"16px"}
className="payment-info_managers-price"
>
<Trans t={t} i18nKey="BusinessFinalDateInfo" ns="Payments">
{{ finalDate: paymentDate }}
</Trans>
</Text>
)}
{renderTooltip()}
</div>
)}
{!isGracePeriod && !isNotPaidPeriod && !isFreeAfterPaidPeriod && (
<div className="payment-info_wrapper">
<Text
noSelect
fontWeight={600}
fontSize={"14px"}
className="payment-info_managers-price"
>
<Trans t={t} i18nKey="PerUserMonth" ns="Common">
From {{ currencySymbol }}
{{ price: startValue }} per admin/power user /month
</Trans>
</Text>
{renderTooltip()}
</div>
)}
<div className="payment-info">
<PriceCalculation
t={t}
isPayer={isPayer}
isFreeAfterPaidPeriod={isFreeAfterPaidPeriod}
/>
{!isNonProfit && (
<PriceCalculation
t={t}
isPayer={isPayer}
isFreeAfterPaidPeriod={isFreeAfterPaidPeriod}
/>
)}
<BenefitsContainer t={t} />
</div>
@ -327,7 +344,9 @@ export default inject(({ auth, payments }) => {
} = auth;
const { showText: expandArticle } = settingsStore;
const { isFreeTariff, currentTariffPlanTitle } = currentQuotaStore;
const { isFreeTariff, currentTariffPlanTitle, isNonProfit } =
currentQuotaStore;
const {
isNotPaidPeriod,
isPaidPeriod,
@ -372,5 +391,6 @@ export default inject(({ auth, payments }) => {
currentTariffPlanTitle,
portalTariffStatus,
portalPaymentQuotas,
isNonProfit,
};
})(withRouter(observer(PaymentContainer)));

View File

@ -40,6 +40,7 @@ const Article = ({
withSendAgain,
mainBarVisible,
isBannerVisible,
isNonProfit,
...rest
}) => {
const [articleHeaderContent, setArticleHeaderContent] = React.useState(null);
@ -178,6 +179,7 @@ const Article = ({
<ArticleProfile showText={showText} />
)}
{isPaymentPageAvailable &&
!isNonProfit &&
(isFreeTariff || isGracePeriod) &&
showText && (
<ArticlePaymentAlert
@ -249,7 +251,7 @@ export default inject(({ auth }) => {
isPaymentPageAvailable,
bannerStore,
} = auth;
const { isFreeTariff } = currentQuotaStore;
const { isFreeTariff, isNonProfit } = currentQuotaStore;
const { isGracePeriod } = currentTariffStatusStore;
const { withSendAgain } = userStore;
@ -283,5 +285,6 @@ export default inject(({ auth }) => {
withSendAgain,
mainBarVisible,
isBannerVisible,
isNonProfit,
};
})(observer(Article));

View File

@ -207,6 +207,10 @@ class QuotasStore {
);
}
get isNonProfit() {
return this.currentPortalQuota?.nonProfit;
}
setPortalQuotaValue = (res) => {
this.currentPortalQuota = res;
this.currentPortalQuotaFeatures = res.features;