99 lines
3.1 KiB
TypeScript
99 lines
3.1 KiB
TypeScript
import { useDispatch, useSelector } from "react-redux";
|
|
import EmailSubstrate from "../../components/EmailSubstrate";
|
|
import styles from "./styles.module.scss";
|
|
import { actions, selectors } from "@/store";
|
|
import Title from "@/components/Title";
|
|
import PriceList from "@/components/pages/ABDesign/v1/components/PriceList";
|
|
import { usePaywall } from "@/hooks/paywall/usePaywall";
|
|
import { EPlacementKeys } from "@/api/resources/Paywall";
|
|
import {
|
|
ELocalesPlacement,
|
|
getDefaultLocaleByLanguage,
|
|
language,
|
|
} from "@/locales";
|
|
import { useState } from "react";
|
|
import Button from "../../components/Button";
|
|
import routes from "@/routes";
|
|
import { useNavigate } from "react-router-dom";
|
|
import Loader from "@/components/Loader";
|
|
import { useTranslations } from "@/hooks/translations";
|
|
import { useMetricABFlags } from "@/services/metric/metricService";
|
|
import { getLongText } from "./abText";
|
|
|
|
function TrialChoice() {
|
|
const { translate } = useTranslations(ELocalesPlacement.PalmistryV1);
|
|
const navigate = useNavigate();
|
|
const dispatch = useDispatch();
|
|
const { products, isLoading, currency, getText } = usePaywall({
|
|
placementKey: EPlacementKeys["aura.placement.palmistry.redesign"],
|
|
localesPlacement: ELocalesPlacement.PalmistryV1,
|
|
});
|
|
|
|
const locale = getDefaultLocaleByLanguage(language);
|
|
|
|
const { flags } = useMetricABFlags();
|
|
const isLongText = flags?.text?.[0] === "on";
|
|
|
|
const [isDisabled, setIsDisabled] = useState(true);
|
|
|
|
const selectedPrice = useSelector(selectors.selectSelectedPrice);
|
|
const email = useSelector(selectors.selectEmail);
|
|
const homeConfig = useSelector(selectors.selectHome);
|
|
|
|
const handlePriceItem = () => {
|
|
setIsDisabled(false);
|
|
};
|
|
|
|
const handleNext = () => {
|
|
if (isDisabled) {
|
|
return;
|
|
}
|
|
dispatch(
|
|
actions.siteConfig.update({
|
|
home: { pathFromHome: homeConfig.pathFromHome, isShowNavbar: false },
|
|
})
|
|
);
|
|
navigate(routes.client.palmistryV1TrialPayment());
|
|
};
|
|
|
|
return (
|
|
<div className={styles.container}>
|
|
{!isLoading && (
|
|
<>
|
|
<EmailSubstrate className={styles["email-substrate"]} email={email} />
|
|
{!isLongText && (
|
|
<Title className={styles.title} variant="h2">
|
|
{getText("text.0")}
|
|
</Title>
|
|
)}
|
|
{isLongText && <p className={styles.text}>{getLongText(locale)}</p>}
|
|
|
|
<div className={styles["price-container"]}>
|
|
<PriceList
|
|
products={products}
|
|
activeItem={selectedPrice}
|
|
classNameItem={styles["price-item"]}
|
|
classNameItemActive={`${styles["price-item-active"]}`}
|
|
classNamePricesContainer={styles["prices-container"]}
|
|
currency={currency}
|
|
click={handlePriceItem}
|
|
/>
|
|
<p className={styles["auxiliary-text"]}>{getText("text.1")}</p>
|
|
</div>
|
|
|
|
<Button
|
|
className={styles.button}
|
|
disabled={isDisabled}
|
|
onClick={handleNext}
|
|
>
|
|
{translate("next")}
|
|
</Button>
|
|
</>
|
|
)}
|
|
{isLoading && <Loader className={styles.loader} />}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default TrialChoice;
|