Browse Source

handle login customer by role_id

pull/1/head
wahyuun 1 year ago
parent
commit
ea05e49b61
  1. 35
      src/views/SimproV2/CreatedProyek/index.js

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

@ -89,17 +89,27 @@ import AssignK3Project from "./AssignK3Project";
import ViewProject from "./ViewProject";
import ReportAnalysis from "./ReportAnalysis";
import { Icon } from "@iconify/react";
// import { Link } from 'react-router-dom';
// import SubProyekComp from './SubProyekComp';
import { Link, useHistory } from "react-router-dom";
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 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='';
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);
} 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');
}
const history = useHistory();
const token = localStorage.getItem("token");
const HEADER = {
@ -200,7 +210,7 @@ const CreatedProyek = ({ params, ...props }) => {
}, [openDialogProyek]);
useEffect(() => {
role_id !== "44" ? getDataProyek() : getDataProyekByCustomer();
parseInt(role_id) !== 44 ? getDataProyek() : getDataProyekByCustomer();
}, [search, rowsPerPage, currentPage]);
useEffect(() => {
@ -894,7 +904,7 @@ const CreatedProyek = ({ params, ...props }) => {
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
role_id !== "44" ? getDataProyek() : getDataProyekByCustomer();
parseInt(role_id) !== 44 ? getDataProyek() : getDataProyekByCustomer();
getProjectImage(idDelete);
deleteImage(idDelete);
setIdDelete(0);
@ -965,7 +975,7 @@ const CreatedProyek = ({ params, ...props }) => {
NotificationManager.success(`${result.data.message}`, "Success!!");
}
role_id !== "44" ? getDataProyek() : getDataProyekByCustomer();
parseInt(role_id) !== 44 ? getDataProyek() : getDataProyekByCustomer();
} else {
NotificationManager.error(`${result.data.message}`, "Failed!!");
}
@ -1144,7 +1154,7 @@ const CreatedProyek = ({ params, ...props }) => {
);
}
if (result && result.status === 200) {
role_id !== "44" ? getDataProyek() : getDataProyekByCustomer();
parseInt(role_id) !== 44 ? getDataProyek() : getDataProyekByCustomer();
NotificationManager.success(`Data proyek berhasil Ubah`, "Success!!");
} else {
NotificationManager.error(`${result.data.message}`, "Failed!!");
@ -1618,7 +1628,7 @@ const CreatedProyek = ({ params, ...props }) => {
dataIndex: "",
key: "x",
render: (text, record) =>
role_id == "44" ? (
parseInt(role_id) == 44 ? (
<>
<Tooltip title="Dashboard Project">
<Button
@ -1997,7 +2007,7 @@ const CreatedProyek = ({ params, ...props }) => {
/>
</Col>
<Col>
{role_id == "44" ? null : ( // role kustomer
{parseInt(role_id) == 44 ? null : ( // role kustomer
<Tooltip title="Add Project">
<Button
style={{ background: "#4caf50", color: "#fff" }}
@ -2068,5 +2078,4 @@ const CreatedProyek = ({ params, ...props }) => {
</div>
);
};
export default CreatedProyek;
export default withRouter(CreatedProyek);

Loading…
Cancel
Save