2022-03-12 20:51:30 +01:00
|
|
|
import { FC } from 'react';
|
2022-03-13 18:56:42 +01:00
|
|
|
import { Button, ButtonProps } from 'reactstrap';
|
2022-03-12 20:51:30 +01:00
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
2022-05-14 11:11:50 +02:00
|
|
|
import { faFileCsv } from '@fortawesome/free-solid-svg-icons';
|
2022-03-12 20:51:30 +01:00
|
|
|
import { prettify } from './helpers/numbers';
|
|
|
|
|
2022-03-13 18:56:42 +01:00
|
|
|
interface ExportBtnProps extends Omit<ButtonProps, 'outline' | 'color' | 'disabled'> {
|
2022-03-12 20:51:30 +01:00
|
|
|
amount?: number;
|
2022-03-13 18:56:42 +01:00
|
|
|
loading?: boolean;
|
2022-03-12 20:51:30 +01:00
|
|
|
}
|
|
|
|
|
2022-03-13 18:56:42 +01:00
|
|
|
export const ExportBtn: FC<ExportBtnProps> = ({ amount = 0, loading = false, ...rest }) => (
|
|
|
|
<Button {...rest} outline color="primary" disabled={loading}>
|
2022-05-14 11:11:50 +02:00
|
|
|
<FontAwesomeIcon icon={faFileCsv} /> {loading ? 'Exporting...' : <>Export ({prettify(amount)})</>}
|
2022-03-12 20:51:30 +01:00
|
|
|
</Button>
|
|
|
|
);
|