import styles from "./styles.module.scss";
import Blob from "../../images/SVG/Blob";
import { images } from "../../data";
import Title from "@/components/Title";
import Button from "../../components/Button";
import Blob2 from "../../images/SVG/Blob2";
import { useNavigate } from "react-router-dom";
import routes from "@/routes";
import { usePaywall } from "@/hooks/paywall/usePaywall";
import { EPlacementKeys } from "@/api/resources/Paywall";
import { addCurrency, ELocalesPlacement } from "@/locales";
import { useTranslations } from "@/hooks/translations";

const placementKey = EPlacementKeys["aura.placement.email.palmistry.discount"]

function SaveOff() {
    const { translate } = useTranslations(ELocalesPlacement.EmailMarketingPalmistryV2);
    const { products, currency, getText } = usePaywall({
        placementKey,
        localesPlacement: ELocalesPlacement.EmailMarketingPalmistryV2,
    });
    const activeProduct = products[0]
    const trialPrice = (activeProduct?.trialPrice || 0) / 100;
    const trialDuration = activeProduct?.trialDuration || 7

    const navigate = useNavigate();

    const handleNext = () => {
        navigate(routes.client.palmistryV2SecretDiscount());
    }

    return (
        <>
            <Blob className={styles.blob} />
            <Blob2 className={styles.blob2} />
            <img className={styles.gift} src={images("gift.svg")} alt="gift" />
            <Title className={styles.title}>
                {translate("save-off.title", { discount: getText("discount") })}
            </Title>
            <p className={styles.description}>
                {translate("save-off.instead", {
                    price: <span className={styles.price}>{addCurrency(trialPrice, currency)}</span>,
                    oldPrice: <span className={styles.discount}>
                        {translate("save-off.instead-old-price", {
                            oldPrice: addCurrency(getText("old.price") as string, currency)
                        })}
                    </span>
                })}
            </p>
            <p className={styles.point} style={{ marginTop: 12 }}>
                <img src={images("fire.png")} alt="fire" />
                {translate("save-off.trial-duration", {
                    trialDuration: trialDuration,
                    oldTrialDuration: <s>{translate("save-off.old-trial-duration", {
                        oldTrialDuration: getText("old.trial.duration")
                    })}</s>,
                })}
            </p>
            <p className={styles.point}>
                <img src={images("gift.png")} alt="gift" />
                {translate("save-off.discount-offer", { discount: getText("discount") })}
            </p>
            <Button className={styles.button} onClick={handleNext}>
                {translate("save-off.button-trial", { days: trialDuration })}
            </Button>
        </>
    )
}

export default SaveOff