|
|
|
@ -3,7 +3,7 @@ import React, { Component } from 'react';
|
|
|
|
|
import { Button, Form, FormFeedback, FormGroup, Input, Label, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap'; |
|
|
|
|
import Select from 'react-select'; |
|
|
|
|
import axios from 'axios'; |
|
|
|
|
import { BASE_URL_GEOHR_API2, ROLE_SEARCH, USER_WASPANG, USER_LIST } from '../../../const/ApiConst'; |
|
|
|
|
import { BASE_URL_GEOHR_API2, ROLE_SEARCH, USER_WASPANG, USER_LIST, USER_SEARCH } from '../../../const/ApiConst'; |
|
|
|
|
import { Transfer } from 'antd'; |
|
|
|
|
import { withTranslation } from 'react-i18next'; |
|
|
|
|
|
|
|
|
@ -51,13 +51,18 @@ class DialogForm extends Component {
|
|
|
|
|
allEmployeeId: [], |
|
|
|
|
idEmployeeDivision: [], |
|
|
|
|
idOrganization: [], |
|
|
|
|
disableTransfer: true |
|
|
|
|
disableTransfer: true, |
|
|
|
|
listCompany: [], |
|
|
|
|
company_id: this.props.company_id, |
|
|
|
|
role_name: '' |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async componentDidMount() { |
|
|
|
|
this.getDataUsers(); |
|
|
|
|
this.getDataRole(); |
|
|
|
|
if (this.props.company_id !== null) { |
|
|
|
|
this.getDataRole(); |
|
|
|
|
this.getDataUsers(); |
|
|
|
|
} |
|
|
|
|
this.props.showDialog(this.showDialog); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -69,14 +74,16 @@ class DialogForm extends Component {
|
|
|
|
|
id: dataEdit.id, |
|
|
|
|
title: dataEdit.title_notif, |
|
|
|
|
description: dataEdit.description, |
|
|
|
|
message: dataEdit.message_notif |
|
|
|
|
message: dataEdit.message_notif, |
|
|
|
|
company_id: dataEdit.company_id |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
this.setState({ |
|
|
|
|
id: 0, |
|
|
|
|
title: "", |
|
|
|
|
description: "", |
|
|
|
|
message: "" |
|
|
|
|
message: "", |
|
|
|
|
company_id: 0 |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
this.setState({ isParentClick: false }); |
|
|
|
@ -128,9 +135,12 @@ class DialogForm extends Component {
|
|
|
|
|
title, |
|
|
|
|
description, |
|
|
|
|
message, |
|
|
|
|
penerima |
|
|
|
|
} = this.state |
|
|
|
|
penerima, |
|
|
|
|
|
|
|
|
|
} = this.state |
|
|
|
|
let { |
|
|
|
|
company_id |
|
|
|
|
} = this.state |
|
|
|
|
let idSend = []; |
|
|
|
|
let send_to_type = "all"; |
|
|
|
|
if (penerima === "all") { |
|
|
|
@ -151,15 +161,17 @@ class DialogForm extends Component {
|
|
|
|
|
} else { |
|
|
|
|
idSend = idSend; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (this.props.role_name !== 'Super Admin') { |
|
|
|
|
company_id = parseInt(this.props.company_id) |
|
|
|
|
} |
|
|
|
|
const data = { |
|
|
|
|
title, |
|
|
|
|
description, |
|
|
|
|
message, |
|
|
|
|
send_to_type, |
|
|
|
|
id: idSend |
|
|
|
|
id: idSend, |
|
|
|
|
company_id: company_id |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (param === 'registered' || param === 'send') { |
|
|
|
|
this.props.handleSaveBroadcast(param, data) |
|
|
|
|
} |
|
|
|
@ -201,7 +213,18 @@ class DialogForm extends Component {
|
|
|
|
|
|
|
|
|
|
getDataRole = async () => { |
|
|
|
|
const payload = { |
|
|
|
|
|
|
|
|
|
"paging": { |
|
|
|
|
"start": 0, |
|
|
|
|
"length": -1 |
|
|
|
|
}, |
|
|
|
|
"columns": [ |
|
|
|
|
{ |
|
|
|
|
"name": "company_id", |
|
|
|
|
"logic_operator": "=", |
|
|
|
|
"value": this.state.company_id, |
|
|
|
|
"operator": "AND" |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
"orders": { "columns": ["id"], "ascending": false } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -231,20 +254,11 @@ class DialogForm extends Component {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getDataUsers = async () => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const payload = { |
|
|
|
|
"paging": { |
|
|
|
|
"start": 0, |
|
|
|
|
"length": 10 |
|
|
|
|
"length": -1 |
|
|
|
|
}, |
|
|
|
|
"filter_columns": [ |
|
|
|
|
{ |
|
|
|
|
"name": "name", |
|
|
|
|
"value": "", |
|
|
|
|
"table_name": "m_users" |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
"columns": [ |
|
|
|
|
{ |
|
|
|
|
"name": "name", |
|
|
|
@ -254,34 +268,10 @@ class DialogForm extends Component {
|
|
|
|
|
"table_name": "m_users" |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
"name": "id", |
|
|
|
|
"name": "company_id", |
|
|
|
|
"logic_operator": "=", |
|
|
|
|
"value": "3", |
|
|
|
|
"operator": "AND", |
|
|
|
|
"table_name": "m_roles" |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
"joins": [ |
|
|
|
|
{ |
|
|
|
|
"name": "m_users", |
|
|
|
|
"column_join": "user_id", |
|
|
|
|
"column_results": [ |
|
|
|
|
"username", |
|
|
|
|
"name", |
|
|
|
|
"email", |
|
|
|
|
"gender", |
|
|
|
|
"phone_number", |
|
|
|
|
"address", |
|
|
|
|
"birth_place", |
|
|
|
|
"birth_date" |
|
|
|
|
] |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
"name": "m_roles", |
|
|
|
|
"column_join": "role_id", |
|
|
|
|
"column_results": [ |
|
|
|
|
"name" |
|
|
|
|
] |
|
|
|
|
"value": this.state.company_id, |
|
|
|
|
"operator": "AND" |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
"orders": { |
|
|
|
@ -293,7 +283,7 @@ class DialogForm extends Component {
|
|
|
|
|
} |
|
|
|
|
//TODO should use search instead
|
|
|
|
|
const result = await axios |
|
|
|
|
.get(USER_LIST, config) |
|
|
|
|
.post(USER_SEARCH, payload, config) |
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
@ -330,11 +320,29 @@ class DialogForm extends Component {
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
handleSelectCompany = (selectedOption) => { |
|
|
|
|
const selectedCompanyId = selectedOption.value; |
|
|
|
|
this.setState({ company_id: selectedCompanyId }, () => { |
|
|
|
|
this.getDataRole(); |
|
|
|
|
this.getDataUsers(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
renderForm = () => { |
|
|
|
|
const t = this.props |
|
|
|
|
const { errorTitle, errorMessage } = this.state |
|
|
|
|
return ( |
|
|
|
|
<Form> |
|
|
|
|
{this.props.role_name === 'Super Admin' && ( |
|
|
|
|
<FormGroup> |
|
|
|
|
<Label>{this.props.t('company')}</Label> |
|
|
|
|
<Select |
|
|
|
|
options={this.props.listCompany.map(company => ({ value: company.id, label: company.company_name }))} |
|
|
|
|
onChange={this.handleSelectCompany} |
|
|
|
|
value={this.state.company_id} |
|
|
|
|
/> |
|
|
|
|
</FormGroup> |
|
|
|
|
)} |
|
|
|
|
<FormGroup> |
|
|
|
|
<Label>{this.props.t('receiver')}</Label> |
|
|
|
|
<Input type="select" value={this.state.penerima} onChange={(e) => this.handleChangePenerima(e.target.value)}> |
|
|
|
@ -395,7 +403,7 @@ class DialogForm extends Component {
|
|
|
|
|
<Label>{this.props.t('broadcastDescription')}</Label> |
|
|
|
|
<Input style={{ minHeight: "100px" }} type="textarea" value={this.state.description} onChange={(e) => this.setState({ description: e.target.value })} placeholder={this.props.t('inputDescription')} /> |
|
|
|
|
</FormGroup> |
|
|
|
|
</Form> |
|
|
|
|
</Form > |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
handleCloseDialog = () => { |
|
|
|
|