Skip to content

Commit

Permalink
refactor: show info when graph is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
maui-r committed Nov 14, 2022
1 parent ce5680a commit f40c813
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
13 changes: 10 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { useEffect, useMemo } from 'react'
import { styled } from '@mui/material/styles'
import { createTheme, CssBaseline, Grid, ThemeProvider, useMediaQuery } from '@mui/material'
import { Alert, Box, createTheme, CssBaseline, Grid, ThemeProvider, useMediaQuery } from '@mui/material'
import { SnackbarProvider } from 'notistack'
import { Provider as UrqlProvider } from 'urql'
import shallow from 'zustand/shallow'
import { WagmiConfig } from 'wagmi'
import wagmiClient from './wallets'
import { ColorMode } from './types'
import { useAppPersistStore, useAppStore, useOptimisticCache } from './stores'
import { useAppPersistStore, useAppStore, useNodeStore, useOptimisticCache } from './stores'
import Header from './components/Header'
import SettingsDrawer from './components/Settings'
import api from './lens/client'
Expand Down Expand Up @@ -97,6 +98,8 @@ const App = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currentAddress, currentProfileId])

const hasNodes = useNodeStore((state) => Object.keys(state.nodes).length > 0, shallow)

return (
<ThemeProvider theme={theme}>
<CssBaseline />
Expand All @@ -109,11 +112,15 @@ const App = () => {
<Dialogs />
<SettingsDrawer />

{!hasNodes ?
<Box sx={{ p: 1 }}>
<Alert severity='info'>Use the search bar to add some nodes 👆</Alert>
</Box>
: null}
<Content container>
<NodeDetails />
<Graph3D />
</Content>

</Wrapper>

</UrqlProvider>
Expand Down
20 changes: 12 additions & 8 deletions src/components/NodeDetails/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import { Alert, Box, Grid } from '@mui/material'
import { useAppStore } from '../../stores'
import shallow from 'zustand/shallow'
import { useAppStore, useNodeStore } from '../../stores'
import Profile from './Profile'

export const NodeDetails = () => {
const selectedNodeId = useAppStore((state) => state.selectedNodeId)
const hasNodes = useNodeStore((state) => Object.keys(state.nodes).length > 0, shallow)


return <Grid item xs={6} sm={4} md={3} xl={2}>
{
selectedNodeId
?
<Profile profileId={selectedNodeId} />
:
<Box sx={{ p: 1 }}>
{selectedNodeId ?
<Profile profileId={selectedNodeId} />
:
hasNodes ?
<Box sx={{ p: 1 }} >
<Alert severity='info'>Click on a node to show info</Alert>
</Box>
:
null
}
</Grid>
</Grid >
}

0 comments on commit f40c813

Please sign in to comment.