import { useTranslations } from "next-intl"; import clsx from "clsx"; import { Card, Icon, IconName, Typography } from "@/components/ui"; import { IFunnelPaymentVariant } from "@/entities/session/funnel/types"; import { getFormattedPrice } from "@/shared/utils/price"; import { Currency } from "@/types"; import styles from "./VideoGuidesOffer.module.scss"; interface VideoGuidesOfferProps { offer: IFunnelPaymentVariant; isActive: boolean; className?: string; onClick: () => void; } export default function VideoGuidesOffer(props: VideoGuidesOfferProps) { const { offer, isActive, className, onClick } = props; const { key, price, oldPrice } = offer; const productKey = key.replaceAll(".", "_"); const t = useTranslations( `AdditionalPurchases.video-guides.products.${productKey}` ); const currency = Currency.USD; const subtitle = t.has("subtitle") ? t("subtitle") : undefined; const discount = Math.round( (((oldPrice || 0) - price) / (oldPrice || 0)) * 100 ); const emoji = t.has("emoji") ? t("emoji") : undefined; return (
{t("title")} {subtitle && ( {subtitle} )}
{t.rich("price", { price: () => ( {getFormattedPrice(price, currency)} ), oldPrice: () => ( {getFormattedPrice(oldPrice || 0, currency)} ), })} {t("discount", { discount: discount || 0, })}
); }