From b958da3bc49ee37caead791b7192445784002c1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Let=C3=ADcia=20Camara?= Date: Tue, 30 Oct 2018 21:17:51 -0300 Subject: [PATCH] Fix ambassadors and merchant sort undefined error --- src/components/EnhancedTable.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/EnhancedTable.js b/src/components/EnhancedTable.js index c7eb76a..a878a7a 100644 --- a/src/components/EnhancedTable.js +++ b/src/components/EnhancedTable.js @@ -94,15 +94,15 @@ class EnhancedTable extends Component { const data = order === 'desc' ? this.state.data.sort((a, b) => { - let a_value = a[orderBy]; - let b_value = b[orderBy]; + let a_value = (a[orderBy] !== undefined) ? a[orderBy]: ''; + let b_value = (b[orderBy] !== undefined) ? b[orderBy]: ''; a_value = a_value.hasOwnProperty('searchText') ? a_value.searchText.toLowerCase() : a_value.toLowerCase(); b_value = b_value.hasOwnProperty('searchText') ? b_value.searchText.toLowerCase() : b_value.toLowerCase(); return (b_value < a_value) ? -1 : 1; }) : this.state.data.sort((a, b) => { - let a_value = a[orderBy]; - let b_value = b[orderBy]; + let a_value = (a[orderBy] !== undefined) ? a[orderBy]: ''; + let b_value = (b[orderBy] !== undefined) ? b[orderBy]: ''; a_value = a_value.hasOwnProperty('searchText') ? a_value.searchText.toLowerCase() : a_value.toLowerCase(); b_value = b_value.hasOwnProperty('searchText') ? b_value.searchText.toLowerCase() : b_value.toLowerCase(); if(a_value.trim() === '') a_value = 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';