From 426567e4340eeffc54b929288ecef5e64d144c58 Mon Sep 17 00:00:00 2001 From: wahyuun Date: Fri, 10 Nov 2023 10:29:29 +0700 Subject: [PATCH] add props --- src/views/SimproV2/CreatedProyek/index.js | 25 ++++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) 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} /> ),