Commit 07bc1c51 authored by a.bairuha's avatar a.bairuha

update redirect login

parent 9db1674e
...@@ -7,6 +7,7 @@ import format from "date-fns/format"; ...@@ -7,6 +7,7 @@ import format from "date-fns/format";
import localeID from "date-fns/locale/id" import localeID from "date-fns/locale/id"
import api from "../../api"; import api from "../../api";
import Images from '../../assets/Images'; import Images from '../../assets/Images';
import Constant from '../../library/Constant';
export default class CreateApprovalMatrix extends Component { export default class CreateApprovalMatrix extends Component {
constructor(props) { constructor(props) {
...@@ -53,11 +54,9 @@ export default class CreateApprovalMatrix extends Component { ...@@ -53,11 +54,9 @@ export default class CreateApprovalMatrix extends Component {
getUserData() { getUserData() {
api.create().getApprovedByAM().then((response) => { api.create().getApprovedByAM().then((response) => {
if(response.status == null){ if(response.data) {
// alert(response.problem) if (response.ok) {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) if (response.data.status == 'success') {
}
else if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let userData = data.map((item) => { let userData = data.map((item) => {
return { return {
...@@ -73,13 +72,30 @@ export default class CreateApprovalMatrix extends Component { ...@@ -73,13 +72,30 @@ export default class CreateApprovalMatrix extends Component {
this.setState({ approvedBy: defaultProps, userData: response.data.data}) this.setState({ approvedBy: defaultProps, userData: response.data.data})
} else { } else {
// alert('Approver Name: ' +response.data.message) // alert('Approver Name: ' +response.data.message)
this.setState({ alert: true, messageAlert: 'Approver Name: ' +response.problem, tipeAlert: 'error' }) if (response.data.message.includes("Token")) {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
})
} else {
this.setState({ alert: true, messageAlert: 'Approver Name: ' + response.data.message, tipeAlert: 'error' })
}
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
getTypeData() { getTypeData() {
api.create().getTypeAM().then((response) => { api.create().getTypeAM().then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let typeData = data.map((item) => { let typeData = data.map((item) => {
...@@ -95,13 +111,30 @@ export default class CreateApprovalMatrix extends Component { ...@@ -95,13 +111,30 @@ export default class CreateApprovalMatrix extends Component {
this.setState({ types: typeProps, typeData: response.data.data }) this.setState({ types: typeProps, typeData: response.data.data })
} else { } else {
// alert('Approval Type: ' +response.data.message) // alert('Approval Type: ' +response.data.message)
this.setState({ alert: true, messageAlert: 'Approval Type: ' +response.problem, tipeAlert: 'error' }) if (response.data.message.includes("Token")) {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
})
} else {
this.setState({ alert: true, messageAlert: 'Approval Type: ' + response.data.message, tipeAlert: 'warning' })
}
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
getOperatorData() { getOperatorData() {
api.create().getOperatorAM().then((response) => { api.create().getOperatorAM().then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let operatorData = data.map((item) => { let operatorData = data.map((item) => {
...@@ -118,7 +151,22 @@ export default class CreateApprovalMatrix extends Component { ...@@ -118,7 +151,22 @@ export default class CreateApprovalMatrix extends Component {
this.setState({ operators: operatorProps, operatorData: response.data.data }) this.setState({ operators: operatorProps, operatorData: response.data.data })
} else { } else {
// alert('Operator: ' +response.data.message) // alert('Operator: ' +response.data.message)
this.setState({ alert: true, messageAlert: 'Operator: ' +response.problem, tipeAlert: 'error' }) if (response.data.message.includes("Token")) {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
})
} else {
this.setState({ alert: true, messageAlert: 'Operator: ' + response.data.message, tipeAlert: 'warning' })
}
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
......
...@@ -6,6 +6,7 @@ import * as R from 'ramda' ...@@ -6,6 +6,7 @@ import * as R from 'ramda'
import format from "date-fns/format"; import format from "date-fns/format";
import api from "../../api"; import api from "../../api";
import Images from '../../assets/Images'; import Images from '../../assets/Images';
import Constant from '../../library/Constant';
export default class EditApprovalMatrix extends Component { export default class EditApprovalMatrix extends Component {
constructor(props) { constructor(props) {
...@@ -53,6 +54,7 @@ export default class EditApprovalMatrix extends Component { ...@@ -53,6 +54,7 @@ export default class EditApprovalMatrix extends Component {
api.create().getDetailAM(this.props.data[1]).then(response => { api.create().getDetailAM(this.props.data[1]).then(response => {
// console.log(response) // console.log(response)
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status === "success") { if (response.data.status === "success") {
let data = response.data.data let data = response.data.data
this.setState({ this.setState({
...@@ -67,13 +69,29 @@ export default class EditApprovalMatrix extends Component { ...@@ -67,13 +69,29 @@ export default class EditApprovalMatrix extends Component {
created: data.created, created: data.created,
updated: data.updated === null ? "" : data.updated updated: data.updated === null ? "" : data.updated
}, () => this.getUserData(), this.getTypeData(), this.getOperatorData()) }, () => this.getUserData(), this.getTypeData(), this.getOperatorData())
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
getUserData() { getUserData() {
api.create().getApprovedByAM().then((response) => { api.create().getApprovedByAM().then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let userData = data.map((item) => { let userData = data.map((item) => {
...@@ -92,13 +110,30 @@ export default class EditApprovalMatrix extends Component { ...@@ -92,13 +110,30 @@ export default class EditApprovalMatrix extends Component {
} else { } else {
// alert('Pemberi Persetujuan: ' +response.data.message) // alert('Pemberi Persetujuan: ' +response.data.message)
if (response.data.message.includes("Token")) {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
})
} else {
this.setState({ alert: true, messageAlert: 'Pemberi Persetujuan: ' +response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: 'Pemberi Persetujuan: ' +response.data.message, tipeAlert: 'error' })
} }
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
}) })
} }
getOperatorData() { getOperatorData() {
api.create().getOperatorAM().then((response) => { api.create().getOperatorAM().then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let operatorData = data.map((item) => { let operatorData = data.map((item) => {
...@@ -115,13 +150,30 @@ export default class EditApprovalMatrix extends Component { ...@@ -115,13 +150,30 @@ export default class EditApprovalMatrix extends Component {
this.setState({ operators: operatorProps, operatorData: response.data.data, getOperators: index == -1 ? operatorData[0]: operatorData[index] }) this.setState({ operators: operatorProps, operatorData: response.data.data, getOperators: index == -1 ? operatorData[0]: operatorData[index] })
} else { } else {
// alert('Operator: ' +response.data.message) // alert('Operator: ' +response.data.message)
if (response.data.message.includes("Token")) {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
})
} else {
this.setState({ alert: true, messageAlert: 'Operator: ' +response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: 'Operator: ' +response.data.message, tipeAlert: 'error' })
} }
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
}) })
} }
getTypeData() { getTypeData() {
api.create().getTypeAM().then((response) => { api.create().getTypeAM().then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let typeData = data.map((item) => { let typeData = data.map((item) => {
...@@ -138,8 +190,23 @@ export default class EditApprovalMatrix extends Component { ...@@ -138,8 +190,23 @@ export default class EditApprovalMatrix extends Component {
this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? typeData[0]: typeData[index] }) this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? typeData[0]: typeData[index] })
} else { } else {
// alert('Approval Type: ' +response.data.message) // alert('Approval Type: ' +response.data.message)
if (response.data.message.includes("Token")) {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
})
} else {
this.setState({ alert: true, messageAlert: 'Approval Type: ' +response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: 'Approval Type: ' +response.data.message, tipeAlert: 'error' })
} }
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
}) })
} }
......
...@@ -7,6 +7,7 @@ import ReactDragListView from 'react-drag-listview'; ...@@ -7,6 +7,7 @@ import ReactDragListView from 'react-drag-listview';
import Autocomplete from '@material-ui/lab/Autocomplete'; import Autocomplete from '@material-ui/lab/Autocomplete';
import api from "../../api"; import api from "../../api";
import { none } from 'ramda'; import { none } from 'ramda';
import Constant from '../../library/Constant';
const type = [ const type = [
...@@ -46,6 +47,7 @@ export default class VisualisasiAM extends Component { ...@@ -46,6 +47,7 @@ export default class VisualisasiAM extends Component {
getTypeData() { getTypeData() {
api.create().getTypeAM().then((response) => { api.create().getTypeAM().then((response) => {
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
// console.log(data) // console.log(data)
...@@ -61,7 +63,17 @@ export default class VisualisasiAM extends Component { ...@@ -61,7 +63,17 @@ export default class VisualisasiAM extends Component {
}; };
this.setState({ types: typeProps, typeData: response.data.data }) this.setState({ types: typeProps, typeData: response.data.data })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -76,6 +88,7 @@ export default class VisualisasiAM extends Component { ...@@ -76,6 +88,7 @@ export default class VisualisasiAM extends Component {
} }
api.create().searchAM(body).then(response => { api.create().searchAM(body).then(response => {
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
// console.log(data) // console.log(data)
...@@ -97,7 +110,17 @@ export default class VisualisasiAM extends Component { ...@@ -97,7 +110,17 @@ export default class VisualisasiAM extends Component {
this.setState({ listApproval: listVisual}) this.setState({ listApproval: listVisual})
// console.log(listVisual); // console.log(listVisual);
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
......
...@@ -6,6 +6,7 @@ import { DatePicker } from '@material-ui/pickers'; ...@@ -6,6 +6,7 @@ import { DatePicker } from '@material-ui/pickers';
import { format } from 'date-fns'; import { format } from 'date-fns';
import * as R from 'ramda' import * as R from 'ramda'
import Images from '../../../assets/Images'; import Images from '../../../assets/Images';
import Constant from '../../../library/Constant';
export default class CreateParameter extends Component { export default class CreateParameter extends Component {
constructor(props) { constructor(props) {
...@@ -76,6 +77,7 @@ export default class CreateParameter extends Component { ...@@ -76,6 +77,7 @@ export default class CreateParameter extends Component {
api.create().getDetailParameter(this.props.data[0]).then((response) => { api.create().getDetailParameter(this.props.data[0]).then((response) => {
console.log(response); console.log(response);
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
this.setState({ this.setState({
...@@ -90,7 +92,17 @@ export default class CreateParameter extends Component { ...@@ -90,7 +92,17 @@ export default class CreateParameter extends Component {
console.log(this.state.tempData) console.log(this.state.tempData)
}) })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -102,6 +114,7 @@ export default class CreateParameter extends Component { ...@@ -102,6 +114,7 @@ export default class CreateParameter extends Component {
api.create().getAllGroup().then(response => { api.create().getAllGroup().then(response => {
console.log(response); console.log(response);
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let typeData = data.map((item) => { let typeData = data.map((item) => {
...@@ -117,7 +130,17 @@ export default class CreateParameter extends Component { ...@@ -117,7 +130,17 @@ export default class CreateParameter extends Component {
}; };
this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? typeData[0] : typeData[index] }) this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? typeData[0] : typeData[index] })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -128,6 +151,7 @@ export default class CreateParameter extends Component { ...@@ -128,6 +151,7 @@ export default class CreateParameter extends Component {
getPerusahaan() { getPerusahaan() {
api.create().getPerusahaanActive().then(response => { api.create().getPerusahaanActive().then(response => {
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let perusahaanData = data.map((item) => { let perusahaanData = data.map((item) => {
...@@ -147,7 +171,17 @@ export default class CreateParameter extends Component { ...@@ -147,7 +171,17 @@ export default class CreateParameter extends Component {
}; };
this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index == -1 ? null : perusahaanData[index], msgErrorPerusahaan: index === -1 ? 'Company has been inactive' : "", errorPerusahaan: index === -1 ? true : false }) this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index == -1 ? null : perusahaanData[index], msgErrorPerusahaan: index === -1 ? 'Company has been inactive' : "", errorPerusahaan: index === -1 ? true : false })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -158,6 +192,7 @@ export default class CreateParameter extends Component { ...@@ -158,6 +192,7 @@ export default class CreateParameter extends Component {
getDataGroup() { getDataGroup() {
api.create().getAllGroup().then((response) => { api.create().getAllGroup().then((response) => {
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let typeData = data.map((item) => { let typeData = data.map((item) => {
...@@ -172,7 +207,17 @@ export default class CreateParameter extends Component { ...@@ -172,7 +207,17 @@ export default class CreateParameter extends Component {
}; };
this.setState({ types: typeProps, typeData: response.data.data }) this.setState({ types: typeProps, typeData: response.data.data })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -183,6 +228,7 @@ export default class CreateParameter extends Component { ...@@ -183,6 +228,7 @@ export default class CreateParameter extends Component {
getDataPerusahaan() { getDataPerusahaan() {
api.create().getPerusahaanActive().then((response) => { api.create().getPerusahaanActive().then((response) => {
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let typeData = data.map((item) => { let typeData = data.map((item) => {
...@@ -201,7 +247,17 @@ export default class CreateParameter extends Component { ...@@ -201,7 +247,17 @@ export default class CreateParameter extends Component {
}; };
this.setState({ perusahaan: typeProps, perusahaanData: response.data.data }) this.setState({ perusahaan: typeProps, perusahaanData: response.data.data })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -213,6 +269,7 @@ export default class CreateParameter extends Component { ...@@ -213,6 +269,7 @@ export default class CreateParameter extends Component {
api.create().getParameterByGroup(id).then(response => { api.create().getParameterByGroup(id).then(response => {
console.log(response); console.log(response);
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let typeData = data.map((item) => { let typeData = data.map((item) => {
...@@ -228,7 +285,17 @@ export default class CreateParameter extends Component { ...@@ -228,7 +285,17 @@ export default class CreateParameter extends Component {
}; };
this.setState({ enableParameter: true, parameter: typeProps, parameterData: response.data.data, getParameter: index == -1 ? typeData[0] : typeData[index] }) this.setState({ enableParameter: true, parameter: typeProps, parameterData: response.data.data, getParameter: index == -1 ? typeData[0] : typeData[index] })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
......
...@@ -10,6 +10,7 @@ import PopUpFailedSave from "../../../library/PopUpFailedSave"; ...@@ -10,6 +10,7 @@ import PopUpFailedSave from "../../../library/PopUpFailedSave";
import ReactTooltip from 'react-tooltip'; import ReactTooltip from 'react-tooltip';
import UploadFile from "../../../library/Upload"; import UploadFile from "../../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer'; import { ExcelRenderer } from 'react-excel-renderer';
import Constant from '../../../library/Constant';
var ct = require("../../../library/CustomTable"); var ct = require("../../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable()); const getMuiTheme = () => createMuiTheme(ct.customTable());
...@@ -67,6 +68,7 @@ export default class Parameter extends Component { ...@@ -67,6 +68,7 @@ export default class Parameter extends Component {
getAllParameter() { getAllParameter() {
api.create().getAllParameter().then(response => { api.create().getAllParameter().then(response => {
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status === "success") { if (response.data.status === "success") {
console.log(response); console.log(response);
let data = response.data.data let data = response.data.data
...@@ -87,7 +89,17 @@ export default class Parameter extends Component { ...@@ -87,7 +89,17 @@ export default class Parameter extends Component {
}) })
this.setState({ dataTable: listData, data: response.data.data }) this.setState({ dataTable: listData, data: response.data.data })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -114,11 +126,22 @@ export default class Parameter extends Component { ...@@ -114,11 +126,22 @@ export default class Parameter extends Component {
api.create().updateParameter(payload).then(response => { api.create().updateParameter(payload).then(response => {
console.log(response); console.log(response);
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.getAllParameter() this.getAllParameter()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -130,11 +153,22 @@ export default class Parameter extends Component { ...@@ -130,11 +153,22 @@ export default class Parameter extends Component {
this.setState({ visibleCreate: false }) this.setState({ visibleCreate: false })
api.create().createParameter(payload).then(response => { api.create().createParameter(payload).then(response => {
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.getAllParameter() this.getAllParameter()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -180,6 +214,7 @@ export default class Parameter extends Component { ...@@ -180,6 +214,7 @@ export default class Parameter extends Component {
api.create().searchParameter(body).then(response => { api.create().searchParameter(body).then(response => {
console.log(response.data); console.log(response.data);
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let listData = data.map((item, index) => { let listData = data.map((item, index) => {
...@@ -199,7 +234,17 @@ export default class Parameter extends Component { ...@@ -199,7 +234,17 @@ export default class Parameter extends Component {
}) })
this.setState({ dataTable: listData, listData: response.data.data }) this.setState({ dataTable: listData, listData: response.data.data })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -241,7 +286,8 @@ export default class Parameter extends Component { ...@@ -241,7 +286,8 @@ export default class Parameter extends Component {
this.setState({ payload: body, buttonError: false }) this.setState({ payload: body, buttonError: false })
api.create().checkUploadParameter(body).then(response => { api.create().checkUploadParameter(body).then(response => {
console.log(response); console.log(response);
if (response.data !== null) { if (response.data) {
if (response.ok) {
if (response.data.status === "success") { if (response.data.status === "success") {
let dataRow = response.data.data.map((item, index) => { let dataRow = response.data.data.map((item, index) => {
return [ return [
...@@ -525,8 +571,19 @@ export default class Parameter extends Component { ...@@ -525,8 +571,19 @@ export default class Parameter extends Component {
cols: columns, cols: columns,
rows: dataRow rows: dataRow
}); });
} else {
this.setState({ dataLoaded: true, cols: [], rows: [], alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else { } else {
this.setState({ this.setState({
alert: true, messageAlert: response.data.message, tipeAlert: 'error',
dataLoaded: true, dataLoaded: true,
cols: [], cols: [],
rows: [] rows: []
...@@ -534,6 +591,7 @@ export default class Parameter extends Component { ...@@ -534,6 +591,7 @@ export default class Parameter extends Component {
} }
} else { } else {
this.setState({ this.setState({
alert: true, messageAlert: response.problem, tipeAlert: 'error',
dataLoaded: true, dataLoaded: true,
cols: [], cols: [],
rows: [] rows: []
...@@ -549,12 +607,23 @@ export default class Parameter extends Component { ...@@ -549,12 +607,23 @@ export default class Parameter extends Component {
uploadParameter() { uploadParameter() {
api.create().uploadParameter(this.state.payload).then(response => { api.create().uploadParameter(this.state.payload).then(response => {
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status === "success") { if (response.data.status === "success") {
console.log(response) 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 {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
......
...@@ -12,6 +12,7 @@ import VisualReportItems from "./formReportItems/VisualReportItems"; ...@@ -12,6 +12,7 @@ import VisualReportItems from "./formReportItems/VisualReportItems";
import api from "../../api"; import api from "../../api";
import ReactTooltip from "react-tooltip"; import ReactTooltip from "react-tooltip";
import PopUpFailedSave from "../../library/PopUpFailedSave"; import PopUpFailedSave from "../../library/PopUpFailedSave";
import Constant from "../../library/Constant";
var ct = require("../../library/CustomTable"); var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable()); const getMuiTheme = () => createMuiTheme(ct.customTable());
...@@ -85,6 +86,8 @@ export default class ReportItems extends Component { ...@@ -85,6 +86,8 @@ export default class ReportItems extends Component {
this.setState({ payload: body, buttonError: false }) this.setState({ payload: body, buttonError: false })
api.create().checkUploadReportItems(body).then(response => { api.create().checkUploadReportItems(body).then(response => {
console.log(response) console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === "success") { if (response.data.status === "success") {
let dataRow = response.data.data.map((item, index) => { let dataRow = response.data.data.map((item, index) => {
return [ return [
...@@ -446,6 +449,21 @@ export default class ReportItems extends Component { ...@@ -446,6 +449,21 @@ export default class ReportItems extends Component {
cols: columns, cols: columns,
rows: dataRow rows: dataRow
}); });
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
console.log(response); console.log(response);
}) })
...@@ -482,6 +500,7 @@ export default class ReportItems extends Component { ...@@ -482,6 +500,7 @@ export default class ReportItems extends Component {
api.create().getReportItems().then((response) => { api.create().getReportItems().then((response) => {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let listData = data.sort((a, b) => a.item_report_id - b.item_report_id).map((item, index) => { let listData = data.sort((a, b) => a.item_report_id - b.item_report_id).map((item, index) => {
...@@ -489,7 +508,17 @@ export default class ReportItems extends Component { ...@@ -489,7 +508,17 @@ export default class ReportItems extends Component {
}) })
this.setState({ dataTable: listData, listData: response.data.data }) this.setState({ dataTable: listData, listData: response.data.data })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -518,6 +547,7 @@ export default class ReportItems extends Component { ...@@ -518,6 +547,7 @@ export default class ReportItems extends Component {
api.create().searchReportItems(body).then(response => { api.create().searchReportItems(body).then(response => {
// console.log(response.data); // console.log(response.data);
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let listData = data.map((item, index) => { let listData = data.map((item, index) => {
...@@ -525,7 +555,17 @@ export default class ReportItems extends Component { ...@@ -525,7 +555,17 @@ export default class ReportItems extends Component {
}) })
this.setState({ dataTable: listData, listData: response.data.data }) this.setState({ dataTable: listData, listData: response.data.data })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -537,11 +577,22 @@ export default class ReportItems extends Component { ...@@ -537,11 +577,22 @@ export default class ReportItems extends Component {
this.setState({ add: false }) this.setState({ add: false })
api.create().createReportItems(payload).then(response => { api.create().createReportItems(payload).then(response => {
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.getData() this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -583,11 +634,22 @@ export default class ReportItems extends Component { ...@@ -583,11 +634,22 @@ export default class ReportItems extends Component {
this.setState({ edit: false }) this.setState({ edit: false })
api.create().updateReportItems(payload).then(response => { api.create().updateReportItems(payload).then(response => {
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.getData() this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -598,12 +660,23 @@ export default class ReportItems extends Component { ...@@ -598,12 +660,23 @@ export default class ReportItems extends Component {
uploadReportItems() { uploadReportItems() {
api.create().uploadReportItems(this.state.payload).then(response => { api.create().uploadReportItems(this.state.payload).then(response => {
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status === "success") { if (response.data.status === "success") {
// alert(response.data.message) // alert(response.data.message)
this.getData() this.getData()
this.setState({ itemReport: true, alert: true, messageAlert: response.data.message, tipeAlert: 'success' }) this.setState({ itemReport: true, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
......
...@@ -13,6 +13,7 @@ import { ExcelRenderer } from 'react-excel-renderer'; ...@@ -13,6 +13,7 @@ import { ExcelRenderer } from 'react-excel-renderer';
import api from "../../api"; import api from "../../api";
import { isThisSecond } from "date-fns"; import { isThisSecond } from "date-fns";
import PopUpFailedSave from "../../library/PopUpFailedSave"; import PopUpFailedSave from "../../library/PopUpFailedSave";
import Constant from "../../library/Constant";
var ct = require("../../library/CustomTable"); var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable()); const getMuiTheme = () => createMuiTheme(ct.customTable());
...@@ -75,6 +76,7 @@ export default class UnitBisnis extends Component { ...@@ -75,6 +76,7 @@ export default class UnitBisnis extends Component {
this.setState({ payload: body, buttonError: false }) this.setState({ payload: body, buttonError: false })
api.create().checkUploadUnitBisnis(body).then(response => { api.create().checkUploadUnitBisnis(body).then(response => {
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status === "success") { if (response.data.status === "success") {
let dataRow = response.data.data.map((item, index) => { let dataRow = response.data.data.map((item, index) => {
return [ return [
...@@ -176,10 +178,23 @@ export default class UnitBisnis extends Component { ...@@ -176,10 +178,23 @@ export default class UnitBisnis extends Component {
cols: columns, cols: columns,
rows: dataRow rows: dataRow
}); });
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ this.setState({
dataLoaded: false, dataLoaded: false,
alert: true, messageAlert: response.problem, tipeAlert: 'error'
}); });
} }
}) })
...@@ -211,6 +226,8 @@ export default class UnitBisnis extends Component { ...@@ -211,6 +226,8 @@ export default class UnitBisnis extends Component {
load: true load: true
}) })
} }
} else {
this.setState({ load: true })
} }
}) })
} }
...@@ -219,6 +236,7 @@ export default class UnitBisnis extends Component { ...@@ -219,6 +236,7 @@ export default class UnitBisnis extends Component {
api.create().getUnitBisnis().then((response) => { api.create().getUnitBisnis().then((response) => {
// console.log(response) // console.log(response)
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let listData = data.sort((a, b) => a.business_unit_id - b.business_unit_id).map((item, index) => { let listData = data.sort((a, b) => a.business_unit_id - b.business_unit_id).map((item, index) => {
...@@ -226,10 +244,20 @@ export default class UnitBisnis extends Component { ...@@ -226,10 +244,20 @@ export default class UnitBisnis extends Component {
}) })
this.setState({ dataTable: listData, listData: response.data.data }) this.setState({ dataTable: listData, listData: response.data.data })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', dataTable: [] }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -256,6 +284,7 @@ export default class UnitBisnis extends Component { ...@@ -256,6 +284,7 @@ export default class UnitBisnis extends Component {
api.create().searchUnitBisnis(body).then(response => { api.create().searchUnitBisnis(body).then(response => {
// console.log(response.data); // console.log(response.data);
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let listData = data.map((item, index) => { let listData = data.map((item, index) => {
...@@ -263,7 +292,17 @@ export default class UnitBisnis extends Component { ...@@ -263,7 +292,17 @@ export default class UnitBisnis extends Component {
}) })
this.setState({ dataTable: listData, listData: response.data.data }) this.setState({ dataTable: listData, listData: response.data.data })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -275,11 +314,22 @@ export default class UnitBisnis extends Component { ...@@ -275,11 +314,22 @@ export default class UnitBisnis extends Component {
this.setState({ visibleEdit: false }) this.setState({ visibleEdit: false })
api.create().updateUnitBisnis(payload).then(response => { api.create().updateUnitBisnis(payload).then(response => {
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.getData() this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -292,11 +342,22 @@ export default class UnitBisnis extends Component { ...@@ -292,11 +342,22 @@ export default class UnitBisnis extends Component {
this.setState({ visibleCreate: false }) this.setState({ visibleCreate: false })
api.create().createUnitBisnis(payload).then(response => { api.create().createUnitBisnis(payload).then(response => {
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.getData() this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -338,11 +399,22 @@ export default class UnitBisnis extends Component { ...@@ -338,11 +399,22 @@ export default class UnitBisnis extends Component {
api.create().uploadUnitBisnis(this.state.payload).then(response => { api.create().uploadUnitBisnis(this.state.payload).then(response => {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status === "success") { if (response.data.status === "success") {
this.getData() this.getData()
this.setState({ visibleUnitBisnis: true, alert: true, messageAlert: response.data.message, tipeAlert: 'success' }) this.setState({ visibleUnitBisnis: true, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
......
...@@ -8,6 +8,7 @@ import format from "date-fns/format"; ...@@ -8,6 +8,7 @@ import format from "date-fns/format";
import { DatePicker } from '@material-ui/pickers'; import { DatePicker } from '@material-ui/pickers';
import Images from '../../../assets/Images'; import Images from '../../../assets/Images';
import MuiAlert from '@material-ui/lab/Alert'; import MuiAlert from '@material-ui/lab/Alert';
import Constant from '../../../library/Constant';
const Alert = withStyles({ const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />); })((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
...@@ -204,7 +205,7 @@ export default class CreateReportItems extends Component { ...@@ -204,7 +205,7 @@ export default class CreateReportItems extends Component {
api.create().getInputType().then((response) => { api.create().getInputType().then((response) => {
// console.log(response.data) // console.log(response.data)
if(response.data) { if(response.data) {
if (response.pk) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let inputData = data.map((item) => { let inputData = data.map((item) => {
...@@ -219,9 +220,19 @@ export default class CreateReportItems extends Component { ...@@ -219,9 +220,19 @@ export default class CreateReportItems extends Component {
}; };
this.setState({ listInputType: defaultProps, inputData: response.data.data }) this.setState({ listInputType: defaultProps, inputData: response.data.data })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
// alert(response.data.message) // alert(response.data.message)
} }
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
...@@ -232,6 +243,7 @@ export default class CreateReportItems extends Component { ...@@ -232,6 +243,7 @@ export default class CreateReportItems extends Component {
api.create().getPerusahaanActive().then((response) => { api.create().getPerusahaanActive().then((response) => {
// console.log(response) // console.log(response)
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let companyData = data.map((item) => { let companyData = data.map((item) => {
...@@ -250,9 +262,19 @@ export default class CreateReportItems extends Component { ...@@ -250,9 +262,19 @@ export default class CreateReportItems extends Component {
}; };
this.setState({ listCompany: typeProps, companyData: response.data.data }) this.setState({ listCompany: typeProps, companyData: response.data.data })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
// alert(response.data.message) // alert(response.data.message)
} }
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
...@@ -263,6 +285,7 @@ export default class CreateReportItems extends Component { ...@@ -263,6 +285,7 @@ export default class CreateReportItems extends Component {
api.create().getReportType().then((response) => { api.create().getReportType().then((response) => {
// console.log(response) // console.log(response)
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let reportTypeData = data.map((item) => { let reportTypeData = data.map((item) => {
...@@ -278,7 +301,17 @@ export default class CreateReportItems extends Component { ...@@ -278,7 +301,17 @@ export default class CreateReportItems extends Component {
this.setState({ listReportType: defaultProps, reportTypeData: response.data.data }) this.setState({ listReportType: defaultProps, reportTypeData: response.data.data })
} else { } else {
// alert(response.data.message) // alert(response.data.message)
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -295,7 +328,7 @@ export default class CreateReportItems extends Component { ...@@ -295,7 +328,7 @@ export default class CreateReportItems extends Component {
api.create().getReportParent(payload).then((response) => { api.create().getReportParent(payload).then((response) => {
// console.log(response) // console.log(response)
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let parentData = data.map((item) => { let parentData = data.map((item) => {
...@@ -310,9 +343,19 @@ export default class CreateReportItems extends Component { ...@@ -310,9 +343,19 @@ export default class CreateReportItems extends Component {
}; };
this.setState({ listParent: defaultProps, parentData: response.data.data }) this.setState({ listParent: defaultProps, parentData: response.data.data })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
// alert(response.data.message) // alert(response.data.message)
} }
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
......
...@@ -8,6 +8,7 @@ import api from '../../../api'; ...@@ -8,6 +8,7 @@ import api from '../../../api';
import * as R from 'ramda' import * as R from 'ramda'
import { titleCase } from '../../../library/Utils'; import { titleCase } from '../../../library/Utils';
import Images from '../../../assets/Images'; import Images from '../../../assets/Images';
import Constant from '../../../library/Constant';
const Alert = withStyles({ const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />); })((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
...@@ -178,6 +179,7 @@ export default class EditReportItems extends Component { ...@@ -178,6 +179,7 @@ export default class EditReportItems extends Component {
getDetailReportItems() { getDetailReportItems() {
api.create().getDetailReportItems(this.props.data[1]).then((response) => { api.create().getDetailReportItems(this.props.data[1]).then((response) => {
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
this.setState({ this.setState({
...@@ -188,7 +190,17 @@ export default class EditReportItems extends Component { ...@@ -188,7 +190,17 @@ export default class EditReportItems extends Component {
this.getReportType(),) this.getReportType(),)
console.log(response.data.data) console.log(response.data.data)
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -200,6 +212,7 @@ export default class EditReportItems extends Component { ...@@ -200,6 +212,7 @@ export default class EditReportItems extends Component {
api.create().getInputType().then((response) => { api.create().getInputType().then((response) => {
// console.log(response) // console.log(response)
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let inputData = data.map((item) => { let inputData = data.map((item) => {
...@@ -216,7 +229,17 @@ export default class EditReportItems extends Component { ...@@ -216,7 +229,17 @@ export default class EditReportItems extends Component {
let index = inputData.findIndex((val) => val.type_item_report_id === this.state.tempData.type_item_report_id) let index = inputData.findIndex((val) => val.type_item_report_id === this.state.tempData.type_item_report_id)
this.setState({ listInputType: defaultProps, InputType: index === -1 ? null : inputData[index] }) this.setState({ listInputType: defaultProps, InputType: index === -1 ? null : inputData[index] })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -228,6 +251,7 @@ export default class EditReportItems extends Component { ...@@ -228,6 +251,7 @@ export default class EditReportItems extends Component {
api.create().getPerusahaanActive().then((response) => { api.create().getPerusahaanActive().then((response) => {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let companyData = data.map((item) => { let companyData = data.map((item) => {
...@@ -248,7 +272,17 @@ export default class EditReportItems extends Component { ...@@ -248,7 +272,17 @@ export default class EditReportItems extends Component {
// let index = companyData.findIndex((val) => val.company_id === this.state.tempData.company_id) // let index = companyData.findIndex((val) => val.company_id === this.state.tempData.company_id)
this.setState({ listCompany: defaultProps, companyData: response.data.data, company: index === -1 ? null : companyData[index], msgErrorPerusahaan: index === -1 ? 'Company has been Inactive.' : "", errorPerusahaan: index === -1 ? true : false }, () => this.getParent()) this.setState({ listCompany: defaultProps, companyData: response.data.data, company: index === -1 ? null : companyData[index], msgErrorPerusahaan: index === -1 ? 'Company has been Inactive.' : "", errorPerusahaan: index === -1 ? true : false }, () => this.getParent())
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -260,6 +294,7 @@ export default class EditReportItems extends Component { ...@@ -260,6 +294,7 @@ export default class EditReportItems extends Component {
api.create().getReportType().then((response) => { api.create().getReportType().then((response) => {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let reportTypeData = data.map((item) => { let reportTypeData = data.map((item) => {
...@@ -276,7 +311,17 @@ export default class EditReportItems extends Component { ...@@ -276,7 +311,17 @@ export default class EditReportItems extends Component {
let index = reportTypeData.findIndex((val) => val.report_id === this.state.tempData.report_id) let index = reportTypeData.findIndex((val) => val.report_id === this.state.tempData.report_id)
this.setState({ listReportType: defaultProps, reportType: index === -1 ? null : reportTypeData[index] }, () => this.getParent()) this.setState({ listReportType: defaultProps, reportType: index === -1 ? null : reportTypeData[index] }, () => this.getParent())
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -294,6 +339,7 @@ export default class EditReportItems extends Component { ...@@ -294,6 +339,7 @@ export default class EditReportItems extends Component {
api.create().getReportParent(payload).then((response) => { api.create().getReportParent(payload).then((response) => {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let currentIndex = null let currentIndex = null
...@@ -318,7 +364,17 @@ export default class EditReportItems extends Component { ...@@ -318,7 +364,17 @@ export default class EditReportItems extends Component {
let index = parentData.findIndex((val) => val.item_report_id === this.state.tempData.parent) let index = parentData.findIndex((val) => val.item_report_id === this.state.tempData.parent)
this.setState({ listParent: defaultProps, parent: index == -1 ? null : parentData[index] }) this.setState({ listParent: defaultProps, parent: index == -1 ? null : parentData[index] })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
......
...@@ -9,6 +9,7 @@ import api from '../../../api'; ...@@ -9,6 +9,7 @@ import api from '../../../api';
import { titleCase } from '../../../library/Utils'; import { titleCase } from '../../../library/Utils';
import Autocomplete from '@material-ui/lab/Autocomplete'; import Autocomplete from '@material-ui/lab/Autocomplete';
import MuiAlert from '@material-ui/lab/Alert'; import MuiAlert from '@material-ui/lab/Alert';
import Constant from '../../../library/Constant';
const useStyles = makeStyles((theme) => ({ const useStyles = makeStyles((theme) => ({
root: { root: {
...@@ -94,7 +95,14 @@ export default class VisualReportItems extends Component { ...@@ -94,7 +95,14 @@ export default class VisualReportItems extends Component {
this.setState({ listReport: defaultProps, report: reportData[0] }) this.setState({ listReport: defaultProps, report: reportData[0] })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
...@@ -125,7 +133,14 @@ export default class VisualReportItems extends Component { ...@@ -125,7 +133,14 @@ export default class VisualReportItems extends Component {
this.getItemHierarki() this.getItemHierarki()
}) })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
...@@ -212,7 +227,14 @@ export default class VisualReportItems extends Component { ...@@ -212,7 +227,14 @@ export default class VisualReportItems extends Component {
}, 1000); }, 1000);
}) })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
......
...@@ -6,6 +6,7 @@ import format from "date-fns/format"; ...@@ -6,6 +6,7 @@ import format from "date-fns/format";
import Images from '../../../assets/Images'; import Images from '../../../assets/Images';
import api from '../../../api'; import api from '../../../api';
import MuiAlert from '@material-ui/lab/Alert'; import MuiAlert from '@material-ui/lab/Alert';
import Constant from '../../../library/Constant';
const Alert = withStyles({ const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />); })((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
...@@ -59,6 +60,7 @@ export default class CreateUnitBisnis extends Component { ...@@ -59,6 +60,7 @@ export default class CreateUnitBisnis extends Component {
api.create().getDetailUnitBisnis(this.props.data[1]).then(response => { api.create().getDetailUnitBisnis(this.props.data[1]).then(response => {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status === "success") { if (response.data.status === "success") {
let data = response.data.data let data = response.data.data
this.setState({ this.setState({
...@@ -72,7 +74,17 @@ export default class CreateUnitBisnis extends Component { ...@@ -72,7 +74,17 @@ export default class CreateUnitBisnis extends Component {
}) })
} }
else { else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
......
...@@ -14,6 +14,7 @@ import { withStyles } from '@material-ui/core/styles'; ...@@ -14,6 +14,7 @@ import { withStyles } from '@material-ui/core/styles';
import { ExcelRenderer } from 'react-excel-renderer'; import { ExcelRenderer } from 'react-excel-renderer';
import ReactTooltip from "react-tooltip"; import ReactTooltip from "react-tooltip";
import PopUpFailedSave from "../../library/PopUpFailedSave"; import PopUpFailedSave from "../../library/PopUpFailedSave";
import Constant from "../../library/Constant";
var ct = require("../../library/CustomTable"); var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable()); const getMuiTheme = () => createMuiTheme(ct.customTable());
...@@ -65,7 +66,14 @@ export default class UserRole extends Component { ...@@ -65,7 +66,14 @@ export default class UserRole extends Component {
}) })
this.setState({ listUser: listData }) this.setState({ listUser: listData })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
...@@ -110,7 +118,14 @@ export default class UserRole extends Component { ...@@ -110,7 +118,14 @@ export default class UserRole extends Component {
}) })
this.setState({ listUser: listData }) this.setState({ listUser: listData })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
...@@ -151,6 +166,7 @@ export default class UserRole extends Component { ...@@ -151,6 +166,7 @@ export default class UserRole extends Component {
api.create().checkUploadUser(body).then(response => { api.create().checkUploadUser(body).then(response => {
console.log(response); console.log(response);
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status === "success") { if (response.data.status === "success") {
let dataRow = response.data.data.map((item, index) => { let dataRow = response.data.data.map((item, index) => {
return [ return [
...@@ -281,7 +297,21 @@ export default class UserRole extends Component { ...@@ -281,7 +297,21 @@ export default class UserRole extends Component {
cols: columns, cols: columns,
rows: dataRow rows: dataRow
}); });
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
} }
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -327,7 +357,14 @@ export default class UserRole extends Component { ...@@ -327,7 +357,14 @@ export default class UserRole extends Component {
this.getUser() this.getUser()
this.closeEdit() this.closeEdit()
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
...@@ -357,7 +394,14 @@ export default class UserRole extends Component { ...@@ -357,7 +394,14 @@ export default class UserRole extends Component {
this.getUser() this.getUser()
this.setState({ visibleUser: true }) this.setState({ visibleUser: true })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
......
...@@ -11,6 +11,7 @@ import { DatePicker } from '@material-ui/pickers'; ...@@ -11,6 +11,7 @@ import { DatePicker } from '@material-ui/pickers';
import * as R from 'ramda' import * as R from 'ramda'
import Images from '../../../assets/Images'; import Images from '../../../assets/Images';
import MuiAlert from '@material-ui/lab/Alert'; import MuiAlert from '@material-ui/lab/Alert';
import Constant from '../../../library/Constant';
const CustomCheckbox = withStyles({ const CustomCheckbox = withStyles({
root: { root: {
...@@ -200,7 +201,14 @@ export default class AddUser extends Component { ...@@ -200,7 +201,14 @@ export default class AddUser extends Component {
this.props.refresh() this.props.refresh()
}, 750); }, 750);
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
...@@ -235,7 +243,14 @@ export default class AddUser extends Component { ...@@ -235,7 +243,14 @@ export default class AddUser extends Component {
}; };
this.setState({ listRole: defaultProps }) this.setState({ listRole: defaultProps })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
...@@ -254,7 +269,14 @@ export default class AddUser extends Component { ...@@ -254,7 +269,14 @@ export default class AddUser extends Component {
this.setState({ listCompany: response.data.data }) this.setState({ listCompany: response.data.data })
console.log(response.data.data) console.log(response.data.data)
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
......
...@@ -10,6 +10,7 @@ import AddIcon from '@material-ui/icons/Add'; ...@@ -10,6 +10,7 @@ import AddIcon from '@material-ui/icons/Add';
import * as R from 'ramda' import * as R from 'ramda'
import Images from '../../../assets/Images'; import Images from '../../../assets/Images';
import MuiAlert from '@material-ui/lab/Alert'; import MuiAlert from '@material-ui/lab/Alert';
import Constant from '../../../library/Constant';
const CustomCheckbox = withStyles({ const CustomCheckbox = withStyles({
root: { root: {
...@@ -145,7 +146,14 @@ export default class EditUser extends Component { ...@@ -145,7 +146,14 @@ export default class EditUser extends Component {
this.getRole(response.data.data.role_id)) this.getRole(response.data.data.role_id))
console.log(response.data.data) console.log(response.data.data)
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
...@@ -220,7 +228,14 @@ export default class EditUser extends Component { ...@@ -220,7 +228,14 @@ export default class EditUser extends Component {
console.log(index) console.log(index)
this.setState({ listRole: defaultProps, role: index === -1 ? null : roleData[index], msgErrorRN: index === -1 ? 'Role has been inactive' : '', errorRoleName: index === -1 ? true : false }) this.setState({ listRole: defaultProps, role: index === -1 ? null : roleData[index], msgErrorRN: index === -1 ? 'Role has been inactive' : '', errorRoleName: index === -1 ? true : false })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
...@@ -238,7 +253,14 @@ export default class EditUser extends Component { ...@@ -238,7 +253,14 @@ export default class EditUser extends Component {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ listCompany: response.data.data }) this.setState({ listCompany: response.data.data })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
......
...@@ -13,6 +13,7 @@ import { InputBase, Snackbar } from "@material-ui/core"; ...@@ -13,6 +13,7 @@ import { InputBase, Snackbar } from "@material-ui/core";
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 { withStyles } from '@material-ui/core/styles'; import { withStyles } from '@material-ui/core/styles';
import Constant from "../../library/Constant";
var ct = require("../../library/CustomTable"); var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable()); const getMuiTheme = () => createMuiTheme(ct.customTable());
...@@ -68,7 +69,14 @@ class UserRole extends Component { ...@@ -68,7 +69,14 @@ class UserRole extends Component {
// }) // })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
...@@ -113,7 +121,14 @@ class UserRole extends Component { ...@@ -113,7 +121,14 @@ class UserRole extends Component {
}) })
this.setState({ listRole: listData }) this.setState({ listRole: listData })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
......
...@@ -9,6 +9,7 @@ import localeID from "date-fns/locale/id" ...@@ -9,6 +9,7 @@ import localeID from "date-fns/locale/id"
import * as R from 'ramda' import * as R from 'ramda'
import Images from '../../../assets/Images'; import Images from '../../../assets/Images';
import MuiAlert from '@material-ui/lab/Alert'; import MuiAlert from '@material-ui/lab/Alert';
import Constant from '../../../library/Constant';
const CustomCheckbox = withStyles({ const CustomCheckbox = withStyles({
root: { root: {
...@@ -143,7 +144,14 @@ export default class AddRole extends Component { ...@@ -143,7 +144,14 @@ export default class AddRole extends Component {
this.props.refresh() this.props.refresh()
}, 750); }, 750);
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
...@@ -188,7 +196,14 @@ export default class AddRole extends Component { ...@@ -188,7 +196,14 @@ export default class AddRole extends Component {
this.setState({ application: app, setting: set, isLoad: true }, () => console.log(this.state.application)) this.setState({ application: app, setting: set, isLoad: true }, () => console.log(this.state.application))
// this.setState({ menuData: response.data.data }) // this.setState({ menuData: response.data.data })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
......
...@@ -8,6 +8,7 @@ import format from "date-fns/format"; ...@@ -8,6 +8,7 @@ import format from "date-fns/format";
import * as R from 'ramda' import * as R from 'ramda'
import Images from '../../../assets/Images'; import Images from '../../../assets/Images';
import MuiAlert from '@material-ui/lab/Alert'; import MuiAlert from '@material-ui/lab/Alert';
import Constant from '../../../library/Constant';
const CustomCheckbox = withStyles({ const CustomCheckbox = withStyles({
root: { root: {
...@@ -103,7 +104,14 @@ export default class EditRole extends Component { ...@@ -103,7 +104,14 @@ export default class EditRole extends Component {
this.setState({ tempData: response.data.data, privileges: response.data.data.privileges }) this.setState({ tempData: response.data.data, privileges: response.data.data.privileges })
console.log(response.data.data.start_date) console.log(response.data.data.start_date)
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
...@@ -163,7 +171,14 @@ export default class EditRole extends Component { ...@@ -163,7 +171,14 @@ export default class EditRole extends Component {
this.props.refresh() this.props.refresh()
}, 750); }, 750);
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
...@@ -208,7 +223,14 @@ export default class EditRole extends Component { ...@@ -208,7 +223,14 @@ export default class EditRole extends Component {
this.setState({ application: app, setting: set, isLoad: true }, () => console.log(this.state.application)) this.setState({ application: app, setting: set, isLoad: true }, () => console.log(this.state.application))
// this.setState({ menuData: response.data.data }) // this.setState({ menuData: response.data.data })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
......
...@@ -120,7 +120,14 @@ export default class Profile extends Component { ...@@ -120,7 +120,14 @@ export default class Profile extends Component {
window.location.reload(); window.location.reload();
}, 1000); }, 1000);
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
...@@ -152,7 +159,14 @@ export default class Profile extends Component { ...@@ -152,7 +159,14 @@ export default class Profile extends Component {
this.setState({ company: response.data.data.company, photo: response.data.data.photo, name: response.data.data.fullname }) this.setState({ company: response.data.data.company, photo: response.data.data.photo, name: response.data.data.fullname })
console.log(response) console.log(response)
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
...@@ -172,7 +186,14 @@ export default class Profile extends Component { ...@@ -172,7 +186,14 @@ export default class Profile extends Component {
this.setState({ listCompany: response.data.data }) this.setState({ listCompany: response.data.data })
console.log(response.data.data) console.log(response.data.data)
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
...@@ -311,7 +332,14 @@ export default class Profile extends Component { ...@@ -311,7 +332,14 @@ export default class Profile extends Component {
}) })
}) })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
......
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