profile refactor
This commit is contained in:
6
src/pages/profile/ui/items/MnemonicItem.module.css
Normal file
6
src/pages/profile/ui/items/MnemonicItem.module.css
Normal file
@@ -0,0 +1,6 @@
|
||||
.hint {
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
@@ -1,10 +1,32 @@
|
||||
import { useMe } from '@features/auth'
|
||||
import { MnemonicSection } from '@widgets/profile'
|
||||
import { Spinner } from '@shared/ui'
|
||||
import { useState } from 'react'
|
||||
import { useRevealMnemonic } from '@features/wallet'
|
||||
import { SeedPhraseWidget } from '@widgets/seed-phrase'
|
||||
import { ProfileSection } from '@widgets/profile'
|
||||
import { Button, Spinner } from '@shared/ui'
|
||||
import styles from './MnemonicItem.module.css'
|
||||
|
||||
// «Мнемоническая фраза» dashboard item.
|
||||
// «Мнемоническая фраза» dashboard item. The mnemonic is fetched only after the
|
||||
// user explicitly clicks "Показать мнемонику" (the query stays disabled until
|
||||
// then), then the seed-phrase content is shown inline.
|
||||
export function MnemonicItem() {
|
||||
const { isLoading } = useMe()
|
||||
const [revealed, setRevealed] = useState(false)
|
||||
const { data: mnemonic, isLoading } = useRevealMnemonic(revealed)
|
||||
|
||||
if (!revealed) {
|
||||
return (
|
||||
<ProfileSection
|
||||
title="Мнемоническая фраза"
|
||||
actions={<Button variant="danger" onClick={() => setRevealed(true)}>Показать мнемонику</Button>}
|
||||
>
|
||||
<p className={styles.hint}>
|
||||
Сид-фраза из 12 слов для восстановления кошелька. Никогда не передавайте её третьим лицам.
|
||||
</p>
|
||||
</ProfileSection>
|
||||
)
|
||||
}
|
||||
|
||||
if (isLoading) return <Spinner fullscreen label="Загрузка" />
|
||||
return <MnemonicSection />
|
||||
|
||||
const words = mnemonic ? mnemonic.split(' ') : []
|
||||
return <SeedPhraseWidget words={words} showProfileLink={false} />
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user