-
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.
Merge pull request #9 from nemac/develop
Develop
- Loading branch information
Showing
4 changed files
with
174 additions
and
251 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 |
---|---|---|
@@ -0,0 +1,141 @@ | ||
import { useState } from 'react'; | ||
import { CssBaseline, Stack, Container, Typography, Box, Button } from '@mui/material'; | ||
import ReadMoreIcon from '@mui/icons-material/ReadMore'; | ||
import { ThemeProvider } from '@mui/material/styles'; | ||
|
||
import PractitionerPane from './PractitionerPane'; | ||
import CommunityPane from './CommunityPane'; | ||
import theme from '../theme'; | ||
import { RowHoverContext, SetHoverRowContext } from './RowHoverContext'; | ||
|
||
export default function ComparisonBoard({ | ||
community, | ||
practitioners, | ||
isSelectable = false, | ||
availableOptions = {}, | ||
onSelectionChange = () => {}, | ||
displayCount = 3, | ||
setDisplayCount = () => {}, | ||
}) { | ||
const [poppedPractitioner, setPoppedPractitioner] = useState(null); | ||
const [hoverRow, setHoverRow] = useState(null); | ||
|
||
// Get visible practitioners | ||
const visiblePractitioners = practitioners.slice(0, displayCount); | ||
const hasMorePractitioners = practitioners.length > displayCount; | ||
|
||
const handleViewMore = () => { | ||
setDisplayCount((prev) => prev + 3); | ||
}; | ||
|
||
return ( | ||
<ThemeProvider theme={theme}> | ||
<RowHoverContext.Provider value={hoverRow}> | ||
<SetHoverRowContext.Provider value={setHoverRow}> | ||
<CssBaseline /> | ||
<Container | ||
maxWidth="xl" | ||
sx={{ p: 2 }} | ||
> | ||
<Stack | ||
direction="row" | ||
gap={1} | ||
sx={{ bgcolor: theme.palette.primary.lightGray }} | ||
> | ||
{/* Community Panel */} | ||
<Box | ||
mt={3} | ||
sx={{ flex: '1 1 250px;' }} | ||
> | ||
<CommunityPane | ||
community={community} | ||
isSelectable={isSelectable} | ||
availableOptions={availableOptions} | ||
onSelectionChange={onSelectionChange} | ||
/> | ||
</Box> | ||
|
||
{/* Practitioners Panel */} | ||
<Stack sx={{ width: '60%', pl: 0, flex: '3 2 auto' }}> | ||
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 2, mt: 1 }}> | ||
<Box sx={{ width: '100%', textAlign: 'center' }}> | ||
<Typography | ||
color="primary.main" | ||
sx={{ | ||
pt: 1, | ||
height: '40px', | ||
fontWeight: 700, | ||
}} | ||
variant="h5" | ||
> | ||
Matched Practitioners | ||
</Typography> | ||
</Box> | ||
|
||
{hasMorePractitioners && ( | ||
<Box | ||
sx={{ | ||
position: 'fixed', | ||
top: '24px', | ||
right: '24px', | ||
zIndex: 1000, | ||
}} | ||
> | ||
<Button | ||
onClick={handleViewMore} | ||
variant="contained" | ||
sx={{ | ||
bgcolor: 'primary.white', | ||
color: 'primary.main', | ||
border: '1px solid', | ||
borderColor: 'primary.borderGray', | ||
borderRadius: 2, | ||
boxShadow: 2, | ||
textTransform: 'none', | ||
'&:hover': { | ||
bgcolor: 'primary.lightGray', | ||
}, | ||
}} | ||
startIcon={<ReadMoreIcon />} | ||
> | ||
View more matches | ||
</Button> | ||
</Box> | ||
)} | ||
</Box> | ||
|
||
{/* Practitioners List */} | ||
<Stack | ||
direction="row" | ||
sx={{ | ||
pb: 2, | ||
width: '100%', | ||
gap: { | ||
sm: '4px', | ||
md: '8px', | ||
}, | ||
overflowX: 'auto', | ||
}} | ||
> | ||
{visiblePractitioners.map((pract, index) => ( | ||
<Box | ||
key={index} | ||
sx={{ flex: '1 1 0' }} | ||
> | ||
<PractitionerPane | ||
community={community} | ||
practitioner={pract} | ||
poppedPractitioner={poppedPractitioner} | ||
setPoppedPractitioner={setPoppedPractitioner} | ||
/> | ||
</Box> | ||
))} | ||
</Stack> | ||
</Stack> | ||
</Stack> | ||
</Container> | ||
</SetHoverRowContext.Provider> | ||
</RowHoverContext.Provider> | ||
</ThemeProvider> | ||
); | ||
} |
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,115 +1,31 @@ | ||
// React | ||
import { useState, useEffect, useContext } from 'react'; | ||
|
||
// router | ||
import { useState, useEffect } from 'react'; | ||
import { useParams } from 'react-router-dom'; | ||
|
||
// API | ||
import { fetchCommunity, fetchPractitionersForCommunity } from '../util/api'; | ||
|
||
// components | ||
import { CssBaseline, Stack, Container, Typography, Box } from '@mui/material'; | ||
|
||
import ComparisonBoard from '../components/ComparisonBoard'; | ||
import FullPageSpinner from '../components/FullPageSpinner'; | ||
import PractitionerPane from '../components/PractitionerPane'; | ||
import CommunityPane from '../components/CommunityPane'; | ||
|
||
import { ThemeProvider } from '@mui/material/styles'; | ||
|
||
// theme | ||
import theme from '../theme'; | ||
|
||
import { RowHoverContext, SetHoverRowContext } from '../components/RowHoverContext'; | ||
|
||
export default function CommunityPage() { | ||
const [community, setCommunity] = useState(false); | ||
const [practitioners, setPractitioners] = useState([]); | ||
// Profile info popup | ||
const [poppedPractitioner, setPoppedPractitioner] = useState(null); | ||
// Tracking the row where mouse hovers | ||
const [hoverRow, setHoverRow] = useState(null); | ||
|
||
const [displayCount, setDisplayCount] = useState(3); | ||
const { communityId } = useParams(); | ||
|
||
useEffect(() => { | ||
fetchPractitionersForCommunity(communityId, setPractitioners); | ||
fetchCommunity(communityId, setCommunity); | ||
}, []); | ||
}, [communityId]); | ||
|
||
if (!(community && practitioners.length)) { | ||
return <FullPageSpinner></FullPageSpinner>; | ||
return <FullPageSpinner />; | ||
} | ||
const practitionerPanes = practitioners.map((pract, index) => { | ||
return ( | ||
<PractitionerPane | ||
community={community} | ||
practitioner={pract} | ||
poppedPractitioner={poppedPractitioner} | ||
setPoppedPractitioner={setPoppedPractitioner} | ||
key={index} | ||
style={{ | ||
flex: 1, | ||
}} | ||
></PractitionerPane> | ||
); | ||
}); | ||
|
||
return ( | ||
<ThemeProvider theme={theme}> | ||
<RowHoverContext.Provider value={hoverRow}> | ||
<SetHoverRowContext.Provider value={setHoverRow}> | ||
<CssBaseline /> | ||
<Container | ||
maxWidth="xl" | ||
sx={{ p: 2 }} | ||
> | ||
<Stack | ||
direction="row" | ||
gap={1} | ||
ml={1} | ||
sx={{ | ||
bgcolor: theme.palette.primary.lightGray, | ||
}} | ||
> | ||
<CommunityPane community={community} /> | ||
|
||
{/* Practitioners */} | ||
|
||
<Stack sx={{ width: '60%' }}> | ||
<Typography | ||
color="primary.main" | ||
sx={{ | ||
pt: 1, | ||
height: '40px', | ||
textAlign: 'center', | ||
fontWeight: 700, | ||
}} | ||
variant="h5" | ||
> | ||
<Box | ||
sx={{ | ||
display: { | ||
xs: 'none', | ||
md: 'inline-block', | ||
}, | ||
}} | ||
> | ||
Matched | ||
</Box>{' '} | ||
Practitioners | ||
</Typography> | ||
<Stack | ||
direction="row" | ||
gap={1} | ||
mr={1} | ||
> | ||
{practitionerPanes} | ||
</Stack> | ||
</Stack> | ||
</Stack> | ||
</Container> | ||
</SetHoverRowContext.Provider> | ||
</RowHoverContext.Provider> | ||
</ThemeProvider> | ||
<ComparisonBoard | ||
community={community} | ||
practitioners={practitioners} | ||
isSelectable={false} | ||
displayCount={displayCount} | ||
setDisplayCount={setDisplayCount} | ||
/> | ||
); | ||
} |
Oops, something went wrong.