import { useMemo } from "react"; import { Modal, Stack, Button } from "@mantine/core"; import { useTranslation } from "react-i18next"; import TrendingUpIcon from "@mui/icons-material/TrendingUpOutlined"; import AnimatedSlideBackground from "@app/components/onboarding/slides/AnimatedSlideBackground"; import styles from "@app/components/onboarding/InitialOnboardingModal/InitialOnboardingModal.module.css"; import { Z_INDEX_OVER_FULLSCREEN_SURFACE } from "@app/styles/zIndex"; import { navigateToSettings } from "@app/utils/settingsNavigation"; import { SpendCapMeterPanel, spendCapSnapshotFromWallet, } from "@app/components/shared/config/configSections/usageMeters"; import { useWallet } from "@app/hooks/useWallet"; interface SpendCapReachedModalProps { onClose: () => void; } function readColor(varName: string, fallback: string): string { return ( getComputedStyle(document.documentElement) .getPropertyValue(varName) .trim() || fallback ); } export function SpendCapReachedModal({ onClose }: SpendCapReachedModalProps) { const { t } = useTranslation(); const { wallet, loading } = useWallet(); // Resolve theme colours once; reading the CSS vars on every render would // force a style recalc. const gradientStops = useMemo<[string, string]>( () => [ readColor("--color-green-500", "#22c55e"), readColor("--color-green-700", "#15803d"), ], [], ); // Hold the modal back until the wallet resolves so the meter never flashes // placeholder numbers before the real ones land. if (loading || !wallet) return null; const snap = spendCapSnapshotFromWallet(wallet); const circles = [ { position: "bottom-left" as const, size: 270, color: "rgba(255, 255, 255, 0.25)", opacity: 0.9, amplitude: 24, duration: 4.5, offsetX: 18, offsetY: 14, }, { position: "top-right" as const, size: 300, color: "rgba(255, 255, 255, 0.2)", opacity: 0.9, amplitude: 28, duration: 4.5, delay: 0.5, offsetX: 24, offsetY: 18, }, ]; const handleRaiseCap = () => { onClose(); navigateToSettings("plan"); }; return (
{t("plan.spendCap.title", "You're on a Roll!")}
{t( "plan.spendCap.message", "You've made the most of this month's cap. That's a load of automation, AI and API work! Bump it up whenever you like to keep going.", )}
); }