Commit de760b73 authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'riri' into 'master'

upload lagi

See merge request !260
parents dc04af2b dc139a35
......@@ -47,7 +47,8 @@ export default class ReportItems extends Component {
load: false,
judul: '',
reportNameDelete: '',
visibleDelete: false
visibleDelete: false,
invalidTemplate: false
}
this.fileHandler = this.fileHandler.bind(this);
......@@ -67,11 +68,11 @@ export default class ReportItems extends Component {
if (item.length > 0) {
payload.push({
id: index + 1,
report_type: item[0] === undefined ? "" : item[0],
report: item[0] === undefined ? "" : item[0],
company: item[1] === undefined ? "" : item[1],
orders: item[2] === undefined ? null : item[2],
orders: item[2] === undefined ? "" : item[2],
description: item[3] === undefined ? "" : item[3],
parent: item[4] === undefined ? null : item[4],
parent: item[4] === undefined ? 0 : item[4],
uom: item[5] === undefined ? "" : item[5],
weight: item[6] === undefined ? "" : item[6],
type_report: item[7] === undefined ? "" : item[7],
......@@ -89,6 +90,13 @@ export default class ReportItems extends Component {
let body = {
item_report: payload
}
if (resp.rows[2].length !== 16) {
this.setState({ invalidTemplate: true })
} else {
this.setState({ invalidTemplate: false })
}
console.log(resp.rows[1])
this.setState({ payload: body, buttonError: false, judul: resp.rows[1][0] })
}
......@@ -104,7 +112,7 @@ export default class ReportItems extends Component {
if (response.data.status === "success") {
dataRow = response.data.data.map((item, index) => {
return [
item.report_type,
item.report,
item.company,
item.orders,
item.description,
......@@ -339,9 +347,9 @@ export default class ReportItems extends Component {
<div style={{ display: 'flex' }}>
{tableMeta.rowData[16] != null && check > -1 ?
<a data-tip={tableMeta.rowData[16][check].message} data-for="formulas">
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
</a> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
}
<ReactTooltip border={true} id="formulas" place="bottom" type="light" effect="solid" />
</div >
......@@ -541,7 +549,7 @@ export default class ReportItems extends Component {
});
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
......@@ -601,7 +609,7 @@ export default class ReportItems extends Component {
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
......@@ -629,7 +637,7 @@ export default class ReportItems extends Component {
this.setState({ visibleDelete: false, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
......@@ -682,7 +690,7 @@ export default class ReportItems extends Component {
this.setState({ dataTable: listData, listData: response.data.data })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
......@@ -709,7 +717,7 @@ export default class ReportItems extends Component {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
......@@ -766,7 +774,7 @@ export default class ReportItems extends Component {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
......@@ -793,7 +801,7 @@ export default class ReportItems extends Component {
this.setState({ itemReport: true, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
......@@ -1195,7 +1203,7 @@ export default class ReportItems extends Component {
this.setState({ uploadStatus: 'idle', percentage: '0' })
}}
onUpload={() => {
this.state.judul === "MASTER DATA - REPORT ITEMS" ?
this.state.judul === "MASTER DATA - REPORT ITEMS" && !this.state.invalidTemplate ?
this.checkUpload() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}}
......
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