@@ -19,7 +19,7 @@ import {
1919 Tooltip
2020} from '@mui/material' ;
2121import PropTypes from 'prop-types' ;
22- import { deleteTeam , updateTeam } from '../../api/team.js' ;
22+ import { updateTeam } from '../../api/team.js' ;
2323import SplitButton from '../split-button/SplitButton' ;
2424
2525const PREFIX = 'TeamSummaryCard' ;
@@ -59,7 +59,6 @@ const displayName = 'TeamSummaryCard';
5959const TeamSummaryCard = ( { team, index, onTeamSelect, selectedTeamId } ) => {
6060 const { state, dispatch } = useContext ( AppContext ) ;
6161 const { teams, userProfile, csrf } = state ;
62- const [ openDelete , setOpenDelete ] = useState ( false ) ;
6362 const [ openKudos , setOpenKudos ] = useState ( false ) ;
6463 // const [selectedTeam, setSelectedTeam] = useState(null);
6564 const [ tooltipIsOpen , setTooltipIsOpen ] = useState ( false ) ;
@@ -81,45 +80,16 @@ const TeamSummaryCard = ({ team, index, onTeamSelect, selectedTeamId }) => {
8180 ? false
8281 : leads . some ( lead => lead . memberId === userProfile . memberProfile . id ) ;
8382
84- const handleOpenDeleteConfirmation = ( ) => setOpenDelete ( true ) ;
8583 const handleOpenKudos = ( ) => setOpenKudos ( true ) ;
86-
87- const handleCloseDeleteConfirmation = ( ) => setOpenDelete ( false ) ;
8884 const handleCloseKudos = ( ) => setOpenKudos ( false ) ;
8985
90- const teamId = team ?. id ;
91- const deleteATeam = useCallback ( async ( ) => {
92- if ( teamId && csrf ) {
93- const result = await deleteTeam ( teamId , csrf ) ;
94- if ( result && result . payload && result . payload . status === 200 ) {
95- window . snackDispatch ( {
96- type : UPDATE_TOAST ,
97- payload : {
98- severity : 'success' ,
99- toast : 'Team deleted'
100- }
101- } ) ;
102- let newTeams = teams . filter ( team => {
103- return team . id !== teamId ;
104- } ) ;
105- dispatch ( {
106- type : UPDATE_TEAMS ,
107- payload : newTeams
108- } ) ;
109- }
110- }
111- } , [ teamId , csrf , dispatch , teams ] ) ;
112-
113- const options =
114- isAdmin || isTeamLead ? [ 'Edit Team' , 'Give Kudos' , 'Delete Team' ] : [ 'Edit Team' , 'Give Kudos' ] ;
86+ const options = [ 'Edit Team' , 'Give Kudos' ] ;
11587
11688 const handleAction = ( e , index ) => {
11789 if ( index === 0 ) {
11890 onTeamSelect ( team . id ) ;
11991 } else if ( index === 1 ) {
12092 handleOpenKudos ( ) ;
121- } else if ( index === 2 ) {
122- handleOpenDeleteConfirmation ( ) ;
12393 }
12494 } ;
12595
@@ -195,27 +165,6 @@ const TeamSummaryCard = ({ team, index, onTeamSelect, selectedTeamId }) => {
195165 { ( isAdmin || isTeamLead ) && (
196166 < >
197167 < SplitButton options = { options } onClick = { handleAction } />
198- < Dialog
199- open = { openDelete }
200- onClose = { handleCloseDeleteConfirmation }
201- aria-labelledby = "alert-dialog-title"
202- aria-describedby = "alert-dialog-description"
203- >
204- < DialogTitle id = "alert-dialog-title" > Delete team?</ DialogTitle >
205- < DialogContent >
206- < DialogContentText id = "alert-dialog-description" >
207- Are you sure you want to delete the team?
208- </ DialogContentText >
209- </ DialogContent >
210- < DialogActions >
211- < Button onClick = { handleCloseDeleteConfirmation } color = "primary" >
212- Cancel
213- </ Button >
214- < Button onClick = { deleteATeam } color = "primary" autoFocus >
215- Yes
216- </ Button >
217- </ DialogActions >
218- </ Dialog >
219168 < KudosDialog
220169 open = { openKudos }
221170 onClose = { handleCloseKudos }
0 commit comments