/** * Price Change Confirmation Dialog (Final Freeze Architecture) * * Displayed when the price changes between Preview and Submit * beyond the user's configured slippage threshold. * * @see Intent: blocklets/core/ai/intent/20260112-dynamic-price.md */ import { Box, Button, Dialog, DialogActions, DialogContent, DialogTitle, Stack, Typography } from '@mui/material'; import WarningAmberIcon from '@mui/icons-material/WarningAmber'; import { useLocaleContext } from '@arcblock/ux/lib/Locale/context'; export interface PriceChangeConfirmProps { open: boolean; previewRate?: string; submitRate?: string; changePercent: number; onConfirm: () => void; onCancel: () => void; loading?: boolean; } export default function PriceChangeConfirm({ open, previewRate = undefined, submitRate = undefined, changePercent, onConfirm, onCancel, loading = false, }: PriceChangeConfirmProps) { const { t } = useLocaleContext(); const changeDirection = changePercent > 0 ? 'increased' : 'decreased'; const absChangePercent = Math.abs(changePercent); return ( {t('payment.checkout.priceChange.title', { fallback: 'Price Changed' })} {t('payment.checkout.priceChange.description', { fallback: `The exchange rate has ${changeDirection} by ${absChangePercent.toFixed(2)}% since you started this checkout.`, direction: changeDirection, percent: absChangePercent.toFixed(2), })} {(previewRate || submitRate) && ( {previewRate && ( {t('payment.checkout.priceChange.previewRate', { fallback: 'Preview Rate' })}: {previewRate} )} {submitRate && ( {t('payment.checkout.priceChange.currentRate', { fallback: 'Current Rate' })}: {submitRate} )} {t('payment.checkout.priceChange.change', { fallback: 'Change' })}: 0 ? 'error.main' : 'success.main'}> {changePercent > 0 ? '+' : ''} {changePercent.toFixed(2)}% )} {t('payment.checkout.priceChange.confirm', { fallback: 'Do you want to continue with the new price?', })} ); }