From a943497c9153f7acbe96bd795746c47cf323d26b Mon Sep 17 00:00:00 2001 From: Chris Brame Date: Tue, 1 Mar 2022 15:05:57 -0500 Subject: [PATCH] fix(tickets): incorrect tickets removed from ticket view --- src/client/reducers/ticketsReducer.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/client/reducers/ticketsReducer.js b/src/client/reducers/ticketsReducer.js index 060ad75a7..b40d3645b 100644 --- a/src/client/reducers/ticketsReducer.js +++ b/src/client/reducers/ticketsReducer.js @@ -128,9 +128,11 @@ const reducer = handleActions( [DELETE_TICKET.SUCCESS]: (state, action) => { const idx = state.tickets.findIndex(ticket => { - return ticket.get('_id') === action.payload.id + return ticket.get('_id').toString() === action.payload.id.toString() }) + if (idx === -1) return { ...state } + return { ...state, tickets: state.tickets.delete(idx) @@ -150,8 +152,10 @@ const reducer = handleActions( case 'deleted': { const id = action.payload.data const idx = state.tickets.findIndex(ticket => { - return ticket.get('_id') === id + return ticket.get('_id').toString() === id.toString() }) + if (idx === -1) return { ...state } + return { ...state, tickets: state.tickets.delete(idx)