fix
This commit is contained in:
@@ -261,7 +261,7 @@ export function getPoolsErrorMessage(e: unknown): string {
|
||||
if (typeof msg === 'string') return msg
|
||||
}
|
||||
if (e instanceof Error) {
|
||||
return e.message === 'Unauthorized' ? 'Сессия истекла — войдите снова.' : e.message
|
||||
return e.message === 'Unauthorized' ? 'Сессия истекла — перезагрузите страницу.' : e.message
|
||||
}
|
||||
return 'Произошла ошибка. Попробуйте ещё раз.'
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ export function getStakingErrorMessage(e: unknown): string {
|
||||
if (typeof msg === 'string') return msg
|
||||
}
|
||||
if (e instanceof Error) {
|
||||
return e.message === 'Unauthorized' ? 'Сессия истекла — войдите снова.' : e.message
|
||||
return e.message === 'Unauthorized' ? 'Сессия истекла — перезагрузите страницу.' : e.message
|
||||
}
|
||||
return 'Произошла ошибка. Попробуйте ещё раз.'
|
||||
}
|
||||
|
||||
@@ -44,10 +44,23 @@
|
||||
.amounts {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
gap: 14px;
|
||||
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 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { PrimaryButton } from '@shared/ui'
|
||||
import { truncateDecimals } from '@shared/lib/utils/truncateDecimals'
|
||||
import type { Pool, LpQuote } from '@features/pools'
|
||||
import { useWalletBalance, type WalletBalanceData } from '@features/wallet'
|
||||
import { formatFeeTier } from '../model/meta'
|
||||
import styles from './LpDepositCard.module.css'
|
||||
|
||||
@@ -25,16 +26,26 @@ interface Props {
|
||||
const DASH = '—'
|
||||
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({
|
||||
symbol,
|
||||
value,
|
||||
onChange,
|
||||
balance,
|
||||
}: {
|
||||
symbol: string
|
||||
value: string
|
||||
onChange: (v: string) => void
|
||||
balance: string
|
||||
}) {
|
||||
return (
|
||||
<div className={styles.amountField}>
|
||||
<div className={styles.amountRow}>
|
||||
<input
|
||||
className={styles.amountInput}
|
||||
@@ -52,6 +63,8 @@ function AmountInput({
|
||||
<span>{symbol}</span>
|
||||
</div>
|
||||
</div>
|
||||
<span className={styles.balance}>Баланс: {truncateDecimals(balance, 6)} {symbol}</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -99,6 +112,8 @@ export function LpDepositCard({
|
||||
onSlippageChange,
|
||||
onSubmit,
|
||||
}: Props) {
|
||||
const { data: walletBalance } = useWalletBalance('ETH')
|
||||
|
||||
if (!pool) {
|
||||
return (
|
||||
<div className={styles.card}>
|
||||
@@ -133,8 +148,18 @@ export function LpDepositCard({
|
||||
|
||||
<span className={styles.tag}>Суммы взноса</span>
|
||||
<div className={styles.amounts}>
|
||||
<AmountInput symbol={pool.symbol0} value={amount0} onChange={onAmount0Change} />
|
||||
<AmountInput symbol={pool.symbol1} value={amount1} onChange={onAmount1Change} />
|
||||
<AmountInput
|
||||
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>
|
||||
|
||||
<span className={styles.tag}>Диапазон цен ({pool.symbol1} за {pool.symbol0})</span>
|
||||
|
||||
Reference in New Issue
Block a user