mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
sort arrays before putting it in state
This commit is contained in:
parent
f397d51858
commit
4a201e7325
@ -114,13 +114,12 @@ export default function ComputeJobs(): ReactElement {
|
||||
})
|
||||
})
|
||||
}
|
||||
setJobs(
|
||||
jobs.sort((a, b) => {
|
||||
if (a.dateCreated > b.dateCreated) return -1
|
||||
if (a.dateCreated < b.dateCreated) return 1
|
||||
return 0
|
||||
})
|
||||
)
|
||||
const jobsSorted = jobs.sort((a, b) => {
|
||||
if (a.dateCreated > b.dateCreated) return -1
|
||||
if (a.dateCreated < b.dateCreated) return 1
|
||||
return 0
|
||||
})
|
||||
setJobs(jobsSorted)
|
||||
} catch (error) {
|
||||
Logger.log(error.message)
|
||||
} finally {
|
||||
@ -130,5 +129,13 @@ export default function ComputeJobs(): ReactElement {
|
||||
getJobs()
|
||||
}, [ocean, account])
|
||||
|
||||
return <Table columns={columns} data={jobs} isLoading={isLoading} />
|
||||
return (
|
||||
<Table
|
||||
columns={columns}
|
||||
data={jobs}
|
||||
isLoading={isLoading}
|
||||
defaultSortField="row.dateCreated"
|
||||
defaultSortAsc={false}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
@ -75,14 +75,13 @@ export default function PoolTransactions(): ReactElement {
|
||||
if (!ocean || !accountId) return
|
||||
setIsLoading(true)
|
||||
const logs = await ocean.pool.getAllPoolLogs(accountId)
|
||||
setLogs(
|
||||
// sort logs by date, newest first
|
||||
logs.sort((a, b) => {
|
||||
if (a.timestamp > b.timestamp) return -1
|
||||
if (a.timestamp < b.timestamp) return 1
|
||||
return 0
|
||||
})
|
||||
)
|
||||
// sort logs by date, newest first
|
||||
const logsSorted = logs.sort((a, b) => {
|
||||
if (a.timestamp > b.timestamp) return -1
|
||||
if (a.timestamp < b.timestamp) return 1
|
||||
return 0
|
||||
})
|
||||
setLogs(logsSorted)
|
||||
setIsLoading(false)
|
||||
}
|
||||
getLogs()
|
||||
|
Loading…
Reference in New Issue
Block a user