File size: 1,275 Bytes
ccefd0b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
import { useState } from "react";
import { downloadData, downloadImage } from "../../utils/utils";
import * as RadioGroup from "@radix-ui/react-radio-group";
import useLocalStorage from "../../utils/useLocalStorage";
import { EXPORT_TYPES } from ".";
import Select from "../Select";
export default function Export({
columns,
data,
type,
setType,
downloadFinished,
}: {
columns: any;
data: any;
type: any;
setType: any;
downloadFinished: (change: boolean) => void;
}) {
const onExport = () => {
switch (type) {
case "csv":
downloadData("csv", columns, data, downloadFinished);
break;
case "png":
downloadImage("table", downloadFinished);
break;
}
};
return (
<div className="flex gap-2 items-center">
<Select
labelType="row"
value={type}
onChange={(value) => {
setType(value);
}}
label="Type"
placeholder="Select type"
groups={[
{
label: "Type",
items: EXPORT_TYPES.map((type) => ({
label: type,
value: type,
})),
},
]}
/>
<button onClick={onExport} className="_btn">
Export
</button>
</div>
);
}
|