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,