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