|
|
|
@ -5,7 +5,7 @@ import React, { Component } from 'react';
|
|
|
|
|
import SweetAlert from 'react-bootstrap-sweetalert'; |
|
|
|
|
import axios from 'axios'; |
|
|
|
|
import moment from 'moment'; |
|
|
|
|
import { USER_LIST, BASE_SIMPRO_LUMEN, ROLE_LIST } from '../../../const/ApiConst'; |
|
|
|
|
import { USER_LIST, BASE_SIMPRO_LUMEN, ROLE_LIST, COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst'; |
|
|
|
|
import { Button, Card, CardBody, CardHeader, DropdownItem, DropdownMenu, DropdownToggle, Input, InputGroup, InputGroupButtonDropdown, Table, Row, Col } from 'reactstrap'; |
|
|
|
|
import { DatePicker, Pagination } from 'antd'; |
|
|
|
|
import { NotificationContainer, NotificationManager } from 'react-notifications'; |
|
|
|
@ -66,6 +66,9 @@ class index extends Component {
|
|
|
|
|
totalPage: 0, |
|
|
|
|
typeClock: "All", |
|
|
|
|
typeDialog: 'Save', |
|
|
|
|
role_name: props.role_name || '', |
|
|
|
|
company_id: props.company_id, |
|
|
|
|
listCompany: [] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -79,42 +82,22 @@ class index extends Component {
|
|
|
|
|
if (startDate !== prevState.startDate) this.getDataBroadcast() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
handleSearch = e => { |
|
|
|
|
const value = e.target.value |
|
|
|
|
this.setState({ search: value, currentPage: 1 }) |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
getDataUsers = async () => { |
|
|
|
|
getDataCompany = async () => { |
|
|
|
|
const result = await axios |
|
|
|
|
.get(USER_LIST, config) |
|
|
|
|
.get(COMPANY_MANAGEMENT_LIST, config) |
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
if (result && result.data && result.status == 200) { |
|
|
|
|
const dataRes = result.data.data; |
|
|
|
|
const finalData = []; |
|
|
|
|
if (dataRes.length > 0) { |
|
|
|
|
dataRes.map((val, index) => { |
|
|
|
|
let data = { |
|
|
|
|
id: val.id, |
|
|
|
|
name: val.name, |
|
|
|
|
}; |
|
|
|
|
finalData.push(data); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
this.setState({ dataUser: finalData }); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getDataRoles = async () => { |
|
|
|
|
const result = await axios |
|
|
|
|
.get(ROLE_LIST, config) |
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|
if (result && result.data && result.status == 200) { |
|
|
|
|
this.setState({ dataRoles: result.data.data }); |
|
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
|
this.setState({ listCompany: result.data.data }) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
handleSearch = e => { |
|
|
|
|
const value = e.target.value |
|
|
|
|
this.setState({ search: value, currentPage: 1 }) |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getDataBroadcast = async () => { |
|
|
|
|
let url = BASE_SIMPRO_LUMEN + `/broadcast/search`; |
|
|
|
@ -141,8 +124,9 @@ class index extends Component {
|
|
|
|
|
"name": searchDetailField, |
|
|
|
|
"operator": "AND", |
|
|
|
|
"value": search |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
"joins": [], |
|
|
|
|
"orders": { |
|
|
|
|
"ascending": false, |
|
|
|
|
"columns": [ |
|
|
|
@ -155,7 +139,22 @@ class index extends Component {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (this.state.search !== "" && this.state.search !== null) { |
|
|
|
|
if (this.state.role_name === 'Super Admin') { |
|
|
|
|
payload.joins.push( |
|
|
|
|
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] } |
|
|
|
|
) |
|
|
|
|
payload.columns.push( |
|
|
|
|
{ name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } |
|
|
|
|
) |
|
|
|
|
} else { |
|
|
|
|
payload.columns.push( |
|
|
|
|
{ |
|
|
|
|
"name": "company_id", |
|
|
|
|
"logic_operator": "=", |
|
|
|
|
"value": this.state.company_id, |
|
|
|
|
"operator": "AND" |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const result = await axios |
|
|
|
@ -165,8 +164,7 @@ class index extends Component {
|
|
|
|
|
if (result && result.data) { |
|
|
|
|
if (result.data.code === 200) { |
|
|
|
|
this.setState({ dataTable: result.data.data, totalPage: result.data.totalRecord }); |
|
|
|
|
this.getDataUsers() |
|
|
|
|
this.getDataRoles() |
|
|
|
|
this.getDataCompany() |
|
|
|
|
} else { |
|
|
|
|
NotificationManager.error('Failed retreiving data!!', 'Failed'); |
|
|
|
|
} |
|
|
|
@ -214,13 +212,13 @@ class index extends Component {
|
|
|
|
|
|
|
|
|
|
saveBroadcast = async (type, data) => { |
|
|
|
|
let url = BASE_SIMPRO_LUMEN + `/broadcast/add`; |
|
|
|
|
|
|
|
|
|
const param = { |
|
|
|
|
"title_notif": data.title, |
|
|
|
|
"status_send": type, |
|
|
|
|
"send_to_type": "all", |
|
|
|
|
"message_notif": data.message, |
|
|
|
|
"description": data.description, |
|
|
|
|
"company_id": data.company_id |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const paramRoles = { |
|
|
|
@ -229,7 +227,8 @@ class index extends Component {
|
|
|
|
|
"send_to_type": "roles", |
|
|
|
|
"message_notif": data.message, |
|
|
|
|
"description": data.description, |
|
|
|
|
"send_to_id": data.id |
|
|
|
|
"send_to_id": data.id, |
|
|
|
|
"company_id": data.company_id |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const paramUsers = { |
|
|
|
@ -238,7 +237,8 @@ class index extends Component {
|
|
|
|
|
"send_to_type": "users", |
|
|
|
|
"message_notif": data.message, |
|
|
|
|
"description": data.description, |
|
|
|
|
"send_to_id": data.send_to_type == "users" ? data.id.map((id, index) => id) : null |
|
|
|
|
"send_to_id": data.send_to_type == "users" ? data.id.map((id, index) => id) : null, |
|
|
|
|
"company_id": data.company_id |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (data.send_to_type === "all") { |
|
|
|
@ -491,6 +491,9 @@ class index extends Component {
|
|
|
|
|
</Col> |
|
|
|
|
</Row> |
|
|
|
|
</td> |
|
|
|
|
{this.state.role_name === 'Super Admin' && |
|
|
|
|
<td>{n.join_first_company_name ? n.join_first_company_name : "-"}</td> |
|
|
|
|
} |
|
|
|
|
<td>{n.title_notif}</td> |
|
|
|
|
<td>{n.message_notif !== "" ? n.message_notif : "-"}</td> |
|
|
|
|
<td>{n.description !== "" ? n.description : "-"}</td> |
|
|
|
@ -557,13 +560,14 @@ class index extends Component {
|
|
|
|
|
render() { |
|
|
|
|
const column = [ |
|
|
|
|
{ name: this.props.t('action') }, |
|
|
|
|
this.state.role_name === 'Super Admin' ? { name: this.props.t('company') } : null, |
|
|
|
|
{ name: this.props.t('title') }, |
|
|
|
|
{ name: this.props.t('message') }, |
|
|
|
|
{ name: this.props.t('description') }, |
|
|
|
|
{ name: this.props.t('receiver') }, |
|
|
|
|
{ name: "Status" }, |
|
|
|
|
{ name: this.props.t('date') }, |
|
|
|
|
] |
|
|
|
|
].filter(column => column && column.name); |
|
|
|
|
const t = this.props; |
|
|
|
|
const { tooltipTambah, tooltipExport, dataTable, splitButtonOpen, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete, statusSend } = this.state |
|
|
|
|
return ( |
|
|
|
@ -591,6 +595,9 @@ class index extends Component {
|
|
|
|
|
dataEdit={this.state.dataEdit} |
|
|
|
|
showDialog={showDialog => this.showChildDialog = showDialog} |
|
|
|
|
dataHs={this.state.dataIdHo} |
|
|
|
|
company_id={this.state.company_id} |
|
|
|
|
role_name={this.state.role_name} |
|
|
|
|
listCompany={this.state.listCompany} |
|
|
|
|
/> |
|
|
|
|
<DialogDetail |
|
|
|
|
openDialog={this.state.openDialogDetail} |
|
|
|
|