profile refactor
This commit is contained in:
@@ -7,7 +7,7 @@ import styles from './ConverterPage.module.css'
|
||||
// Пока покупка валюты для физлиц недоступна — показываем им заглушку вместо
|
||||
// конвертера. Для юрлиц всё работает как прежде.
|
||||
// Чтобы вернуть конвертер физлицам, поставьте PURCHASE_ENABLED = true.
|
||||
const PURCHASE_ENABLED = false
|
||||
const PURCHASE_ENABLED = true
|
||||
|
||||
export function ConverterPage() {
|
||||
const { data, isLoading } = useMe()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState } from 'react'
|
||||
import { useRef, useState } from 'react'
|
||||
import styles from './SwapConfirmModal.module.css'
|
||||
|
||||
interface SwapData {
|
||||
@@ -24,17 +24,28 @@ export function SwapConfirmModal({ data, insufficientBalance, onConfirm, onClose
|
||||
const { details, fees } = data
|
||||
const { currencyIn, currencyOut, totalImpact, rate } = details
|
||||
const [closing, setClosing] = useState(false)
|
||||
// Which action to run once the exit animation finishes.
|
||||
const pendingAction = useRef<'close' | 'confirm'>('close')
|
||||
|
||||
const impactPercent = parseFloat(totalImpact.percent)
|
||||
const rateFormatted = parseFloat(rate).toFixed(4)
|
||||
|
||||
// Play the exit animation first, then actually unmount once it ends.
|
||||
// Trigger the exit animation; the real action fires on animation end so every
|
||||
// close path (×, backdrop, confirm) plays the same closing transition.
|
||||
function requestClose() {
|
||||
pendingAction.current = 'close'
|
||||
setClosing(true)
|
||||
}
|
||||
|
||||
function requestConfirm() {
|
||||
pendingAction.current = 'confirm'
|
||||
setClosing(true)
|
||||
}
|
||||
|
||||
function handleAnimationEnd() {
|
||||
if (closing) onClose()
|
||||
if (!closing) return
|
||||
if (pendingAction.current === 'confirm') onConfirm()
|
||||
else onClose()
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -94,7 +105,7 @@ export function SwapConfirmModal({ data, insufficientBalance, onConfirm, onClose
|
||||
</p>
|
||||
)}
|
||||
|
||||
<button className={styles.confirmBtn} onClick={onConfirm}>
|
||||
<button className={styles.confirmBtn} onClick={requestConfirm}>
|
||||
Подтвердить
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState } from 'react'
|
||||
import { useRef, useState } from 'react'
|
||||
import type { TrxSwapQuoteData } from '@features/wallet'
|
||||
import styles from './TrxConfirmModal.module.css'
|
||||
|
||||
@@ -15,14 +15,25 @@ interface Props {
|
||||
export function TrxConfirmModal({ quote, fromSymbol, toSymbol, amountHuman, insufficientBalance, onConfirm, onClose }: Props) {
|
||||
const { expectedOutFormatted, minOutFormatted, fees } = quote
|
||||
const [closing, setClosing] = useState(false)
|
||||
// Which action to run once the exit animation finishes.
|
||||
const pendingAction = useRef<'close' | 'confirm'>('close')
|
||||
|
||||
// Play the exit animation first, then actually unmount once it ends.
|
||||
// Trigger the exit animation; the real action fires on animation end so every
|
||||
// close path (×, backdrop, confirm) plays the same closing transition.
|
||||
function requestClose() {
|
||||
pendingAction.current = 'close'
|
||||
setClosing(true)
|
||||
}
|
||||
|
||||
function requestConfirm() {
|
||||
pendingAction.current = 'confirm'
|
||||
setClosing(true)
|
||||
}
|
||||
|
||||
function handleAnimationEnd() {
|
||||
if (closing) onClose()
|
||||
if (!closing) return
|
||||
if (pendingAction.current === 'confirm') onConfirm()
|
||||
else onClose()
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -67,7 +78,7 @@ export function TrxConfirmModal({ quote, fromSymbol, toSymbol, amountHuman, insu
|
||||
</p>
|
||||
)}
|
||||
|
||||
<button className={styles.confirmBtn} onClick={onConfirm}>
|
||||
<button className={styles.confirmBtn} onClick={requestConfirm}>
|
||||
Подтвердить
|
||||
</button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user