Browse Source

Merge pull request 'staging' (#108) from staging into master

Reviewed-on: ordo/adw-frontend#108
pull/2/head
ibnu 1 year ago
parent
commit
58a1349ba2
  1. 1
      .env
  2. 49
      src/appredux/modules/map/actions.js
  3. BIN
      src/assets/img/map/pin_route_on_trip.png
  4. 970
      src/const/ApiConst.js
  5. 1525
      src/views/Dashboard/DashboardProject.js
  6. 48
      src/views/MapMonitoring/index.js
  7. 34
      src/views/Master/MasterBroadcast/DialogDetail.js
  8. 20
      src/views/Master/MasterBroadcast/DialogForm.js
  9. 8
      src/views/Master/MasterBroadcast/index.js
  10. 294
      src/views/SimproV2/CreatedProyek/AsignCustProject.js
  11. 2
      src/views/SimproV2/CreatedProyek/DataRequestMaterial.js
  12. 173
      src/views/SimproV2/CreatedProyek/DialogAssignCust.js
  13. 185
      src/views/SimproV2/CreatedProyek/index.js
  14. 87
      src/views/SimproV2/Gantt/index.js

1
.env

@ -1,3 +1,4 @@
PORT=3000 PORT=3000
CHOKIDAR_USEPOLLING=true CHOKIDAR_USEPOLLING=true
GENERATE_SOURCEMAP=false GENERATE_SOURCEMAP=false
SKIP_PREFLIGHT_CHECK=true

49
src/appredux/modules/map/actions.js

@ -158,11 +158,41 @@ export const getUserHistory = async (userId, dateString) => {
"features": [] "features": []
} }
// build waypoint line
let featureLine = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": []
}
}
userHistory.data.map((n, idx) => {
featureLine.geometry.coordinates.push([parseFloat(n.lon), parseFloat(n.lat)])
if (idx > startIdx && idx < endIdx) {
let featureOnTrip = {
"type": "Feature",
"properties": {
"type": "Working",
"wptime": n.wptime
},
"geometry": {
"type": "Point",
"coordinates": [parseFloat(n.lon), parseFloat(n.lat)]
}
}
featureCollection.features.push(featureOnTrip);
}
});
featureCollection.features.push(featureLine);
// set waypoint start // set waypoint start
let featurePointStart = { let featurePointStart = {
"type": "Feature", "type": "Feature",
"properties": { "properties": {
"type": "start", "type": "Start",
"wptime": userHistory.data[startIdx].wptime "wptime": userHistory.data[startIdx].wptime
}, },
"geometry": { "geometry": {
@ -176,7 +206,7 @@ export const getUserHistory = async (userId, dateString) => {
let featurePointEnd = { let featurePointEnd = {
"type": "Feature", "type": "Feature",
"properties": { "properties": {
"type": "end", "type": "End",
"wptime": userHistory.data[endIdx].wptime "wptime": userHistory.data[endIdx].wptime
}, },
"geometry": { "geometry": {
@ -186,21 +216,6 @@ export const getUserHistory = async (userId, dateString) => {
} }
featureCollection.features.push(featurePointEnd); featureCollection.features.push(featurePointEnd);
// build waypoint line
let featureLine = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": []
}
}
userHistory.data.map(n => {
featureLine.geometry.coordinates.push([parseFloat(n.lon), parseFloat(n.lat)])
});
featureCollection.features.push(featureLine);
store.dispatch(setUserHistory(featureCollection)); store.dispatch(setUserHistory(featureCollection));
store.dispatch(setIsSearchingRoute(false)); store.dispatch(setIsSearchingRoute(false));
} }

BIN
src/assets/img/map/pin_route_on_trip.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

970
src/const/ApiConst.js

File diff suppressed because it is too large Load Diff

1525
src/views/Dashboard/DashboardProject.js

File diff suppressed because it is too large Load Diff

48
src/views/MapMonitoring/index.js

@ -17,11 +17,15 @@ import "react-toastify/dist/ReactToastify.css";
import './MapMonitoring.css'; import './MapMonitoring.css';
import { BASE_SIMPRO_LUMEN_IMAGE } from '../../const/ApiConst'; import { BASE_SIMPRO_LUMEN_IMAGE } from '../../const/ApiConst';
import DEFAULT_USER_ICON from '../../assets/img/avatars/user.png'; import DEFAULT_USER_ICON from '../../assets/img/avatars/user.png';
import pinRouteStart from '../../assets/img/map/pin_route_green.png';
import pinRouteEnd from '../../assets/img/map/pin_route_red.png';
import pinRouteOnTrip from '../../assets/img/map/pin_route_on_trip.png';
import 'leaflet.markercluster/dist/MarkerCluster.Default.css' import 'leaflet.markercluster/dist/MarkerCluster.Default.css'
import 'leaflet.markercluster/dist/MarkerCluster.css' import 'leaflet.markercluster/dist/MarkerCluster.css'
import 'leaflet.markercluster/dist/leaflet.markercluster.js' import 'leaflet.markercluster/dist/leaflet.markercluster.js'
import 'leaflet-control-geocoder/dist/Control.Geocoder.css' import 'leaflet-control-geocoder/dist/Control.Geocoder.css'
import 'leaflet-control-geocoder/dist/Control.Geocoder.js' import 'leaflet-control-geocoder/dist/Control.Geocoder.js'
import moment from 'moment';
const MapMonitoring = () => { const MapMonitoring = () => {
@ -81,8 +85,50 @@ const MapMonitoring = () => {
if (mymap) { if (mymap) {
removeLayerByName('userHistoryLayer'); removeLayerByName('userHistoryLayer');
if (userHistory) { if (userHistory) {
var startIcon = new L.Icon({
iconSize: [60, 60],
iconAnchor: [30, 47],
popupAnchor: [1, -24],
iconUrl: pinRouteStart
});
var endIcon = new L.Icon({
iconSize: [60, 60],
iconAnchor: [30, 47],
popupAnchor: [1, -24],
iconUrl: pinRouteEnd
});
var onTripIcon = new L.Icon({
iconSize: [60, 60],
iconAnchor: [30, 47],
popupAnchor: [1, -24],
iconUrl: pinRouteOnTrip
});
let userHistoryLayer = L.geoJson(userHistory, { let userHistoryLayer = L.geoJson(userHistory, {
name: 'userHistoryLayer' name: 'userHistoryLayer',
onEachFeature: function(feature, layer) {
var popupText = `<b>Status: </b>${feature.properties.type}<br>
<b>Time: </b> ${feature.properties.wptime ? moment(feature.properties.wptime).format("DD-MM-YYYY HH:mm:ss") : '-'}`;
layer.bindPopup(popupText, {
closeButton: true,
// offset: L.point(0, -20)
});
layer.on('click', function() {
layer.openPopup();
});
},
pointToLayer: function(feature, latlng) {
var type = feature.properties.type;
if (type === 'Start') {
return L.marker(latlng, {icon: startIcon});
}
else if (type === "Working") {
return L.marker(latlng, {icon: onTripIcon});
}
else if (type === "End") {
return L.marker(latlng, {icon: endIcon});
}
},
}); });
userHistoryLayer.addTo(mymap); userHistoryLayer.addTo(mymap);
mymap.fitBounds(userHistoryLayer.getBounds()); mymap.fitBounds(userHistoryLayer.getBounds());

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") {

294
src/views/SimproV2/CreatedProyek/AsignCustProject.js

@ -0,0 +1,294 @@
import React, { useEffect, useState, useMemo } from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { Button, Form } from 'reactstrap';
import { Table, Tooltip } from 'antd';
import 'antd/dist/antd.css';
import moment from 'moment';
import { API_ADW, TOKEN_ADW, ASSIGN_HR_PROJECT_SEARCH, ASSIGN_HR_PROJECT_DELETE, USER_LIST, PROJECT_ROLE_SEARCH, ASSIGN_HR_PROJECT_ADD, ASSIGN_HR_PROJECT_EDIT } from '../../../const/ApiConst';
import axios from "../../../const/interceptorApi"
import { NotificationContainer, NotificationManager } from 'react-notifications';
import SweetAlert from 'react-bootstrap-sweetalert';
import FormAsignCust from './DialogAssignCust';
import { formatThousand } from '../../../const/CustomFunc';
const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsResource, proyekName }) => {
const token = localStorage.getItem("token")
const HEADER = {
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
}
}
const [dataUserToProject, setdataUserToProject] = useState([])
const [alertDelete, setAlertDelete] = useState(false)
const [idDelete, setIdDelete] = useState(0)
const [openDialogFormTools, setOpenDialogFormTools] = useState(false)
const [dataEdit, setDataEdit] = useState(null)
const [listUser, setListUser] = useState([])
const [listRole, setListRole] = useState([])
useEffect(() => {
if (idTask > 0) {
getDataAssignHr();
}
}, [openDialog]);
useEffect(() => {
if (openDialog) {
getDataProjectRole();
getDataUser();
}
}, [dataUserToProject])
const getDataAssignHr = async () => {
const payload = {
"paging": {
"start": 0,
"length": -1
},
"columns": [
{ "name": "name", "logic_operator": "ilike", "value": "", "table_name": "m_users" },
{ "name": "proyek_id", "logic_operator": "=", "value": idTask }
],
"joins": [
{ "name": "m_users", "column_join": "user_id", "column_results": ["name"] },
{ "name": "m_role_proyek", "column_join": "project_role", "column_results": ["name"] },
],
"orders": {
"columns": [
"id"
],
"ascending": false
}
}
const URL = ASSIGN_HR_PROJECT_SEARCH
const result = await axios
.post(URL, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || []
const filteredData = dataRes.filter(item => item.is_customer === true);
setdataUserToProject(filteredData);
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
}
const getDataUser = async () => {
const HEADER_ADW = {
headers: {
"Authorization": `${TOKEN_ADW}`
}
}
const result = await axios
.get(USER_LIST, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.data.length != 0) {
let dataRes = result.data.data
setListUser(dataRes)
}
}
const getDataProjectRole = async () => {
const payload = {
"paging": {
"start": 0,
"length": -1
},
"columns": [
{ "name": "created_by", "logic_operator": "ilike", "value": "" },
],
"joins": [],
"orders": {
"columns": [
"id"
],
"ascending": false
}
}
const result = await axios
.post(PROJECT_ROLE_SEARCH, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || []
setListRole(dataRes);
} else {
}
}
const handleDelete = (id) => {
setIdDelete(id)
setAlertDelete(true)
}
const cancelDelete = () => {
setAlertDelete(false)
setIdDelete(0)
}
const onConfirmDelete = async () => {
let urlDel = ASSIGN_HR_PROJECT_DELETE(idDelete)
const result = await axios.delete(urlDel, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
getDataAssignHr()
setIdDelete(0)
setAlertDelete(false)
NotificationManager.success(`Data assign human resource berhasil dihapus`, 'Success!!');
} else {
setIdDelete(0)
setAlertDelete(false)
NotificationManager.error(`Data assign human resource gagal dihapus`, 'Failed!!');
}
}
const handleOpenDialogFormTools = () => {
setOpenDialogFormTools(true)
}
const handleCancel = () => {
closeDialog('cancel', 'none')
}
const RenderTable = useMemo(() => {
const columns = [
{
title: 'Action',
dataIndex: '',
key: 'x',
className: "nowrap",
render: (text, record) => <><Tooltip title="Delete Request Resource">
<Button size={"sm"} color='danger' onClick={() => handleDelete(text.id)}><i className="fa fa-trash"></i></Button>
</Tooltip>{" "}</>,
},
{ title: 'Name Human Resource', dataIndex: 'join_first_name', key: 'join_first_name', className: "nowrap" },
{ title: 'Role Human Resource', dataIndex: 'join_second_name', key: 'join_second_name', className: "nowrap" },
{ title: 'Percentage Available User', dataIndex: 'max_used', key: 'max_used', className: "nowrap", render: (text, record) => record.max_used ? formatThousand(record.max_used) : '-' },
{ title: 'Standard Rate', dataIndex: 'standart_rate', key: 'standart_rate', className: "nowrap", render: (text, record) => record.standart_rate ? formatThousand(record.standart_rate) : '-' },
{ title: 'UOM Standard Rate', dataIndex: 'uom_standart_rate', key: 'uom_standart_rate', className: "nowrap" },
{ title: 'Overtime Rate', dataIndex: 'overtime_rate', key: 'overtime_rate', className: "nowrap", render: (text, record) => record.overtime_rate ? formatThousand(record.overtime_rate) : '-' },
{ title: 'UOM Overtime Rate', dataIndex: 'uom_overtime_rate', key: 'uom_overtime_rate', className: "nowrap" },
];
return (
<Table
size="small"
columns={columns}
dataSource={dataUserToProject}
pagination={{ position: ["bottomLeft"] }}
/>
)
}, [dataUserToProject])
const renderForm = () => {
return (
<div style={{"overflowX":"scroll"}}>
{RenderTable}
</div>
)
}
const handleCloseDialogFormTools = (type, data) => {
if(type=="add"){
addDataAssignHr(data);
}else if(type=="edit"){
editDataAssignHr(data);
}else{
setDataEdit(null)
setOpenDialogFormTools(false)
}
}
const addDataAssignHr = async (payload) => {
const result = await axios
.post(ASSIGN_HR_PROJECT_ADD, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
getDataAssignHr();
NotificationManager.success('assign human resource berhasil!!', 'Success');
setDataEdit(null)
setOpenDialogFormTools(false)
} else {
NotificationManager.error('assign human resource gagal!!', 'Failed');
}
}
const editDataAssignHr = async (payload) => {
let url = ASSIGN_HR_PROJECT_EDIT(payload.id)
const result = await axios
.put(url, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
getDataAssignHr();
NotificationManager.success('assign human resource berhasil diedit!!', 'Success');
setDataEdit(null)
setOpenDialogFormTools(false)
} else {
NotificationManager.error('assign human resource gagal diedit!!', 'Failed');
}
}
const toogleDialogFormTools = () => {
if (openDialogFormTools) {
setDataEdit(null)
}
setOpenDialogFormTools(!openDialogFormTools)
}
return (
<>
<NotificationContainer />
<SweetAlert
show={alertDelete}
warning
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title={`Are you sure?`}
onConfirm={onConfirmDelete}
onCancel={() => cancelDelete()}
focusCancelBtn
>
Delete this data
</SweetAlert>
<Modal size="xl" isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize withBtn" toggle={closeDialog}>
<div>Assign Customer - {proyekName}</div> <Button onClick={handleOpenDialogFormTools} size='sm' color="primary"><i className='fa fa-plus'></i></Button>
</ModalHeader>
<ModalBody>
{renderForm()}
</ModalBody>
</Modal>
<FormAsignCust
openDialog={openDialogFormTools}
closeDialog={handleCloseDialogFormTools}
toggleDialog={toogleDialogFormTools}
idTask={idTask}
dataEdit={dataEdit}
dataHr={listUser}
dataRole={listRole}
dataCurrentHr={dataUserToProject}
/>
</>
)
}
export default AssignHrProject;

2
src/views/SimproV2/CreatedProyek/DataRequestMaterial.js

@ -26,7 +26,7 @@ const DialogFormMaterial = ({ openDialog, closeDialog, toggleDialog, idTask, mat
useEffect(() => { useEffect(() => {
if (idTask > 0) { if (idTask > 0) {
getDataRequestMaterial(); // getDataRequestMaterial();
} }
}, [idTask]) }, [idTask])

173
src/views/SimproV2/CreatedProyek/DialogAssignCust.js

@ -0,0 +1,173 @@
import React, { useEffect, useState } from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { Button, Form } from 'reactstrap';
import axios from "../../../const/interceptorApi";
import { USER_VERSION_GANTT_ADDS, USER_VERSION_GANTT_SEARCH, USER_LIST} from '../../../const/ApiConst';
import { Transfer } from 'antd';
import 'antd/dist/antd.css';
const role_id = localStorage.getItem('role_id');
const DialogAssignCust = ({ openDialog, closeDialog, toggleDialog, idGantt}) => {
const token = localStorage.getItem("token")
const HEADER = {
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
}
}
const [id, setId] = useState(0)
const [targetKeys, setTargetKeys] = useState([])
const [assignCustomer, setAssignCustomer] = useState([])
const handleCLearData = () => {
setId(0)
setTargetKeys([])
}
useEffect(() => {
if(!openDialog){
handleCLearData()
} else {
getDataAssignCustomer();
}
}, [openDialog])
useEffect(() => {
if(idGantt && idGantt > 0){
getUserGantt()
}
}, [idGantt])
const getDataAssignCustomer = async () => {
const result = await axios
.get(USER_LIST, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.status == 200) {
let dataRes = result.data.data;
const filteredData = dataRes.filter(item => item.role_id === 44);
setTransferUser(filteredData);
} else {
}
}
const setTransferUser = (data) => {
const finalData = []
data.map((val, index) => {
let data = {
key: val.id,
title: val.name
}
finalData.push(data)
});
setAssignCustomer(finalData)
}
const getUserGantt = async () => {
const payload = {
"columns": [
{ "name": "version_gantt_id", "logic_operator": "=", "value": idGantt, "operator": "AND" }
]
}
const result = await axios
.post(USER_VERSION_GANTT_SEARCH, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
if(result && result.status==200){
console.log("cek resource get user gantt",result.data.data)
setUserGantt(result.data.data);
}else{
}
}
const setUserGantt = (data) => {
let newTargetKeys = []
data.map((val,index)=> {
newTargetKeys.push(val.user_id)
});
setTargetKeys(newTargetKeys)
}
const handleSave = async () => {
await saveVersionGantt()
handleCLearData()
}
const saveVersionGantt= async () => {
const formData = {
user_id:targetKeys,
version_gantt_id:idGantt
}
const result = await axios
.post(USER_VERSION_GANTT_ADDS, formData, HEADER)
.then(res => res)
.catch((error) => error.response);
if(result && result.status==200){
closeDialog('success')
}else{
closeDialog('failed')
}
}
const handleCancel = () => {
closeDialog('cancel')
handleCLearData()
}
const handleChange = targetKeys => {
setTargetKeys(targetKeys)
};
const renderForm = () => {
return (
<div style={{
alignContent: "center",
justifyContent: "center !imporant",
paddingLeft: 20,
paddingRight: 20,
overflow: "auto"
}}>
<Transfer
showSearch
titles={['Available Customer', 'Granted to']}
dataSource={assignCustomer}
targetKeys={targetKeys}
onChange={handleChange}
render={item => item.title}
listStyle={{
width: 250,
height: 300,
}}
/>
</div>
)
}
return (
<>
<Modal size="lg" style={{maxWidth: '600px', width: '100%'}} isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize" toggle={closeDialog}>Add Customer</ModalHeader>
<ModalBody>
{renderForm()}
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => handleSave()}>Save</Button>{' '}
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Cancel</Button>
</ModalFooter>
</Modal>
</>
)
}
export default DialogAssignCust;

185
src/views/SimproV2/CreatedProyek/index.js

@ -35,6 +35,7 @@ import {
TYPE_PROYEK, TYPE_PROYEK,
PROYEK_ADD, PROYEK_ADD,
PROYEK_SEARCH, PROYEK_SEARCH,
PROYEK_SEARCH_BY_USER,
PROYEK_EDIT, PROYEK_EDIT,
PROYEK_DELETE, PROYEK_DELETE,
TOOLS_RESOURCE_SEARCH, TOOLS_RESOURCE_SEARCH,
@ -52,7 +53,7 @@ import {
VERSION_GANTT_SEARCH, VERSION_GANTT_SEARCH,
PHASE_PROYEK, PHASE_PROYEK,
DIVISI_LIST, DIVISI_LIST,
BASE_OSPRO BASE_OSPRO,
} from "../../../const/ApiConst"; } from "../../../const/ApiConst";
import { import {
formatNumber, formatNumber,
@ -70,6 +71,7 @@ import DialogGantt from "./DialogGantt";
import DialogHierarchy from "./DialogHierarchy"; import DialogHierarchy from "./DialogHierarchy";
// import DialogAsignHr from './AsignHrProject'; // import DialogAsignHr from './AsignHrProject';
import AssignHrProject from "./AsignHrProject"; import AssignHrProject from "./AsignHrProject";
import AssignCustProject from "./AsignCustProject";
import AssignK3Project from "./AssignK3Project"; import AssignK3Project from "./AssignK3Project";
import ViewProject from "./ViewProject"; import ViewProject from "./ViewProject";
import { Icon } from "@iconify/react"; import { Icon } from "@iconify/react";
@ -80,6 +82,7 @@ import { Link, useHistory } from "react-router-dom";
const url = ""; const url = "";
const proyek_id = localStorage.getItem("proyek_id"); const proyek_id = localStorage.getItem("proyek_id");
const role_id = localStorage.getItem("role_id"); const role_id = localStorage.getItem("role_id");
const user_id = localStorage.getItem("user_id");
const format = "DD-MM-YYYY"; const format = "DD-MM-YYYY";
const CreatedProyek = ({ params, ...props }) => { const CreatedProyek = ({ params, ...props }) => {
@ -104,6 +107,7 @@ const CreatedProyek = ({ params, ...props }) => {
const [openDialogGantt, setOpenDialogGantt] = useState(false); const [openDialogGantt, setOpenDialogGantt] = useState(false);
const [openDialogHierarchy, setOpenDialogHierarchy] = useState(false); const [openDialogHierarchy, setOpenDialogHierarchy] = useState(false);
const [openDialogAsignHR, setOpenDialogAsignHR] = useState(false); const [openDialogAsignHR, setOpenDialogAsignHR] = useState(false);
const [openDialogAsignCust, setOpenDialogAsignCust] = useState(false);
const [openDialogAssignK3, setOpenDialogAssignK3] = useState(false); const [openDialogAssignK3, setOpenDialogAssignK3] = useState(false);
const [dataK3, setDataK3] = useState([]); // transfer list const [dataK3, setDataK3] = useState([]); // transfer list
const [idDelete, setIdDelete] = useState(0); const [idDelete, setIdDelete] = useState(0);
@ -163,10 +167,10 @@ const CreatedProyek = ({ params, ...props }) => {
handleGetDivisions(); handleGetDivisions();
handleGetDataPm(); handleGetDataPm();
} }
}, [openDialogProyek]) }, [openDialogProyek]);
useEffect(() => { useEffect(() => {
getDataProyek(); role_id !== "44" ? getDataProyek() : getDataProyekByCustomer();
}, [search, rowsPerPage, currentPage]); }, [search, rowsPerPage, currentPage]);
useEffect(() => { useEffect(() => {
@ -231,20 +235,27 @@ const CreatedProyek = ({ params, ...props }) => {
const handleDashboard = async (text) => { const handleDashboard = async (text) => {
const URL = `${BASE_OSPRO}/api/project/detail/${text.id}`; const URL = `${BASE_OSPRO}/api/project/detail/${text.id}`;
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const result = await axios
.get(URL, HEADER)
.then((res) => res)
.catch((err) => err.response);
if (!result) { if (!result) {
NotificationManager.error(`Could not connect to internet.`, "Failed"); NotificationManager.error(`Could not connect to internet.`, "Failed");
return; return;
} }
if (result.status !== 200) { if (result.status !== 200) {
NotificationManager.error(`Get project detail failed, ${result.data.message}`, "Failed"); NotificationManager.error(
`Get project detail failed, ${result.data.message}`,
"Failed"
);
return; return;
} else if (result.status == 200 && result.data.data) {
history.push(
`dashboard-customer/${text.id}/${result.data.gantt.last_gantt_id}/1`
);
} }
else if (result.status == 200 && result.data.data) { };
history.push(`dashboard-customer/${text.id}/${result.data.gantt.last_gantt_id}/1`);
}
}
const getDataProyek = async () => { const getDataProyek = async () => {
let start = 0; let start = 0;
@ -262,7 +273,15 @@ const CreatedProyek = ({ params, ...props }) => {
operator: "AND", operator: "AND",
}, },
], ],
select: ["id", "nama", "rencana_biaya", "type_proyek_id", "currency_symbol", "mulai_proyek", "akhir_proyek"], select: [
"id",
"nama",
"rencana_biaya",
"type_proyek_id",
"currency_symbol",
"mulai_proyek",
"akhir_proyek",
],
joins: [ joins: [
{ {
name: "m_users", name: "m_users",
@ -286,7 +305,6 @@ const CreatedProyek = ({ params, ...props }) => {
]; ];
} }
const result = await axios const result = await axios
.post(PROYEK_SEARCH, payload, HEADER) .post(PROYEK_SEARCH, payload, HEADER)
.then((res) => res) .then((res) => res)
@ -304,6 +322,24 @@ const CreatedProyek = ({ params, ...props }) => {
} }
}; };
const getDataProyekByCustomer = async () => {
const url = `${BASE_OSPRO}/api/project-by-customer/${user_id}`;
const result = await axios
.get(url, HEADER)
.then((res) => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || [];
setDatatable(dataRes);
setTotalPage(result.data.totalRecord);
setLoading(false);
} else {
setLoading(false);
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
}
};
const getDataMaterialResource = async () => { const getDataMaterialResource = async () => {
const result = await axios const result = await axios
.get(MATERIAL_RESOURCE_LIST, HEADER) .get(MATERIAL_RESOURCE_LIST, HEADER)
@ -435,6 +471,12 @@ const CreatedProyek = ({ params, ...props }) => {
setOpenDialogAsignHR(true); setOpenDialogAsignHR(true);
}; };
const handleOpenAsignCust = (data) => {
setidTask(data.id);
setProyekName(data.nama);
setOpenDialogAsignCust(true);
};
const handleOpenAssignK3 = (data) => { const handleOpenAssignK3 = (data) => {
setidTask(data.id); setidTask(data.id);
setProyekName(data.nama); setProyekName(data.nama);
@ -461,23 +503,30 @@ const CreatedProyek = ({ params, ...props }) => {
const getProjectDetail = async (id) => { const getProjectDetail = async (id) => {
const URL = `${BASE_OSPRO}/api/project/detail/${id}`; const URL = `${BASE_OSPRO}/api/project/detail/${id}`;
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const result = await axios
.get(URL, HEADER)
.then((res) => res)
.catch((err) => err.response);
if (!result) { if (!result) {
NotificationManager.error(`Could not connect to internet.`, "Failed"); NotificationManager.error(`Could not connect to internet.`, "Failed");
return; return;
} }
if (result.status !== 200) { if (result.status !== 200) {
NotificationManager.error(`Get project detail failed, ${result.data.message}`, "Failed"); NotificationManager.error(
`Get project detail failed, ${result.data.message}`,
"Failed"
);
return; return;
} else if (result.status == 200 && result.data.data) {
history.push(
`/dashboard-project/${id}/${result.data.gantt.last_gantt_id}/1`
);
} }
else if (result.status == 200 && result.data.data) { };
history.push(`/dashboard-project/${id}/${result.data.gantt.last_gantt_id}/1`);
}
}
const handleSCurve = async (data) => { const handleSCurve = async (data) => {
getProjectDetail(data.id) getProjectDetail(data.id);
}; };
const getDataProject = async (proyek_id) => { const getDataProject = async (proyek_id) => {
@ -532,7 +581,6 @@ const CreatedProyek = ({ params, ...props }) => {
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data; let dataRes = result.data.data;
setProjectParticipant(dataRes); setProjectParticipant(dataRes);
} else { } else {
NotificationManager.error("Gagal Mengambil Data!!", "Failed"); NotificationManager.error("Gagal Mengambil Data!!", "Failed");
} }
@ -603,7 +651,8 @@ const CreatedProyek = ({ params, ...props }) => {
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.data.code === 200) { if (result && result.data && result.data.code === 200) {
getDataProyek(); role_id !== "44" ? getDataProyek() : getDataProyekByCustomer();
setIdDelete(0); setIdDelete(0);
setAlertDelete(false); setAlertDelete(false);
NotificationManager.success(`Data proyek berhasil dihapus`, "Success!!"); NotificationManager.success(`Data proyek berhasil dihapus`, "Success!!");
@ -649,7 +698,7 @@ const CreatedProyek = ({ params, ...props }) => {
NotificationManager.success(`${result.data.message}`, "Success!!"); NotificationManager.success(`${result.data.message}`, "Success!!");
} }
getDataProyek(); role_id !== "44" ? getDataProyek() : getDataProyekByCustomer();
} else { } else {
NotificationManager.error(`${result.data.message}`, "Failed!!"); NotificationManager.error(`${result.data.message}`, "Failed!!");
} }
@ -730,7 +779,7 @@ const CreatedProyek = ({ params, ...props }) => {
const resultMilestone = await editMilestone(data.id, milestones); const resultMilestone = await editMilestone(data.id, milestones);
const resultApproval = await editApproval(data.id, approval); const resultApproval = await editApproval(data.id, approval);
if (result && result.status === 200) { if (result && result.status === 200) {
getDataProyek(); role_id !== "44" ? getDataProyek() : getDataProyekByCustomer();
NotificationManager.success(`Data proyek berhasil Ubah`, "Success!!"); NotificationManager.success(`Data proyek berhasil Ubah`, "Success!!");
} else { } else {
NotificationManager.error(`${result.data.message}`, "Failed!!"); NotificationManager.error(`${result.data.message}`, "Failed!!");
@ -834,7 +883,6 @@ const CreatedProyek = ({ params, ...props }) => {
.then((res) => res) .then((res) => res)
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
let resData = result.data.data; let resData = result.data.data;
const excelData = []; const excelData = [];
@ -1005,6 +1053,12 @@ const CreatedProyek = ({ params, ...props }) => {
</span> </span>
<span className="menu-text">Assign Human Resource</span> <span className="menu-text">Assign Human Resource</span>
</div> </div>
<div className="menu-list" onClick={() => handleOpenAsignCust(text)}>
<span className="menu-icon">
<i className="fa fa-user-circle-o"></i>
</span>
<span className="menu-text">Assign Customer</span>
</div>
<div className="menu-list" onClick={() => handleOpenAssignK3(text)}> <div className="menu-list" onClick={() => handleOpenAssignK3(text)}>
<span className="menu-icon"> <span className="menu-icon">
<i className="fa fa-plus-circle"></i> <i className="fa fa-plus-circle"></i>
@ -1068,7 +1122,7 @@ const CreatedProyek = ({ params, ...props }) => {
</div> </div>
)} )}
{(!loadVersionGantt && text.type_proyek_id !== 9) && ( {!loadVersionGantt && text.type_proyek_id !== 9 && (
<> <>
{dataVersionGantt.slice(0, 8).map((res) => ( {dataVersionGantt.slice(0, 8).map((res) => (
<Link to={`/projects/${res.id}/${text.id}/gantt`}> <Link to={`/projects/${res.id}/${text.id}/gantt`}>
@ -1094,7 +1148,7 @@ const CreatedProyek = ({ params, ...props }) => {
)} )}
</> </>
)} )}
{text.type_proyek_id == 9 ? {text.type_proyek_id == 9 ? (
<div <div
className="menu-list" className="menu-list"
onClick={() => handleOpenDialogHierarchy(text)} onClick={() => handleOpenDialogHierarchy(text)}
@ -1103,7 +1157,8 @@ const CreatedProyek = ({ params, ...props }) => {
<i className="fa fa-bars"></i> <i className="fa fa-bars"></i>
</span> </span>
<span className="menu-text">More Hierarchy Menu ...</span> <span className="menu-text">More Hierarchy Menu ...</span>
</div> : </div>
) : (
<div <div
className="menu-list" className="menu-list"
onClick={() => handleOpenDialogGantt(text)} onClick={() => handleOpenDialogGantt(text)}
@ -1112,7 +1167,8 @@ const CreatedProyek = ({ params, ...props }) => {
<i className="fa fa-bars"></i> <i className="fa fa-bars"></i>
</span> </span>
<span className="menu-text">More Gantt Menu ...</span> <span className="menu-text">More Gantt Menu ...</span>
</div>} </div>
)}
</div> </div>
); );
}; };
@ -1123,17 +1179,21 @@ const CreatedProyek = ({ params, ...props }) => {
title: "Action", title: "Action",
dataIndex: "", dataIndex: "",
key: "x", key: "x",
render: (text, record) => ( render: (text, record) =>
role_id == "44" role_id == "44" ? (
?
<> <>
<Tooltip title="Dashboard Project"> <Tooltip title="Dashboard Project">
<Button size="small" onClick={() => handleDashboard(text)} type="link" style={{ color: "green" }}> <Button
size="small"
onClick={() => handleDashboard(text)}
type="link"
style={{ color: "green" }}
>
<i className="fa fa-line-chart"></i> <i className="fa fa-line-chart"></i>
</Button> </Button>
</Tooltip> </Tooltip>
</> </>
: ) : (
<> <>
<Popover <Popover
placement="rightTop" placement="rightTop"
@ -1151,15 +1211,11 @@ const CreatedProyek = ({ params, ...props }) => {
content={popupMenuGantt(text, record)} content={popupMenuGantt(text, record)}
trigger="click" trigger="click"
> >
{ {text.type_proyek_id == 9 ? (
text.type_proyek_id == 9 ? <Button size="small" type="link" style={{ color: "green" }}>
<Button
size="small"
type="link"
style={{ color: "green" }}
>
<i className="fa fa-bars"></i> <i className="fa fa-bars"></i>
</Button> : </Button>
) : (
<Button <Button
onClick={() => getdataGantt(text.id)} onClick={() => getdataGantt(text.id)}
size="small" size="small"
@ -1168,7 +1224,7 @@ const CreatedProyek = ({ params, ...props }) => {
> >
<i className="fa fa-bars"></i> <i className="fa fa-bars"></i>
</Button> </Button>
} )}
</Popover> </Popover>
</> </>
), ),
@ -1235,6 +1291,11 @@ const CreatedProyek = ({ params, ...props }) => {
setOpenDialogAsignHR(false); setOpenDialogAsignHR(false);
}; };
const handleCloseDialogAsignCust = () => {
setidTask(0);
setOpenDialogAsignCust(false);
};
const handleCloseDialogAssignK3 = (status) => { const handleCloseDialogAssignK3 = (status) => {
if (status == "success") { if (status == "success") {
NotificationManager.success( NotificationManager.success(
@ -1279,7 +1340,14 @@ const CreatedProyek = ({ params, ...props }) => {
dataPM={dataPm} dataPM={dataPm}
/> />
), ),
[openDialogProyek, dataPm, dataDivisions, dataPhaseProject, dataTypeProyek, idTask] [
openDialogProyek,
dataPm,
dataDivisions,
dataPhaseProject,
dataTypeProyek,
idTask,
]
); );
const RenderDialogFormMaterial = useMemo( const RenderDialogFormMaterial = useMemo(
@ -1295,7 +1363,14 @@ const CreatedProyek = ({ params, ...props }) => {
proyekName={proyekName} proyekName={proyekName}
/> />
), ),
[openDialogMaterial, proyekName, materialResource, materialProyek, userProyek, idTask] [
openDialogMaterial,
proyekName,
materialResource,
materialProyek,
userProyek,
idTask,
]
); );
const RenderDialogTableTools = useMemo( const RenderDialogTableTools = useMemo(
@ -1328,6 +1403,21 @@ const CreatedProyek = ({ params, ...props }) => {
[openDialogAsignHR] [openDialogAsignHR]
); );
// DialogAsignCust
const RenderDialogAsignCust = useMemo(
() => (
<AssignCustProject
openDialog={openDialogAsignCust}
closeDialog={() => setOpenDialogAsignCust(false)}
toggleDialog={() => setOpenDialogAsignCust(!openDialogAsignCust)}
handleClose={handleCloseDialogAsignCust}
idTask={idTask}
proyekName={proyekName}
/>
),
[openDialogAsignCust]
);
// DialogAssignK3 // DialogAssignK3
const RenderDialogAssignK3 = useMemo( const RenderDialogAssignK3 = useMemo(
() => ( () => (
@ -1428,6 +1518,7 @@ const CreatedProyek = ({ params, ...props }) => {
{renderDialogGantt} {renderDialogGantt}
{renderDialogHierarchy} {renderDialogHierarchy}
{RenderDialogAsignHr} {RenderDialogAsignHr}
{RenderDialogAsignCust}
{RenderDialogAssignK3} {RenderDialogAssignK3}
<Card> <Card>
<CardHeader <CardHeader
@ -1447,11 +1538,7 @@ const CreatedProyek = ({ params, ...props }) => {
/> />
</Col> </Col>
<Col> <Col>
{ {role_id == "44" ? null : ( // role kustomer
role_id == "44" // role kustomer
?
null
:
<Tooltip title="Add Project"> <Tooltip title="Add Project">
<Button <Button
style={{ background: "#4caf50", color: "#fff" }} style={{ background: "#4caf50", color: "#fff" }}
@ -1460,7 +1547,7 @@ const CreatedProyek = ({ params, ...props }) => {
<i className="fa fa-plus"></i> <i className="fa fa-plus"></i>
</Button> </Button>
</Tooltip> </Tooltip>
} )}
<Tooltip title="Export Excel"> <Tooltip title="Export Excel">
<Popover <Popover
// content={<a onClick={hide}>Close</a>} // content={<a onClick={hide}>Close</a>}

87
src/views/SimproV2/Gantt/index.js

@ -1,87 +1,98 @@
import React, { useEffect, useMemo, useState } from 'react'; import React, { useEffect, useMemo, useState } from "react";
import Timeline from 'react-calendar-timeline' import Timeline from "react-calendar-timeline";
import 'react-calendar-timeline/lib/Timeline.css' import "react-calendar-timeline/lib/Timeline.css";
import { USER_VERSION_GANTT_SEARCH, BASE_SIMPRO_LUMEN, BASE_URL_GANTT } from '../../../const/ApiConst'; import {
import axios from "../../../const/interceptorApi" USER_VERSION_GANTT_SEARCH,
import { Fab, Action } from 'react-tiny-fab'; BASE_SIMPRO_LUMEN,
import 'react-tiny-fab/dist/styles.css'; BASE_URL_GANTT,
} from "../../../const/ApiConst";
import axios from "../../../const/interceptorApi";
import { Fab, Action } from "react-tiny-fab";
import "react-tiny-fab/dist/styles.css";
import { useHistory } from "react-router-dom"; import { useHistory } from "react-router-dom";
import GanttFrame from './GanttFrame'; import GanttFrame from "./GanttFrame";
const token = localStorage.getItem("token") const token = localStorage.getItem("token");
const userId = parseInt(localStorage.getItem("user_id")); const userId = parseInt(localStorage.getItem("user_id"));
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
"Authorization": `Bearer ${token}` Authorization: `Bearer ${token}`,
} },
} };
let roCount = 0; let roCount = 0;
const Gantt = (props) => { const Gantt = (props) => {
const versionGanttId = props.match.params ? props.match.params.id : 0; const versionGanttId = props.match.params ? props.match.params.id : 0;
const idProject = props.match.params.project ? props.match.params.project : 0; const idProject = props.match.params.project ? props.match.params.project : 0;
const timestamp = props.match.params.timestamp ? props.match.params.timestamp : 0; const timestamp = props.match.params.timestamp
? props.match.params.timestamp
: 0;
const [ro, setRo] = useState(1) const [ro, setRo] = useState(1);
const [listUserGant, setListUserGantt] = useState([]) const [listUserGant, setListUserGantt] = useState([]);
const [ready, setReady] = useState(false) const [ready, setReady] = useState(false);
let history = useHistory(); let history = useHistory();
useEffect(() => { useEffect(() => {
document.getElementsByClassName("breadcrumb-item active").innerHTML = "Gantt Project"; document.getElementsByClassName("breadcrumb-item active").innerHTML =
"Gantt Project";
getDataUserGantt(); getDataUserGantt();
}, []); }, []);
useEffect(() => { useEffect(() => {
cekPermission(); cekPermission();
}, [listUserGant]) }, [listUserGant]);
useEffect(() => { useEffect(() => {}, [ro]);
}, [ro])
const getDataUserGantt = async () => { const getDataUserGantt = async () => {
const payload = { const payload = {
"columns": [ columns: [
{ "name": "version_gantt_id", "logic_operator": "=", "value": versionGanttId, "operator": "AND" } {
] name: "version_gantt_id",
} logic_operator: "=",
value: versionGanttId,
operator: "AND",
},
],
};
const result = await axios const result = await axios
.post(USER_VERSION_GANTT_SEARCH, payload, HEADER) .post(USER_VERSION_GANTT_SEARCH, payload, HEADER)
.then(res => res) .then((res) => res)
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.status == 200) { if (result && result.status == 200) {
setUserGantt(result.data.data); setUserGantt(result.data.data);
} else { } else {
cekPermission() cekPermission();
}
} }
};
const setUserGantt = (data) => { const setUserGantt = (data) => {
let newTargetKeys = [] let newTargetKeys = [];
data.map((val, index) => { data.map((val, index) => {
newTargetKeys.push(val.user_id) newTargetKeys.push(val.user_id);
}); });
setListUserGantt(newTargetKeys) setListUserGantt(newTargetKeys);
} };
const handleRedirect = () => { const handleRedirect = () => {
history.push("/dashboard-project/" + idProject + "/" + versionGanttId); history.push("/dashboard-project/" + idProject + "/" + versionGanttId);
} };
const cekPermission = () => { const cekPermission = () => {
let check = listUserGant.includes(userId) let check = listUserGant.includes(userId);
if (check) { if (check) {
setRo(0) setRo(0);
} else { } else {
setRo(1) setRo(1);
} }
if (roCount >= 1) { if (roCount >= 1) {
setReady(true) setReady(true);
} }
roCount = roCount + 1; roCount = roCount + 1;
} };
return ( return (
<> <>
@ -98,6 +109,6 @@ const Gantt = (props) => {
</div> </div>
</> </>
); );
} };
export default Gantt; export default Gantt;

Loading…
Cancel
Save