diff --git a/src/routes.js b/src/routes.js index 85e3523..4df1073 100644 --- a/src/routes.js +++ b/src/routes.js @@ -53,7 +53,7 @@ const routes = [ { path: '/', exact: true, name: 'Home' }, // { path: '/dashboard', name: 'Dashboard', component: Dashboard}, { path: '/dashboard', name: 'DashboardBOD', component: DashboardBOD }, - { path: '/dashboard-customer/:PROJECT_ID/:GANTT_ID', name: 'DashboardCustomer', component: DashboardCustomer }, + // { path: '/dashboard-customer/:PROJECT_ID/:GANTT_ID', name: 'DashboardCustomer', component: DashboardCustomer }, { path: '/dashboard-customer/:PROJECT_ID/:GANTT_ID/:SCURVE', name: 'DashboardCustomer', component: DashboardCustomer }, { path: '/dashboard-project/:PROJECT_ID/:GANTT_ID', exact: true, name: 'Dashboard Project', component: DashboardProject }, { path: '/dashboard-project/:PROJECT_ID/:GANTT_ID/:SCURVE', exact: true, name: 'Dashboard Project', component: DashboardProject }, diff --git a/src/views/Dashboard/DashboardBOD.js b/src/views/Dashboard/DashboardBOD.js index 344faf5..74e64d0 100644 --- a/src/views/Dashboard/DashboardBOD.js +++ b/src/views/Dashboard/DashboardBOD.js @@ -13,8 +13,21 @@ import toRupiah from '@develoka/angka-rupiah-js'; import Icon from '@iconify/react'; import { HealthByBudget, HealthBySchedule } from './Components'; -const DashboardBOD = () => { - const token = localStorage.getItem("token") +const DashboardBOD = (props) => { + let role_id = '', user_id='',isLogin='',token=''; + if (props.location.state && props.location.state.role_id && props.location.state.user_id) { + role_id = props.location.state.role_id; + user_id = props.location.state.user_id; + token = props.location.state.token; + isLogin = props.location.state.isLogin; + console.log('props.location.state success'); + } else { + role_id = localStorage.getItem("role_id"); + user_id = localStorage.getItem("user_id"); + token = localStorage.getItem("token"); + isLogin = localStorage.getItem("isLogin"); + console.error('undefined in props.location.state'); + } const HEADER = { headers: { "Content-Type": "application/json", diff --git a/src/views/Dashboard/DashboardCustomer.js b/src/views/Dashboard/DashboardCustomer.js index 63ee536..7d482e8 100644 --- a/src/views/Dashboard/DashboardCustomer.js +++ b/src/views/Dashboard/DashboardCustomer.js @@ -25,8 +25,21 @@ const center = { lng: 106.816666 } -const DashboardCustomer = () => { - const token = localStorage.getItem("token") +const DashboardCustomer = (props) => { + let role_id = '', user_id='',isLogin='',token=''; + if (props.location.state && props.location.state.role_id && props.location.state.user_id) { + role_id = props.location.state.role_id; + user_id = props.location.state.user_id; + token = props.location.state.token; + isLogin = props.location.state.isLogin; + console.log('props.location.state success'); + } else { + role_id = localStorage.getItem("role_id"); + user_id = localStorage.getItem("user_id"); + token = localStorage.getItem("token"); + isLogin = localStorage.getItem("isLogin"); + console.error('Undefined in props.location.state'); + } const HEADER = { headers: { "Content-Type": "application/json", @@ -34,8 +47,7 @@ const DashboardCustomer = () => { } } const { PROJECT_ID, GANTT_ID, SCURVE } = useParams(); - const URL_GANTT = `https://adw-gantt.ospro.id/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1`; - const mapRef = useRef() + const URL_GANTT = `https://adw-gantt.ospro.id/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1`; const mapRef = useRef() const [projectName, setProjectName] = useState(""); const [projectManagerName, setProjectManagerName] = useState(''); const [customerName, setCustomerName] = useState(""); diff --git a/src/views/Pages/Login/Login.js b/src/views/Pages/Login/Login.js index 9c49869..e0c67bf 100644 --- a/src/views/Pages/Login/Login.js +++ b/src/views/Pages/Login/Login.js @@ -159,14 +159,14 @@ class Login extends Component { else { this.props.history.push({ pathname: "/dashboard", - state: { role_id: role_id, user_id: user_id } + state: { role_id: role_id, user_id: user_id, token: token, isLogin: true } }); } if (this.state.defaultPage) { if (role_id === 44) { this.props.history.push({ pathname: this.state.defaultPage, - state: { role_id: role_id, user_id: user_id } + state: { role_id: role_id, user_id: user_id, token: token, isLogin: true } }); } else { this.props.history.push(this.state.defaultPage); @@ -177,7 +177,7 @@ class Login extends Component { else { this.props.history.push({ pathname: "/dashboard", - state: { role_id: role_id, user_id: user_id } + state: { role_id: role_id, user_id: user_id, token: token, isLogin: true } }); } } else { diff --git a/src/views/SimproV2/CreatedProyek/DialogGantt.js b/src/views/SimproV2/CreatedProyek/DialogGantt.js index e2ce30c..3af6883 100644 --- a/src/views/SimproV2/CreatedProyek/DialogGantt.js +++ b/src/views/SimproV2/CreatedProyek/DialogGantt.js @@ -13,8 +13,20 @@ import DialogUserGantt from './DialogUserGantt'; import { Link } from 'react-router-dom'; -const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, hierarchyId, hierarchyName, openDialogHierarchy }) => { - const token = localStorage.getItem("token") +const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, hierarchyId, hierarchyName, openDialogHierarchy, isLogin, token, role_id, user_id }) => { + if (role_id && user_id && token && isLogin) { + role_id = role_id; + user_id = user_id; + token = token; + isLogin = isLogin; + console.log('props.location.state success'); + } else { + role_id = localStorage.getItem("role_id"); + user_id = localStorage.getItem("user_id"); + token = localStorage.getItem("token"); + isLogin = localStorage.getItem("isLogin"); + console.error('Undefined in props.location.state'); + } const HEADER = { headers: { "Content-Type": "application/json", @@ -35,6 +47,7 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName useEffect(() => { if (openDialog && hierarchyId > 0 || idTask > 0 && !openDialogHierarchy) { + setLoading(true); getdataGantt(); } if (!openDialog) { @@ -150,7 +163,15 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName {" "} - + {" "} diff --git a/src/views/SimproV2/CreatedProyek/DialogHierarchy.js b/src/views/SimproV2/CreatedProyek/DialogHierarchy.js index a6ac1b1..feeedf9 100644 --- a/src/views/SimproV2/CreatedProyek/DialogHierarchy.js +++ b/src/views/SimproV2/CreatedProyek/DialogHierarchy.js @@ -1,7 +1,7 @@ import React, { useEffect, useState, useMemo } from 'react' import { Modal, ModalHeader, ModalBody, } from 'reactstrap'; import { Button } from 'reactstrap'; -import { Space, Table, Tooltip } from 'antd'; +import { Space, Table, Tooltip, Spin } from 'antd'; import 'antd/dist/antd.css'; import moment from 'moment'; import SweetAlert from 'react-bootstrap-sweetalert'; @@ -41,8 +41,10 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek const [idGantt, setIdGantt] = useState(0) const [humanResource, setHumanResource] = useState([]) const { t } = useTranslation(); + const [loading, setLoading] = useState(true); useEffect(() => { if (idTask > 0) { + setLoading(true); getdataHierarchy(); } }, [saveHierarchy, idTask, openDialog, closeDialog, openDialogFormGantt]) @@ -157,7 +159,9 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek if (result && result.status == 200) { const sortedData = _.orderBy(result.data.data, ['name'], ['asc']); setDataHierarchy(sortedData); + setLoading(false); } else { + setLoading(false); NotificationManager.error(`Data gantt project gagal terload silahkan coba lagi!`, 'Failed!!'); } } @@ -285,9 +289,11 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek -
- {RenderTable} -
+ +
+ {RenderTable} +
+
{/* diff --git a/src/views/SimproV2/CreatedProyek/index.js b/src/views/SimproV2/CreatedProyek/index.js index 726326c..9b85ac1 100644 --- a/src/views/SimproV2/CreatedProyek/index.js +++ b/src/views/SimproV2/CreatedProyek/index.js @@ -93,25 +93,25 @@ import { Icon } from "@iconify/react"; import { Link, useHistory, withRouter } from "react-router-dom"; const url = ""; -// const proyek_id = localStorage.getItem("proyek_id"); -// const role_id = localStorage.getItem("role_id"); -// const user_id = localStorage.getItem("user_id"); const format = "DD-MM-YYYY"; const CreatedProyek = ({ params, ...props }) => { - let role_id = '', user_id='',proyek_id=''; + let role_id = '', user_id='',proyek_id='',isLogin='',token=''; if (props.location.state && props.location.state.role_id && props.location.state.user_id) { role_id = props.location.state.role_id; user_id = props.location.state.user_id; - console.log('role_id:', role_id); + token = props.location.state.token; + isLogin = props.location.state.isLogin; + console.log('props.location.state success'); } else { role_id = localStorage.getItem("role_id"); proyek_id = localStorage.getItem("proyek_id"); user_id = localStorage.getItem("user_id"); - console.error('Role ID is undefined in props.location.state'); + token = localStorage.getItem("token"); + isLogin = localStorage.getItem("isLogin"); + console.error('Undefined in props.location.state'); } const history = useHistory(); - const token = localStorage.getItem("token"); const HEADER = { headers: { "Content-Type": "application/json", @@ -294,9 +294,10 @@ const CreatedProyek = ({ params, ...props }) => { ); return; } else if (result.status == 200 && result.data.data) { - history.push( - `/dashboard-customer/${id}/${result.data.gantt}/1` - ); + history.push({ + pathname: `/dashboard-customer/${id}/${result.data.gantt}/1`, + state: { role_id: role_id, user_id: user_id, token: token, isLogin: true } + }); } }; @@ -1942,6 +1943,10 @@ const CreatedProyek = ({ params, ...props }) => { closeDialog={closeDialogGantt} toggleDialog={toggleDialogGantt} idTask={idTask} + role_id={role_id} + user_id={user_id} + token={token} + isLogin={isLogin} proyekName={proyekName} /> ), diff --git a/src/views/SimproV2/Gantt/GanttFrame.js b/src/views/SimproV2/Gantt/GanttFrame.js index f175154..ec90a85 100644 --- a/src/views/SimproV2/Gantt/GanttFrame.js +++ b/src/views/SimproV2/Gantt/GanttFrame.js @@ -1,16 +1,30 @@ import React, { useEffect, useState } from 'react'; -import { useHistory } from 'react-router-dom'; +import { useHistory, withRouter } from 'react-router-dom'; import { BASE_SIMPRO_LUMEN } from '../../../const/ApiConst'; const GanttFrame = React.memo((props) => { + let role_id = '', user_id='',proyek_id='',isLogin='',token=''; + if (props.location.state && props.location.state.role_id && props.location.state.user_id) { + role_id = props.location.state.role_id; + user_id = props.location.state.user_id; + isLogin = props.location.state.isLogin; + token = props.location.state.token; + console.log('props.location.state success'); + } else { + role_id = localStorage.getItem("role_id"); + proyek_id = localStorage.getItem("proyek_id"); + user_id = localStorage.getItem("user_id"); + isLogin = localStorage.getItem("isLogin"); + token = localStorage.getItem("token"); + console.error('Undefined in props.location.state'); + } const history = useHistory(); - const { versionGanttId, idProject, token, ro, timestamp } = props; + const { versionGanttId, idProject, ro, timestamp } = props; const iframeSrc = `https://adw-gantt.ospro.id/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}×tamp=${timestamp}`; - const [batchEntityData, setBatchEntityData] = useState(null); - + useEffect(() => { const handleMessage = (event) => { if (event.data && event.data.batchEntity) { @@ -46,4 +60,4 @@ const GanttFrame = React.memo((props) => { ); }); -export default GanttFrame; +export default withRouter(GanttFrame); diff --git a/src/views/SimproV2/Gantt/index.js b/src/views/SimproV2/Gantt/index.js index c1c2dda..b46b34d 100644 --- a/src/views/SimproV2/Gantt/index.js +++ b/src/views/SimproV2/Gantt/index.js @@ -11,18 +11,30 @@ import { Fab, Action } from "react-tiny-fab"; import "react-tiny-fab/dist/styles.css"; import { useHistory } from "react-router-dom"; import GanttFrame from "./GanttFrame"; -const token = localStorage.getItem("token"); -const userId = parseInt(localStorage.getItem("user_id")); -const HEADER = { - headers: { - "Content-Type": "application/json", - Authorization: `Bearer ${token}`, - }, -}; let roCount = 0; const Gantt = (props) => { + let role_id = '', userId='',isLogin='',token=''; + if (props.location.state && props.location.state.role_id && props.location.state.user_id) { + role_id = props.location.state.role_id; + userId = props.location.state.user_id; + token = props.location.state.token; + isLogin = props.location.state.isLogin; + console.log('props.location.state success'); + } else { + role_id = localStorage.getItem("role_id"); + userId = localStorage.getItem("user_id"); + token = localStorage.getItem("token"); + isLogin = localStorage.getItem("isLogin"); + console.error('Undefined in props.location.state'); + } + const HEADER = { + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${token}`, + }, + }; const versionGanttId = props.match.params ? props.match.params.id : 0; const idProject = props.match.params.project ? props.match.params.project : 0; const timestamp = props.match.params.timestamp