From bf26374fa424c59456db0733f980bebd9eae8e43 Mon Sep 17 00:00:00 2001 From: wahyuun Date: Fri, 10 Nov 2023 10:34:17 +0700 Subject: [PATCH] add props --- src/views/Dashboard/DashboardCustomer.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/views/Dashboard/DashboardCustomer.js b/src/views/Dashboard/DashboardCustomer.js index 63ee536..5928cef 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,7 +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 URL_GANTT = `http://localhost:8444/adw-gantt/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('');