Commit 375bc669 authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'syadziy' into 'master'

update redirect login

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