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

Loading…
Cancel
Save