Commit 970bf0b5 authored by d.arizona's avatar d.arizona

apdet wiken

parent 963725e6
......@@ -267,12 +267,20 @@ export default class BudgetTahunan extends Component {
api.create().getPeriodeTransaction().then(response => {
// let dateNow = new Date
// let year = this.state.rawData ? this.state.rawData.periode : format(dateNow, 'yyyy')
let currentYear = new Date().getFullYear()
console.log(currentYear)
if (response.data) {
if (response.data.status === "success") {
let data = []
response.data.data.map((item) => {
if ((item == this.state.latestPeriode || item > this.state.latestPeriode) && (item == this.state.lastPeriod || item < this.state.lastPeriod)) {
data.push(item)
if (this.state.isApprover) {
if (item >= 2000 && item <= (Number(currentYear) + 1)) {
data.push(item)
}
} else {
if ((item >= 2000) && (item == this.state.lastPeriod || item < this.state.lastPeriod)) {
data.push(item)
}
}
})
let periodeData = data.map((item) => {
......@@ -284,7 +292,11 @@ export default class BudgetTahunan extends Component {
options: periodeData,
getOptionLabel: (option) => option.periode,
};
let index = data.sort((a, b) => a - b).findIndex((val) => val === this.state.lastPeriod)
let index = data.sort((a, b) => a - b).findIndex((val) => val === (this.state.lastPeriod == ""? String(Number(currentYear) + 1) : this.state.lastPeriod))
console.log(data)
console.log(this.state.lastPeriod)
console.log(periodeData)
console.log(index)
this.setState({ listPeriode: defaultProps, periode: index === -1 ? periodeData[0] : periodeData[index] }, () => {
if (this.state.isApprover === true) {
this.getCompanySubmitted()
......@@ -913,7 +925,7 @@ export default class BudgetTahunan extends Component {
<div style={{ width: '50%' }}>
<Typography style={{ fontSize: '16px', color: '#4b4b4b', fontWeight: 'bold' }}>Attachment: </Typography>
</div>
{!this.state.isApprover && (
{!this.state.isApprover && (this.state.lastStatus !== 'SUBMITTED' && this.state.lastStatus !== 'APPROVED') && (
<div style={{ width: '50%' }}>
<button
style={{
......@@ -959,7 +971,7 @@ export default class BudgetTahunan extends Component {
: null
}
</div>
{!this.state.isApprover && (
{!this.state.isApprover && (this.state.lastStatus !== 'SUBMITTED' && this.state.lastStatus !== 'APPROVED') && (
<div style={{ width: '50%' }}>
{this.state.listAttachment.length > 0 ?
this.state.listAttachment.map((item) => {
......
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