Added Export CSV

This commit is contained in:
Joao Ramos
2023-12-23 00:01:24 +00:00
parent c37bb2691b
commit fea8e0672e
3 changed files with 32 additions and 3 deletions

View File

@@ -26,6 +26,7 @@ import ReactDatePicker from "react-datepicker";
import moment from "moment";
import PaymentAssetManager from "@/components/PaymentAssetManager";
import {toFixedNumber} from "@/utils/number";
import { CSVLink } from "react-csv";
export const getServerSideProps = withIronSessionSsr(({req, res}) => {
const user = req.session.user;
@@ -544,9 +545,23 @@ export default function PaymentRecord() {
<div className="w-full flex flex-end justify-between p-2">
<h1 className="text-2xl font-semibold">Payment Record</h1>
{(user.type === "developer" || user.type === "admin") && (
<Button className="w-full max-w-[200px]" variant="outline" onClick={() => setIsCreatingPayment(true)}>
New Payment
</Button>
<div className="flex justify-end gap-2">
<Button className="max-w-[200px]" variant="outline">
<CSVLink
data={displayPayments}
headers={defaultColumns.filter((e) => e.header).map((e) => ({
label: e.header,
key: e.accessorKey,
}))}
filename="payment-records.csv"
>
Download CSV
</CSVLink>
</Button>
<Button className="max-w-[200px]" variant="outline" onClick={() => setIsCreatingPayment(true)}>
New Payment
</Button>
</div>
)}
</div>
<div className="flex gap-8 w-full">