From 615b0a45df409fcaefa08ffc11250500f0054213 Mon Sep 17 00:00:00 2001 From: wahyun Date: Mon, 10 Jun 2024 22:24:00 +0700 Subject: [PATCH] fix: gantt token --- src/views/SimproV2/Gantt/GanttFrame.js | 2 +- src/views/SimproV2/Gantt/index.js | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/views/SimproV2/Gantt/GanttFrame.js b/src/views/SimproV2/Gantt/GanttFrame.js index 37c1dfb..decf9d0 100644 --- a/src/views/SimproV2/Gantt/GanttFrame.js +++ b/src/views/SimproV2/Gantt/GanttFrame.js @@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'; import { useHistory, withRouter } from 'react-router-dom'; import { BASE_SIMPRO_LUMEN } from '../../../const/ApiConst'; -const GanttFrame = React.memo((props) => { +const GanttFrame = React.memo(({ versionGanttId, idProject, ro, timestamp, dataViewStartDate, token, companyId, role_name, company_name }) => { const history = useHistory(); const { versionGanttId, idProject, ro, timestamp, dataViewStartDate, token, companyId, role_name, company_name } = props; const iframeSrc = `https://si-gantt.ospro.id/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}×tamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&company_id=${companyId}&company_name=${company_name}`; diff --git a/src/views/SimproV2/Gantt/index.js b/src/views/SimproV2/Gantt/index.js index 7570d2a..e2483f7 100644 --- a/src/views/SimproV2/Gantt/index.js +++ b/src/views/SimproV2/Gantt/index.js @@ -10,7 +10,21 @@ let roCount = 0; const Gantt = (props) => { const location = useLocation(); - const { isLogin, token, role_id, user_id, company_id, dataViewStartDate, companyName, role_name } = location.state || {}; + const { company_id, dataViewStartDate, companyName, role_name } = location.state || {}; + + 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; + } else { + role_id = localStorage.getItem("role_id"); + userId = localStorage.getItem("user_id"); + token = localStorage.getItem("token"); + isLogin = localStorage.getItem("isLogin"); + } + const HEADER = { headers: { "Content-Type": "application/json", @@ -76,7 +90,7 @@ const Gantt = (props) => { }; const cekPermission = () => { - let check = listUserGant.includes(parseInt(user_id)); + let check = listUserGant.includes(parseInt(userId)); if (check) { setRo(0); } else { @@ -100,6 +114,7 @@ const Gantt = (props) => { role_name={role_name} companyId={company_id} timestamp={timestamp} + dataViewStartDate={dataViewStartDate} company_name={companyName} /> )}