File tree Expand file tree Collapse file tree 4 files changed +32
-6
lines changed Expand file tree Collapse file tree 4 files changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -146,6 +146,17 @@ class TicketDashboard extends Component {
146146 } ) ;
147147 } ;
148148
149+ deleteTicket = ( id ) => {
150+ const newTickets = this . state . all . filter ( ele => ele . _id !== id )
151+ this . setState ( {
152+ all : [ ...newTickets ] ,
153+ viewingTicket : null ,
154+ filtered : [ ...newTickets ] ,
155+ } , async ( ) => {
156+ await Axios . delete ( `${ BASE_URL } /ticket/${ id } ` )
157+ } )
158+ }
159+
149160 render ( ) {
150161 console . log ( this . state . notifications ) ;
151162 return (
@@ -194,6 +205,7 @@ class TicketDashboard extends Component {
194205 back = { this . handleViewTicket }
195206 currentUser = { this . props . user }
196207 removeTag = { this . handleRemoveTag }
208+ deleteTicket = { this . deleteTicket }
197209 ticketId = { this . state . viewingTicket }
198210 singleUpdate = { this . handleTicketSingleUpdate }
199211 />
@@ -213,7 +225,7 @@ class TicketDashboard extends Component {
213225 onClose = { this . toggleDrawer }
214226 >
215227 < List className = "list" >
216- { this . state . notifications . map ( ( notification ) => (
228+ { this . state . notifications && this . state . notifications . map ( ( notification ) => (
217229 < ListItem
218230 style = { {
219231 display : "flex" ,
Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ class Layout extends Component {
3232 editsAllowed = { this . props . editsAllowed }
3333 singleUpdate = { this . props . singleUpdate }
3434 updateTicket = { this . props . updateTicket }
35+ deleteTicket = { this . props . deleteTicket }
36+ deleteAllowed = { this . props . deleteAllowed }
3537 />
3638 < div className = "ticket-tabs" >
3739 < span className = "nav__tab container" >
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import EditButton from "@material-ui/icons/EditOutlined";
66import SaveButton from "@material-ui/icons/SaveOutlined" ;
77import BadgeElement from "../../TicketContent/BadgeElement" ;
88import CancelButton from "@material-ui/icons/ClearOutlined" ;
9+ import DeleteOutlineOutlinedIcon from "@material-ui/icons/DeleteOutlineOutlined" ;
910
1011class Title extends Component {
1112 constructor ( props ) {
@@ -49,15 +50,24 @@ class Title extends Component {
4950 < div className = "ticket-title" >
5051 { ! this . state . editor && (
5152 < React . Fragment >
52- < dv style = { { display : "flex" , alignItems : "center" } } >
53+ < div style = { { display : "flex" , alignItems : "center" } } >
5354 < BadgeElement ticketState = { this . props . ticket . status } />
5455 < span style = { { marginLeft : "16px" } } className = "title-text" >
5556 { this . props . ticket . title }
5657 </ span >
57- </ dv >
58- { this . props . editsAllowed && (
59- < EditButton onClick = { this . toggleEditor } />
60- ) }
58+ </ div >
59+ < div >
60+ { this . props . editsAllowed && (
61+ < EditButton onClick = { this . toggleEditor } />
62+ ) }
63+ { this . props . deleteAllowed && (
64+ < DeleteOutlineOutlinedIcon
65+ onClick = { ( ) =>
66+ this . props . deleteTicket ( this . props . ticket . _id )
67+ }
68+ />
69+ ) }
70+ </ div >
6171 </ React . Fragment >
6272 ) }
6373 { this . state . editor && (
Original file line number Diff line number Diff line change @@ -181,8 +181,10 @@ class TicketDiscussions extends Component {
181181 handleBack = { this . handleBack }
182182 removeTag = { this . handleDeleteTag }
183183 editsAllowed = { this . editsAllowed }
184+ deleteAllowed = { this . deleteAllowed }
184185 updateTicket = { this . handleUpdateTicket }
185186 singleUpdate = { this . props . singleUpdate }
187+ deleteTicket = { this . props . deleteTicket }
186188 handleViewChange = { this . handleViewChange }
187189 >
188190 { this . state . view === "discussions" && (
You can’t perform that action at this time.
0 commit comments