Commit 33b604a9 authored by d.arizona's avatar d.arizona

update

parent 65bd51db
......@@ -32,7 +32,8 @@ export default class DashboardCAT extends Component {
dataDashboard: [],
selectedKPI: [],
listKPI: [],
rawData: {}
selectedMonth: [],
rawData: null
}
}
......@@ -42,7 +43,7 @@ export default class DashboardCAT extends Component {
let dataStorageCAT = localStorage.getItem(Constant.DATACAT)
console.log(dataStorageCAT)
if (dataStorageCAT != 'datacat') {
this.setState({selectedKPI: JSON.parse(dataStorageCAT).listKPI})
this.setState({ selectedKPI: JSON.parse(dataStorageCAT).listKPI })
console.log(dataStorageCAT)
}
if (this.props.location.state !== undefined) {
......@@ -106,7 +107,7 @@ export default class DashboardCAT extends Component {
if (response.data) {
if (response.data.status === 'success') {
let data = response.data.data
let comID = this.state.rawData ? this.state.rawData.companyId : 0
let comID = this.state.rawData != null ? this.state.rawData.companyId : 0
// console.log(comID)
let companyData = data.map((item) => {
return {
......@@ -172,7 +173,7 @@ export default class DashboardCAT extends Component {
let data = []
console.log(response.data.data)
console.log(this.state.lastPeriod)
let periodeID = this.state.rawData ? this.state.rawData.periode : 0
let periodeID = this.state.rawData != null ? this.state.rawData.periode : 0
response.data.data.map((item) => {
if (this.state.isApprover) {
if (item >= 2000 && item <= (Number(currentYear) + 1)) {
......@@ -194,7 +195,7 @@ export default class DashboardCAT extends Component {
getOptionLabel: (option) => option.periode,
};
let periode = (this.state.lastPeriod == "" ? String(Number(currentYear) + 1) : this.state.lastPeriod)
let index = periodeData.sort((a, b) => a.periode - b.periode).findIndex((val) => periodeID == 0? val.periode === periode : val.periode == periodeID)
let index = periodeData.sort((a, b) => a.periode - b.periode).findIndex((val) => periodeID == 0 ? val.periode === periode : val.periode == periodeID)
// // console.log(this.props.location.state.rawData)
// console.log(this.state.lastPeriod)
console.log(data)
......@@ -218,7 +219,7 @@ export default class DashboardCAT extends Component {
if (response.data.status === "success") {
console.log(response);
let data = response.data.data
let monthID = this.state.rawData ? this.state.rawData.month : 0
let monthID = this.state.rawData != null ? this.state.rawData.month : 0
let monthData = data.map((item) => {
return {
month_id: item.id,
......@@ -229,10 +230,16 @@ export default class DashboardCAT extends Component {
options: monthData,
getOptionLabel: (option) => option.month_value,
};
let index = data.findIndex((val) => monthID == 0? val.month_name == month : val.id == monthID)
let index = data.findIndex((val) => monthID == 0 ? val.month_name == month : val.id == monthID)
console.log(index);
let selectedMonth = []
monthData.map((item, indexs) => {
if (indexs <= index) {
selectedMonth.push(item.month_value)
}
})
this.setState({ listMonth: defaultProps, month: index == -1 ? monthData[0] : monthData[index] }, () => {
this.setState({ listMonth: defaultProps, month: index == -1 ? monthData[0] : monthData[index], selectedMonth }, () => {
this.getDasboardCAT()
})
} else {
......@@ -289,7 +296,7 @@ export default class DashboardCAT extends Component {
userID: localStorage.getItem(Constant.USER),
listKPI: this.state.selectedKPI
}
localStorage.setItem(Constant.DATACAT, this.state.selectedKPI.length == 0? 'datacat' : JSON.stringify(payloadData))
localStorage.setItem(Constant.DATACAT, this.state.selectedKPI.length == 0 ? 'datacat' : JSON.stringify(payloadData))
})
}
......@@ -362,6 +369,14 @@ export default class DashboardCAT extends Component {
{...this.state.listMonth}
id="month"
onChange={(event, newInputValue) => this.setState({ month: newInputValue, loading: true }, () => {
let index = this.state.listMonth.options.findIndex((val) => val.month_id == this.state.month.month_id)
let selectedMonth = []
this.state.listMonth.options.map((item, indexs) => {
if (indexs <= index) {
selectedMonth.push(item.month_value)
}
})
this.setState({selectedMonth})
this.getDasboardCAT()
})}
disableClearable
......@@ -382,7 +397,7 @@ export default class DashboardCAT extends Component {
</Tabs>
</AppBar>
{this.state.tab === 0 ?
<ExceutiveScoreboard selectedKPI={this.state.selectedKPI} setSelectedKPI={this.setSelectedKPI.bind(this)} height={this.props.height} data={this.state.dataDashboard} dataPayload={{ month: this.state.month, periode: this.state.periode, company: this.state.company }} />
<ExceutiveScoreboard selectedKPI={this.state.selectedKPI} selectedMonth={this.state.selectedMonth} setSelectedKPI={this.setSelectedKPI.bind(this)} height={this.props.height} data={this.state.dataDashboard} dataPayload={{ month: this.state.month, periode: this.state.periode, company: this.state.company }} />
:
this.state.tab === 1 ?
<StrategiMap height={this.props.height} data={this.state.dataDashboard} dataPayload={{ month: this.state.month, periode: this.state.periode, company: this.state.company }} />
......
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