import Image from "next/image"; import { useTranslations } from "next-intl"; import { Card, Typography } from "@/components/ui"; import { IFunnelPaymentVariant } from "@/entities/session/funnel/types"; import { getFormattedPrice } from "@/shared/utils/price"; import { Currency } from "@/types"; import styles from "./Offer.module.scss"; interface OfferProps { offer: IFunnelPaymentVariant; isActive: boolean; className?: string; onClick: () => void; } export default function Offer(props: OfferProps) { const { offer, isActive, className, onClick } = props; const { key, price, oldPrice } = offer; const productKey = key.replaceAll(".", "_"); const t = useTranslations( `AdditionalPurchases.add-guides.products.${productKey}` ); const currency = Currency.USD; const subtitle = t.has("subtitle") ? t("subtitle") : undefined; const discount = (((oldPrice || 0) - price) / (oldPrice || 0)) * 100; const emoji = t.has("emoji") ? t("emoji") : undefined; const typographyColor = isActive ? "white" : "default"; return (
{/* TODO: add icon after merge with chat */} {isActive && ( Checkmark )}
{t("title")} {!!subtitle?.length && productKey !== "main_skip_offer" && ( {subtitle} )}
{productKey !== "main_skip_offer" && ( {t.rich("price", { price: () => ( {getFormattedPrice(price, currency)} ), oldPrice: () => ( {getFormattedPrice(oldPrice || 0, currency)} ), })} )} {productKey === "main_skip_offer" && ( {subtitle} )} {productKey !== "ultra_pack" && (
{t("discount", { discount: discount || 0, })}
)}
); }