Commit 2f5785b5 authored by rifkaki's avatar rifkaki

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

parents 8004221d b2cdb131
......@@ -78,14 +78,15 @@ export default class DashboardFinancial extends React.Component {
minEBITDA: 0,
maxEBITDA: 0,
intervalEBITDA: 0,
data: [
],
data: [],
defaultMonth: [],
defaultYear: []
};
}
componentDidMount() {
console.log(this.props.height)
this.setState({loading: true})
this.setState({ loading: true })
this.getDetailUser()
}
......@@ -164,13 +165,13 @@ export default class DashboardFinancial extends React.Component {
business_unit_name: String(item.business_unit_name).toLocaleLowerCase(),
}
})
businessData.sort((a,b) => a.business_unit_name.localeCompare(b.business_unit_name))
businessData.sort((a, b) => a.business_unit_name.localeCompare(b.business_unit_name))
let defaultProps = {
options: businessData,
getOptionLabel: (option) => titleCase(option.business_unit_name),
};
// let index = arrayBaru.findIndex((val) => val.company_id == comID)
this.setState({ listBusiness: defaultProps, businessUnit: businessData[0]}, () => {
this.setState({ listBusiness: defaultProps, businessUnit: businessData[0] }, () => {
this.getMonth()
})
} else {
......@@ -199,19 +200,28 @@ export default class DashboardFinancial extends React.Component {
if (response.data.status === "success") {
console.log(response);
let data = response.data.data
let monthData = data.map((item) => {
return {
let index = data.findIndex((val) => val.month_name == month)
let monthData = []
let defaultMonth = []
data.map((item, indexs) => {
if (indexs <= index + 1) {
monthData.push({
month_id: item.id,
month_value: String(item.month_name).substr(0, 3)
})
}
defaultMonth.push({
month_id: item.id,
month_value: String(item.month_name).substr(0, 3)
})
})
let defaultProps = {
options: monthData,
getOptionLabel: (option) => option.month_value,
};
let index = data.findIndex((val) => val.month_name == month)
console.log(index);
this.setState({ listMonth: defaultProps, month: index == -1 ? monthData[0] : monthData[index], month2: index == -1 ? monthData[1] : monthData[index+1], }, () => {
console.log(monthData);
this.setState({ defaultMonth, listMonth: defaultProps, listMonth2: defaultProps, month: index == -1 ? monthData[0] : monthData[index], month2: index == -1 ? monthData[1] : monthData[index + 1], }, () => {
console.log(this.state.month)
this.getPeriode()
})
......@@ -240,7 +250,7 @@ export default class DashboardFinancial extends React.Component {
let data = []
response.data.data.map((item) => {
// if (this.state.isApprover) {
if (item >= 2000 && item <= (Number(currentYear) + 1)) {
if (item >= 2000 && item <= (Number(currentYear))) {
data.push(item)
}
// }
......@@ -263,7 +273,7 @@ export default class DashboardFinancial extends React.Component {
// console.log(this.state.latestPeriode)
// console.log(periodeData)
// console.log(index)
this.setState({ listPeriode: defaultProps, periode: index === -1 ? periodeData[0] : periodeData[index], periode2: index === -1 ? periodeData[1] : periodeData[index+1] }, () => {
this.setState({ listPeriode: defaultProps, listPeriode2: { ...defaultProps, options: [periodeData[index]] }, periode: index === -1 ? periodeData[0] : periodeData[index], periode2: periodeData[index] }, () => {
this.getDashboardFinancial()
})
}
......@@ -284,10 +294,10 @@ export default class DashboardFinancial extends React.Component {
},
toolbox: {
feature: {
dataView: {show: true, readOnly: false},
magicType: {show: true, type: ['line', 'bar']},
restore: {show: true},
saveAsImage: {show: true}
dataView: { show: true, readOnly: false },
magicType: { show: true, type: ['line', 'bar'] },
restore: { show: true },
saveAsImage: { show: true }
}
},
legend: {
......@@ -367,13 +377,13 @@ export default class DashboardFinancial extends React.Component {
const handleName = (name) => {
let newName = ''
if(String(name).includes(':')) {
if (String(name).includes(':')) {
let indexTidu = String(name).indexOf(':')
let indexSpace = String(name).indexOf(' ')
if (indexTidu > indexSpace) {
newName = String(name).substr(0,indexSpace)
newName = String(name).substr(0, indexSpace)
} else {
newName = String(name).substr(0,indexTidu)
newName = String(name).substr(0, indexTidu)
}
} else {
// if (String(name).includes('Consolidated')) {
......@@ -389,7 +399,7 @@ export default class DashboardFinancial extends React.Component {
api.create().getDashboardFinancial(payload).then((res) => {
console.log(res)
if (res.data) {
let response = res.data.data.ytd != null? res.data.data.ytd : (res.data.data.mtd != null? res.data.data.mtd : res.data.data.summary)
let response = res.data.data.ytd != null ? res.data.data.ytd : (res.data.data.mtd != null ? res.data.data.mtd : res.data.data.summary)
let revenue = []
let totalAssets = []
......@@ -414,7 +424,11 @@ export default class DashboardFinancial extends React.Component {
let minEBITDA = response.ebitda.vertical_pointing[1]
let intervalEBITDA = Number(response.ebitda.interval)
response.revenue.nodes.map((item,index) => {
if (response.total_assets != undefined) {
}
response.revenue.nodes.map((item, index) => {
if (this.state.report.value == 'summary') {
companyRev.push(item.periode)
mbRev.push(item.value)
......@@ -427,7 +441,7 @@ export default class DashboardFinancial extends React.Component {
})
response.tpat.nodes.map((item,index) => {
response.tpat.nodes.map((item, index) => {
if (this.state.report.value == 'summary') {
companyTPAT.push(item.periode)
mbTPAT.push(item.value)
......@@ -439,7 +453,7 @@ export default class DashboardFinancial extends React.Component {
}
})
response.ebitda.nodes.map((item,index) => {
response.ebitda.nodes.map((item, index) => {
if (this.state.report.value == 'summary') {
companyEBITDA.push(item.periode)
mbEBITDA.push(item.value)
......@@ -452,7 +466,7 @@ export default class DashboardFinancial extends React.Component {
})
if (this.state.report.value == 'summary') {
response.revenue.nodes.map((item,index) => {
response.revenue.nodes.map((item, index) => {
totalAssets.push({
"company": item.company,
"MB": item.value_mb,
......@@ -462,9 +476,9 @@ export default class DashboardFinancial extends React.Component {
})
})
}
this.setState({companyRev, mbRev, mrRev, minRev, maxRev, intervalRev, companyTPAT, mbTPAT, mrTPAT, minTPAT, maxTPAT, intervalTPAT, companyEBITDA, mbEBITDA, mrEBITDA, minEBITDA, maxEBITDA, intervalEBITDA}, () => {
this.setState({ companyRev, mbRev, mrRev, minRev, maxRev, intervalRev, companyTPAT, mbTPAT, mrTPAT, minTPAT, maxTPAT, intervalTPAT, companyEBITDA, mbEBITDA, mrEBITDA, minEBITDA, maxEBITDA, intervalEBITDA }, () => {
console.log(companyTPAT)
this.setState({loading: false})
this.setState({ loading: false })
})
}
})
......@@ -539,11 +553,21 @@ export default class DashboardFinancial extends React.Component {
value={this.state.report}
/>
</div>
<div style={{ display: 'flex', marginTop: 10}}>
<div style={{ display: 'flex', marginTop: 10 }}>
<Autocomplete
{...this.state.listMonth}
id="month"
onChange={(event, newInputValue) => this.setState({ month: newInputValue, loading: true }, () => {
let indexMonth1 = this.state.listMonth.options.findIndex((val) => val.month_value == newInputValue.month_value)
let listMonth2 = []
this.state.listMonth.options.map((item, index) => {
if (index >= indexMonth1) {
listMonth2.push(item)
}
})
this.setState({ listMonth2: Number(this.state.periode.periode) < Number(this.state.periode2.periode) ? this.state.listMonth2 : { ...this.state.listMonth2, options: listMonth2, month2: listMonth2[0] } }, () => {
this.setState({ month2: Number(this.state.periode.periode) < Number(this.state.periode2.periode) ? this.state.month2 : this.state.listMonth2.options[0] })
})
this.getDashboardFinancial()
})}
disableClearable
......@@ -555,16 +579,67 @@ export default class DashboardFinancial extends React.Component {
{...this.state.listPeriode}
id="periode"
onChange={(event, newInputValue) => this.setState({ periode: newInputValue, loading: true }, () => {
let indexPeriode1 = this.state.listPeriode.options.findIndex((val) => val.periode == newInputValue.periode)
let listPeriode2 = []
let listMonth = []
let listMonth2 = this.state.listMonth2.options
let dateNow = new Date()
let dateNow2 = new Date()
let yearNow = dateNow.getFullYear()
dateNow2.setMonth(dateNow2.getMonth() - 1);
let month = format(dateNow2, 'MMMM')
this.state.listPeriode.options.map((item, index) => {
if (index >= indexPeriode1) {
listPeriode2.push(item)
}
})
let data = this.state.defaultMonth
let index = data.findIndex((val) => val.month_value == String(month).substr(0, 3))
let monthData = []
let monthData2 = []
if (Number(newInputValue.periode) < Number(yearNow)) {
listMonth = this.state.defaultMonth
data.map((item, indexs) => {
if (indexs <= index + 1) {
monthData2.push({
month_id: item.month_id,
month_value: String(item.month_value).substr(0, 3)
})
}
})
listMonth2 = monthData2
} else {
data.map((item, indexs) => {
if (indexs <= index + 1) {
monthData.push({
month_id: item.month_id,
month_value: String(item.month_value).substr(0, 3)
})
}
})
listMonth = monthData
}
this.setState({ listPeriode2: { ...this.state.listPeriode2, options: listPeriode2, periode2: listPeriode2[0], } }, () => {
this.setState({
periode2: Number(this.state.periode.periode) < Number(this.state.periode2.periode) ? this.state.periode2 : this.state.listPeriode2.options[0],
listMonth: { ...this.state.listMonth, options: listMonth },
listMonth2: { ...this.state.listMonth2, options: listMonth2 },
month: Number(newInputValue.periode) < Number(this.state.periode.periode) ? this.state.month : listMonth[0]
}, () => {
this.getDashboardFinancial()
})
})
})}
disableClearable
style={{ width: 250 }}
renderInput={(params) => <TextField {...params} label="Period" margin="normal" style={{ marginTop: 7 }} />}
value={this.state.periode}
/>
{this.state.report.value == 'summary' && <Typography style={{ fontSize: '16px', color: 'black', alignSelf: 'center', marginLeft: 25, marginRight: 25, paddingTop: 25}}>To</Typography>}
{this.state.report.value == 'summary' && <Typography style={{ fontSize: '16px', color: 'black', alignSelf: 'center', marginLeft: 25, marginRight: 25, paddingTop: 25 }}>To</Typography>}
{this.state.report.value == 'summary' && <Autocomplete
{...this.state.listMonth}
{...this.state.listMonth2}
id="month"
onChange={(event, newInputValue) => this.setState({ month2: newInputValue, loading: true }, () => {
this.getDashboardFinancial()
......@@ -575,10 +650,53 @@ export default class DashboardFinancial extends React.Component {
value={this.state.month2}
/>}
{this.state.report.value == 'summary' && <Autocomplete
{...this.state.listPeriode}
{...this.state.listPeriode2}
id="periode"
onChange={(event, newInputValue) => this.setState({ periode2: newInputValue, loading: true }, () => {
let dateNow = new Date()
let yearNow = dateNow.getFullYear()
let data = this.state.defaultMonth
let monthData2 = []
let dateNow2 = new Date()
dateNow2.setMonth(dateNow2.getMonth() - 1);
let month = format(dateNow2, 'MMMM')
if (Number(this.state.periode2.periode) < Number(yearNow)) {
if (Number(this.state.periode2.periode) == Number(this.state.periode.periode)) {
let index = data.findIndex((val) => val.month_value == this.state.month.month_value)
data.map((item, indexs) => {
if (indexs >= index) {
monthData2.push({
month_id: item.month_id,
month_value: String(item.month_value).substr(0, 3)
})
}
})
let listMonth2 = monthData2
this.setState({ month2: listMonth2[0], listMonth2: {...this.state.listMonth2, options: listMonth2} }, () => {
this.getDashboardFinancial()
})
} else {
this.setState({ listMonth2: { ...this.state.listMonth2, options: this.state.defaultMonth } }, () => {
this.getDashboardFinancial()
})
}
} else {
let index = data.findIndex((val) => val.month_value == String(month).substr(0, 3))
data.map((item, indexs) => {
if (indexs <= index + 1) {
monthData2.push({
month_id: item.month_id,
month_value: String(item.month_value).substr(0, 3)
})
}
})
let listMonth2 = monthData2
this.setState({ listMonth2: { ...this.state.listMonth2, options: listMonth2 } }, () => {
this.setState({ month2: this.state.listMonth2.options[0] }, () => {
this.getDashboardFinancial()
})
})
}
})}
disableClearable
style={{ width: 250 }}
......@@ -634,18 +752,18 @@ export default class DashboardFinancial extends React.Component {
/>
</div> */}
</div>
<Divider style={{marginTop: 15}}/>
<div style={{ minWidth: 'max-content', padding: '20px 20px 0px 20px'}}>
<Divider style={{ marginTop: 15 }} />
<div style={{ minWidth: 'max-content', padding: '20px 20px 0px 20px' }}>
<div>
<Typography style={{ fontSize: '16px', color: 'black' }}>{this.state.report.value == 'mtd'? 'Graph MTD by Industry' : this.state.report.value == 'ytd'? 'Graph YTD by Industry' : 'Graph Monthly Historical by Company'}</Typography>
<Typography style={{ fontSize: '16px', color: 'black' }}>{this.state.report.value == 'mtd' ? 'Graph MTD by Industry' : this.state.report.value == 'ytd' ? 'Graph YTD by Industry' : 'Graph Monthly Historical by Company'}</Typography>
{this.state.month != null && this.state.periode != null && <Typography style={{ fontSize: '16px', color: 'black' }}>Period : {String(this.state.month.month_value).toLocaleUpperCase()} {this.state.periode.periode}</Typography>}
<Typography style={{ fontSize: '16px', color: 'black' }}>in IDR mn</Typography>
</div>
<div style={{ height: Number(0.6 * this.props.height), border: '1px solid black', marginTop: 25, paddingBottom: 50}}>
{this.state.businessUnit != null && <Typography style={{ fontSize: '16px', color: 'black', textAlign: 'center', marginTop: 10, marginBottom: 10 }}>{`Revenue ${this.state.report.value == 'mtd' || this.state.report.value == 'ytd'? String(this.state.report.value).toLocaleUpperCase() : ''} - ${this.state.report.value == 'mtd' || this.state.report.value == 'ytd'? titleCase(this.state.businessUnit.business_unit_name) : this.state.company.company_name}`}</Typography>}
<div style={{ height: Number(0.6 * this.props.height), border: '1px solid black', marginTop: 25, paddingBottom: 50 }}>
{this.state.businessUnit != null && <Typography style={{ fontSize: '16px', color: 'black', textAlign: 'center', marginTop: 10, marginBottom: 10 }}>{`Revenue ${this.state.report.value == 'mtd' || this.state.report.value == 'ytd' ? String(this.state.report.value).toLocaleUpperCase() : ''} - ${this.state.report.value == 'mtd' || this.state.report.value == 'ytd' ? titleCase(this.state.businessUnit.business_unit_name) : this.state.company.company_name}`}</Typography>}
{!this.state.loading && <ReactECharts
style={{height: 500, width: '100%', marginTop: 20}}
style={{ height: 500, width: '100%', marginTop: 20 }}
option={{
tooltip: {
trigger: 'axis',
......@@ -658,12 +776,12 @@ export default class DashboardFinancial extends React.Component {
},
toolbox: {
feature: {
restore: {show: true},
saveAsImage: {show: true}
restore: { show: true },
saveAsImage: { show: true }
}
},
legend: {
data: ['Revenue', 'GP Margin']
data: ['MB', 'MR', 'Revenue', 'GP Margin']
},
xAxis: [
{
......@@ -674,7 +792,7 @@ export default class DashboardFinancial extends React.Component {
}
}
],
yAxis: this.state.report.value != 'summary'?
yAxis: this.state.report.value != 'summary' ?
[
{
type: 'value',
......@@ -704,7 +822,7 @@ export default class DashboardFinancial extends React.Component {
}
]
,
series: this.state.report.value != 'summary'?
series: this.state.report.value != 'summary' ?
[
{
name: 'MB',
......@@ -734,10 +852,10 @@ export default class DashboardFinancial extends React.Component {
/>}
</div>
<div style={{ height: Number(0.6 * this.props.height), border: '1px solid black', marginTop: 50, paddingBottom: 50}}>
{this.state.businessUnit != null && <Typography style={{ fontSize: '16px', color: 'black', textAlign: 'center', marginTop: 10, marginBottom: 10 }}>{`TPAT ${this.state.report.value == 'mtd' || this.state.report.value == 'ytd'? String(this.state.report.value).toLocaleUpperCase() : ''} - ${this.state.report.value == 'mtd' || this.state.report.value == 'ytd'? titleCase(this.state.businessUnit.business_unit_name) : this.state.company.company_name}`}</Typography>}
<div style={{ height: Number(0.6 * this.props.height), border: '1px solid black', marginTop: 50, paddingBottom: 50 }}>
{this.state.businessUnit != null && <Typography style={{ fontSize: '16px', color: 'black', textAlign: 'center', marginTop: 10, marginBottom: 10 }}>{`TPAT ${this.state.report.value == 'mtd' || this.state.report.value == 'ytd' ? String(this.state.report.value).toLocaleUpperCase() : ''} - ${this.state.report.value == 'mtd' || this.state.report.value == 'ytd' ? titleCase(this.state.businessUnit.business_unit_name) : this.state.company.company_name}`}</Typography>}
{!this.state.loading && <ReactECharts
style={{height: 500, width: '100%', marginTop: 20}}
style={{ height: 500, width: '100%', marginTop: 20 }}
option={{
tooltip: {
trigger: 'axis',
......@@ -750,12 +868,12 @@ export default class DashboardFinancial extends React.Component {
},
toolbox: {
feature: {
restore: {show: true},
saveAsImage: {show: true}
restore: { show: true },
saveAsImage: { show: true }
}
},
legend: {
data: ['TPAT', 'TPAT Margin']
data: ['MB', 'MR', 'TPAT', 'TPAT Margin']
},
xAxis: [
{
......@@ -766,7 +884,7 @@ export default class DashboardFinancial extends React.Component {
}
}
],
yAxis: this.state.report.value != 'summary'?
yAxis: this.state.report.value != 'summary' ?
[
{
type: 'value',
......@@ -796,7 +914,7 @@ export default class DashboardFinancial extends React.Component {
}
]
,
series: this.state.report.value != 'summary'?
series: this.state.report.value != 'summary' ?
[
{
name: 'MB',
......@@ -838,8 +956,8 @@ export default class DashboardFinancial extends React.Component {
},
toolbox: {
feature: {
dataView: {show: true, readOnly: false},
magicType: {show: true, type: ['line', 'bar']},
// dataView: {show: true, readOnly: false},
// magicType: {show: true, type: ['bar']},
restore: {show: true},
saveAsImage: {show: true}
}
......@@ -900,10 +1018,10 @@ export default class DashboardFinancial extends React.Component {
/> */}
</div>
<div style={{ height: Number(0.6 * this.props.height), border: '1px solid black', marginTop: 50, paddingBottom: 50}}>
{this.state.businessUnit != null && <Typography style={{ fontSize: '16px', color: 'black', textAlign: 'center', marginTop: 10, marginBottom: 10 }}>{`EBITDA ${this.state.report.value == 'mtd' || this.state.report.value == 'ytd'? String(this.state.report.value).toLocaleUpperCase() : ''} - ${this.state.report.value == 'mtd' || this.state.report.value == 'ytd'? titleCase(this.state.businessUnit.business_unit_name) : this.state.company.company_name}`}</Typography>}
<div style={{ height: Number(0.6 * this.props.height), border: '1px solid black', marginTop: 50, paddingBottom: 50 }}>
{this.state.businessUnit != null && <Typography style={{ fontSize: '16px', color: 'black', textAlign: 'center', marginTop: 10, marginBottom: 10 }}>{`EBITDA ${this.state.report.value == 'mtd' || this.state.report.value == 'ytd' ? String(this.state.report.value).toLocaleUpperCase() : ''} - ${this.state.report.value == 'mtd' || this.state.report.value == 'ytd' ? titleCase(this.state.businessUnit.business_unit_name) : this.state.company.company_name}`}</Typography>}
{!this.state.loading && <ReactECharts
style={{height: 500, width: '100%', marginTop: 20}}
style={{ height: 500, width: '100%', marginTop: 20 }}
option={{
tooltip: {
trigger: 'axis',
......@@ -916,12 +1034,12 @@ export default class DashboardFinancial extends React.Component {
},
toolbox: {
feature: {
restore: {show: true},
saveAsImage: {show: true}
restore: { show: true },
saveAsImage: { show: true }
}
},
legend: {
data: ['EBITDA', 'EBITDA Margin']
data: ['MB', 'MR', 'EBITDA', 'EBITDA Margin']
},
xAxis: [
{
......@@ -932,7 +1050,7 @@ export default class DashboardFinancial extends React.Component {
}
}
],
yAxis: this.state.report.value != 'summary'?
yAxis: this.state.report.value != 'summary' ?
[
{
type: 'value',
......@@ -962,7 +1080,7 @@ export default class DashboardFinancial extends React.Component {
}
]
,
series: this.state.report.value != 'summary'?
series: this.state.report.value != 'summary' ?
[
{
name: 'MB',
......@@ -992,110 +1110,97 @@ export default class DashboardFinancial extends React.Component {
/>}
</div>
{/* {this.state.report.value == 'summary' && <div style={{ height: Number(0.5 * this.props.height), border: '1px solid black', marginTop: 50, paddingBottom: 50}}>
{this.state.report.value == 'summary' && <div style={{ height: Number(0.6 * this.props.height), border: '1px solid black', marginTop: 50, paddingBottom: 50 }}>
<Typography style={{ fontSize: '16px', color: 'black', textAlign: 'center', marginTop: 10, marginBottom: 10 }}>{`Total Assets - ${this.state.company.company_name}`}</Typography>
<ResponsiveBar
data={this.state.totalAssets}
keys={['MB', 'MR']}
indexBy="company"
margin={{ top: 50, right: 50, bottom: 100, left: 75 }}
padding={0.3}
groupMode="grouped"
valueScale={{ type: 'linear' }}
indexScale={{ type: 'band', round: true }}
colors={['#2a70c0','#5399ea']}
// defs={[
// {
// id: 'dots',
// type: 'patternDots',
// background: 'inherit',
// color: '#5399ea',
// size: 4,
// padding: 1,
// stagger: true
// },
// {
// id: 'lines',
// type: 'patternLines',
// background: 'inherit',
// color: '#2a70c0',
// rotation: -45,
// lineWidth: 6,
// spacing: 10
// }
// ]}
// fill={[
// {
// match: {
// id: 'MB'
// },
// id: 'dots'
// },
// {
// match: {
// id: 'MR'
// },
// id: 'lines'
// }
// ]}
borderColor={{ from: 'color', modifiers: [['darker', 1.6]] }}
axisTop={null}
axisRight={null}
axisBottom={{
tickSize: 20,
tickPadding: 0,
tickRotation: 0,
legend: 'Company',
legendPosition: 'middle',
// legendOffset: 32,
// renderTick: CustomTick,
// lineStyle: { stroke: '#f47560', strokeWidth: 1 },
// textStyle: { fill: '#e25c3b' },
// legend: 'Company',
// legendPosition: 'middle',
// legendOrientation: 'vertical',
legendOffset: 50,
}}
// axisLeft={{
// tickSize: 5,
// tickPadding: 5,
// tickRotation: 0,
// legend: 'food',
// legendPosition: 'middle',
// legendOffset: -40
// }}
labelSkipWidth={12}
labelSkipHeight={12}
labelTextColor={{ from: 'color', modifiers: [['darker', 1.6]] }}
legends={[
{!this.state.loading && <ReactECharts
style={{ height: 500, width: '100%', marginTop: 20 }}
option={{
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
crossStyle: {
color: '#999'
}
}
},
toolbox: {
feature: {
restore: { show: true },
saveAsImage: { show: true }
}
},
legend: {
data: ['MB', 'MR', 'EBITDA', 'EBITDA Margin']
},
xAxis: [
{
dataFrom: 'keys',
anchor: 'bottom',
direction: 'row',
justify: false,
translateX: 30,
translateY: 85,
itemsSpacing: 7,
itemWidth: 109,
itemHeight: 10,
itemDirection: 'left-to-right',
itemOpacity: 0.85,
symbolSize: 25,
effects: [
type: 'category',
data: this.state.companyEBITDA,
axisPointer: {
type: 'shadow'
}
}
],
yAxis: this.state.report.value != 'summary' ?
[
{
on: 'hover',
style: {
itemOpacity: 1
type: 'value',
name: '(Rp bn)',
min: this.state.minEBITDA,
max: this.state.maxEBITDA,
interval: this.state.intervalEBITDA
}
] :
[
{
type: 'value',
name: '(Rp bn)',
min: this.state.minEBITDA,
max: this.state.maxEBITDA,
interval: this.state.intervalEBITDA
},
{
type: 'value',
name: '(%)',
min: 0,
max: 100,
interval: 20,
axisLabel: {
formatter: '{value}%'
}
}
]
,
series: this.state.report.value != 'summary' ?
[
{
name: 'MB',
type: 'bar',
data: this.state.mbEBITDA
},
{
name: 'MR',
type: 'bar',
data: this.state.mrEBITDA
}
]}
animate={true}
motionStiffness={90}
motionDamping={15}
/>
</div>} */}
] :
[
{
name: 'EBITDA',
type: 'bar',
data: this.state.mbEBITDA
},
{
name: 'EBITDA Margin',
type: 'line',
yAxisIndex: 1,
data: this.state.mrEBITDA
}
]
}}
/>}
</div>}
</div>
</Paper>
</div>
......
......@@ -16,6 +16,7 @@ export default class EditMasterDataCAT extends Component {
constructor(props) {
super(props)
this.state = {
loading: true,
company: null,
parent: null,
reportType: null,
......@@ -26,13 +27,15 @@ export default class EditMasterDataCAT extends Component {
listPeriode: null,
errorWeight: false,
msgErrorWeight: '',
getParent: []
getParent: [],
periode: null,
created_by: '',
updated_by: ''
}
}
componentDidMount() {
this.getInputType()
this.getPerusahaan()
this.getReportType()
let date = format(new Date, 'yyyy-MM-dd')
this.setState({
......@@ -65,7 +68,7 @@ export default class EditMasterDataCAT extends Component {
if (response.data) {
if (response.data.status === 'success') {
let data = response.data.data
let comID = this.state.rawData ? this.state.rawData.company_id : 0
let comID = this.props.data[8]
let companyData = data.map((item) => {
return {
company_id: item.company_id,
......@@ -137,8 +140,8 @@ export default class EditMasterDataCAT extends Component {
};
// let periode = (this.state.lastPeriod == "" ? String(Number(currentYear) + 1) : this.state.lastPeriod)
let periode = String(Number(currentYear))
let index = data.sort((a, b) => a - b).findIndex((val) => val === periode)
// console.log(data)
let index = data.sort((a, b) => a - b).findIndex((val) => val == this.props.data[6])
// console.log(this.props.data)
// console.log(this.state.latestPeriode)
// console.log(periodeData)
console.log(index)
......@@ -181,7 +184,7 @@ export default class EditMasterDataCAT extends Component {
handleReportName(item) {
let indexString = String(item).indexOf('-')
let gantiNama = String(item).substr(0, indexString)
let gantiNama = indexString === -1 ? item : String(item).substr(0, indexString)
return gantiNama
}
......@@ -219,7 +222,7 @@ export default class EditMasterDataCAT extends Component {
"detail": simpan
}
console.log(payload)
this.props.createReportItems(payload)
this.props.updateReportItems(payload)
}
......@@ -261,48 +264,6 @@ export default class EditMasterDataCAT extends Component {
})
}
getPerusahaan() {
api.create().getPerusahaanActive().then((response) => {
// console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let companyData = data.map((item) => {
return {
company_id: item.company_id,
company_name: item.company_name
}
})
companyData.push({
company_id: 0,
company_name: 'Default'
})
let typeProps = {
options: companyData.sort((a, b) => a.company_id - b.company_id),
getOptionLabel: (option) => option.company_name,
};
this.setState({ listCompany: typeProps, companyData: response.data.data })
} 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);
}
})
// alert(response.data.message)
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
getReportType() {
api.create().getReportType().then((response) => {
// console.log(response)
......@@ -341,71 +302,23 @@ export default class EditMasterDataCAT extends Component {
})
}
getParent() {
if (this.state.reportType !== null && this.state.company !== null) {
let payload = {
"report_id": this.state.reportType.report_id,
"company_id": this.state.company.company_id
}
api.create().getReportParent(payload).then((response) => {
// console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
let parentData = data.map((item) => {
return {
item_report_id: item.item_report_id,
description: item.description
}
})
let defaultProps = {
options: parentData,
getOptionLabel: (option) => titleCase(option.description),
};
this.setState({ listParent: defaultProps, parentData: response.data.data })
} 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);
}
})
// alert(response.data.message)
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
}
handleDate(item) {
let value = format(item, 'dd MMMM yyyy')
return value
}
getDetailMasterDataCat() {
console.log(this.props);
api.create().getDetailMasterDataCat(this.props.data[1], this.props.data[6]).then((response) => {
console.log(response);
this.setState({ loading: true })
api.create().getDetailMasterDataCat(this.props.data[8], this.props.data[6]).then((response) => {
// console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let data = response.data.data
this.setState({
tempData: response.data.data,
getCompanyID: data.company_id
}, () => this.getInputType(),
this.getPerusahaan(),
this.getReportType())
// console.log(response.data.data)
if (response.data.status === "success") {
this.setState({ getParent: response.data.data.filter((val) => String(val.type_item_report_name).toLocaleLowerCase() != 'break'), created_by: response.data.data[0].created, updated_by: response.data.data[0].created_at }, () => {
// console.log(this.state.getParent[0].created);
this.setState({ loading: false })
})
} else {
// alert(response.data.message)
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
......@@ -415,9 +328,6 @@ export default class EditMasterDataCAT extends Component {
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
......@@ -437,7 +347,7 @@ export default class EditMasterDataCAT extends Component {
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
<div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Create Data</span>
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Edit Data</span>
</div>
</div>
<div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
......@@ -464,11 +374,8 @@ export default class EditMasterDataCAT extends Component {
<Autocomplete
{...this.state.listCompany}
id="company"
disabled={this.state.intent === 'Home' ? true : false}
onChange={(event, newInputValue) => this.setState({ company: newInputValue, loading: true, previewTable: false }, () => {
this.getReportType()
})}
disableClearable
onChange={(event, newInputValue) => this.setState({ company_name: newInputValue }, () => this.getParent(), this.clearMessage())}
debug
style={{ width: 250 }}
renderInput={(params) =>
<TextField {...params}
......@@ -589,7 +496,7 @@ export default class EditMasterDataCAT extends Component {
disabled
// onChange={(e) => this.handleChange(e, null)}
// value={this.state.order}
value={this.handleReportName(item.description)}
value={this.handleReportName(item.item_report_name)}
// error={this.state.errorOrder}
// helperText={this.state.msgErrorOrder}
inputProps={{
......@@ -673,9 +580,11 @@ export default class EditMasterDataCAT extends Component {
<div className="margin-top-10px" style={{ paddingTop: 10, paddingBottom: 30, paddingRight: 30, paddingLeft: 30 }}>
<div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '13%' }}>Created By :</Typography>
{!this.state.loading && <Typography style={{ fontSize: 11 }}>: {this.state.created_by}</Typography>}
</div>
<div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '13%' }}>Updated By :</Typography>
{!this.state.loading && <Typography style={{ fontSize: 11 }}>: {this.state.updated_by}</Typography>}
</div>
</div>
</div>
......
......@@ -722,7 +722,7 @@ export default class MasterDataCAT extends Component {
}
createReportItems = (payload) => {
this.setState({ add: false })
this.setState({ add: false, edit: false })
api.create().saveMasterDataCat(payload).then(response => {
// console.log(response);
if (response.data) {
......@@ -781,33 +781,6 @@ export default class MasterDataCAT extends Component {
}
}
// updateReportItems = (payload) => {
// this.setState({ edit: false })
// api.create().updateReportItems(payload).then(response => {
// if (response.data) {
// if (response.ok) {
// if (response.data.status == 'success') {
// this.getData()
// this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
// } 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 {
// this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
// }
// } else {
// this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
// }
// })
// }
uploadReportItems() {
api.create().uploadReportItems(this.state.payload).then(response => {
if (response.data) {
......
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