diff --git a/web-ui/package.json b/web-ui/package.json index 4d178dd9ff..1aaa116a97 100644 --- a/web-ui/package.json +++ b/web-ui/package.json @@ -89,7 +89,7 @@ "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-vitest": "^0.5.4", "globals": "^15.0.0", - "happy-dom": "^15.10.1", + "happy-dom": "^15.10.2", "jest-fetch-mock": "^3.0.3", "jsdom": "^24.0.0", "msw": "^2.2.13", diff --git a/web-ui/src/components/guild-results/EditGuildModal.jsx b/web-ui/src/components/guild-results/EditGuildModal.jsx index 9e8ecebec2..953c5ccfb1 100644 --- a/web-ui/src/components/guild-results/EditGuildModal.jsx +++ b/web-ui/src/components/guild-results/EditGuildModal.jsx @@ -11,7 +11,8 @@ import { FormControlLabel, Modal, Switch, - TextField + TextField, + Checkbox, } from '@mui/material'; import Autocomplete from '@mui/material/Autocomplete'; import './EditGuildModal.css'; @@ -166,18 +167,19 @@ const EditGuildModal = ({ guild = {}, open, onSave, onClose, headerText }) => { value={editedGuild.name ? editedGuild.name : ''} onChange={e => setGuild({ ...editedGuild, name: e.target.value })} /> - {guild.id && { - const { checked } = event.target; - setGuild({ ...editedGuild, active: checked }); - }} - /> - } + {guild.id && (<> + } + variant="outlined" + className="halfWidth" + checked={editedGuild.active ? editedGuild.active : false} + onChange={event => { + const { checked } = event.target; + setGuild({ ...editedGuild, active: checked }); + }} + /> Active + )}
{ const { state } = useContext(AppContext); const loading = selectTeamsLoading(state); const [addingTeam, setAddingTeam] = useState(false); + const [activeTeams, setActiveTeams] = useState(true); const [searchText, setSearchText] = useState(''); const [selectedTeamId, setSelectedTeamId] = useState(''); const teams = selectNormalizedTeams(state, searchText); - const teamCards = teams.map((team, index) => { - return ( - - ); - }); - useQueryParameters([ { name: 'addNew', @@ -89,16 +78,41 @@ const TeamResults = () => { setSearchText(e.target.value); }} /> - +
+ + { + const { checked } = event.target; + setActiveTeams(checked); + }} + /> + } + label="Active Teams Only" + /> +
{loading ? Array.from({ length: 20 }).map((_, index) => ( )) - : teams?.length && !loading - ? teamCards - : null} + : teams.filter((team) => !activeTeams || + (activeTeams && team.active)) + .map((team, index) => { + return ( + + ); + }) + }
); diff --git a/web-ui/src/components/team-results/TeamSummaryCard.jsx b/web-ui/src/components/team-results/TeamSummaryCard.jsx index 7e7e0e3724..c60abe631a 100644 --- a/web-ui/src/components/team-results/TeamSummaryCard.jsx +++ b/web-ui/src/components/team-results/TeamSummaryCard.jsx @@ -19,7 +19,7 @@ import { Tooltip } from '@mui/material'; import PropTypes from 'prop-types'; -import { deleteTeam, updateTeam } from '../../api/team.js'; +import { updateTeam } from '../../api/team.js'; import SplitButton from '../split-button/SplitButton'; const PREFIX = 'TeamSummaryCard'; @@ -59,7 +59,6 @@ const displayName = 'TeamSummaryCard'; const TeamSummaryCard = ({ team, index, onTeamSelect, selectedTeamId }) => { const { state, dispatch } = useContext(AppContext); const { teams, userProfile, csrf } = state; - const [openDelete, setOpenDelete] = useState(false); const [openKudos, setOpenKudos] = useState(false); // const [selectedTeam, setSelectedTeam] = useState(null); const [tooltipIsOpen, setTooltipIsOpen] = useState(false); @@ -81,45 +80,16 @@ const TeamSummaryCard = ({ team, index, onTeamSelect, selectedTeamId }) => { ? false : leads.some(lead => lead.memberId === userProfile.memberProfile.id); - const handleOpenDeleteConfirmation = () => setOpenDelete(true); const handleOpenKudos = () => setOpenKudos(true); - - const handleCloseDeleteConfirmation = () => setOpenDelete(false); const handleCloseKudos = () => setOpenKudos(false); - const teamId = team?.id; - const deleteATeam = useCallback(async () => { - if (teamId && csrf) { - const result = await deleteTeam(teamId, csrf); - if (result && result.payload && result.payload.status === 200) { - window.snackDispatch({ - type: UPDATE_TOAST, - payload: { - severity: 'success', - toast: 'Team deleted' - } - }); - let newTeams = teams.filter(team => { - return team.id !== teamId; - }); - dispatch({ - type: UPDATE_TEAMS, - payload: newTeams - }); - } - } - }, [teamId, csrf, dispatch, teams]); - - const options = - isAdmin || isTeamLead ? ['Edit Team', 'Give Kudos', 'Delete Team'] : ['Edit Team', 'Give Kudos']; + const options = ['Edit Team', 'Give Kudos']; const handleAction = (e, index) => { if (index === 0) { onTeamSelect(team.id); } else if (index === 1) { handleOpenKudos(); - } else if (index === 2) { - handleOpenDeleteConfirmation(); } }; @@ -195,27 +165,6 @@ const TeamSummaryCard = ({ team, index, onTeamSelect, selectedTeamId }) => { {(isAdmin || isTeamLead) && ( <> - - Delete team? - - - Are you sure you want to delete the team? - - - - - - - - + +
- +
+