From 075c581c85fd587603260fb3d8ef08f1fe2e4ba1 Mon Sep 17 00:00:00 2001 From: deanchen Date: Thu, 7 Apr 2022 14:49:20 +0800 Subject: [PATCH] fix: tolowercase --- server/models/Earnings.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/server/models/Earnings.js b/server/models/Earnings.js index 0bdef82..bc2cbb4 100644 --- a/server/models/Earnings.js +++ b/server/models/Earnings.js @@ -185,15 +185,21 @@ class Earnings { } if (filter?.grower) { - formattedEarnings = formattedEarnings.filter(({ grower }) => - grower.toLowerCase().includes(filter?.grower.toLowerCase()), - ); + formattedEarnings = formattedEarnings.filter(({ grower }) => { + if (!grower) { + return false; + } + return grower.toLowerCase().includes(filter?.grower.toLowerCase()); + }); } if (filter?.phone) { - formattedEarnings = formattedEarnings.filter(({ phone }) => - phone.toLowerCase().includes(filter?.phone.toLowerCase()), - ); + formattedEarnings = formattedEarnings.filter(({ phone }) => { + if (!phone) { + return false; + } + return phone.toLowerCase().includes(filter?.phone.toLowerCase()); + }); } // after grower and phone filters have been applied