This commit is contained in:
Daniil Chemerkin 2024-08-29 21:30:04 +00:00
parent 7ea88302d2
commit dfac0e4d5b
5 changed files with 63 additions and 17 deletions

View File

@ -1,4 +1,4 @@
import styles from "./styles.module.css"; import styles from "./styles.module.scss";
import { useCallback, useEffect, useState } from "react"; import { useCallback, useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { actions, selectors } from "@/store"; import { actions, selectors } from "@/store";
@ -17,12 +17,14 @@ import Loader from "@/components/Loader";
import metricService, { import metricService, {
EGoals, EGoals,
EMetrics, EMetrics,
useMetricABFlags,
} from "@/services/metric/metricService"; } from "@/services/metric/metricService";
import PersonalVideo from "../TrialPayment/components/PersonalVideo"; import PersonalVideo from "../TrialPayment/components/PersonalVideo";
import Toast from "../../components/Toast"; import Toast from "../../components/Toast";
import BlurComponent from "@/components/BlurComponent"; import BlurComponent from "@/components/BlurComponent";
import { useTranslations } from "@/hooks/translations"; import { useTranslations } from "@/hooks/translations";
import { addCurrency, ELocalesPlacement } from "@/locales"; import { addCurrency, ELocalesPlacement } from "@/locales";
import DiscountExpires from "../TrialPayment/components/DiscountExpires";
enum EDisplayOptionButton { enum EDisplayOptionButton {
"alwaysVisible" = "alwaysVisible", "alwaysVisible" = "alwaysVisible",
@ -51,6 +53,9 @@ function TrialChoicePage() {
}); });
const arrowLeft = useSelector(selectors.selectTrialChoiceArrowOptions)?.left; const arrowLeft = useSelector(selectors.selectTrialChoiceArrowOptions)?.left;
const { flags } = useMetricABFlags();
const isShowTimer = flags?.showTimerTrial?.[0] === "show";
const getPrice = useCallback( const getPrice = useCallback(
(product: IPaywallProduct) => { (product: IPaywallProduct) => {
if (!product?.trialPrice) { if (!product?.trialPrice) {
@ -109,6 +114,16 @@ function TrialChoicePage() {
return () => clearTimeout(timeOut); return () => clearTimeout(timeOut);
}, [visibleToast]); }, [visibleToast]);
const getFirstParagraphMargin = useCallback(() => {
if (isShowTimer) {
return "12px";
}
if (videoUrl.length) {
return "calc((100% + 84px) / 16* 9 + 16px)";
}
return "60px";
}, [isShowTimer, videoUrl.length]);
return ( return (
<section <section
className={`${styles.page} page`} className={`${styles.page} page`}
@ -137,12 +152,20 @@ function TrialChoicePage() {
)} )}
{!isLoading && ( {!isLoading && (
<> <>
{isShowTimer && (
<DiscountExpires
className={styles["discount-expires"]}
style={{
marginTop: !videoUrl.length
? "60px"
: "calc((100% + 84px) / 16* 9 + 16px)",
}}
/>
)}
<p <p
className={styles.text} className={styles.text}
style={{ style={{
marginTop: !videoUrl.length marginTop: getFirstParagraphMargin(),
? "60px"
: "calc((100% + 84px) / 16* 9 + 16px)",
}} }}
> >
{getText("text.0", { {getText("text.0", {

View File

@ -34,7 +34,7 @@
} }
.blue { .blue {
color: #1C38EA; color: #1c38ea;
} }
.auxiliary-text { .auxiliary-text {
@ -81,11 +81,11 @@
} }
.price-item-active.male { .price-item-active.male {
background-color: #85B6FF; background-color: #85b6ff;
} }
.price-item-active.female { .price-item-active.female {
background-color: #D1ACF2; background-color: #d1acf2;
} }
.arrow-image { .arrow-image {
@ -102,11 +102,11 @@
} }
.emails-container.female { .emails-container.female {
background-color: #D6BBEE; background-color: #d6bbee;
} }
.emails-container.male { .emails-container.male {
background-color: #85B6FF; background-color: #85b6ff;
} }
.emails-title { .emails-title {
@ -183,4 +183,22 @@
z-index: 30; z-index: 30;
margin-top: 0 !important; margin-top: 0 !important;
border-radius: 0 !important; border-radius: 0 !important;
} }
.discount-expires {
flex-direction: row !important;
gap: 12px;
font-size: 1.5rem;
& > h6 {
font-size: 17px;
}
& > div > p,
& > div > div > span:first-child {
font-size: 20px;
}
& > div > div > span:last-child {
font-size: 10px;
}
}

View File

@ -1,10 +1,12 @@
import { useEffect, useMemo, useState } from "react"; import { HTMLAttributes, useEffect, useMemo, useState } from "react";
import styles from "./styles.module.css"; import styles from "./styles.module.css";
import Title from "@/components/Title"; import Title from "@/components/Title";
import { useTranslations } from "@/hooks/translations"; import { useTranslations } from "@/hooks/translations";
import { ELocalesPlacement } from "@/locales"; import { ELocalesPlacement } from "@/locales";
function DiscountExpires() { type TDiscountExpiresProps = HTMLAttributes<HTMLDivElement>;
function DiscountExpires({ className = "", ...props }: TDiscountExpiresProps) {
const { translate } = useTranslations(ELocalesPlacement.V1); const { translate } = useTranslations(ELocalesPlacement.V1);
const [currentDate, setCurrentDate] = useState(new Date()); const [currentDate, setCurrentDate] = useState(new Date());
const endDate = useMemo( const endDate = useMemo(
@ -39,7 +41,7 @@ function DiscountExpires() {
}; };
return ( return (
<div className={styles["discount-expires"]}> <div {...props} className={`${styles["discount-expires"]} ${className}`}>
<Title variant="h6" className={styles.title}> <Title variant="h6" className={styles.title}>
{translate("/trial-payment.discount_expires")} {translate("/trial-payment.discount_expires")}
</Title> </Title>

View File

@ -6,7 +6,11 @@ import { useDispatch, useSelector } from "react-redux";
import parse from "html-react-parser"; import parse from "html-react-parser";
import { defaultPaywalls } from "./defaultPaywalls"; import { defaultPaywalls } from "./defaultPaywalls";
import locales from "@/locales/locales"; import locales from "@/locales/locales";
import { ELocalesPlacement, language } from "@/locales"; import {
ELocalesPlacement,
getDefaultLocaleByLanguage,
language,
} from "@/locales";
import { useTranslations } from "@/hooks/translations"; import { useTranslations } from "@/hooks/translations";
import { Currency } from "@/components/PaymentTable"; import { Currency } from "@/components/PaymentTable";
@ -108,7 +112,7 @@ export function usePaywall({
const property = properties.find((property) => property.key === key); const property = properties.find((property) => property.key === key);
if (!property) return ""; if (!property) return "";
let text = property.value; let text = property.value;
if (locale in locales) { if (getDefaultLocaleByLanguage(locale) in locales) {
text = `${paywall?.key.replaceAll(".", "_")}.${key.replaceAll( text = `${paywall?.key.replaceAll(".", "_")}.${key.replaceAll(
".", ".",
"_" "_"
@ -151,7 +155,6 @@ export function usePaywall({
return parse(element); return parse(element);
} }
if (text && replacement?.length) { if (text && replacement?.length) {
if (text.includes("text_2")) console.log(text);
return replacement.reduce((acc, _replacement) => { return replacement.reduce((acc, _replacement) => {
return acc.replace(_replacement.target, _replacement.replacement); return acc.replace(_replacement.target, _replacement.replacement);
}, translate(text)); }, translate(text));

View File

@ -130,7 +130,7 @@ const initMetricAB = () => {
} }
export const useMetricABFlags = () => { export const useMetricABFlags = () => {
return useExperiments<typeof EFlags>({ return useExperiments<typeof EFlags & { showTimerTrial: "show" | "hide" }>({
clientId: `metrika.${metricCounterNumber}` clientId: `metrika.${metricCounterNumber}`
}) })
} }