Browse Source

filter project by role_id

pull/2/head
wahyuun 1 year ago
parent
commit
ac3edde4b7
  1. 81
      src/views/SimproV2/CreatedProyek/index.js

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

@ -52,7 +52,7 @@ import {
VERSION_GANTT_SEARCH,
PHASE_PROYEK,
DIVISI_LIST,
BASE_OSPRO
BASE_OSPRO,
} from "../../../const/ApiConst";
import {
formatNumber,
@ -162,7 +162,7 @@ const CreatedProyek = ({ params, ...props }) => {
handleGetDivisions();
handleGetDataPm();
}
}, [openDialogProyek])
}, [openDialogProyek]);
useEffect(() => {
getDataProyek();
@ -248,7 +248,7 @@ const CreatedProyek = ({ params, ...props }) => {
{
name: "m_users",
column_join: "pm_id",
column_results: ["name", "username"],
column_results: ["name", "username", "role_id"],
},
{
name: "m_type_proyek",
@ -267,17 +267,17 @@ const CreatedProyek = ({ params, ...props }) => {
];
}
const result = await axios
.post(PROYEK_SEARCH, payload, HEADER)
.then((res) => res)
// .then((res) => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || [];
setDatatable(dataRes);
const filteredData = dataRes.filter(
(item) => item.join_first_role_id === parseInt(role_id)
);
setDatatable(filteredData);
setTotalPage(result.data.totalRecord);
} else {
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
@ -440,23 +440,30 @@ const CreatedProyek = ({ params, ...props }) => {
const getProjectDetail = async (id) => {
const URL = `${BASE_OSPRO}/api/project/detail/${id}`;
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const result = await axios
.get(URL, HEADER)
.then((res) => res)
.catch((err) => err.response);
if (!result) {
NotificationManager.error(`Could not connect to internet.`, "Failed");
return;
}
if (result.status !== 200) {
NotificationManager.error(`Get project detail failed, ${result.data.message}`, "Failed");
NotificationManager.error(
`Get project detail failed, ${result.data.message}`,
"Failed"
);
return;
} else if (result.status == 200 && result.data.data) {
history.push(
`/dashboard-project/${id}/${result.data.gantt.last_gantt_id}/1`
);
}
else if (result.status == 200 && result.data.data) {
history.push(`/dashboard-project/${id}/${result.data.gantt.last_gantt_id}/1`);
}
}
};
const handleSCurve = async (data) => {
getProjectDetail(data.id)
getProjectDetail(data.id);
};
const getDataProject = async (proyek_id) => {
@ -511,7 +518,6 @@ const CreatedProyek = ({ params, ...props }) => {
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data;
setProjectParticipant(dataRes);
} else {
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
}
@ -813,7 +819,6 @@ const CreatedProyek = ({ params, ...props }) => {
.then((res) => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let resData = result.data.data;
const excelData = [];
@ -1047,7 +1052,7 @@ const CreatedProyek = ({ params, ...props }) => {
</div>
)}
{(!loadVersionGantt && text.type_proyek_id !== 9) && (
{!loadVersionGantt && text.type_proyek_id !== 9 && (
<>
{dataVersionGantt.slice(0, 8).map((res) => (
<Link to={`/projects/${res.id}/${text.id}/gantt`}>
@ -1073,7 +1078,7 @@ const CreatedProyek = ({ params, ...props }) => {
)}
</>
)}
{text.type_proyek_id == 9 ?
{text.type_proyek_id == 9 ? (
<div
className="menu-list"
onClick={() => handleOpenDialogHierarchy(text)}
@ -1082,7 +1087,8 @@ const CreatedProyek = ({ params, ...props }) => {
<i className="fa fa-bars"></i>
</span>
<span className="menu-text">More Hierarchy Menu ...</span>
</div> :
</div>
) : (
<div
className="menu-list"
onClick={() => handleOpenDialogGantt(text)}
@ -1091,7 +1097,8 @@ const CreatedProyek = ({ params, ...props }) => {
<i className="fa fa-bars"></i>
</span>
<span className="menu-text">More Gantt Menu ...</span>
</div>}
</div>
)}
</div>
);
};
@ -1120,15 +1127,11 @@ const CreatedProyek = ({ params, ...props }) => {
content={popupMenuGantt(text, record)}
trigger="click"
>
{
text.type_proyek_id == 9 ?
<Button
size="small"
type="link"
style={{ color: "green" }}
>
{text.type_proyek_id == 9 ? (
<Button size="small" type="link" style={{ color: "green" }}>
<i className="fa fa-bars"></i>
</Button> :
</Button>
) : (
<Button
onClick={() => getdataGantt(text.id)}
size="small"
@ -1137,7 +1140,7 @@ const CreatedProyek = ({ params, ...props }) => {
>
<i className="fa fa-bars"></i>
</Button>
}
)}
</Popover>
</>
),
@ -1248,7 +1251,14 @@ const CreatedProyek = ({ params, ...props }) => {
dataPM={dataPm}
/>
),
[openDialogProyek, dataPm, dataDivisions, dataPhaseProject, dataTypeProyek, idTask]
[
openDialogProyek,
dataPm,
dataDivisions,
dataPhaseProject,
dataTypeProyek,
idTask,
]
);
const RenderDialogFormMaterial = useMemo(
@ -1264,7 +1274,14 @@ const CreatedProyek = ({ params, ...props }) => {
proyekName={proyekName}
/>
),
[openDialogMaterial, proyekName, materialResource, materialProyek, userProyek, idTask]
[
openDialogMaterial,
proyekName,
materialResource,
materialProyek,
userProyek,
idTask,
]
);
const RenderDialogTableTools = useMemo(

Loading…
Cancel
Save