"use client"; import { useMemo, useState } from "react"; import { useTranslations } from "next-intl"; import { RESOLUTION_ORDER, renderSecondsCost, type SecondsPlan, } from "@/lib/plans-catalog"; interface Props { plans: SecondsPlan[]; } /** * Interactive "how many seconds do I need" helper. The user picks a video length * and resolution; we show the per-render cost (length × resolution multiplier) * and how many such videos each paid plan's monthly seconds would cover. */ export function SecondsCalculator({ plans }: Props) { const t = useTranslations("pricing"); const [length, setLength] = useState(15); const [resolution, setResolution] = useState("720p"); const cost = useMemo( () => renderSecondsCost(length, resolution), [length, resolution] ); const paidPlans = plans.filter((p) => p.priceTomans > 0); return (

{t("calcTitle")}

{t("calcDesc")}

{/* Length */}
setLength(Number(e.target.value))} className="w-full accent-indigo-600" />
{/* Resolution */}
{RESOLUTION_ORDER.map((r) => ( ))}
{/* Cost */}

{t("calcCost")}

{cost}{" "} {t("calcSecondsUnit")}

{paidPlans.length > 0 && (

{t("calcRendersWith")}

{paidPlans.map((p) => ( {p.name} {": "} {t("calcVideosFmt", { count: Math.floor(p.secondsCharge / Math.max(cost, 1)), })} ))}
)}
); }