-
Notifications
You must be signed in to change notification settings - Fork 3
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 #6 from DaleMcGrew/Dale_WCC_Dec16-2024
Can add and remove team member.
- Loading branch information
Showing
10 changed files
with
392 additions
and
74 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
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
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
File renamed without changes.
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,90 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles } from '@mui/styles'; | ||
import { messageService } from '../../stores/AppObservableStore'; | ||
import PersonStore from '../../stores/PersonStore'; | ||
import TeamStore from '../../stores/TeamStore'; | ||
import { renderLog } from '../../common/utils/logging'; | ||
|
||
|
||
const TeamMemberList = ({ classes, teamId }) => { | ||
renderLog('TeamMemberList'); // Set LOG_RENDER_EVENTS to log all renders | ||
const [teamMemberList, setTeamMemberList] = React.useState([]); | ||
|
||
const onAppObservableStoreChange = () => { | ||
}; | ||
|
||
const onRetrieveTeamListChange = () => { | ||
setTeamMemberList(TeamStore.getTeamMemberList(teamId)); | ||
}; | ||
|
||
const onPersonStoreChange = () => { | ||
onRetrieveTeamListChange(); | ||
}; | ||
|
||
const onTeamStoreChange = () => { | ||
onRetrieveTeamListChange(); | ||
}; | ||
|
||
React.useEffect(() => { | ||
setTeamMemberList([]); | ||
const appStateSubscription = messageService.getMessage().subscribe(() => onAppObservableStoreChange()); | ||
onAppObservableStoreChange(); | ||
const personStoreListener = PersonStore.addListener(onPersonStoreChange); | ||
onPersonStoreChange(); | ||
const teamStoreListener = TeamStore.addListener(onTeamStoreChange); | ||
onTeamStoreChange(); | ||
|
||
return () => { | ||
appStateSubscription.unsubscribe(); | ||
personStoreListener.remove(); | ||
teamStoreListener.remove(); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<TeamMembersWrapper> | ||
{teamMemberList.map((person) => ( | ||
<OnePersonWrapper key={`teamMember-${person.personId}`}> | ||
<PersonCell width={200}>{person.firstName}</PersonCell> | ||
</OnePersonWrapper> | ||
))} | ||
</TeamMembersWrapper> | ||
); | ||
}; | ||
TeamMemberList.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
teamId: PropTypes.number.isRequired, | ||
}; | ||
|
||
const styles = (theme) => ({ | ||
ballotButtonIconRoot: { | ||
marginRight: 8, | ||
}, | ||
addTeamButtonRoot: { | ||
width: 120, | ||
[theme.breakpoints.down('md')]: { | ||
width: '100%', | ||
}, | ||
}, | ||
}); | ||
|
||
const OnePersonWrapper = styled('div')` | ||
display: flex; | ||
align-items: center; | ||
justify-content: flex-start; | ||
`; | ||
|
||
const PersonCell = styled('div', { | ||
shouldForwardProp: (prop) => !['width'].includes(prop), | ||
})(({ width }) => (` | ||
${width ? `max-width: ${width}px;` : ''}; | ||
${width ? `min-width: ${width}px;` : ''}; | ||
${width ? `width: ${width}px;` : ''}; | ||
`)); | ||
|
||
const TeamMembersWrapper = styled('div')` | ||
`; | ||
|
||
export default withStyles(styles)(TeamMemberList); |
Oops, something went wrong.