fix
This commit is contained in:
@@ -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 'Произошла ошибка. Попробуйте ещё раз.'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 'Произошла ошибка. Попробуйте ещё раз.'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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,16 +26,26 @@ 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.amountField}>
|
||||||
<div className={styles.amountRow}>
|
<div className={styles.amountRow}>
|
||||||
<input
|
<input
|
||||||
className={styles.amountInput}
|
className={styles.amountInput}
|
||||||
@@ -52,6 +63,8 @@ function AmountInput({
|
|||||||
<span>{symbol}</span>
|
<span>{symbol}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<span className={styles.balance}>Баланс: {truncateDecimals(balance, 6)} {symbol}</span>
|
||||||
|
</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>
|
||||||
|
|||||||
Reference in New Issue
Block a user