Commit 40a0e700 authored by d.arizona's avatar d.arizona

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

parents 89d546cd 21a26477
......@@ -26,6 +26,7 @@ class HomePage extends Component {
],
isApprover: true,
listSubcoMB: [],
listSubcoMR: [],
valueSubmit: 0,
listdmb: [],
dataTableMB: [],
......@@ -69,22 +70,37 @@ class HomePage extends Component {
getListUserSubco() {
api.create().getDashboardUser().then(response => {
// console.log(response);
console.log(response);
let valueSubmit = 0
let valueSubmitMR = 0
let dataMB = []
let dataMR = []
if (response.data) {
if (response.data.status === "success") {
response.data.data.map((item, index) => {
if (item.is_submit === true) {
if (item.is_submit === true && item.type === "master_budget") {
valueSubmit += 1
} else if (item.is_submit === true && item.type === "monthly_report") {
valueSubmitMR += 1
}
if ( item.type === "master_budget" ) {
dataMB.push(item)
} else {
dataMR.push(item)
}
})
this.setState({
listSubcoMB: response.data.data,
listSubcoMB: dataMB,
listSubcoMR: dataMR,
valueSubmit,
valueSubmitMR,
loading: false
})
}
}
console.log(this.state.listSubcoMB)
console.log(this.state.listSubcoMR)
})
}
......@@ -92,13 +108,25 @@ class HomePage extends Component {
let listDashboard = []
let rawData = []
api.create().getDashboard().then((response) => {
// console.log(response);
console.log(response);
if (String(response.data.status).toLocaleLowerCase() == 'success') {
let data = response.data.data
data.map((item, index) => {
let statusConvert = item.status == 'approval_review'? 'Waiting For Review' : item.status == 'approval_proccess'? 'Waiting For Approval' : titleCase(item.status)
listDashboard.push([index + 1, item.approval_id, item.company_name, `${item.type_report} - ${item.periode}`, item.revision, item.status, statusConvert])
rawData.push(item)
if (this.state.isApproverMB && this.state.isApproverMR){
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) {
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])
rawData.push(item)
}
} else if (this.state.isApproverMR) {
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])
rawData.push(item)
}
}
})
this.setState({ listDashboard, rawData })
}
......@@ -107,6 +135,10 @@ class HomePage extends Component {
getApprMat() {
this.setState({loading: true})
let isApproverMR = false
let isApproverMB = false
// let isApproverMRTabel = false
// let isApproverMBTabel = false
api.create().getAM().then((response) => {
console.log(response);
let actAMActive = []
......@@ -117,11 +149,35 @@ class HomePage extends Component {
}
})
let userId = localStorage.getItem(Constant.USER)
console.log(userId);
let indexId = actAMActive.findIndex((val) => val.user_id == userId)
actAMActive.map((item, index) => {
if (item.approval_type_name === "MONTHLY_REPORT"){
isApproverMR = true
} else if (item.approval_type_name === "MASTER_BUDGET"){
isApproverMB = true
}
})
if (indexId === -1) {
this.setState({ isApprover: false })
this.getListUserSubco()
}
}
// else if (isApproverMR){
// if (isApproverMBTabel === false){
// this.setState({ isApproverMRTabel: true, isApproverMBList: true })
// } else {
// this.setState({ isApproverMRTabel: true })
// }
// }
// else if (isApproverMB){
// if (isApproverMRTabel === false){
// this.setState({ isApproverMBTabel: true, isApproverMRList: true })
// } else {
// this.setState({ isApproverMBTabel: true })
// }
// }
this.setState({ isApproverMB, isApproverMR})
this.getDashboardMB()
// console.log(actAM)
this.setState({loading: false})
......@@ -130,7 +186,7 @@ class HomePage extends Component {
getDashboardMB() {
api.create().getDashboardMB().then((response) => {
// console.log(response)
console.log(response)
if (String(response.data.status).toLocaleLowerCase() == 'success') {
let data = response.data.data
let listdmb = data.sort((a, b) => a.company_id - b.company_id).map((item, index) => {
......@@ -156,11 +212,11 @@ class HomePage extends Component {
name: "Action",
options: {
customBodyRender: (val, tableMeta) => {
// console.log(tableMeta);
console.log(tableMeta);
return (
<div style={{ display: 'flex' }}>
<Link to={{
pathname: `/home/master-budget/`,
pathname: this.state.isApproverMB ? `/home/master-budget/` : `/home/monthly-report/`,
state: {
userType: 'approver',
rawData: this.state.rawData[tableMeta.rowIndex]
......@@ -241,6 +297,9 @@ class HomePage extends Component {
/>
</div>
);
let bulan = new Date().toLocaleString('default', { month: 'long'})
let tahun = new Date().getFullYear()
return (
<div style={{ flex: 1, backgroundColor: '#f8f8f8', minHeight: this.props.height }}>
{this.state.loading && loadingComponent}
......@@ -249,33 +308,36 @@ class HomePage extends Component {
<div className={"main-color"} style={{ height: 78, flex: 1, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
<Typography style={{ fontSize: '24px', color: 'white' }}>{this.state.userData === null ? '' : `Welcome, ${this.state.userData.fullname} !`}</Typography>
</div>
<div style={{ flex: 1, padding: 20, width: '100%' }}>
<div style={{ display: 'flex' }}>
<Typography style={{ color: '#656565', fontSize: '16px', fontWeight: 'bold' }}>Waiting Your Approval</Typography>
</div>
<div>
<div style={{ flex: 1, padding: 20, width: '100%' }}>
<div style={{ display: 'flex' }}>
<Typography style={{ color: '#656565', fontSize: '16px', fontWeight: 'bold' }}>Waiting Your Approval</Typography>
</div>
</div>
<div style={{ flex: 1, padding: 20, width: '100%' }}>
<div>
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={this.state.listDashboard}
columns={columns}
options={options}
/>
</MuiThemeProvider>
</div>
<div style={{ marginTop: 20 }}>
<Typography style={{ color: '#656565', fontSize: '16px', fontWeight: 'bold' }}>Master Budget & CAT</Typography>
<div style={{ marginTop: 10, width: '100%' }}>
<div style={{ flex: 1, padding: 20, width: '100%' }}>
<div>
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={this.state.dataTableMB}
columns={columnsMB}
data={this.state.listDashboard}
columns={columns}
options={options}
/>
</MuiThemeProvider>
</div>
<div style={{ marginTop: 20 }}>
<Typography style={{ color: '#656565', fontSize: '16px', fontWeight: 'bold' }}>Master Budget & CAT</Typography>
<div style={{ marginTop: 10, width: '100%' }}>
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
data={this.state.dataTableMB}
columns={columnsMB}
options={options}
/>
</MuiThemeProvider>
</div>
</div>
</div>
{/* <div style={{ marginTop: 20 }}>
<Typography style={{ color: '#656565', fontSize: '16px', fontWeight: 'bold' }}>Status Laporan</Typography>
......@@ -417,42 +479,84 @@ class HomePage extends Component {
<Typography style={{ color: '#656565', fontSize: '16px', fontWeight: 'bold' }}>Tasks to be Complete</Typography>
</div>
</div>
<div style={{ flex: 1, padding: 20, width: '100%' }}>
<Paper style={{ width: 450, padding: 20, borderRadius: 10 }}>
<Typography style={{ fontWeight: 'bold', textDecorationLine: 'underline' }}>{`Master Budget ${this.state.valueSubmit}/${this.state.listSubcoMB.length}`}</Typography>
{this.state.listSubcoMB.map((item, index) => {
return (
<div style={{ display: 'flex', justifyContent: 'space-between', marginTop: 10, paddingLeft: 10 }}>
<div style={{ display: 'flex' }}>
<img src={item.is_submit === true ? Images.dotDone : item.is_overdue === true ? Images.dotOverdue : Images.dotOpen} />
<Link to={{
pathname: `/home/master-budget/`,
state: {
userType: 'user',
rawData: item
}
}}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5,
outline: 'none'
}}>
<Typography style={{ marginLeft: 10, color: '#5198ea', fontSize: 13 }}>{item.company_name}</Typography>
</button>
</Link>
<div style={{ display: 'inline-flex' }}>
<div style={{ flex: 1, padding: 20, width: '100%' }}>
<Paper style={{ width: 450, padding: 20, borderRadius: 10 }}>
<Typography style={{ fontWeight: 'bold', textDecorationLine: 'underline' }}>{`Master Budget ${this.state.valueSubmit}/${this.state.listSubcoMB.length}`}</Typography>
{this.state.listSubcoMB.map((item, index) => {
return (
<div style={{ display: 'flex', justifyContent: 'space-between', marginTop: 10, paddingLeft: 10 }}>
<div style={{ display: 'flex' }}>
<img src={item.is_submit === true ? Images.dotDone : item.is_overdue === true ? Images.dotOverdue : Images.dotOpen} />
<Link to={{
pathname: `/home/master-budget/`,
state: {
userType: 'user',
rawData: item
}
}}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5,
outline: 'none'
}}>
<Typography style={{ marginLeft: 10, color: '#5198ea', fontSize: 13 }}>{item.company_name}</Typography>
</button>
</Link>
</div>
{item.is_overdue && (
<div style={{ backgroundColor: '#f65a4c', paddingRight: 5, paddingLeft: 5, borderRadius: 5, alignSelf: 'center' }}>
<Typography style={{ fontSize: 11, color: '#fff' }}>Overdue</Typography>
</div>
)}
</div>
{item.is_overdue && (
<div style={{ backgroundColor: '#f65a4c', paddingRight: 5, paddingLeft: 5, borderRadius: 5, alignSelf: 'center' }}>
<Typography style={{ fontSize: 11, color: '#fff' }}>Overdue</Typography>
)
})}
</Paper>
</div>
{/* : this.state.isApproverMRList === true || this.state.isApprover === false ? */}
<div style={{ flex: 1, padding: 20, width: '100%' }}>
<Paper style={{ width: 450, padding: 20, borderRadius: 10 }}>
<Typography style={{ fontWeight: 'bold', textDecorationLine: 'underline' }}>{`Monthly Report ${this.state.valueSubmitMR}/${this.state.listSubcoMR.length} - ${bulan} ${tahun}`}</Typography>
{this.state.listSubcoMR.map((item, index) => {
return (
<div style={{ display: 'flex', justifyContent: 'space-between', marginTop: 10, paddingLeft: 10 }}>
<div style={{ display: 'flex' }}>
<img src={item.is_submit === true ? Images.dotDone : item.is_overdue === true ? Images.dotOverdue : Images.dotOpen} />
<Link to={{
pathname: `/home/master-budget/`,
state: {
userType: 'user',
rawData: item
}
}}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5,
outline: 'none'
}}>
<Typography style={{ marginLeft: 10, color: '#5198ea', fontSize: 13 }}>{item.company_name}</Typography>
</button>
</Link>
</div>
)}
</div>
)
})}
</Paper>
{item.is_overdue && (
<div style={{ backgroundColor: '#f65a4c', paddingRight: 5, paddingLeft: 5, borderRadius: 5, alignSelf: 'center' }}>
<Typography style={{ fontSize: 11, color: '#fff' }}>Overdue</Typography>
</div>
)}
</div>
)
})}
</Paper>
</div>
{/* : null
} */}
</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