Commit 9f9ad787 authored by muhammad ridwan's avatar muhammad ridwan

bug fixing and using one component

parent 7b555da0
......@@ -9,11 +9,11 @@ import api from '../../api';
import PropagateLoader from "react-spinners/PropagateLoader"
import TableDocument from "./TableDocument";
import PopUpKonfirmasi from "../DocumentManagement/PopUpKonfirmasi";
import CreateCrafmDoc from "./CreateCrafmDoc";
import CreateCarfmDoc from "./CreateCarfmDoc";
const Alert = withStyles({})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class RiskManagement extends Component {
export default class CarfmDocument extends Component {
constructor(props) {
super(props);
......@@ -27,21 +27,48 @@ export default class RiskManagement extends Component {
name: '',
userCompActive: [],
isHasAccessDocument: false,
submenu_id: 27,
submenu_name: "anti-fraud",
menu_title: "Anti-Fraud"
submenu_id : 0,
submenu_name: "",
menu_title: ""
}
}
componentDidMount() {
async componentDidMount() {
// this.getPermission()
await this.getMenuName();
this.getDataCarfm();
this.getDetailUser();
}
getDataCarfm(){
async getMenuName(){
await api.create().getMenuByUser().then(
response => {
if(response.data){
if(response.data.status === 'success'){
response.data.data.map(
(item) => {
let arr = window.location.href.split('/');
if(item.class_id == arr.slice(-1)[0]){
this.setState({
submenu_id : item.menu_id,
submenu_name : item.menu_name.toLowerCase(),
menu_title : item.menu_name.replace(/\b\w/g, c => c.toUpperCase())
})
}
}
)
}
}
}
)
}
getDataCarfm(create){
let payload = {
submenu_id : this.state.submenu_id
}
......@@ -63,7 +90,7 @@ export default class RiskManagement extends Component {
isHasAccessDocument: dataList.length == 0 ? false : true,
listData: dataList,
loadTable: true,
refresh: ''
refresh: create == undefined ? '' : create
}, () => {
this.getPermission(this.state.submenu_name)
})
......@@ -213,7 +240,7 @@ export default class RiskManagement extends Component {
this.setState({ konfirmasi: true, formData: payload, docId: response.data.data.document_id, loading: false })
}
else if (response.data.message === "Data was Saved Successfully") {
this.getDataCarfm()
this.getDataCarfm('create')
this.setState({ visibleCreate: false, loading: false, alert: true, messageAlert: response.data.message, tipeAlert: 'success'})
}
else {
......@@ -339,7 +366,7 @@ export default class RiskManagement extends Component {
/>
)}
{this.state.visibleCreate && (
<CreateCrafmDoc
<CreateCarfmDoc
onClickClose={() => this.setState({ visibleCreate: false })}
// getDataDocument={this.getDataDocument.bind(this)}
createDocument={this.createDocument.bind(this)}
......
......@@ -14,7 +14,7 @@ import PropagateLoader from "react-spinners/PropagateLoader"
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class CreateCrafmDoc extends Component {
export default class CreateCarfmDoc extends Component {
constructor(props) {
super(props)
this.state = {
......@@ -48,7 +48,8 @@ export default class CreateCrafmDoc extends Component {
docId: '',
sizeUpload: "1",
disabledPeriode: false,
menuName: null
menuName: null,
saveDisable: false
}
}
......@@ -253,7 +254,7 @@ export default class CreateCrafmDoc extends Component {
validasi() {
if (this.state.disabledPeriode === true) {
if (R.isNil(this.state.file)) {
this.setState({ alert: true, messageAlert: 'File Cannot be Empty', tipeAlert: 'warning' })
this.setState({ alert: true, messageAlert: 'File Cannot be Empty', tipeAlert: 'warning', saveDisable: false })
} else {
const formData = new FormData();
formData.append("file", this.state.file);
......@@ -276,14 +277,14 @@ export default class CreateCrafmDoc extends Component {
} else {
if (R.isNil(this.state.getPerusahaan)) {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty' })
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty', saveDisable: false })
}else if (R.isNil(this.state.periode)) {
this.setState({ errorPeriode: true, msgErrorPeriode: 'Period Cannot be Empty' })
this.setState({ errorPeriode: true, msgErrorPeriode: 'Period Cannot be Empty', saveDisable: false })
} else if (R.isNil(this.state.monthId)) {
this.setState({ errorMonth: true, msgErrorMonth: 'Month Cannot be Empty' })
this.setState({ errorMonth: true, msgErrorMonth: 'Month Cannot be Empty', saveDisable: false })
}
else if (R.isNil(this.state.file)) {
this.setState({ alert: true, messageAlert: 'File Cannot be Empty', tipeAlert: 'warning' })
this.setState({ alert: true, messageAlert: 'File Cannot be Empty', tipeAlert: 'warning', saveDisable: false })
} else {
const formData = new FormData();
formData.append("file", this.state.file);
......@@ -484,13 +485,19 @@ export default class CreateCrafmDoc extends Component {
</button>
</div>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button
{!this.state.saveDisable && <button
disabled={this.state.saveDisable}
type="button"
onClick={() =>
{this.props.handleLoading(1)
{
this.setState({
saveDisable: true
});
this.props.handleLoading(1);
setTimeout(() => {
this.validasi()
console.log(this.validasi());
console.log("vlidasi " + this.validasi());
}, 100)
}
}
......@@ -498,7 +505,8 @@ export default class CreateCrafmDoc extends Component {
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Save</span>
</div>
</button>
</button>}
</div>
</div>
</div>
......
This diff is collapsed.
This diff is collapsed.
......@@ -20,9 +20,7 @@ import SubHolding from '../container/Reports/SubHolding';
import SummaryTriputra from '../container/SummaryTriputra/SummaryOfTriputra';
import MasterDataCAT from '../container/MasterData/MasterDataCAT/MasterDataCAT';
import ProgressReport from '../container/ProgressReport/ProgressReport';
import InternalAudit from "../container/CRFM/InternalAudit";
import AntiFraud from "../container/CRFM/AntiFraud";
import RiskManagement from "../container/CRFM/RiskManagement";
import CarfmDocument from "../container/CRFM/CarfmDocument";
const routes = [
{
......@@ -115,15 +113,15 @@ const routes = [
},
{
path: "/home/internal-audit",
main: InternalAudit
main: CarfmDocument
},
{
path: "/home/anti-fraud",
main: AntiFraud
main: CarfmDocument
},
{
path: "/home/risk-management",
main: RiskManagement
main: CarfmDocument
},
{
path: "*",
......
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