Commit 905cfbf3 authored by r.kurnia's avatar r.kurnia

homeeeeee

parent a296332d
...@@ -562,13 +562,16 @@ class HomePage extends Component { ...@@ -562,13 +562,16 @@ class HomePage extends Component {
let data = response.data.data let data = response.data.data
data.map((item, index) => { data.map((item, index) => {
let statusConvert = item.status == 'approval_review' ? 'Waiting For Review' : item.status == 'approval_proccess' ? 'Waiting For Approval' : titleCase(item.status) let statusConvert = item.status == 'approval_review' ? 'Waiting For Review' : item.status == 'approval_proccess' ? 'Waiting For Approval' : titleCase(item.status)
if (this.state.isApproverMB && this.state.isApproverMR) { if (this.state.isApproverMB && this.state.isApproverMR && this.state.isApproverRO && this.state.isApproverOL) {
if (String(item.type_report).toLocaleLowerCase().includes("master")) { if (String(item.type_report).toLocaleLowerCase().includes("master")) {
listDashboard.push([index + 1, item.approval_id, item.company_name, `${item.type_report} - ${item.periode}`, item.revision, item.status, statusConvert]) listDashboard.push([index + 1, item.approval_id, item.company_name, `${item.type_report} - ${item.periode}`, item.revision, item.status, statusConvert])
rawData.push(item) rawData.push(item)
} else if (String(item.type_report).toLocaleLowerCase().includes("monthly")) { } else if (String(item.type_report).toLocaleLowerCase().includes("monthly")) {
listDashboard.push([index + 1, item.approval_id, item.company_name, `${item.type_report} ${item.periode}`, item.revision, item.status, statusConvert]) listDashboard.push([index + 1, item.approval_id, item.company_name, `${item.type_report} ${item.periode}`, item.revision, item.status, statusConvert])
rawData.push(item) rawData.push(item)
} else if (String(item.type_report).toLocaleLowerCase().includes("outlook")) {
listDashboard.push([index + 1, item.approval_id, item.company_name, `${item.type_report} ${item.periode}`, item.revision, item.status, statusConvert])
rawData.push(item)
} }
} else if (this.state.isApproverMB) { } else if (this.state.isApproverMB) {
if (String(item.type_report).toLocaleLowerCase().includes("master")) { if (String(item.type_report).toLocaleLowerCase().includes("master")) {
...@@ -580,6 +583,11 @@ class HomePage extends Component { ...@@ -580,6 +583,11 @@ class HomePage extends Component {
listDashboard.push([index + 1, item.approval_id, item.company_name, `${item.type_report} ${item.periode}`, item.revision, item.status, statusConvert]) listDashboard.push([index + 1, item.approval_id, item.company_name, `${item.type_report} ${item.periode}`, item.revision, item.status, statusConvert])
rawData.push(item) rawData.push(item)
} }
} else if (this.state.isApproverRO || this.state.isApproverOL) {
if (String(item.type_report).toLocaleLowerCase().includes("outlook")) {
listDashboard.push([index + 1, item.approval_id, item.company_name, `${item.type_report} ${item.periode}`, item.revision, item.status, statusConvert])
rawData.push(item)
}
} }
}) })
this.setState({ listDashboard, rawData }) this.setState({ listDashboard, rawData })
...@@ -591,8 +599,10 @@ class HomePage extends Component { ...@@ -591,8 +599,10 @@ class HomePage extends Component {
this.setState({ loading: true }) this.setState({ loading: true })
let isApproverMR = false let isApproverMR = false
let isApproverMB = false let isApproverMB = false
let isApproverRO = false
let isApproverOL = false
api.create().getAM().then((response) => { api.create().getAM().then((response) => {
// console.log(response); console.log(response);
let actAMActive = [] let actAMActive = []
let actAM = response.data.data.map((item, index) => { let actAM = response.data.data.map((item, index) => {
if (String(item.status).toLocaleLowerCase() == 'active') { if (String(item.status).toLocaleLowerCase() == 'active') {
...@@ -608,6 +618,10 @@ class HomePage extends Component { ...@@ -608,6 +618,10 @@ class HomePage extends Component {
isApproverMR = true isApproverMR = true
} else if (item.approval_type_name === "MASTER_BUDGET") { } else if (item.approval_type_name === "MASTER_BUDGET") {
isApproverMB = true isApproverMB = true
} else if (item.approval_type_name === "ROLLING_OUTLOOK") {
isApproverRO = true
} else if (item.approval_type_name === "OUTLOOK_PA") {
isApproverOL = true
} }
}) })
...@@ -616,7 +630,7 @@ class HomePage extends Component { ...@@ -616,7 +630,7 @@ class HomePage extends Component {
this.getMonth() this.getMonth()
// this.getListUserSubco() // this.getListUserSubco()
} }
this.setState({ isApproverMB, isApproverMR }) this.setState({ isApproverMB, isApproverMR, isApproverRO, isApproverOL })
this.getDashboardMB() this.getDashboardMB()
// this.getDashboardMB() // this.getDashboardMB()
this.getDashboard() this.getDashboard()
...@@ -707,14 +721,16 @@ class HomePage extends Component { ...@@ -707,14 +721,16 @@ class HomePage extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
// console.log(tableMeta); // console.log(tableMeta);
// console.log(this.state.rawData);
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<Link to={{ <Link to={{
pathname: String(tableMeta.rowData[3]).toLocaleLowerCase().includes("master") ? `/home/master-budget/` : `/home/monthly-report/`, pathname: String(tableMeta.rowData[3]).toLocaleLowerCase().includes("master") ? `/home/master-budget/` : String(tableMeta.rowData[3]).toLocaleLowerCase().includes("monthly") ? `/home/monthly-report/` : String(tableMeta.rowData[3]).toLocaleLowerCase().includes("rolling") ? `/home/rolling-outlook/` : `/home/outlook-performance/`,
state: { state: {
userType: 'approver', userType: 'approver',
rawData: this.state.rawData[tableMeta.rowIndex], rawData: this.state.rawData[tableMeta.rowIndex],
month: String(tableMeta.rowData[3]).toLocaleLowerCase().includes("master") ? null : getDataMonth(this.state.rawData[tableMeta.rowIndex]) month: String(tableMeta.rowData[3]).toLocaleLowerCase().includes("master") ? null : getDataMonth(this.state.rawData[tableMeta.rowIndex]),
quartal: String(tableMeta.rowData[3]).toLocaleLowerCase().includes("rolling") ? this.state.quarter.value : null
} }
}}> }}>
<button <button
...@@ -1200,7 +1216,7 @@ class HomePage extends Component { ...@@ -1200,7 +1216,7 @@ class HomePage extends Component {
</div> </div>
</div> </div>
} }
<div style={{ display: 'inline-flex' }}> <div style={{ display: 'flex', overflowX: 'scroll', width: this.props.width * 0.95 }}>
{this.state.accessMB && {this.state.accessMB &&
<div style={{ flex: 1, padding: 20, width: '100%' }}> <div style={{ flex: 1, padding: 20, width: '100%' }}>
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
...@@ -1385,8 +1401,7 @@ class HomePage extends Component { ...@@ -1385,8 +1401,7 @@ class HomePage extends Component {
pathname: `/home/rolling-outlook/`, pathname: `/home/rolling-outlook/`,
state: { state: {
userType: 'user', userType: 'user',
rawData: item, rawData: {...item, quarter: this.state.quarter.value},
quarter: this.state.quarter
} }
}}> }}>
<button <button
......
...@@ -72,8 +72,8 @@ export default class OutlookPA extends Component { ...@@ -72,8 +72,8 @@ export default class OutlookPA extends Component {
this.setState({ loading: true }) this.setState({ loading: true })
this.props.selectIndex('Outlook Performance Appraisal') this.props.selectIndex('Outlook Performance Appraisal')
if (this.props.location.state !== undefined) { if (this.props.location.state !== undefined) {
// console.log(this.props); console.log(this.props);
this.setState({ userType: this.props.location.state.userType, intent: 'Home', lastPeriod: this.props.location.state.rawData.periode, rawData: this.props.location.state.rawData }, () => { this.setState({ userType: this.props.location.state.userType, intent: 'Home', lastPeriodProps: this.props.location.state.rawData.periode, rawData: this.props.location.state.rawData }, () => {
this.checkApprover() this.checkApprover()
}) })
} else { } else {
...@@ -118,7 +118,11 @@ export default class OutlookPA extends Component { ...@@ -118,7 +118,11 @@ export default class OutlookPA extends Component {
options: companyData, options: companyData,
getOptionLabel: (option) => titleCase(option.company_name), getOptionLabel: (option) => titleCase(option.company_name),
}; };
this.setState({ listCompany: defaultProps, company: companyData[0] }, () => { let indexID = null
if (this.state.rawData !== undefined) {
indexID = companyData.findIndex((val) => val.company_id == this.state.rawData.company_id)
}
this.setState({ listCompany: defaultProps, company: indexID == null ? companyData[0] : companyData[indexID] }, () => {
// // console.log(response.data.data); // // console.log(response.data.data);
if (response.data.data.length > 0) { if (response.data.data.length > 0) {
this.getRevision() this.getRevision()
...@@ -329,7 +333,7 @@ export default class OutlookPA extends Component { ...@@ -329,7 +333,7 @@ export default class OutlookPA extends Component {
options: periodeData, options: periodeData,
getOptionLabel: (option) => option.periode, getOptionLabel: (option) => option.periode,
}; };
let periode = (this.state.lastPeriod == "" ? String(Number(currentYear) + 1) : Number(this.state.lastPeriod)) let periode = (this.state.lastPeriod == "" ? String(Number(currentYear) + 1) : this.state.lastPeriodProps == undefined ? this.state.lastPeriodProps : Number(this.state.lastPeriod))
let index = data.sort((a, b) => a - b).findIndex((val) => val == periode) let index = data.sort((a, b) => a - b).findIndex((val) => val == periode)
// console.log(data) // console.log(data)
// console.log(this.state.lastPeriod) // console.log(this.state.lastPeriod)
......
...@@ -85,14 +85,14 @@ export default class RollingOutlook extends Component { ...@@ -85,14 +85,14 @@ export default class RollingOutlook extends Component {
componentDidMount() { componentDidMount() {
this.setState({ loading: true }) this.setState({ loading: true })
this.props.selectIndex('Rolling Outlook & CAT') this.props.selectIndex('Rolling Outlook & CAT')
// if (this.props.location.state !== undefined) { if (this.props.location.state !== undefined) {
// console.log(this.props); console.log(this.props);
// this.setState({ userType: this.props.location.state.userType, intent: 'Home', lastPeriod: this.props.location.state.rawData.periode, rawData: this.props.location.state.rawData }, () => { this.setState({ userType: this.props.location.state.userType, intent: 'Home', lastPeriod: this.props.location.state.rawData.periode, rawData: this.props.location.state.rawData }, () => {
// this.checkApprover() this.getPermission()
// }) })
// } else { } else {
this.getPermission() this.getPermission()
// } }
} }
getPermission() { getPermission() {
...@@ -452,7 +452,8 @@ export default class RollingOutlook extends Component { ...@@ -452,7 +452,8 @@ export default class RollingOutlook extends Component {
let yearNow = dateNow.getFullYear() let yearNow = dateNow.getFullYear()
// let indexMonthMR = MR.findIndex((val) => val.value == yearNow) // let indexMonthMR = MR.findIndex((val) => val.value == yearNow)
// console.log(yearNow) // console.log(yearNow)
let index = data.sort((a, b) => a - b).findIndex((val) => val == yearNow) // let index = data.sort((a, b) => a - b).findIndex((val) => val == yearNow)
let index = data.sort((a, b) => a - b).findIndex((val) => val === periode)
// console.log(data) // console.log(data)
// console.log(this.state.lastPeriod) // console.log(this.state.lastPeriod)
// console.log(periodeData) // console.log(periodeData)
...@@ -461,7 +462,11 @@ export default class RollingOutlook extends Component { ...@@ -461,7 +462,11 @@ export default class RollingOutlook extends Component {
options: this.state.quarterList, options: this.state.quarterList,
getOptionLabel: (option) => option.name getOptionLabel: (option) => option.name
} }
this.setState({ listPeriode: defaultProps, listQuarter: defaultPropsQuarter, quarter: this.state.quarterList[0], periode: index === -1 ? periodeData[0] : periodeData[index] }, () => { let indexID = null
if (this.state.rawData !== undefined) {
indexID = this.state.quarterList.findIndex((val) => String(val.value).toLocaleLowerCase() == this.state.rawData.quarter)
}
this.setState({ listPeriode: defaultProps, listQuarter: defaultPropsQuarter, quarter: indexID == null ? this.state.quarterList[0] : this.state.quarterList[indexID], periode: index === -1 ? periodeData[0] : periodeData[index] }, () => {
// if (this.state.isApprover === true && this.state.submittedOnly) { // if (this.state.isApprover === true && this.state.submittedOnly) {
this.getDetailUser() this.getDetailUser()
// this.getCompanySubmitted() // this.getCompanySubmitted()
......
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