Browse Source

Merge pull request 'update broadcast' (#104) from dev-wahyu into staging

Reviewed-on: ordo/adw-frontend#104
pull/2/head
ibnu 1 year ago
parent
commit
1523d8d0c0
  1. 34
      src/views/Master/MasterBroadcast/DialogDetail.js
  2. 20
      src/views/Master/MasterBroadcast/DialogForm.js
  3. 8
      src/views/Master/MasterBroadcast/index.js

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

@ -4,10 +4,17 @@ 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_URL_GEOHR_API } from '../../../const/ApiConst'; import { BASE_SIMPRO_LUMEN, BASE_URL_GEOHR_API } 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 config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const ERROR_TITLE = "judul is required!" const ERROR_TITLE = "judul is required!"
const ERROR_MESSAGE = "message is required!" const ERROR_MESSAGE = "message is required!"
const BASE_URL = "https://oslog.id/geohr-api/"; const BASE_URL = "https://oslog.id/geohr-api/";
@ -42,26 +49,23 @@ class DialogDetail extends Component {
getDataDetail = async () => { getDataDetail = async () => {
countError++; countError++;
let url = BASE_URL_GEOHR_API + `/broadcast-detail/search?broadcastId=${this.state.id}`; let url = BASE_SIMPRO_LUMEN + `/broadcast/search`;
const payload = { const payload = {
"paging": { "start": 0, "length": 25 }, "paging": { "start": 0, "length": 25 },
"orders": { "columns": ["id"], "ascending": true }, "orders": { "columns": ["id"], "ascending": true },
"columns": [ "columns": [
{ "name": "status_send", "logic_operator": "ilike", "value": "", "operator": "AND" } { "name": "id", "logic_operator": "=", "value": this.state.id, "operator": "AND" }
],
"joins": [
{ "name": "m_broadcast", "column_results": ["title_notif", "message_notif", "description", "status_send"], "column_join": "broadcast_id" }
] ]
} }
const result = await axios const result = await axios
.post(url, payload) .post(url, payload, config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
console.log('cek data detail', result.data) console.log('cek data detail', result.data)
if (result && result.data && result.data.code === 200) { if (result && result.data && result.data.code === 200) {
if (result.data.data && result.data.data.broadcast_details) { if (result.data.data && result.data.data) {
this.setState({ dataListDetail: result.data.data.broadcast_details }) this.setState({ dataListDetail: result.data.data })
} }
} else { } else {
if (countError < 6) { if (countError < 6) {
@ -97,11 +101,11 @@ class DialogDetail extends Component {
{this.state.dataListDetail.map((val, index) => { {this.state.dataListDetail.map((val, index) => {
return ( return (
<tr key={index}> <tr key={index}>
<td>{val.join.status_send === "" ? "-" : val.status_send}</td> <td>{val.status_send === "" ? "-" : val.status_send}</td>
<td>{val.join.created_date === "" ? "-" : moment(val.created_date).format("YYYY-MM-DD HH:mm:ss")}</td> <td>{val.created_at === "" ? "-" : moment(val.created_date).format("DD-MM-YYYY HH:mm:ss")}</td>
<td>{val.join.broadcast_description === "" ? "-" : val.join.broadcast_description}</td> <td>{val.description === "" ? "-" : val.description}</td>
<td>{val.join.broadcast_title_notif === "" ? "-" : val.join.broadcast_title_notif}</td> <td>{val.title_notif === "" ? "-" : val.title_notif}</td>
<td>{val.join.broadcast_message_notif === "" ? "-" : val.join.broadcast_message_notif}</td> <td>{val.message_notif === "" ? "-" : val.message_notif}</td>
</tr> </tr>
) )
})} })}

20
src/views/Master/MasterBroadcast/DialogForm.js

@ -3,7 +3,7 @@ import React, { Component } from 'react';
import { Button, Form, FormFeedback, FormGroup, Input, Label, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap'; import { Button, Form, 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_URL_GEOHR_API2, ROLE_SEARCH, USER_WASPANG } from '../../../const/ApiConst'; import { BASE_URL_GEOHR_API2, ROLE_SEARCH, USER_WASPANG, USER_LIST } from '../../../const/ApiConst';
import { Transfer } from 'antd'; import { Transfer } from 'antd';
import { withTranslation } from 'react-i18next'; import { withTranslation } from 'react-i18next';
@ -137,7 +137,7 @@ class DialogForm extends Component {
if (penerima === "all") { if (penerima === "all") {
idSend = this.state.allEmployeeId; idSend = this.state.allEmployeeId;
send_to_type = "all"; send_to_type = "all";
} else if (penerima === "division") { } else if (penerima === "organization") {
idSend = this.state.idOrganization; idSend = this.state.idOrganization;
send_to_type = "roles"; send_to_type = "roles";
} else if (penerima === "karyawan") { } else if (penerima === "karyawan") {
@ -145,9 +145,13 @@ class DialogForm extends Component {
send_to_type = "users"; send_to_type = "users";
} }
if(Array.isArray(idSend)){
idSend = idSend.map(function (e) { idSend = idSend.map(function (e) {
return e.toString() return e.toString()
}); });
} else {
idSend = idSend;
}
const data = { const data = {
title, title,
@ -186,7 +190,7 @@ class DialogForm extends Component {
} }
setEmployeeOrganization = () => { setEmployeeOrganization = () => {
let arrEd = this.state.dataEmployee; let arrEd = this.state.dataEmployee.data;
let cek = arrEd.filter(this.filterId) let cek = arrEd.filter(this.filterId)
this.setState({ idEmployeeDivision: cek }) this.setState({ idEmployeeDivision: cek })
@ -289,14 +293,14 @@ class DialogForm extends Component {
"ascending": false "ascending": false
} }
} }
//TODO should use search instead
const result = await axios const result = await axios
.post(USER_WASPANG, payload, config) .get(USER_LIST, config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
console.log('test role', result) console.log('test role', result)
if (result && result.data && result.code == "200") { if (result && result.data && result.status == 200) {
this.setState({ dataEmployee: result.data }, () => { this.setState({ dataEmployee: result.data }, () => {
this.setDataEmployee(); this.setDataEmployee();
}); });
@ -307,12 +311,12 @@ class DialogForm extends Component {
setDataEmployee = () => { setDataEmployee = () => {
const listEmployee = []; const listEmployee = [];
const allIdEmployee = []; const allIdEmployee = [];
this.state.dataEmployee.map((val, index) => { this.state.dataEmployee.data.map((val, index) => {
allIdEmployee.push(val.id); allIdEmployee.push(val.id);
listEmployee.push({ listEmployee.push({
key: val.id, key: val.id,
id: val.id, id: val.id,
title: val.join.m_users_name title: val.name
}); });
}) })

8
src/views/Master/MasterBroadcast/index.js

@ -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 { API_BROADCAST_SIMPRO, BASE_SIMPRO, BASE_URL_GEOHR_API2 } from '../../../const/ApiConst'; import { API_BROADCAST_SIMPRO, BASE_SIMPRO, BASE_SIMPRO_LUMEN, BASE_URL_GEOHR_API2 } 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';
@ -85,7 +85,7 @@ class index extends Component {
}; };
getDataBroadcast = async () => { getDataBroadcast = async () => {
let url = BASE_SIMPRO + `/broadcast/search`; let url = BASE_SIMPRO_LUMEN + `/broadcast/search`;
const { searchDetail } = this.state const { searchDetail } = this.state
let start = 0; let start = 0;
@ -180,7 +180,7 @@ class index extends Component {
} }
saveBroadcast = async (type, data) => { saveBroadcast = async (type, data) => {
let url = BASE_SIMPRO + `/broadcast/add`; let url = BASE_SIMPRO_LUMEN + `/broadcast/add`;
const param = { const param = {
"title_notif": data.title, "title_notif": data.title,
@ -205,7 +205,7 @@ 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.id.map((id, index) => id) "send_to_id": data.send_to_type == "users" ? data.id.map((id, index) => id) : null
} }
if (data.send_to_type === "all") { if (data.send_to_type === "all") {

Loading…
Cancel
Save