-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
236 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,101 @@ | ||
|
||
import { Typography } from "@mui/material"; | ||
|
||
import HeaderBox from "./HeaderBox"; | ||
import ScoreSection from './ScoreSection'; | ||
import Pane from './Pane'; | ||
import Section from './Section'; | ||
|
||
import { Box, Stack } from '@mui/material'; | ||
|
||
import theme from '../theme'; | ||
|
||
|
||
const getSectionData = community => [ | ||
const getSectionData = (community, isSelectable, availableOptions, onSelectionChange) => [ | ||
{ | ||
header: 'State', | ||
cards: [ community.state ] | ||
cards: community.state, | ||
availableSelections: isSelectable ? availableOptions?.state || [] : [], | ||
}, | ||
{ | ||
header: 'Activities', | ||
cards: community.activities | ||
cards: community.activities, | ||
availableSelections: isSelectable ? availableOptions?.activities || [] : [], | ||
}, | ||
{ | ||
header: 'Sectors', | ||
cards: community.sectors | ||
cards: community.sectors, | ||
availableSelections: isSelectable ? availableOptions?.sectors || [] : [], | ||
}, | ||
{ | ||
header: 'Hazards', | ||
cards: community.hazards | ||
cards: community.hazards, | ||
availableSelections: isSelectable ? availableOptions?.hazards || [] : [], | ||
}, | ||
{ | ||
header: 'Size', | ||
cards: [ community.size ] | ||
cards: community.size, | ||
availableSelections: isSelectable ? availableOptions?.size || [] : [], | ||
} | ||
] | ||
.map((section, index) => { | ||
].map((section, index) => { | ||
section.type = 'community' | ||
section.key=`section${index}` | ||
section.key = `section${index}` | ||
section.isSelectable = isSelectable | ||
section.onSelectionChange = onSelectionChange | ||
return section | ||
}); | ||
|
||
export default function CommunityPane({ | ||
community, | ||
isSelectable = false, | ||
availableOptions = {}, | ||
onSelectionChange = () => {} | ||
}) { | ||
const sectionData = getSectionData(community, isSelectable, availableOptions, onSelectionChange); | ||
|
||
export default function CommunityPane({ community }) { | ||
const sectionData = getSectionData(community); | ||
return ( | ||
<Box | ||
sx={{ | ||
bgcolor: 'primary.white', | ||
borderRadius: 4, | ||
border: `0px solid ${theme.palette.primary.white}`, | ||
pr: 1, | ||
pl: 1, | ||
pt: 0, | ||
pb: 1, | ||
}} | ||
> | ||
<Stack | ||
sx={{ width: '100%' }}> | ||
<HeaderBox> | ||
<Typography | ||
color="primary.main" | ||
fontWeight="700" | ||
align="center" | ||
variant="h5" | ||
sx={{ | ||
fontSize: { | ||
'xs': '1rem', | ||
'lg': '1.5rem', | ||
} | ||
}} | ||
>{ community.name }</Typography> | ||
</HeaderBox> | ||
{ /* filler box to match height of "Matched Practitioners" heading */ } | ||
<Box sx={{ height: '40px', width: '100%', }}></Box> | ||
</Stack> | ||
<Pane | ||
boxShadow={2} | ||
sx={{ pl: 1 }}> | ||
{ | ||
sectionData.map((section, index) => { | ||
return Section(section) | ||
}) | ||
} | ||
<ScoreSection | ||
<Box | ||
sx={{ | ||
pr: 2, | ||
bgcolor: 'primary.white', | ||
borderRadius: 4, | ||
border: `0px solid ${theme.palette.primary.white}`, | ||
pr: 1, | ||
pl: 1, | ||
justifyContent: 'space-between', | ||
}} | ||
pt: 0, | ||
pb: 1, | ||
}} | ||
> | ||
<Stack sx={{ width: '100%' }}> | ||
<HeaderBox> | ||
<Typography | ||
color="primary.main" | ||
fontWeight="700" | ||
align="center" | ||
variant="h5" | ||
sx={{ | ||
fontSize: { | ||
'xs': '1rem', | ||
'lg': '1.5rem', | ||
} | ||
}} | ||
>{community.name}</Typography> | ||
</HeaderBox> | ||
{/* filler box to match height of "Matched Practitioners" heading */} | ||
<Box sx={{ height: '40px', width: '100%', }}></Box> | ||
</Stack> | ||
<Pane | ||
boxShadow={2} | ||
sx={{ pl: 1 }} | ||
> | ||
<div>Total</div> | ||
<div>{ community.totalCategories }</div> | ||
</ScoreSection> | ||
</Pane> | ||
</Box> | ||
{sectionData.map((section, index) => { | ||
return Section(section) | ||
})} | ||
<ScoreSection | ||
sx={{ | ||
pr: 2, | ||
pl: 1, | ||
justifyContent: 'space-between', | ||
}} | ||
> | ||
<div>Total</div> | ||
<div>{community.totalCategories}</div> | ||
</ScoreSection> | ||
</Pane> | ||
</Box> | ||
) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,39 @@ | ||
|
||
import { Typography, Box, Stack } from "@mui/material" | ||
|
||
import Cell from "./Cell" | ||
import DropDownSelector from "./DropDownSelector" | ||
import theme from '../theme' | ||
|
||
export default function Section ({ header='', type, cards, key }) { | ||
export default function Section({ header='', type, cards, key, isSelectable, onSelectionChange, availableSelections = [] }) { | ||
const cells = cards.map((label, index) => Cell({ label, type, key: `${key}_row${index}` })) | ||
|
||
return ( | ||
<Box key={ key } sx={{ mb: 2 }}> | ||
<Box sx={{ minHeight: '40px', mt: '5px', mb: '5px' }}> | ||
<Typography variant="body1" >{ header }</Typography> | ||
<Box key={key} sx={{ mb: 2 }}> | ||
{/* Section Header */} | ||
<Box sx={{ minHeight: '40px', mt: '5px', mb: '5px' }}> | ||
<Typography variant="body1">{header}</Typography> | ||
</Box> | ||
|
||
{/* Selector if isSelectable */} | ||
{isSelectable && ( | ||
<Box sx={{ | ||
mb: 2, | ||
backgroundColor: theme.palette.primary.white, | ||
borderRadius: 2, | ||
p: 2 | ||
}}> | ||
<DropDownSelector | ||
availableSelections={availableSelections} | ||
selections={cards} | ||
setSelections={(newSelections) => onSelectionChange(header.toLowerCase(), newSelections)} | ||
option={header} | ||
/> | ||
</Box> | ||
)} | ||
|
||
{/* Content */} | ||
<Stack gap={2} useFlexGap={true}> | ||
{cells} | ||
</Stack> | ||
</Box> | ||
<Stack gap={2} useFlexGap={true}> | ||
{ cells } | ||
</Stack> | ||
</Box> | ||
) | ||
} | ||
} |
Oops, something went wrong.