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

update download

parent 8ce98fd8
......@@ -81,27 +81,25 @@ class DownloadReport extends Component {
this.state = {
load: false,
loading: false,
listDownload: [],
listDownload: []
}
}
componentDidMount() {
// const interval = setInterval(() => {
const interval = setInterval(() => {
this.getListDownload()
// }, 500);
// return () => clearInterval(interval);
}, 500);
return () => clearInterval(interval);
}
getListDownload() {
api.create().getListDownload().then((response) => {
// console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let listDate = []
let arr = [];
var groups = this.groupItems(data, "created_at"); // array will be grouped by 'date' property
......@@ -112,29 +110,6 @@ class DownloadReport extends Component {
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 })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
......@@ -161,7 +136,6 @@ class DownloadReport extends Component {
var pastDate = moment(reference, "DD-MM-YYYY");
var todayDate = moment(moment().format("DD-MM-YYYY"), "DD-MM-YYYY");
let dDiff = todayDate.diff(pastDate, "days");
console.log(item);
var name = item.status === 0 ? "" : (dDiff === 0 ? "Today" : dDiff === 1 ? "Yesterday" : "Days Ago");
var group = groups[name] || (groups[name] = []);
group.push(item);
......@@ -187,7 +161,7 @@ class DownloadReport extends Component {
}
render() {
let { listDownload, messageAlert } = this.state
let { listDownload, messageAlert, pageEmpty } = this.state
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)' }}>
<PropagateLoader
......@@ -224,7 +198,9 @@ class DownloadReport extends Component {
listItem.items.map((item) => {
return (
<div>
{item.status == 0 ? null :
{item.status == 0 ?
null
:
<div style={{ display: 'flex' }}>
<div style={{ width: '7%', height: 90, background: '#D9D9D9', borderRadius: 10, marginBottom: 15, marginRight: 2, borderBottomRightRadius: 0, borderTopRightRadius: 0 }}>
<div style={{ alignItems: 'center', display: 'flex' }}>
......@@ -281,7 +257,7 @@ class DownloadReport extends Component {
}}
>
<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>
</button>
:
......@@ -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>
</Paper>
</div>
......@@ -308,11 +285,23 @@ class DownloadReport extends Component {
<div style={{ flexDirection: 'column', textAlign: 'center' }}>
<CloudDownloadIcon style={{ fontSize: 50, color: 'grey' }} />
<h3 style={{ marginTop: 5, color: 'grey' }}>
Download Report
Download Report Empty
</h3>
</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>
);
......
......@@ -624,6 +624,7 @@ export default class MonthlyReport extends Component {
}
getMonthlyReportID(type) {
this.setState({ selectReport: [], isCheckAll: false }, () => {
let payload = {
"company_id": this.state.company.company_id,
"periode": this.state.periode.periode,
......@@ -723,6 +724,7 @@ export default class MonthlyReport extends Component {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
})
})
}
getLatestPeriodSubmit() {
......@@ -2183,9 +2185,9 @@ export default class MonthlyReport extends Component {
} else {
let checkAll = this.state.selectReport
let isAllDetail = true
console.log(checkAll, this.state.selectReport, data);
// console.log(checkAll, this.state.selectReport, data);
data.map((item, index) => {
if (item[5] || this.state.periode.periode <= 2022) {
if (item[5] === true || this.state.periode.periode <= 2022) {
if (!this.state.selectReport.includes(item[4])) {
checkAll.push(item[4])
}
......@@ -2264,10 +2266,9 @@ export default class MonthlyReport extends Component {
handleGenerateReport(data) {
let { selectReport, monthlyReportId, company, periode, revisionTable, month, downloadedFileReportId } = this.state
console.log(selectReport);
let a = []
if (selectReport.length > 0) {
selectReport.map(async (items) => {
let urlReport = items === 8 ? "profit_loss" : items === 12 ? "tax_planning" : null
let urlReport = items === 8 ? "profit_loss" : items === 12 ? "tax_planning" : items === 7 ? "balance_sheet" : items === 9 ? "fam" : items === 13 ? "cash_flow" : items === 11 ? "locf" : items === 10 ? "cat" : null
let datas = data.findIndex((val) => val[4] == items)
let report = data[datas]
let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/${urlReport}/monthly_report/export_monthly_report?monthly_report_id=${monthlyReportId}&&report_id=${report[4]}&&company_id=${company.company_id}&&year=${periode.periode}&&revision=${report[2]}&&months=${month.month_id}&&download_file_report_id=${downloadedFileReportId}`
......@@ -2366,11 +2367,6 @@ export default class MonthlyReport extends Component {
// }
})
console.log(a, selectReport);
// setTimeout(() => {
// this.handleZip()
// }, 1000);
// this.setState({ popupDownload: true })
} else {
alert("Anda harus memilih report yang ingin di download terlebih dahulu!")
this.setState({ popupDownload: false })
......@@ -2916,7 +2912,7 @@ export default class MonthlyReport extends Component {
<button
type="button"
disabled={this.state.buttonError}
onClick={() => this.handleDownloadReport(this.state.dataTable)}
onClick={() => this.state.selectReport.length > 0 ? this.handleDownloadReport(this.state.dataTable) : alert("Anda harus memilih report yang ingin di download terlebih dahulu!")}
style={{
backgroundColor: 'transparent',
borderColor: 'transparent',
......
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