Добавлен уникальный key для данных журнала посещений

Изменена строковая сортировка
This commit is contained in:
Александр Сироткин 2021-12-20 13:38:40 +05:00
parent df9eeae047
commit 996065bd58
2 changed files with 6 additions and 13 deletions

View File

@ -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) => {

View File

@ -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,