Browse Source

add USER_LIST variabel apiConst

pull/2/head
wahyuun 1 year ago
parent
commit
cb9e192815
  1. 22
      src/views/Master/MasterBroadcast/DialogDetail.js

22
src/views/Master/MasterBroadcast/DialogDetail.js

@ -4,7 +4,7 @@ import moment from 'moment';
import { Button, Table, FormFeedback, FormGroup, Input, Label, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap'; import { Button, Table, FormFeedback, FormGroup, Input, Label, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap';
import Select from 'react-select'; import Select from 'react-select';
import axios from 'axios'; import axios from 'axios';
import { BASE_SIMPRO_LUMEN, BASE_URL_GEOHR_API } from '../../../const/ApiConst'; import { BASE_SIMPRO_LUMEN, USER_LIST } from '../../../const/ApiConst';
import { Transfer } from 'antd'; import { Transfer } from 'antd';
import { withTranslation } from 'react-i18next'; import { withTranslation } from 'react-i18next';
const token = window.localStorage.getItem('token'); const token = window.localStorage.getItem('token');
@ -42,11 +42,25 @@ class DialogDetail extends Component {
id: dataDetail.id id: dataDetail.id
}, () => { }, () => {
this.getDataDetail(); this.getDataDetail();
this.getDataUsers();
this.setState({ isParentClick: false }); this.setState({ isParentClick: false });
}); });
} }
} }
getDataUsers = async () => {
const result = await axios
.get(USER_LIST, config)
.then(res => res)
.catch((error) => error.response);
console.log('Get Data User', result)
if (result && result.data && result.status == 200) {
this.setState({ dataUser: result.data.data }, () => {
});
}
}
getDataDetail = async () => { getDataDetail = async () => {
countError++; countError++;
let url = BASE_SIMPRO_LUMEN + `/broadcast/search`; let url = BASE_SIMPRO_LUMEN + `/broadcast/search`;
@ -70,6 +84,7 @@ class DialogDetail extends Component {
} else { } else {
if (countError < 6) { if (countError < 6) {
this.getDataDetail(); this.getDataDetail();
this.getDataUsers();
} }
} }
} }
@ -81,8 +96,8 @@ class DialogDetail extends Component {
handleCloseDialog = () => { handleCloseDialog = () => {
this.props.closeDialog() this.props.closeDialog()
} }
render() { render() {
const dataUser = this.state.dataUser || [];
return ( return (
<Modal size="xl" isOpen={this.props.openDialog} toggle={this.props.toggleDialog}> <Modal size="xl" isOpen={this.props.openDialog} toggle={this.props.toggleDialog}>
<ModalHeader toggle={this.handleCloseDialog}>{this.props.t('broadcastDetail')}</ModalHeader> <ModalHeader toggle={this.handleCloseDialog}>{this.props.t('broadcastDetail')}</ModalHeader>
@ -93,17 +108,20 @@ class DialogDetail extends Component {
<th>{this.props.t('statusSend')}</th> <th>{this.props.t('statusSend')}</th>
<th>{this.props.t('dateSend')}</th> <th>{this.props.t('dateSend')}</th>
<th>{this.props.t('description')}</th> <th>{this.props.t('description')}</th>
<th>{this.props.t('receiver')}</th>
<th>{this.props.t('titleNotification')}</th> <th>{this.props.t('titleNotification')}</th>
<th>{this.props.t('messageNotification')}</th> <th>{this.props.t('messageNotification')}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{this.state.dataListDetail.map((val, index) => { {this.state.dataListDetail.map((val, index) => {
const matchedUser = dataUser.find(item => item.id == val.send_to_id);
return ( return (
<tr key={index}> <tr key={index}>
<td>{val.status_send === "" ? "-" : val.status_send}</td> <td>{val.status_send === "" ? "-" : val.status_send}</td>
<td>{val.created_at === "" ? "-" : moment(val.created_date).format("DD-MM-YYYY HH:mm:ss")}</td> <td>{val.created_at === "" ? "-" : moment(val.created_date).format("DD-MM-YYYY HH:mm:ss")}</td>
<td>{val.description === "" ? "-" : val.description}</td> <td>{val.description === "" ? "-" : val.description}</td>
<td>{ matchedUser ? matchedUser.name : "-" }</td>
<td>{val.title_notif === "" ? "-" : val.title_notif}</td> <td>{val.title_notif === "" ? "-" : val.title_notif}</td>
<td>{val.message_notif === "" ? "-" : val.message_notif}</td> <td>{val.message_notif === "" ? "-" : val.message_notif}</td>
</tr> </tr>

Loading…
Cancel
Save