|
|
|
@ -3,9 +3,8 @@ import { Modal, ModalHeader, ModalBody, ModalFooter, Row, Col, Table } from 'rea
|
|
|
|
|
import { Button, Form, FormGroup, Label, Input } from 'reactstrap'; |
|
|
|
|
import 'antd/dist/antd.css'; |
|
|
|
|
import axios from 'axios'; |
|
|
|
|
import { MENU_SEARCH } from '../../../const/ApiConst.js'; |
|
|
|
|
import { MENU_COMPANY_SEARCH, MENU_SEARCH } from '../../../const/ApiConst.js'; |
|
|
|
|
import { withTranslation, WithTranslation } from 'react-i18next'; |
|
|
|
|
const BASE_URL = "http://siopas.co.id/custom-php/api/geohr/"; |
|
|
|
|
|
|
|
|
|
const token = window.localStorage.getItem('token'); |
|
|
|
|
|
|
|
|
@ -52,30 +51,64 @@ class DialogMenuRoles extends Component {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getAllMenu = async () => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { companyID } = this.props; |
|
|
|
|
const { roleName } = this.props; |
|
|
|
|
if (roleName !== "Super Admin") { |
|
|
|
|
const payload = { |
|
|
|
|
"paging": { "start": 0, "length": -1 }, |
|
|
|
|
"columns": [ |
|
|
|
|
{ "name": "name", "logic_operator": "ilike", "value": "", "operator": "AND" } |
|
|
|
|
], |
|
|
|
|
"joins": [], |
|
|
|
|
"paging": { |
|
|
|
|
"start": 0, |
|
|
|
|
"length": -1 |
|
|
|
|
}, |
|
|
|
|
"columns": [{ |
|
|
|
|
"name": "company_id", |
|
|
|
|
"logic_operator": "=", |
|
|
|
|
"value": companyID, |
|
|
|
|
"operator": "AND" |
|
|
|
|
}], |
|
|
|
|
"joins": [{ |
|
|
|
|
"name": "m_menu", |
|
|
|
|
"column_join": "menu_id", |
|
|
|
|
"column_results": [ |
|
|
|
|
"name" |
|
|
|
|
] |
|
|
|
|
}], |
|
|
|
|
"orders": { "columns": ["id"], "ascending": false } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const result = await axios |
|
|
|
|
.post(MENU_SEARCH, payload, config) |
|
|
|
|
.post(MENU_COMPANY_SEARCH, payload, config) |
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
|
console.log('data Menu Role :', result.data.data); |
|
|
|
|
this.setState({ menu: result.data.data }, () => { |
|
|
|
|
this.setStateMenu(false); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
const payload = { |
|
|
|
|
"paging": { |
|
|
|
|
"start": 0, |
|
|
|
|
"length": -1 |
|
|
|
|
}, |
|
|
|
|
"columns": [{ |
|
|
|
|
"name": "name", |
|
|
|
|
"logic_operator": "ilike", |
|
|
|
|
"value": "", |
|
|
|
|
"operator": "AND" |
|
|
|
|
}], |
|
|
|
|
"orders": { "columns": ["id"], "ascending": false } |
|
|
|
|
} |
|
|
|
|
const result = await axios |
|
|
|
|
.post(MENU_SEARCH, payload, config) |
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
|
this.setState({ menu: result.data.data }); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
setStateMenu = edit => { |
|
|
|
@ -155,7 +188,7 @@ class DialogMenuRoles extends Component {
|
|
|
|
|
menu.map((val, index) => { |
|
|
|
|
return ( |
|
|
|
|
<tr key={index}> |
|
|
|
|
<td>{val.name}</td> |
|
|
|
|
<td>{val.join_first_name ?? val.name}</td> |
|
|
|
|
<td><input type="checkbox" onClick={(e) => this.handleChangeCheckbox(e.target.checked, index)} defaultChecked={stateMenu[index]} /></td> |
|
|
|
|
</tr> |
|
|
|
|
) |
|
|
|
|