Commit d5824a92 authored by Dida Adams Arizona's avatar Dida Adams Arizona

tinggal issue be

parent 4fd26de9
...@@ -66,7 +66,8 @@ export default class BudgetTahunan extends Component { ...@@ -66,7 +66,8 @@ export default class BudgetTahunan extends Component {
latestPeriode: '', latestPeriode: '',
minDateRevision: new Date(), minDateRevision: new Date(),
maxDateRevision: new Date(), maxDateRevision: new Date(),
btnApprove: false btnApprove: false,
isAdmin: false
} }
this.myRef = React.createRef() this.myRef = React.createRef()
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
...@@ -89,12 +90,42 @@ export default class BudgetTahunan extends Component { ...@@ -89,12 +90,42 @@ export default class BudgetTahunan extends Component {
} }
} }
getRole(id) {
api.create().getDetailRole(id).then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
// this.setState({ tempData: response.data.data, privileges: response.data.data.privileges })
// console.log(response.data.data)
if (String(response.data.data.role_name).toLocaleLowerCase() == 'superadmin') {
this.setState({isAdmin: true})
}
} 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' })
}
})
}
componentWillUnmount() { componentWillUnmount() {
document.body.style.overflow = 'unset'; document.body.style.overflow = 'unset';
} }
checkApprover() { checkApprover() {
api.create().checkApprover().then(response => { api.create().checkApprover().then(response => {
console.log(response.data.data)
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
// console.log(response); // console.log(response);
...@@ -262,6 +293,7 @@ export default class BudgetTahunan extends Component { ...@@ -262,6 +293,7 @@ export default class BudgetTahunan extends Component {
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.getRole(response.data.data.role_id)
this.setState({ userCompany: response.data.data.company }, () => { this.setState({ userCompany: response.data.data.company }, () => {
this.getCompanyActive() this.getCompanyActive()
}) })
...@@ -423,7 +455,7 @@ export default class BudgetTahunan extends Component { ...@@ -423,7 +455,7 @@ export default class BudgetTahunan extends Component {
"is_approver": this.state.isApprover "is_approver": this.state.isApprover
} }
api.create().getSubmission(payload).then(response => { api.create().getSubmission(payload).then(response => {
// console.log(response) console.log(response.data.data.last_status)
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
this.setState({ this.setState({
...@@ -502,15 +534,16 @@ export default class BudgetTahunan extends Component { ...@@ -502,15 +534,16 @@ export default class BudgetTahunan extends Component {
"min_periode": moment(this.state.minDateRevision).format('YYYY-MM-DD'), "min_periode": moment(this.state.minDateRevision).format('YYYY-MM-DD'),
"max_periode": moment(this.state.maxDateRevision).format('YYYY-MM-DD') "max_periode": moment(this.state.maxDateRevision).format('YYYY-MM-DD')
} }
// console.log(payload) console.log(payload)
console.log(body)
api.create().approvalSubmission(body).then((res) => { api.create().approvalSubmission(body).then((res) => {
// console.log(res) console.log(res)
// this.setState({ loading: false }, () => { // this.setState({ loading: false }, () => {
this.getSubmission()
// }) // })
if (type == 'revision') { if (type == 'revision') {
api.create().createPeriodeRevision(payload).then((res)) api.create().createPeriodeRevision(payload).then((res))
} }
this.getSubmission()
}) })
} }
...@@ -1198,7 +1231,41 @@ export default class BudgetTahunan extends Component { ...@@ -1198,7 +1231,41 @@ export default class BudgetTahunan extends Component {
</div> </div>
)} )}
</div> </div>
{this.state.checkApprover === true ? {this.state.isAdmin && this.state.lastStatus == 'APPROVED'?
<div className="grid grid-2x" style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', }}>
<div className="col-1" />
<div className="col-2" style={{ display: 'flex', justifyContent: 'flex-end', maxWidth: '100%' }}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
marginRight: 20
}}
onClick={() => this.setState({ visibleRevision: true })}
>
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Revision</Typography>
</div>
</button>
{/* <button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
onClick={() => this.approvalSubmission('approve')}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Approve</Typography>
</div>
</button> */}
</div>
</div>
:
this.state.checkApprover === true ?
this.state.lastStatus === 'WAITING FOR REVIEW' ? this.state.lastStatus === 'WAITING FOR REVIEW' ?
<div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} > <div style={{ borderTop: 'solid 1px #c4c4c4', padding: 10, backgroundColor: '#f5f5f5', width: '100%', display: 'flex', justifyContent: 'flex-end' }} >
<button <button
......
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