This commit is contained in:
2026-06-18 15:57:24 +03:00
parent 594ba4fd07
commit 7236bab31b
4 changed files with 58 additions and 20 deletions

View File

@@ -261,7 +261,7 @@ export function getPoolsErrorMessage(e: unknown): string {
if (typeof msg === 'string') return msg if (typeof msg === 'string') return msg
} }
if (e instanceof Error) { if (e instanceof Error) {
return e.message === 'Unauthorized' ? 'Сессия истекла — войдите снова.' : e.message return e.message === 'Unauthorized' ? 'Сессия истекла — перезагрузите страницу.' : e.message
} }
return 'Произошла ошибка. Попробуйте ещё раз.' return 'Произошла ошибка. Попробуйте ещё раз.'
} }

View File

@@ -269,7 +269,7 @@ export function getStakingErrorMessage(e: unknown): string {
if (typeof msg === 'string') return msg if (typeof msg === 'string') return msg
} }
if (e instanceof Error) { if (e instanceof Error) {
return e.message === 'Unauthorized' ? 'Сессия истекла — войдите снова.' : e.message return e.message === 'Unauthorized' ? 'Сессия истекла — перезагрузите страницу.' : e.message
} }
return 'Произошла ошибка. Попробуйте ещё раз.' return 'Произошла ошибка. Попробуйте ещё раз.'
} }

View File

@@ -44,10 +44,23 @@
.amounts { .amounts {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 10px; gap: 14px;
margin-bottom: 20px; margin-bottom: 20px;
} }
.amountField {
display: flex;
flex-direction: column;
gap: 6px;
}
.balance {
font-size: 13px;
color: var(--text-secondary);
text-align: right;
padding: 0 4px;
}
.amountRow { .amountRow {
display: flex; display: flex;
align-items: center; align-items: center;

View File

@@ -1,6 +1,7 @@
import { PrimaryButton } from '@shared/ui' import { PrimaryButton } from '@shared/ui'
import { truncateDecimals } from '@shared/lib/utils/truncateDecimals' import { truncateDecimals } from '@shared/lib/utils/truncateDecimals'
import type { Pool, LpQuote } from '@features/pools' import type { Pool, LpQuote } from '@features/pools'
import { useWalletBalance, type WalletBalanceData } from '@features/wallet'
import { formatFeeTier } from '../model/meta' import { formatFeeTier } from '../model/meta'
import styles from './LpDepositCard.module.css' import styles from './LpDepositCard.module.css'
@@ -25,32 +26,44 @@ interface Props {
const DASH = '—' const DASH = '—'
const decimalRe = /^(\d+\.?\d*|\.?\d*)$/ const decimalRe = /^(\d+\.?\d*|\.?\d*)$/
// Баланс ноги по символу: нативный токен (chain === символ) берём из native, остальное — из tokens.
function legBalance(wb: WalletBalanceData | undefined, symbol: string): string {
if (!wb) return '0'
if (symbol === wb.chain) return wb.native.formatted
return wb.tokens[symbol]?.formatted ?? '0'
}
function AmountInput({ function AmountInput({
symbol, symbol,
value, value,
onChange, onChange,
balance,
}: { }: {
symbol: string symbol: string
value: string value: string
onChange: (v: string) => void onChange: (v: string) => void
balance: string
}) { }) {
return ( return (
<div className={styles.amountRow}> <div className={styles.amountField}>
<input <div className={styles.amountRow}>
className={styles.amountInput} <input
type="text" className={styles.amountInput}
inputMode="decimal" type="text"
value={value} inputMode="decimal"
onChange={(e) => { value={value}
const v = e.target.value onChange={(e) => {
if (decimalRe.test(v) || v === '') onChange(v) const v = e.target.value
}} if (decimalRe.test(v) || v === '') onChange(v)
placeholder="0" }}
aria-label={`Сумма ${symbol}`} placeholder="0"
/> aria-label={`Сумма ${symbol}`}
<div className={styles.token}> />
<span>{symbol}</span> <div className={styles.token}>
<span>{symbol}</span>
</div>
</div> </div>
<span className={styles.balance}>Баланс: {truncateDecimals(balance, 6)} {symbol}</span>
</div> </div>
) )
} }
@@ -99,6 +112,8 @@ export function LpDepositCard({
onSlippageChange, onSlippageChange,
onSubmit, onSubmit,
}: Props) { }: Props) {
const { data: walletBalance } = useWalletBalance('ETH')
if (!pool) { if (!pool) {
return ( return (
<div className={styles.card}> <div className={styles.card}>
@@ -133,8 +148,18 @@ export function LpDepositCard({
<span className={styles.tag}>Суммы взноса</span> <span className={styles.tag}>Суммы взноса</span>
<div className={styles.amounts}> <div className={styles.amounts}>
<AmountInput symbol={pool.symbol0} value={amount0} onChange={onAmount0Change} /> <AmountInput
<AmountInput symbol={pool.symbol1} value={amount1} onChange={onAmount1Change} /> symbol={pool.symbol0}
value={amount0}
onChange={onAmount0Change}
balance={legBalance(walletBalance, pool.symbol0)}
/>
<AmountInput
symbol={pool.symbol1}
value={amount1}
onChange={onAmount1Change}
balance={legBalance(walletBalance, pool.symbol1)}
/>
</div> </div>
<span className={styles.tag}>Диапазон цен ({pool.symbol1} за {pool.symbol0})</span> <span className={styles.tag}>Диапазон цен ({pool.symbol1} за {pool.symbol0})</span>