Skip to content

Commit

Permalink
Add Profile empty state
Browse files Browse the repository at this point in the history
  • Loading branch information
buberdds committed Sep 21, 2023
1 parent 8e35762 commit 0367804
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 4 deletions.
Expand Up @@ -8,7 +8,7 @@ const renderComponent = (store: any) =>
render(
<Provider store={store}>
<ThemeProvider>
<Profile />
<Profile closeHandler={() => {}} />
</ThemeProvider>
</Provider>,
)
Expand Down
54 changes: 52 additions & 2 deletions src/app/components/Toolbar/Features/Profile/index.tsx
@@ -1,11 +1,61 @@
import { useContext } from 'react'
import { useContext, ReactNode } from 'react'
import { useSelector } from 'react-redux'
import { useNavigate } from 'react-router-dom'
import { Trans, useTranslation } from 'react-i18next'
import { Box } from 'grommet/es6/components/Box'
import { Button } from 'grommet/es6/components/Button'
import { ResponsiveContext } from 'grommet/es6/contexts/ResponsiveContext'
import { User } from 'grommet-icons/es6/icons/User'
import { selectUnlockedStatus } from 'app/state/selectUnlockedStatus'
import { UpdatePassword } from './UpdatePassword'
import { layerOverlayMinHeight } from './../layer'

export const Profile = () => {
type ProfileEmptyStateProps = {
children: ReactNode
}

const ProfileEmptyState = ({ children }: ProfileEmptyStateProps) => (
<Box gap="medium" align="center" pad={{ top: 'large' }}>
<User size="36px" color="currentColor" />
<Box pad="large">{children}</Box>
</Box>
)

interface ProfileProps {
closeHandler: () => any
}

export const Profile = ({ closeHandler }: ProfileProps) => {
const { t } = useTranslation()
const isMobile = useContext(ResponsiveContext) === 'small'
const unlockedStatus = useSelector(selectUnlockedStatus)
const isAvailable = unlockedStatus === 'unlockedProfile'
const navigate = useNavigate()

if (!isAvailable) {
return (
<ProfileEmptyState>
<Box style={{ display: 'block' }}>
<Trans
i18nKey="toolbar.profile.notAvailable"
t={t}
components={{
OpenWalletButton: (
<Button
color="link"
onClick={() => {
closeHandler()
navigate('/open-wallet')
}}
/>
),
}}
defaults="You can setup your profile while <OpenWalletButton>opening a wallet</OpenWalletButton>."
/>
</Box>
</ProfileEmptyState>
)
}

return (
<Box flex="grow" height={{ min: isMobile ? 'auto' : layerOverlayMinHeight }} pad={{ vertical: 'medium' }}>
Expand Down
Expand Up @@ -76,7 +76,7 @@ export const SettingsButton = memo(() => {
<Contacts closeHandler={hideLayer} />
</Tab>
<Tab data-testid="toolbar-profile-tab" title={t('toolbar.settings.profile', 'Profile')}>
<Profile />
<Profile closeHandler={hideLayer} />
</Tab>
</Tabs>
</Box>
Expand Down
1 change: 1 addition & 0 deletions src/locales/en/translation.json
Expand Up @@ -412,6 +412,7 @@
"testnet": "Testnet"
},
"profile": {
"notAvailable": "You can setup your profile while <OpenWalletButton>opening a wallet</OpenWalletButton>.",
"password": {
"current": "Current password",
"enterCurrent": "Enter your current password",
Expand Down

0 comments on commit 0367804

Please sign in to comment.