Add profit and balance to admin csv export
This commit is contained in:
parent
367046a6e0
commit
bf13e2fc12
|
@ -32,12 +32,24 @@ function UsersTable() {
|
|||
// For each user, set their email from the PrivateUser
|
||||
const fullUsers = users
|
||||
.map((user) => {
|
||||
return { email: privateUsersById[user.id]?.email, ...user }
|
||||
return {
|
||||
email: privateUsersById[user.id]?.email,
|
||||
profit: user.profitCached.allTime,
|
||||
...user,
|
||||
}
|
||||
})
|
||||
.sort((a, b) => b.createdTime - a.createdTime)
|
||||
|
||||
function exportCsv() {
|
||||
const csv = fullUsers.map((u) => [u.email, u.name].join(', ')).join('\n')
|
||||
const lines = [['Email', 'Name', 'Balance', 'Profit']].concat(
|
||||
fullUsers.map((u) => [
|
||||
u.email ?? '',
|
||||
u.name,
|
||||
Math.round(u.balance).toString(),
|
||||
Math.round(u.profitCached.allTime).toString(),
|
||||
])
|
||||
)
|
||||
const csv = lines.map((line) => line.join(', ')).join('\n')
|
||||
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8' })
|
||||
const url = URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
|
@ -90,6 +102,11 @@ function UsersTable() {
|
|||
name: 'Balance',
|
||||
formatter: (cell) => (cell as number).toFixed(0),
|
||||
},
|
||||
{
|
||||
id: 'profit',
|
||||
name: 'profit',
|
||||
formatter: (cell) => (cell as number).toFixed(0),
|
||||
},
|
||||
{
|
||||
id: 'id',
|
||||
name: 'ID',
|
||||
|
|
Loading…
Reference in New Issue
Block a user