Skip to content

Commit

Permalink
changed from csv download button to csv link
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegPhenomenon committed Jul 1, 2021
1 parent bd84881 commit a99b4e5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/components/UserData/UserData.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable camelcase,sort-keys */
/* eslint-disable */
import React, { useState } from 'react';
import { Button, Grid, Icon, Container } from 'semantic-ui-react';
import { FormattedMessage, useIntl } from 'react-intl';
import { CSVDownload } from 'react-csv';
import { CSVDownload, CSVLink } from 'react-csv';
import PropTypes from 'prop-types';
import moment from 'moment';
import pdfMake from 'pdfmake/build/pdfmake';
Expand All @@ -23,7 +23,7 @@ const UserData = ({ domains, isTech }) => {
const hasDomains = !!Object.keys(domains).length;
const [isLoadingCSV, setIsLoadingCSV] = useState(false);
const [isLoadingPDF, setIsLoadingPDF] = useState(false);
const [userCSV, setUserCSV] = useState(null);
const [userCSV, setUserCSV] = useState('');
const { formatMessage } = useIntl();

const savePDF = () => {
Expand Down Expand Up @@ -459,8 +459,8 @@ const UserData = ({ domains, isTech }) => {
};
});

setIsLoadingCSV(false);
setUserCSV(csv);
setIsLoadingCSV(false);
};

return (
Expand All @@ -483,8 +483,10 @@ const UserData = ({ domains, isTech }) => {
<Icon name="table" />
CSV
</Button.Content>
<Button.Content hidden>
<Button.Content hidden>
<CSVLink id="csvLink" data={userCSV} filename="eis_andmed.csv">
<Icon name="download" />
</CSVLink>
</Button.Content>
</Button>
<Button.Or text="või" />
Expand All @@ -505,7 +507,6 @@ const UserData = ({ domains, isTech }) => {
</Button.Content>
</Button>
</Button.Group>
{userCSV && <CSVDownload data={userCSV} filename="eis_andmed.csv" />}
</Grid.Column>
</Grid.Row>
</Grid>
Expand Down

0 comments on commit a99b4e5

Please sign in to comment.