Skip to content

Commit

Permalink
fix: do not render the component without items
Browse files Browse the repository at this point in the history
  • Loading branch information
DiogoSoaress committed Oct 29, 2024
1 parent 6ce6722 commit b5eeca0
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/components/Wallet/BigCardsGrid/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,26 @@ import type { BaseBlock } from '@/components/Home/types'
import layoutCss from '@/components/common/styles.module.css'
import getComponentByName from '@/lib/getComponentByName'

const BigCardsGrid = ({ items }: { items: Array<BaseBlock['items'] & { component: string }> }) => (
<Container className={layoutCss.containerShort}>
<Grid container spacing={{ xs: '30px', xl: '50px' }}>
{items?.map((item, index) => {
const { component } = item
const BigCardsGrid = ({ items }: { items: Array<BaseBlock['items'] & { component: string }> }) => {
if (!items || !items.length) return null

const CardComponent = getComponentByName(`${component}`, () => <></>)
return (
<Container className={layoutCss.containerShort}>
<Grid container spacing={{ xs: '30px', xl: '50px' }}>
{items?.map((item, index) => {
const { component } = item

return (
<Grid key={index} item xs={12} md={6}>
<CardComponent {...item} />
</Grid>
)
})}
</Grid>
</Container>
)
const CardComponent = getComponentByName(component, () => <></>)

return (
<Grid key={index} item xs={12} md={6}>
<CardComponent {...item} />
</Grid>
)
})}
</Grid>
</Container>
)
}

export default BigCardsGrid

0 comments on commit b5eeca0

Please sign in to comment.