Commit 469afb6b authored by faisalhamdi's avatar faisalhamdi

Merge branch 'master' of http://103.44.149.204/d.arizona/tia-dev into faisal

parents d11333af 21ce0aae
......@@ -161,6 +161,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const getRevision = (body) => api.post('transaction/get_revision', body)
const getPeriodeTransaction = () => api.get('transaction/get_periode')
const deleteAttachment = (id) => api.post(`transaction/delete_attachment/${id}`)
const getDetailReportMB = (body) => api.post('/transaction/master_budget/get_report_hierarki', body)
//Template
const downloadTemplate = (fileName, fileType) => api.get(`attachment/download_file?fileName=${fileName}&&fileType=${fileType}`)
......@@ -264,7 +265,8 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
uploadAttachment,
getPeriodeTransaction,
getRevision,
deleteAttachment
deleteAttachment,
getDetailReportMB
}
}
......
......@@ -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,72 +54,119 @@ 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') {
let data = response.data.data
let userData = data.map((item) => {
return {
user_id: item.user_id,
fullname: item.fullname
if(response.data) {
if (response.ok) {
if (response.data.status == 'success') {
let data = response.data.data
let userData = data.map((item) => {
return {
user_id: item.user_id,
fullname: item.fullname
}
})
// console.log(userData)
let defaultProps = {
options: userData,
getOptionLabel: (option) => option.fullname,
};
this.setState({ approvedBy: defaultProps, userData: response.data.data})
} else {
// alert('Approver Name: ' +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: 'Approver Name: ' + response.data.message, tipeAlert: 'error' })
}
}
})
// console.log(userData)
let defaultProps = {
options: userData,
getOptionLabel: (option) => option.fullname,
};
this.setState({ approvedBy: defaultProps, userData: response.data.data})
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
} else {
// alert('Approver Name: ' +response.data.message)
this.setState({ alert: true, messageAlert: 'Approver Name: ' +response.problem, tipeAlert: 'error' })
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
getTypeData() {
api.create().getTypeAM().then((response) => {
if (response.data.status == 'success') {
let data = response.data.data
let typeData = data.map((item) => {
return {
approval_type_id: item.approval_type_id,
approval_type_name: item.approval_type_name
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
let data = response.data.data
let typeData = data.map((item) => {
return {
approval_type_id: item.approval_type_id,
approval_type_name: item.approval_type_name
}
})
let typeProps = {
options: typeData,
getOptionLabel: (option) => option.approval_type_name,
};
this.setState({ types: typeProps, typeData: response.data.data })
} 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: 'warning' })
}
}
})
let typeProps = {
options: typeData,
getOptionLabel: (option) => option.approval_type_name,
};
this.setState({ types: typeProps, typeData: response.data.data })
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
} else {
// alert('Approval Type: ' +response.data.message)
this.setState({ alert: true, messageAlert: 'Approval Type: ' +response.problem, tipeAlert: 'error' })
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
getOperatorData() {
api.create().getOperatorAM().then((response) => {
if (response.data.status == 'success') {
let data = response.data.data
let operatorData = data.map((item) => {
return {
operator_type_id: item.operator_type_id,
operator_type_name: item.operator_type_name
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
let data = response.data.data
let operatorData = data.map((item) => {
return {
operator_type_id: item.operator_type_id,
operator_type_name: item.operator_type_name
}
})
// console.log(userData)
let operatorProps = {
options: operatorData,
getOptionLabel: (option) => option.operator_type_name,
};
this.setState({ operators: operatorProps, operatorData: response.data.data })
} 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: 'warning' })
}
}
})
// console.log(userData)
let operatorProps = {
options: operatorData,
getOptionLabel: (option) => option.operator_type_name,
};
this.setState({ operators: operatorProps, operatorData: response.data.data })
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
} else {
// alert('Operator: ' +response.data.message)
this.setState({ alert: true, messageAlert: 'Operator: ' +response.problem, tipeAlert: 'error' })
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -456,9 +504,9 @@ export default class CreateApprovalMatrix extends Component {
</div>
</div> */}
</div>
<div className="margin-top-10px" style={{ padding: 10, paddingLeft: 0 }}>
<Typography style={{ fontSize: 11 }}>{`Created by : `}</Typography>
{/* <Typography style={{ fontSize: 11 }}>Diubah : Admin - 21 Jul 2020, 18:45</Typography> */}
<div className="margin-top-10px" style={{ paddingTop: 10, paddingBottom: 10, paddingLeft: 10, paddingRight: 30 }}>
<Typography style={{ fontSize: 11 }}>{`Created By : `}</Typography>
<Typography style={{ fontSize: 11 }}>{`Updated By :`}</Typography>
</div>
</div>
<div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
......
......@@ -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 = [
......@@ -45,22 +46,37 @@ export default class VisualisasiAM extends Component {
getTypeData() {
api.create().getTypeAM().then((response) => {
if (response.data.status == 'success') {
let data = response.data.data
// console.log(data)
let typeData = data.map((item) => {
return {
approval_type_id: item.approval_type_id,
approval_type_name: item.approval_type_name
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
let data = response.data.data
// console.log(data)
let typeData = data.map((item) => {
return {
approval_type_id: item.approval_type_id,
approval_type_name: item.approval_type_name
}
})
let typeProps = {
options: typeData,
getOptionLabel: (option) => option.approval_type_name,
};
this.setState({ types: typeProps, typeData: response.data.data })
} 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);
}
})
}
})
let typeProps = {
options: typeData,
getOptionLabel: (option) => option.approval_type_name,
};
this.setState({ types: typeProps, typeData: response.data.data })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -71,28 +87,43 @@ export default class VisualisasiAM extends Component {
"keyword": this.state.typeName
}
api.create().searchAM(body).then(response => {
if (response.data.status == 'success') {
let data = response.data.data
// console.log(data)
let listVisual = []
data.map((item, index) => {
let indexId = listVisual.findIndex((val) => val.orderId == item.orders)
if(indexId == -1){
listVisual.push({
orderId: item.orders,
data: [item]
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
let data = response.data.data
// console.log(data)
let listVisual = []
data.map((item, index) => {
let indexId = listVisual.findIndex((val) => val.orderId == item.orders)
if(indexId == -1){
listVisual.push({
orderId: item.orders,
data: [item]
})
// console.log(listVisual);
} else {
listVisual[indexId].data.push(item)
// console.log('listVisual');
// console.log(listVisual);
}
})
this.setState({ listApproval: listVisual})
// console.log(listVisual);
} else {
listVisual[indexId].data.push(item)
// console.log('listVisual');
// console.log(listVisual);
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);
}
})
}
})
this.setState({ listApproval: listVisual})
// console.log(listVisual);
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......
......@@ -32,7 +32,8 @@ export default class BudgetTahunan extends Component {
visibleFAM: false,
visibleCAT: false,
listAttachment: [],
visibleUpload: false
visibleUpload: false,
revisionTable: null
}
this.fileHandler = this.fileHandler.bind(this);
}
......@@ -161,54 +162,59 @@ export default class BudgetTahunan extends Component {
})
}
clickDetail(item, id) {
this.setState({ report_id: id })
if (item === 'Balance Sheet') {
this.setState({
visibleBudgetTahunan: false,
visibleBS: true,
visiblePL: false,
visibleCAT: false,
visibleFAM: false,
visibleTP: false,
})
} else if (item === 'Profit & Loss') {
this.setState({
visibleBudgetTahunan: false,
visibleBS: false,
visiblePL: true,
visibleCAT: false,
visibleFAM: false,
visibleTP: false
})
} else if (item === 'Tax Planning') {
this.setState({
visibleBudgetTahunan: false,
visibleBS: false,
visiblePL: false,
visibleCAT: false,
visibleFAM: false,
visibleTP: true
})
} else if (item === 'Fixed Assets Movement') {
this.setState({
visibleBudgetTahunan: false,
visibleBS: false,
visiblePL: false,
visibleCAT: false,
visibleFAM: true,
visibleTP: false
})
} else if (item === 'CAT') {
this.setState({
visibleBudgetTahunan: false,
visibleBS: false,
visiblePL: false,
visibleCAT: true,
visibleFAM: false,
visibleTP: false
})
}
clickDetail(item, id, revision) {
console.log(item);
this.setState({
report_id: id,
revisionTable: revision,
}, () => {
if (item === 'Balance Sheet') {
this.setState({
visibleBudgetTahunan: false,
visibleBS: true,
visiblePL: false,
visibleCAT: false,
visibleFAM: false,
visibleTP: false,
})
} else if (item === 'Profit Loss') {
this.setState({
visibleBudgetTahunan: false,
visibleBS: false,
visiblePL: true,
visibleCAT: false,
visibleFAM: false,
visibleTP: false
})
} else if (item === 'Tax Planning') {
this.setState({
visibleBudgetTahunan: false,
visibleBS: false,
visiblePL: false,
visibleCAT: false,
visibleFAM: false,
visibleTP: true
})
} else if (item === 'Fixed Assets Movement') {
this.setState({
visibleBudgetTahunan: false,
visibleBS: false,
visiblePL: false,
visibleCAT: false,
visibleFAM: true,
visibleTP: false
})
} else if (item === 'CAT') {
this.setState({
visibleBudgetTahunan: false,
visibleBS: false,
visiblePL: false,
visibleCAT: true,
visibleFAM: false,
visibleTP: false
})
}
})
}
handleChange(value, tableMeta) {
......@@ -323,7 +329,7 @@ export default class BudgetTahunan extends Component {
borderColor: 'transparent'
}}
onClick={() =>
tableMeta.rowData[5] ? this.clickDetail(tableMeta.rowData[1], tableMeta.rowData[4]) : null
tableMeta.rowData[5] ? this.clickDetail(tableMeta.rowData[1], tableMeta.rowData[4], tableMeta.rowData[2]) : null
}
>
<Typography style={{ color: tableMeta.rowData[5] ? '#5198ea' : 'GrayText', fontSize: 12, }}>Detail</Typography>
......@@ -554,6 +560,8 @@ export default class BudgetTahunan extends Component {
<BalanceSheet
report_id={this.state.report_id}
company={this.state.company}
revision={this.state.revisionTable}
periode={this.state.periode.periode}
onClickClose={() => this.setState({ visibleBS: false, visibleBudgetTahunan: true })}
/>
)}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -113,7 +113,7 @@ class Login extends Component {
this.props.history.push('/home/beranda')
} else {
if (response.data.message == 'Password is Not Correct') {
this.setState({ errorPassword: true, msgPassword: response.data.message })
this.setState({ errorPassword: true, msgPassword: 'Incorrect Password' })
} else {
this.setState({ errorEmail: true, msgEmail: response.data.message })
}
......
......@@ -7,6 +7,7 @@ import Autocomplete from '@material-ui/lab/Autocomplete';
import MuiAlert from '@material-ui/lab/Alert';
import api from '../../../api';
import Images from '../../../assets/Images';
import Constant from '../../../library/Constant';
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
......@@ -71,23 +72,34 @@ export default class CreatePerusahaan extends Component {
api.create().getDetailPerusahaan(this.props.data[1]).then(response => {
console.log(response)
if (response.data) {
if (response.data.status === "success") {
this.setState({
businessID: response.data.data.business_unit_id,
companyID: response.data.data.company_id,
status: response.data.data.status,
company: response.data.data.company_name,
parentID: response.data.data.parent,
parent: response.data.data.parent_name,
startDate: response.data.data.start_date,
endDate: response.data.data.end_date,
totalReport: response.data.data.total_report,
created: response.data.data.created,
updated: response.data.data.updated === null ? "" : response.data.data.updated
}, () => this.getAllUnitBisnis(), this.getCompanyActive())
if (response.ok) {
if (response.data.status === "success") {
this.setState({
businessID: response.data.data.business_unit_id,
companyID: response.data.data.company_id,
status: response.data.data.status,
company: response.data.data.company_name,
parentID: response.data.data.parent,
parent: response.data.data.parent_name,
startDate: response.data.data.start_date,
endDate: response.data.data.end_date,
totalReport: response.data.data.total_report,
created: response.data.data.created,
updated: response.data.data.updated === null ? "" : response.data.data.updated
}, () => this.getAllUnitBisnis(), this.getCompanyActive())
} 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: 'warning' })
}
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
......@@ -103,23 +115,34 @@ export default class CreatePerusahaan extends Component {
api.create().getPerusahaanActive(payload).then(response => {
console.log(response)
if (response.data) {
if (response.data.status == 'success') {
let data = response.data.data
let perusahaanData = data.map((item) => {
return {
company_id: item.company_id,
company_name: item.company_name
}
})
let index = perusahaanData.sort((a, b) => a.company_id - b.company_id).findIndex((val) => val.company_id == this.state.parentID)
let typeProps = {
options: perusahaanData,
getOptionLabel: (option) => option.company_name,
};
this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index == -1 ? null : perusahaanData[index] })
if (response.ok) {
if (response.data.status == 'success') {
let data = response.data.data
let perusahaanData = data.map((item) => {
return {
company_id: item.company_id,
company_name: item.company_name
}
})
let index = perusahaanData.sort((a, b) => a.company_id - b.company_id).findIndex((val) => val.company_id == this.state.parentID)
let typeProps = {
options: perusahaanData,
getOptionLabel: (option) => option.company_name,
};
this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index == -1 ? null : perusahaanData[index] })
} 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: 'warning' })
}
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
......@@ -130,25 +153,36 @@ export default class CreatePerusahaan extends Component {
getAllUnitBisnis() {
api.create().getUnitBisnisActive().then(response => {
if (response.data) {
if (response.data.status === 'success') {
let data = response.data.data
let typeData = data.map((item) => {
return {
business_unit_id: item.business_unit_id,
business_unit_name: item.business_unit_name
}
})
// console.log(typeData)
let index = typeData.findIndex((val) => val.business_unit_id == this.state.businessID)
console.log(index)
let typeProps = {
options: typeData,
getOptionLabel: (option) => option.business_unit_name,
};
this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? null : typeData[index] })
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let typeData = data.map((item) => {
return {
business_unit_id: item.business_unit_id,
business_unit_name: item.business_unit_name
}
})
// console.log(typeData)
let index = typeData.findIndex((val) => val.business_unit_id == this.state.businessID)
console.log(index)
let typeProps = {
options: typeData,
getOptionLabel: (option) => option.business_unit_name,
};
this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? null : typeData[index] })
} 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: 'warning' })
}
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 Nestable from 'react-nestable/dist/Nestable';
import AddIcon from '@material-ui/icons/Add';
import RemoveIcon from '@material-ui/icons/Remove';
import api from '../../../api';
import Constant from '../../../library/Constant';
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
......@@ -55,11 +56,22 @@ export default class VisualPerusahaan extends Component {
api.create().getPerusahaanHierarki().then((response) => {
console.log(response)
if (response.data) {
if (response.data.status == 'success') {
this.setState({ items: response.data.data })
console.log(response.data.data)
if (response.ok) {
if (response.data.status == 'success') {
this.setState({ items: response.data.data })
console.log(response.data.data)
} 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: 'warning' })
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
......@@ -89,8 +101,30 @@ export default class VisualPerusahaan extends Component {
"company": this.state.items
}
api.create().saveVisualisasiPerusahaan(payload).then((response) => {
// if (response.data.status == 'ucces') {
this.props.onClickClose()
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' }, () => {
setTimeout(() => {
this.props.onClickClose()
}, 1000);
})
} 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' })
}
// } else {
// alert(response.data.message)
// }
......
This diff is collapsed.
This diff is collapsed.
......@@ -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,21 +60,32 @@ export default class CreateUnitBisnis extends Component {
api.create().getDetailUnitBisnis(this.props.data[1]).then(response => {
console.log(response)
if (response.data) {
if (response.data.status === "success") {
let data = response.data.data
this.setState({
id: data.business_unit_id,
name: data.business_unit_name,
startDate: data.start_date,
endDate: data.end_date,
status: data.status,
created: data.created,
updated: data.updated === null ? "" : data.updated
})
}
else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
if (response.ok) {
if (response.data.status === "success") {
let data = response.data.data
this.setState({
id: data.business_unit_id,
name: data.business_unit_name,
startDate: data.start_date,
endDate: data.end_date,
status: data.status,
created: data.created,
updated: data.updated === null ? "" : data.updated
})
}
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' })
}
......
This diff is collapsed.
......@@ -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' })
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment