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