Commit 4e4fed2e authored by Riri Novita's avatar Riri Novita

update download

parent 8ce98fd8
...@@ -81,27 +81,25 @@ class DownloadReport extends Component { ...@@ -81,27 +81,25 @@ class DownloadReport extends Component {
this.state = { this.state = {
load: false, load: false,
loading: false, loading: false,
listDownload: [], listDownload: []
} }
} }
componentDidMount() { componentDidMount() {
// const interval = setInterval(() => { const interval = setInterval(() => {
this.getListDownload() this.getListDownload()
// }, 500); }, 500);
// return () => clearInterval(interval); return () => clearInterval(interval);
} }
getListDownload() { getListDownload() {
api.create().getListDownload().then((response) => { api.create().getListDownload().then((response) => {
// console.log(response);
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let listDate = []
let arr = []; let arr = [];
var groups = this.groupItems(data, "created_at"); // array will be grouped by 'date' property var groups = this.groupItems(data, "created_at"); // array will be grouped by 'date' property
...@@ -112,29 +110,6 @@ class DownloadReport extends Component { ...@@ -112,29 +110,6 @@ class DownloadReport extends Component {
items: groups[key], items: groups[key],
}); });
} }
console.log(arr, 'ihiw');
// data.map((item) => {
// var reference = moment(item.created_at).format('YYYY-MM-DD');
// var today = moment().subtract(0, "days").format("YYYY-MM-DD");
// var yesterday = moment().subtract(1, "days").format("YYYY-MM-DD");
// let dateType = ""
// if (reference === today) {
// listDate.push({
// dateType: 'today'
// })
// } else if (reference === yesterday) {
// listDate.push({
// dateType: 'yesterday'
// })
// } else {
// listDate.push({
// dateType: 'daysago'
// })
// }
// console.log(listDate);
// })
this.setState({ listDownload: arr }) this.setState({ listDownload: arr })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
...@@ -161,7 +136,6 @@ class DownloadReport extends Component { ...@@ -161,7 +136,6 @@ class DownloadReport extends Component {
var pastDate = moment(reference, "DD-MM-YYYY"); var pastDate = moment(reference, "DD-MM-YYYY");
var todayDate = moment(moment().format("DD-MM-YYYY"), "DD-MM-YYYY"); var todayDate = moment(moment().format("DD-MM-YYYY"), "DD-MM-YYYY");
let dDiff = todayDate.diff(pastDate, "days"); let dDiff = todayDate.diff(pastDate, "days");
console.log(item);
var name = item.status === 0 ? "" : (dDiff === 0 ? "Today" : dDiff === 1 ? "Yesterday" : "Days Ago"); var name = item.status === 0 ? "" : (dDiff === 0 ? "Today" : dDiff === 1 ? "Yesterday" : "Days Ago");
var group = groups[name] || (groups[name] = []); var group = groups[name] || (groups[name] = []);
group.push(item); group.push(item);
...@@ -187,7 +161,7 @@ class DownloadReport extends Component { ...@@ -187,7 +161,7 @@ class DownloadReport extends Component {
} }
render() { render() {
let { listDownload, messageAlert } = this.state let { listDownload, messageAlert, pageEmpty } = this.state
const loadingComponent = ( const loadingComponent = (
<div style={{ position: 'absolute', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}> <div style={{ position: 'absolute', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}>
<PropagateLoader <PropagateLoader
...@@ -224,7 +198,9 @@ class DownloadReport extends Component { ...@@ -224,7 +198,9 @@ class DownloadReport extends Component {
listItem.items.map((item) => { listItem.items.map((item) => {
return ( return (
<div> <div>
{item.status == 0 ? null : {item.status == 0 ?
null
:
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<div style={{ width: '7%', height: 90, background: '#D9D9D9', borderRadius: 10, marginBottom: 15, marginRight: 2, borderBottomRightRadius: 0, borderTopRightRadius: 0 }}> <div style={{ width: '7%', height: 90, background: '#D9D9D9', borderRadius: 10, marginBottom: 15, marginRight: 2, borderBottomRightRadius: 0, borderTopRightRadius: 0 }}>
<div style={{ alignItems: 'center', display: 'flex' }}> <div style={{ alignItems: 'center', display: 'flex' }}>
...@@ -281,7 +257,7 @@ class DownloadReport extends Component { ...@@ -281,7 +257,7 @@ class DownloadReport extends Component {
}} }}
> >
<div style={{ backgroundColor: '#354960', width: 140, height: 40, borderRadius: 10, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> <div style={{ backgroundColor: '#354960', width: 140, height: 40, borderRadius: 10, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '16px', color: '#fff', textAlign: 'center' }}>Download <span><CheckCircleIcon fontSize='small' style={{ marginBottom: 3, marginLeft: 7 }} /></span></Typography> <Typography style={{ fontSize: '16px', color: '#fff', textAlign: 'center' }}>Download <span><CheckCircleIcon fontSize='small' style={{ marginBottom: 1, marginLeft: 7 }} /></span></Typography>
</div> </div>
</button> </button>
: :
...@@ -300,6 +276,7 @@ class DownloadReport extends Component { ...@@ -300,6 +276,7 @@ class DownloadReport extends Component {
) )
})} })}
<div style={{ fontSize: 12, fontWeight: 700, color: 'red', marginLeft: 5, marginBottom: 10 }}>Note : File download akan hilang dalam 3 hari setelah di generate.</div>
</div> </div>
</Paper> </Paper>
</div> </div>
...@@ -308,11 +285,23 @@ class DownloadReport extends Component { ...@@ -308,11 +285,23 @@ class DownloadReport extends Component {
<div style={{ flexDirection: 'column', textAlign: 'center' }}> <div style={{ flexDirection: 'column', textAlign: 'center' }}>
<CloudDownloadIcon style={{ fontSize: 50, color: 'grey' }} /> <CloudDownloadIcon style={{ fontSize: 50, color: 'grey' }} />
<h3 style={{ marginTop: 5, color: 'grey' }}> <h3 style={{ marginTop: 5, color: 'grey' }}>
Download Report Download Report Empty
</h3> </h3>
</div> </div>
</div> </div>
} }
{/* {this.state.pageEmpty &&
<div style={{ flex: 1, height: '100vh', alignItems: 'center', justifyContent: 'center', display: 'flex' }}>
<div style={{ flexDirection: 'column', textAlign: 'center' }}>
<CloudDownloadIcon style={{ fontSize: 50, color: 'grey' }} />
<h3 style={{ marginTop: 5, color: 'grey' }}>
Download Report Empty
</h3>
</div>
</div>
} */}
</div> </div>
</div> </div>
); );
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment