Commit 7d6e8282 authored by d.arizona's avatar d.arizona

update month periode

parent b76eabbb
......@@ -449,7 +449,7 @@ export default class BudgetTahunan extends Component {
options: periodeData,
getOptionLabel: (option) => option.periode,
};
let periode = (this.state.lastPeriod == "" ? String(Number(currentYear) + 1) : this.state.lastPeriod)
let periode = (this.state.lastPeriod == "" ? String(Number(currentYear)) : this.state.lastPeriod)
let index = data.sort((a, b) => a - b).findIndex((val) => val === periode)
// // console.log(this.props.location.state.rawData)
// console.log(this.state.lastPeriod)
......
......@@ -100,8 +100,13 @@ class HomePage extends Component {
options: MR,
getOptionLabel: (option) => option.name,
};
// console.log(MR[MR.length - 1])
let dateNow = new Date()
dateNow.setMonth(dateNow.getMonth() - 1);
let yearNow = dateNow.getFullYear()
let indexMonthMR = MR.findIndex((val) => val.value == yearNow)
this.setState({listPeriodeMB: defaultPropsMB, periodeMB: MB[MB.length - 1], listPeriodeMR: defaultPropsMR, periodeMR: MR[MR.length - 1]}, () => {
this.setState({listPeriodeMB: defaultPropsMB, periodeMB: MB[MB.length - 1], listPeriodeMR: defaultPropsMR, periodeMR: MR[indexMonthMR]}, () => {
this.getListUserSubcoMB()
this.getListUserSubcoMR()
})
......@@ -109,9 +114,10 @@ class HomePage extends Component {
getMonth() {
api.create().getMonthTransaction().then(response => {
let dateNow = new Date
let dateNow = new Date()
dateNow.setMonth(dateNow.getMonth() - 1);
let month = format(dateNow, 'MMMM')
console.log(response);
// console.log(month);
if (response.data) {
if (response.data.status === "success") {
// console.log(response);
......@@ -312,7 +318,7 @@ 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) => {
......@@ -398,6 +404,14 @@ class HomePage extends Component {
}
render() {
const getDataMonth = (item) => {
let months = item.months
let dataMonth = this.state.listMonth.options
let indexID = dataMonth.findIndex((val) => val.month_id == months)
// console.log(dataMonth[indexID])
return dataMonth[indexID]
}
const columns = ["#", "ID", "Company", "Report Type", "Revision",
{
name: "",
......@@ -416,7 +430,7 @@ class HomePage extends Component {
state: {
userType: 'approver',
rawData: this.state.rawData[tableMeta.rowIndex],
month: String(tableMeta.rowData[3]).toLocaleLowerCase().includes("master") ? null : this.state.month
month: String(tableMeta.rowData[3]).toLocaleLowerCase().includes("master") ? null : getDataMonth(this.state.rawData[tableMeta.rowIndex])
}
}}>
<button
......
......@@ -165,8 +165,13 @@ export default class SubHolding extends Component {
options: periodeData,
getOptionLabel: (option) => option.periode,
};
let periode = (this.state.lastPeriod == "" ? String(Number(currentYear) + 1) : this.state.lastPeriod)
let index = data.sort((a, b) => a - b).findIndex((val) => val === periode)
let periode = (this.state.lastPeriod == "" ? String(Number(currentYear)) : this.state.lastPeriod)
let dateNow = new Date()
dateNow.setMonth(dateNow.getMonth() - 1);
let yearNow = dateNow.getFullYear()
console.log(yearNow)
console.log(periode)
let index = data.sort((a, b) => a - b).findIndex((val) => val == String(this.state.report.label).toLocaleLowerCase().includes('summary') ? yearNow : periode)
// console.log(data)
// console.log(this.state.latestPeriode)
......@@ -189,8 +194,9 @@ export default class SubHolding extends Component {
getMonth() {
api.create().getMonthTransaction().then(response => {
let dateNow = new Date
let month = format(dateNow, 'MMMM')
let dateNow = new Date()
dateNow.setMonth(dateNow.getMonth() - 1);
let month = format(dateNow, 'MMMM')
console.log(response);
if (response.data) {
if (response.data.status === "success") {
......@@ -832,7 +838,7 @@ export default class SubHolding extends Component {
FRID = null
}
this.setState({ FRID }, () => {
let payloads = {...payload, submission_id: this.state.FRID, months: this.state.month.month_id, quarter: 0}
let payloads = {...payload, report_id: 29, submission_id: this.state.FRID, months: this.state.month.month_id, quarter: 0}
api.create().getReportFR(payloads).then(response => {
console.log(payload);
console.log(response);
......
......@@ -307,7 +307,8 @@ export default class MonthlyReport extends Component {
getMonth() {
api.create().getMonthTransaction().then(response => {
let dateNow = new Date
let dateNow = new Date()
dateNow.setMonth(dateNow.getMonth() - 1);
let month = format(dateNow, 'MMMM')
console.log(response);
if (response.data) {
......@@ -402,11 +403,16 @@ export default class MonthlyReport extends Component {
getOptionLabel: (option) => option.periode,
};
let periode = (this.state.lastPeriod == "" ? String(Number(currentYear)) : this.state.lastPeriod === undefined ? String(Number(currentYear)) : this.state.lastPeriod)
let index = data.sort((a, b) => a - b).findIndex((val) => val === periode)
let dateNow = new Date()
dateNow.setMonth(dateNow.getMonth() - 1);
let yearNow = dateNow.getFullYear()
// let indexMonthMR = MR.findIndex((val) => val.value == yearNow)
// console.log(yearNow)
let index = data.sort((a, b) => a - b).findIndex((val) => val == yearNow)
// console.log(data)
console.log(this.state.lastPeriod)
// console.log(this.state.lastPeriod)
// console.log(periodeData)
console.log(index)
// console.log(index)
this.setState({ listPeriode: defaultProps, periode: index === -1 ? periodeData[0] : periodeData[index] }, () => {
// if (this.state.isApprover === true && this.state.submittedOnly) {
this.getDetailUser()
......
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