Commit 32966a92 authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'deni-dev(pc)' into 'master'

fix invalid template

See merge request !225
parents 504b968e 3629fd5d
...@@ -35,7 +35,8 @@ export default class Parameter extends Component { ...@@ -35,7 +35,8 @@ export default class Parameter extends Component {
messageAlert: '', messageAlert: '',
create: false, create: false,
edit: false, edit: false,
load: false load: false,
judul: ''
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
} }
...@@ -260,7 +261,7 @@ export default class Parameter extends Component { ...@@ -260,7 +261,7 @@ export default class Parameter extends Component {
console.log(err); console.log(err);
} }
else { else {
let judul = resp.rows[2] // let judul = resp.rows[2]
let isi = resp.rows.slice(3) let isi = resp.rows.slice(3)
let payload = [] let payload = []
isi.map((item, index) => { isi.map((item, index) => {
...@@ -283,8 +284,14 @@ export default class Parameter extends Component { ...@@ -283,8 +284,14 @@ export default class Parameter extends Component {
let body = { let body = {
setting: payload setting: payload
} }
this.setState({ payload: body, buttonError: false }) console.log(resp.rows[1]);
api.create().checkUploadParameter(body).then(response => { this.setState({ payload: body, buttonError: false, judul: resp.rows[1][0] })
}
});
}
checkUpload(){
api.create().checkUploadParameter(this.state.payload).then(response => {
console.log(response); console.log(response);
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
...@@ -569,7 +576,9 @@ export default class Parameter extends Component { ...@@ -569,7 +576,9 @@ export default class Parameter extends Component {
this.setState({ this.setState({
dataLoaded: true, dataLoaded: true,
cols: columns, cols: columns,
rows: dataRow rows: dataRow,
visibleUpload: false,
visibleParameter: false
}); });
} else { } else {
this.setState({ dataLoaded: true, cols: [], rows: [], alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ dataLoaded: true, cols: [], rows: [], alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
...@@ -599,17 +608,14 @@ export default class Parameter extends Component { ...@@ -599,17 +608,14 @@ export default class Parameter extends Component {
} }
}) })
}
});
} }
uploadParameter() { uploadParameter() {
api.create().uploadParameter(this.state.payload).then(response => { api.create().uploadParameter(this.state.payload).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") {
console.log(response)
this.getAllParameter() this.getAllParameter()
this.setState({ visibleParameter: true, alert: true, messageAlert: response.data.message, tipeAlert: 'success' }) this.setState({ visibleParameter: true, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { } else {
...@@ -910,7 +916,8 @@ export default class Parameter extends Component { ...@@ -910,7 +916,8 @@ export default class Parameter extends Component {
</button> </button>
<button <button
type="button" type="button"
onClick={() => this.state.buttonError ? this.setState({ popupError: true }) : this.uploadParameter()} disabled={this.state.buttonError ? true : false}
onClick={() => this.uploadParameter()}
style={{}} style={{}}
> >
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}> <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
...@@ -966,7 +973,11 @@ export default class Parameter extends Component { ...@@ -966,7 +973,11 @@ export default class Parameter extends Component {
this.fileHandler(dt) this.fileHandler(dt)
this.setState({ uploadStatus: 'idle', percentage: '0' }) this.setState({ uploadStatus: 'idle', percentage: '0' })
}} }}
onUpload={() => this.setState({ visibleUpload: false, visibleParameter: false })} onUpload={() => {
this.state.judul === "MASTER DATA - PARAMETER" ?
this.checkUpload() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}}
/> />
</div> </div>
</div> </div>
......
...@@ -8,7 +8,7 @@ import MUIDataTable from "mui-datatables"; ...@@ -8,7 +8,7 @@ import MUIDataTable from "mui-datatables";
import CreateUnitBisnis from "./formUnitBisnis/CreateUnitBisnis"; import CreateUnitBisnis from "./formUnitBisnis/CreateUnitBisnis";
import ReactTooltip from 'react-tooltip'; import ReactTooltip from 'react-tooltip';
import MuiAlert from '@material-ui/lab/Alert'; import MuiAlert from '@material-ui/lab/Alert';
import { TextField, InputBase, Snackbar, withStyles } from "@material-ui/core"; import { TextField, InputBase, Snackbar, withStyles, LinearProgress } from "@material-ui/core";
import { ExcelRenderer } from 'react-excel-renderer'; import { ExcelRenderer } from 'react-excel-renderer';
import api from "../../api"; import api from "../../api";
import { isThisSecond } from "date-fns"; import { isThisSecond } from "date-fns";
...@@ -44,7 +44,8 @@ export default class UnitBisnis extends Component { ...@@ -44,7 +44,8 @@ export default class UnitBisnis extends Component {
create: false, create: false,
edit: false, edit: false,
load: false, load: false,
judul: '' judul: '',
// visibleLoad: true
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
} }
...@@ -74,7 +75,12 @@ export default class UnitBisnis extends Component { ...@@ -74,7 +75,12 @@ export default class UnitBisnis extends Component {
} }
console.log(resp.rows[1]) console.log(resp.rows[1])
this.setState({ payload: body, buttonError: false, judul: resp.rows[1][0] }) this.setState({ payload: body, buttonError: false, judul: resp.rows[1][0] })
api.create().checkUploadUnitBisnis(body).then(response => { }
});
}
checkUpload(){
api.create().checkUploadUnitBisnis(this.state.payload).then(response => {
console.log(response) console.log(response)
let dataRow = [] let dataRow = []
if (response.data) { if (response.data) {
...@@ -178,7 +184,8 @@ export default class UnitBisnis extends Component { ...@@ -178,7 +184,8 @@ export default class UnitBisnis extends Component {
this.setState({ this.setState({
dataLoaded: true, dataLoaded: true,
cols: columns, cols: columns,
rows: dataRow rows: dataRow, visibleUpload: false,
visibleUnitBisnis: false
}); });
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
...@@ -200,9 +207,6 @@ export default class UnitBisnis extends Component { ...@@ -200,9 +207,6 @@ export default class UnitBisnis extends Component {
}); });
} }
}) })
}
});
} }
componentDidMount() { componentDidMount() {
...@@ -685,13 +689,21 @@ export default class UnitBisnis extends Component { ...@@ -685,13 +689,21 @@ export default class UnitBisnis extends Component {
}} }}
onUpload={() => { onUpload={() => {
this.state.judul === "MASTER DATA - BUSINESS UNIT" ? this.state.judul === "MASTER DATA - BUSINESS UNIT" ?
this.setState({ visibleUpload: false, visibleUnitBisnis: false }) : this.checkUpload() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning'}) this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}} }}
/> />
</div> </div>
</div> </div>
)} )}
{/* {this.state.visibleLoad && (
<div className="test app-popup-show">
<div className="popup-content" style={{ textAlign: 'center'}}>
<img src={Images.triputraLogo} style={{ height: 100, width: 100}}/>
</div>
</div>
)} */}
</div> </div>
); );
} }
......
...@@ -166,7 +166,12 @@ export default class UserRole extends Component { ...@@ -166,7 +166,12 @@ export default class UserRole extends Component {
} }
console.log(resp.rows[1]) console.log(resp.rows[1])
this.setState({ payload: body, rows: [], judul: resp.rows[1][0] }) this.setState({ payload: body, rows: [], judul: resp.rows[1][0] })
api.create().checkUploadUser(body).then(response => { }
});
}
checkUpload(){
api.create().checkUploadUser(this.state.payload).then(response => {
console.log(response); console.log(response);
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
...@@ -301,7 +306,9 @@ export default class UserRole extends Component { ...@@ -301,7 +306,9 @@ export default class UserRole extends Component {
this.setState({ this.setState({
dataLoaded: true, dataLoaded: true,
cols: columns, cols: columns,
rows: dataRow rows: dataRow,
visibleUpload: false,
visibleUser: false
}); });
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
...@@ -321,8 +328,6 @@ export default class UserRole extends Component { ...@@ -321,8 +328,6 @@ export default class UserRole extends Component {
} }
}) })
} }
});
}
downloadFile = async () => { downloadFile = async () => {
let res = await fetch( let res = await fetch(
...@@ -775,7 +780,7 @@ export default class UserRole extends Component { ...@@ -775,7 +780,7 @@ export default class UserRole extends Component {
}} }}
onUpload={() => { onUpload={() => {
this.state.judul === 'MASTER DATA - USER' ? this.state.judul === 'MASTER DATA - USER' ?
this.setState({ visibleUpload: false, visibleUser: false }) : this.checkUpload() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' }) 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