Export all users to a CSV with name and email
This commit is contained in:
parent
dc2fada751
commit
d2f5742231
|
@ -35,7 +35,22 @@ function UsersTable() {
|
||||||
// Sort users by createdTime descending, by default
|
// Sort users by createdTime descending, by default
|
||||||
users = users.sort((a, b) => b.createdTime - a.createdTime)
|
users = users.sort((a, b) => b.createdTime - a.createdTime)
|
||||||
|
|
||||||
|
function exportCsv() {
|
||||||
|
const csv = users
|
||||||
|
// @ts-ignore
|
||||||
|
.map((u) => [u.email, u.name].join(', '))
|
||||||
|
.join('\n')
|
||||||
|
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8' })
|
||||||
|
const url = URL.createObjectURL(blob)
|
||||||
|
const a = document.createElement('a')
|
||||||
|
a.href = url
|
||||||
|
a.download = 'manifold-users.csv'
|
||||||
|
a.click()
|
||||||
|
URL.revokeObjectURL(url)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<Grid
|
<Grid
|
||||||
data={users}
|
data={users}
|
||||||
columns={[
|
columns={[
|
||||||
|
@ -84,6 +99,10 @@ function UsersTable() {
|
||||||
limit: 25,
|
limit: 25,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<button className="btn" onClick={exportCsv}>
|
||||||
|
Export emails to CSV
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user