Commit 7462c7bd authored by fahrur huzain's avatar fahrur huzain

closing dan logactivity

parent 7a14bac1
......@@ -11,7 +11,8 @@ import UploadFile from "../../library/Upload";
import CreateApprovalMatrix from "../ApprovalMatrix/CreateApprovalMatrix";
import EditApprovalMatrix from "../ApprovalMatrix/EditApprovalMatrix";
import VisualisasiAM from "../ApprovalMatrix/VisualisasiAM";
import DeleteApprovalMatrix from "../ApprovalMatrix/DeleteApprovalMatrix";
import DeleteApprovalMatrix from "../ApprovalMatrix/DeleteApprovalMatrix"
import RollbackAuditTrails from "../GeneralSetting/RollbackAuditTrails";
import PopUpFailedSave from "../../library/PopUpFailedSave";
import api from "../../api";
import Constant from '../../library/Constant';
......@@ -136,11 +137,6 @@ export default class AuditTrails extends Component {
rowData: index,
popupRollback: true
})
} else if (type === 'delete') {
this.setState({
rowData: index,
popupDel: true
})
}
else {
this.setState({
......@@ -235,12 +231,12 @@ export default class AuditTrails extends Component {
marginRight: 15
}}
// onClick={() => console.log(tableMeta)}
onClick={() => this.openPopUp(tableMeta.rowData, 'edit')}
onClick={() => this.openPopUp(tableMeta.rowData, 'rollback')}
>
<img src={Images.rollback} />
</button>
</a>
<ReactTooltip border={true} id="edit" place="bottom" type="light" effect="solid" />
<ReactTooltip border={true} id="rollback" place="bottom" type="light" effect="solid" />
</span>}
</div >
);
......@@ -354,7 +350,7 @@ export default class AuditTrails extends Component {
/>
</div> */}
</div>
<div style={{ padding: 25, width: '100%' }}>
<div style={{ paddingTop: 25, paddingLeft:25, paddingRight:25, width: '100%' }}>
{this.state.loading && loadingComponent}
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
......@@ -379,13 +375,13 @@ export default class AuditTrails extends Component {
/>
:
<div style={{ height: this.props.height }}>
<div class="main-color" style={{ height: 195, width: '100%' }} />
<div class="main-color" style={{ height: this.props.height, width: '100%' }} />
<div>
<div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -165 }}>
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center' }}>Preview Data</label>
</div>
<div style={{ padding: 25 }}>
<div style={{ paddingTop: 25, paddingLeft:25, paddingRight:25 }}>
{this.state.dataLoaded && (
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
......@@ -424,10 +420,10 @@ export default class AuditTrails extends Component {
</div>
</div>
}
{this.state.popupDel && (
<DeleteApprovalMatrix
type={"delete"}
onClickClose={() => this.setState({ popupDel: false })}
{this.state.popupRollback && (
<RollbackAuditTrails
type={"rollback"}
onClickClose={() => this.setState({ popupRollback: false })}
data={this.state.rowData}
// getList={() => this.getData.bind(this)}
deleteAM={this.deleteAM.bind(this)}
......
import React, { Component } from 'react';
import Images from '../../assets/Images';
import { Typography } from '@material-ui/core';
import api from "../../api";
import Constant from '../../library/Constant';
export default class CloseClosingReport extends Component {
constructor(props) {
super(props)
this.state = {
id: '',
getApprovedBy: null,
getTypes: null,
}
}
componentDidMount() {
if (this.props.type === 'close') {
this.getDetailAM()
}
}
getDetailAM() {
api.create().getDetailAM(this.props.data[1]).then(response => {
// console.log(response.data)
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
let data = response.data.data
this.setState({
id: data.approval_matrix_id,
getTypes: data.approval_type_name,
getApprovedBy: data.fullname
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
onClickDelete() {
if (this.props.type === 'close') {
let payload = this.state.id
this.props.deleteAM(payload)
}
}
render() {
return (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div style={{ display: 'flex', justifyContent: 'center', paddingTop: 20 }}>
<img src={Images.failed} />
</div>
<div style={{ display: 'grid', justifyContent: 'center', marginTop: 20, paddingBottom: 20 }}>
<span style={{ textAlign: 'center', fontSize: 14, fontWeight: 'bold', fontFamily: 'Nunito Sans, sans-serif' }}>
Do you wanna close {this.state.getTypes} - {this.state.getApprovedBy}?
</span>
</div>
<div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1" style={{ alignSelf: 'center' }}>
<button
type="button"
onClick={() => this.props.onClickClose()}
>
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
</div>
</button>
</div>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button
type="button"
onClick={()=> this.onClickDelete()}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Delete</span>
</div>
</button>
</div>
</div>
</div>
</div>
);
}
}
......@@ -10,8 +10,10 @@ import MuiAlert from '@material-ui/lab/Alert';
import UploadFile from "../../library/Upload";
import CreateApprovalMatrix from "../ApprovalMatrix/CreateApprovalMatrix";
import EditApprovalMatrix from "../ApprovalMatrix/EditApprovalMatrix";
import CloseClosingReport from "../GeneralSetting/CloseClosingReport";
import VisualisasiAM from "../ApprovalMatrix/VisualisasiAM";
import DeleteApprovalMatrix from "../ApprovalMatrix/DeleteApprovalMatrix";
import ExtendClosingReport from "../GeneralSetting/ExtendClosingReport";
import PopUpFailedSave from "../../library/PopUpFailedSave";
import api from "../../api";
import Constant from '../../library/Constant';
......@@ -59,7 +61,8 @@ export default class ClosingReport extends Component {
btndelete: false,
load: false,
judul: '',
popupDel: false,
popupExtend: false,
popupClose: false,
loading: false
}
}
......@@ -130,15 +133,15 @@ export default class ClosingReport extends Component {
}
openPopUp(index, type) {
if (type === 'edit') {
if (type === 'extend') {
this.setState({
rowData: index,
visibleEdit: true
popupExtend: true
})
} else if (type === 'delete') {
} else if (type === 'close') {
this.setState({
rowData: index,
popupDel: true
popupClose: true
})
}
else {
......@@ -182,6 +185,33 @@ export default class ClosingReport extends Component {
})
}
deleteAM = (payload) => {
this.setState({ popupDel: false })
api.create().deleteAM(payload).then(response => {
// console.log(response.data)
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({ loading: false, alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ loading: false, alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ loading: false, alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
closeAlert() {
this.setState({ alert: false })
......@@ -198,7 +228,7 @@ export default class ClosingReport extends Component {
return (
<div style={{ display: 'flex' }}>
{this.state.btnedit && <span>
<a data-tip={'Edit'} data-for="edit">
<a data-tip={'Extend'} data-for="extend">
<button
style={{
backgroundColor: 'transparent',
......@@ -207,15 +237,15 @@ export default class ClosingReport extends Component {
marginRight: 15
}}
// onClick={() => console.log(tableMeta)}
onClick={() => this.openPopUp(tableMeta.rowData, 'edit')}
onClick={() => this.openPopUp(tableMeta.rowData, 'extend')}
>
<img src={Images.circleCheck} />
</button>
</a>
<ReactTooltip border={true} id="edit" place="bottom" type="light" effect="solid" />
<ReactTooltip border={true} id="extend" place="bottom" type="light" effect="solid" />
</span>}
{this.state.btndelete && <span>
<a data-tip={'Delete'} data-for="delete">
<a data-tip={'Close'} data-for="close">
<button
style={{
backgroundColor: 'transparent',
......@@ -223,12 +253,12 @@ export default class ClosingReport extends Component {
borderColor: 'transparent',
}}
// onClick={() => console.log(tableMeta)}
onClick={() => this.openPopUp(tableMeta.rowData, 'delete')}
onClick={() => this.openPopUp(tableMeta.rowData, 'close')}
>
<img src={Images.crossCircle} />
</button>
</a>
<ReactTooltip border={true} id="delete" place="bottom" type="light" effect="solid" />
<ReactTooltip border={true} id="close" place="bottom" type="light" effect="solid" />
</span>}
</div >
);
......@@ -412,7 +442,24 @@ export default class ClosingReport extends Component {
</div>
</div>
}
{this.state.popupExtend && (
<ExtendClosingReport
type={"extend"}
onClickClose={() => this.setState({ popupExtend: false })}
data={this.state.rowData}
// getList={() => this.getData.bind(this)}
deleteAM={this.deleteAM.bind(this)}
/>
)}
{this.state.popupClose && (
<CloseClosingReport
type={"close"}
onClickClose={() => this.setState({ popupClose: false })}
data={this.state.rowData}
// getList={() => this.getData.bind(this)}
deleteAM={this.deleteAM.bind(this)}
/>
)}
{this.state.popupError && (
<PopUpFailedSave onClickClose={() => this.setState({ popupError: false })} />
)}
......
import React, { Component } from 'react';
import Images from '../../assets/Images';
import { Typography } from '@material-ui/core';
import api from "../../api";
import Constant from '../../library/Constant';
export default class ExtendClosingReport extends Component {
constructor(props) {
super(props)
this.state = {
id: '',
getApprovedBy: null,
getTypes: null,
}
}
componentDidMount() {
if (this.props.type === 'extend') {
this.getDetailAM()
}
}
getDetailAM() {
api.create().getDetailAM(this.props.data[1]).then(response => {
// console.log(response.data)
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
let data = response.data.data
this.setState({
id: data.approval_matrix_id,
getTypes: data.approval_type_name,
getApprovedBy: data.fullname
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
onClickDelete() {
if (this.props.type === 'extend') {
let payload = this.state.id
this.props.deleteAM(payload)
}
}
render() {
return (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div style={{ display: 'flex', justifyContent: 'center', paddingTop: 20 }}>
<img src={Images.failed} />
</div>
<div style={{ display: 'grid', justifyContent: 'center', marginTop: 20, paddingBottom: 20 }}>
<span style={{ textAlign: 'center', fontSize: 14, fontWeight: 'bold', fontFamily: 'Nunito Sans, sans-serif' }}>
Do you wanna extend {this.state.getTypes} - {this.state.getApprovedBy}?
</span>
</div>
<div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1" style={{ alignSelf: 'center' }}>
<button
type="button"
onClick={() => this.props.onClickClose()}
>
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
</div>
</button>
</div>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button
type="button"
onClick={()=> this.onClickDelete()}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Delete</span>
</div>
</button>
</div>
</div>
</div>
</div>
);
}
}
......@@ -15,7 +15,7 @@ export default class RollbackAuditTrails extends Component {
}
componentDidMount() {
if (this.props.type === 'delete') {
if (this.props.type === 'rollback') {
this.getDetailAM()
}
}
......@@ -52,7 +52,7 @@ export default class RollbackAuditTrails extends Component {
}
onClickDelete() {
if (this.props.type === 'delete') {
if (this.props.type === 'rollback') {
let payload = this.state.id
this.props.deleteAM(payload)
}
......@@ -67,7 +67,7 @@ export default class RollbackAuditTrails extends Component {
</div>
<div style={{ display: 'grid', justifyContent: 'center', marginTop: 20, paddingBottom: 20 }}>
<span style={{ textAlign: 'center', fontSize: 14, fontWeight: 'bold', fontFamily: 'Nunito Sans, sans-serif' }}>
Delete {this.state.getTypes} - {this.state.getApprovedBy}?
Do you wanna rollback {this.state.getTypes} - {this.state.getApprovedBy}?
</span>
</div>
<div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
......
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