Commit 38830578 authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'riri' into 'master'

company operating indicator & budget tahunan

See merge request !378
parents 94e4ab92 471f0858
...@@ -54,7 +54,7 @@ export default class BudgetTahunan extends Component { ...@@ -54,7 +54,7 @@ export default class BudgetTahunan extends Component {
} }
componentDidMount() { componentDidMount() {
this.getCompanyActive() this.getDetailUser()
} }
getReportAttachment() { getReportAttachment() {
...@@ -103,6 +103,21 @@ export default class BudgetTahunan extends Component { ...@@ -103,6 +103,21 @@ export default class BudgetTahunan extends Component {
}) })
} }
getDetailUser() {
let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.setState({ userCompany: response.data.data.company}, () => {
this.getCompanyActive()
})
}
}
}
})
}
getCompanyActive() { getCompanyActive() {
api.create().getPerusahaanActive().then((response) => { api.create().getPerusahaanActive().then((response) => {
if (response.data) { if (response.data) {
...@@ -114,11 +129,21 @@ export default class BudgetTahunan extends Component { ...@@ -114,11 +129,21 @@ export default class BudgetTahunan extends Component {
company_name: item.company_name, company_name: item.company_name,
} }
}) })
let arrayBaru = []
this.state.userCompany.map((item,index) => {
let indexID = companyData.findIndex((val) => val.company_id == item)
if (indexID !== -1) {
arrayBaru.push(companyData[indexID])
}
})
let defaultProps = { let defaultProps = {
options: companyData, options: arrayBaru,
getOptionLabel: (option) => titleCase(option.company_name), getOptionLabel: (option) => titleCase(option.company_name),
}; };
this.setState({ listCompany: defaultProps, company: companyData[0] }, () => {
this.setState({ listCompany: defaultProps, company: arrayBaru[0] }, () => {
this.getPeriode() this.getPeriode()
}) })
} else { } else {
...@@ -134,7 +159,6 @@ export default class BudgetTahunan extends Component { ...@@ -134,7 +159,6 @@ export default class BudgetTahunan extends Component {
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', listCompany: null, company: null }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', listCompany: null, company: null })
} }
}) })
} }
......
...@@ -9,6 +9,7 @@ import { titleCase } from '../../library/Utils'; ...@@ -9,6 +9,7 @@ import { titleCase } from '../../library/Utils';
import { ExcelRenderer } from 'react-excel-renderer'; import { ExcelRenderer } from 'react-excel-renderer';
import UploadFile from "../../library/Upload"; import UploadFile from "../../library/Upload";
import { format } from 'date-fns'; import { format } from 'date-fns';
import Constant from '../../library/Constant';
var ct = require("../../library/CustomTable"); var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable()); const getMuiTheme = () => createMuiTheme(ct.customTable());
...@@ -35,7 +36,7 @@ export default class OperatingIndicator extends Component { ...@@ -35,7 +36,7 @@ export default class OperatingIndicator extends Component {
} }
componentDidMount() { componentDidMount() {
this.getCompanyActive() this.getDetailUser()
} }
getReportAttachment() { getReportAttachment() {
...@@ -82,25 +83,61 @@ export default class OperatingIndicator extends Component { ...@@ -82,25 +83,61 @@ export default class OperatingIndicator extends Component {
}) })
} }
getDetailUser() {
let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.setState({ userCompany: response.data.data.company}, () => {
this.getCompanyActive()
})
}
}
}
})
}
getCompanyActive() { getCompanyActive() {
api.create().getPerusahaanActive().then((response) => { api.create().getPerusahaanActive().then((response) => {
if (response.data.status === 'success') { if (response.data) {
let data = response.data.data if (response.data.status === 'success') {
let companyData = data.map((item) => { let data = response.data.data
return { let companyData = data.map((item) => {
company_id: item.company_id, return {
company_name: item.company_name, company_id: item.company_id,
} company_name: item.company_name,
}) }
let defaultProps = { })
options: companyData,
getOptionLabel: (option) => titleCase(option.company_name), let arrayBaru = []
}; this.state.userCompany.map((item,index) => {
this.setState({ listCompany: defaultProps, company: companyData[0] }, () => { let indexID = companyData.findIndex((val) => val.company_id == item)
this.getPeriode() if (indexID !== -1) {
}) arrayBaru.push(companyData[indexID])
}
})
let defaultProps = {
options: arrayBaru,
getOptionLabel: (option) => titleCase(option.company_name),
};
this.setState({ listCompany: defaultProps, company: arrayBaru[0] }, () => {
this.getPeriode()
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', listCompany: null, company: null })
} }
}) })
} }
...@@ -378,7 +415,13 @@ export default class OperatingIndicator extends Component { ...@@ -378,7 +415,13 @@ export default class OperatingIndicator extends Component {
debug debug
disableClearable disableClearable
style={{ width: 250 }} style={{ width: 250 }}
renderInput={(params) => <TextField {...params} label="Company" margin="normal" style={{ marginTop: 7 }} />} renderInput={(params) =>
<TextField
{...params}
label="Company"
margin="normal"
style={{ marginTop: 7 }}
/>}
value={this.state.company} value={this.state.company}
/> />
</div> </div>
......
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