Skip to content

Commit

Permalink
basic functionality of adding self service is working
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffbliss committed Nov 14, 2024
1 parent 8d463fb commit f3dcdf1
Show file tree
Hide file tree
Showing 7 changed files with 346 additions and 295 deletions.
16 changes: 16 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
"dependencies": {
"@emotion/react": "^11.13.0",
"@emotion/styled": "^11.13.0",
"@mui/material": "^5.16.6",
"@mui/icons-material": "^5.16.6",
"@mui/material": "^5.16.6",
"airtable": "^0.12.2",
"prettier": "^3.3.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.26.0"
Expand Down
55 changes: 37 additions & 18 deletions src/components/Cell.jsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,54 @@
import { useContext } from 'react';
import { Box, Button, Typography } from '@mui/material';

import { useContext } from "react";
import { Box, Typography } from "@mui/material";
import { RowHoverContext, SetHoverRowContext } from './RowHoverContext';

import { RowHoverContext, SetHoverRowContext } from "./RowHoverContext";
import PractMatchSymbol from './svg/PractMatchSymbol';

import PractMatchSymbol from "./svg/PractMatchSymbol"
import theme from '../theme';

import theme from "../theme";

export default function Cell ({ label, type, key }) {
export default function Cell(props) {
const { label, type, key, isSelectable, handleRemove, rowToHover } = props;
const hoverRow = useContext(RowHoverContext);
const setHoverRow = useContext(SetHoverRowContext);

let content;
if (type === 'community') {
content = <Typography variant="body1" sx={{ textAlign: 'left' }}>
{ label }
</Typography>
content = (
<Typography
variant="body1"
sx={{ textAlign: 'left', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}
>
{label}
{isSelectable && (
<Button
onClick={() => handleRemove(label)}
sx={{
backgroundColor: 'white',
color: 'black',
borderRadius: '50%',
minWidth: '40px',
minHeight: '40px',
padding: 0,
}}
>
x
</Button>
)}
</Typography>
);
} else {
content = PractMatchSymbol({ label })
content = PractMatchSymbol({ label });
}
return (
<Box
onMouseEnter={ e => {
onMouseEnter={(e) => {
setHoverRow(key);
}}
onMouseLeave={ e => {
onMouseLeave={(e) => {
setHoverRow(null);
}}
key={ key }
key={key}
sx={{
display: 'flex',
flexDirection: 'column',
Expand All @@ -42,8 +62,7 @@ export default function Cell ({ label, type, key }) {
justifyContent: 'center',
}}
>
{ content }
</Box>
)
{content}
</Box>
);
}

174 changes: 89 additions & 85 deletions src/components/CommunityPane.jsx
Original file line number Diff line number Diff line change
@@ -1,101 +1,105 @@
import { Typography } from "@mui/material";
import HeaderBox from "./HeaderBox";
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, isSelectable, availableOptions, onSelectionChange) => [
{
header: 'State',
cards: community.state,
availableSelections: isSelectable ? availableOptions?.state || [] : [],
},
{
header: 'Activities',
cards: community.activities,
availableSelections: isSelectable ? availableOptions?.activities || [] : [],
},
{
header: 'Sectors',
cards: community.sectors,
availableSelections: isSelectable ? availableOptions?.sectors || [] : [],
},
{
header: 'Hazards',
cards: community.hazards,
availableSelections: isSelectable ? availableOptions?.hazards || [] : [],
},
{
header: 'Size',
cards: community.size,
availableSelections: isSelectable ? availableOptions?.size || [] : [],
}
].map((section, index) => {
section.type = 'community'
section.key = `section${index}`
section.isSelectable = isSelectable
section.onSelectionChange = onSelectionChange
return section
});
const getSectionData = (community, isSelectable, availableOptions, onSelectionChange) =>
[
{
header: 'State',
cards: community.state,
availableSelections: isSelectable ? availableOptions?.state || [] : [],
},
{
header: 'Activities',
cards: community.activities,
availableSelections: isSelectable ? availableOptions?.activities || [] : [],
},
{
header: 'Sectors',
cards: community.sectors,
availableSelections: isSelectable ? availableOptions?.sectors || [] : [],
},
{
header: 'Hazards',
cards: community.hazards,
availableSelections: isSelectable ? availableOptions?.hazards || [] : [],
},
{
header: 'Size',
cards: community.size,
availableSelections: isSelectable ? availableOptions?.size || [] : [],
},
].map((section, index) => {
section.type = 'community';
section.key = `section${index}`;
section.rowToHover = `section${index}`;
section.isSelectable = isSelectable;
section.onSelectionChange = onSelectionChange;
return section;
});

export default function CommunityPane({
community,
isSelectable = false,
availableOptions = {},
onSelectionChange = () => {}
}) {
community,
isSelectable = false,
availableOptions = {},
onSelectionChange = () => {},
}) {
const sectionData = getSectionData(community, isSelectable, availableOptions, onSelectionChange);

return (
<Box
<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%' }} />
</Stack>
<Pane
boxShadow={2}
sx={{ pl: 1 }}
>
{sectionData.map((section, index) => {
return Section(section);
})}
<ScoreSection
sx={{
bgcolor: 'primary.white',
borderRadius: 4,
border: `0px solid ${theme.palette.primary.white}`,
pr: 1,
pr: 2,
pl: 1,
pt: 0,
pb: 1,
justifyContent: 'space-between',
}}
>
<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
sx={{
pr: 2,
pl: 1,
justifyContent: 'space-between',
}}
>
<div>Total</div>
<div>{community.totalCategories}</div>
</ScoreSection>
</Pane>
</Box>
)
<div>Total</div>
<div>{community.totalCategories}</div>
</ScoreSection>
</Pane>
</Box>
);
}
Loading

0 comments on commit f3dcdf1

Please sign in to comment.