Browse Source

add props

pull/1/head
wahyuun 1 year ago
parent
commit
426567e434
  1. 25
      src/views/SimproV2/CreatedProyek/index.js

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

@ -93,25 +93,25 @@ import { Icon } from "@iconify/react";
import { Link, useHistory, withRouter } from "react-router-dom"; import { Link, useHistory, withRouter } from "react-router-dom";
const url = ""; 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 format = "DD-MM-YYYY";
const CreatedProyek = ({ params, ...props }) => { 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) { if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id; role_id = props.location.state.role_id;
user_id = props.location.state.user_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 { } else {
role_id = localStorage.getItem("role_id"); role_id = localStorage.getItem("role_id");
proyek_id = localStorage.getItem("proyek_id"); proyek_id = localStorage.getItem("proyek_id");
user_id = localStorage.getItem("user_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 history = useHistory();
const token = localStorage.getItem("token");
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -294,9 +294,10 @@ const CreatedProyek = ({ params, ...props }) => {
); );
return; return;
} else if (result.status == 200 && result.data.data) { } else if (result.status == 200 && result.data.data) {
history.push( history.push({
`/dashboard-customer/${id}/${result.data.gantt}/1` 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} closeDialog={closeDialogGantt}
toggleDialog={toggleDialogGantt} toggleDialog={toggleDialogGantt}
idTask={idTask} idTask={idTask}
role_id={role_id}
user_id={user_id}
token={token}
isLogin={isLogin}
proyekName={proyekName} proyekName={proyekName}
/> />
), ),

Loading…
Cancel
Save