Skip to content
Snippets Groups Projects
Commit 0062ee2c authored by lfr20's avatar lfr20
Browse files

Created a new file to dowload a the entire collection

parent 866fe16a
No related branches found
No related tags found
4 merge requests!57Merge of develop into master,!56Fixed buttons reportar, seguir, compartilhar, guardar and entrar (in comments...,!39Update admin system,!32Homologa
import React, { useContext, useState, useEffect } from 'react';
import axios from 'axios';
import GetAppIcon from '@material-ui/icons/GetApp';
import Button from '@material-ui/core/Button';
import styled from 'styled-components';
import { apiUrl, apiDomain } from '../env';
import FollowCollectionButton from './FollowCollectionButton.js';
import { Store } from '../Store.js'
import { Grid } from '@material-ui/core';
const DowloadButton = (props) => {
const { state } = useContext(Store);
const [download_url, setDownloadUrl] = useState('');
useEffect(() => {
const body = {
"package": {
"object": [{ "type": "Collection", "id": props.id }]
}
};
axios
.post(apiUrl + '/package', body)
.catch(err => {
if (err.response && err.response.status === 302) {
setDownloadUrl(apiDomain + '/' + err.response.data.url);
}
});
}, [props.id]);
return (
<>
<DownloadAnchor href={download_url} >
<DownloadButton
variant="outlined"
color="primary"
startIcon={<GetAppIcon fontSize="large" />}
size="small"
>
<ButtonText>Baixar Coleção</ButtonText>
</DownloadButton>
</DownloadAnchor>
</>
)
}
const ButtonText = styled.span`
font-weight: bolder;
font-size: 1.2em;
`
const DownloadButton = styled(Button)`
padding-left: 10;
padding-right: 10;
width: 250px;
`
const DownloadAnchor = styled.a`
text-decoration: none !important;
`
export default DowloadButton;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment