From 996065bd5833c25c6deb8c6b640384e3e59acdc9 Mon Sep 17 00:00:00 2001 From: goodm2ice Date: Mon, 20 Dec 2021 13:38:40 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D1=83=D0=BD=D0=B8=D0=BA=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B?= =?UTF-8?q?=D0=B9=20key=20=D0=B4=D0=BB=D1=8F=20=D0=B4=D0=B0=D0=BD=D0=BD?= =?UTF-8?q?=D1=8B=D1=85=20=D0=B6=D1=83=D1=80=D0=BD=D0=B0=D0=BB=D0=B0=20?= =?UTF-8?q?=D0=BF=D0=BE=D1=81=D0=B5=D1=89=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=98?= =?UTF-8?q?=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B0=20=D1=81=D1=82=D1=80?= =?UTF-8?q?=D0=BE=D0=BA=D0=BE=D0=B2=D0=B0=D1=8F=20=D1=81=D0=BE=D1=80=D1=82?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Table/sorters.ts | 17 ++++------------- src/pages/AdminPanel/VisitLog.jsx | 2 ++ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/components/Table/sorters.ts b/src/components/Table/sorters.ts index 8a377ae..f29d7b6 100644 --- a/src/components/Table/sorters.ts +++ b/src/components/Table/sorters.ts @@ -1,20 +1,11 @@ export const makeNumericSorter = (key: string) => (a: any, b: any) => Number(a[key]) - Number(b[key]) export const makeStringSorter = (key: string) => (a: any, b: any) => { - if (a == null) return 1 - if (b == null) return -1 + if (!a && !b) return 0 + if (!a) return 1 + if (!b) return -1 - const aValue = a[key] - const bValue = b[key] - - for (let i = 0; i < a.length; i++) { - if (isNaN(aValue.charCodeAt(i)) || (aValue.charCodeAt(i) > bValue.charCodeAt(i))) - return 1 - - if (aValue.charCodeAt(i) > bValue.charCodeAt(i)) - return -1 - } - return 0 + return ('' + a[key]).localeCompare(b[key]) } export const makeDateSorter = (key: string) => (a: any, b: any) => { diff --git a/src/pages/AdminPanel/VisitLog.jsx b/src/pages/AdminPanel/VisitLog.jsx index 4c3165d..f858534 100644 --- a/src/pages/AdminPanel/VisitLog.jsx +++ b/src/pages/AdminPanel/VisitLog.jsx @@ -22,6 +22,8 @@ export const VisitLog = () => { async () => { const logData = await RequerstTrackerService.getUsersStat(1000) + logData.forEach((log) => log.key = `${log.login}${log.ip}`) + setLogData(logData) }, setIsLoading,