From f8946f1c121a552e77f8907f7b7a47bb0831ad57 Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Tue, 9 May 2023 13:51:24 +0700 Subject: [PATCH 1/4] Remove unnecessary request --- .../SimproV2/CreatedProyek/DialogGantt.js | 5 - .../SimproV2/CreatedProyek/DialogHierarchy.js | 5 - .../SimproV2/CreatedProyek/DialogUserGantt.js | 34 ++++++- src/views/SimproV2/CreatedProyek/index.js | 98 ++++++++++--------- 4 files changed, 84 insertions(+), 58 deletions(-) diff --git a/src/views/SimproV2/CreatedProyek/DialogGantt.js b/src/views/SimproV2/CreatedProyek/DialogGantt.js index 7341d44..d52819f 100644 --- a/src/views/SimproV2/CreatedProyek/DialogGantt.js +++ b/src/views/SimproV2/CreatedProyek/DialogGantt.js @@ -39,10 +39,6 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName } }, [hierarchyId, idTask, openDialog]) - useEffect(() => { - getDataHumanResource(); - }, []) - useEffect(() => { if (!openDialog) { setDataGantt([]); @@ -274,7 +270,6 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName { - getDataHumanResource(); - }, []) - useEffect(() => { if (!openDialog) { setDataHierarchy([]); @@ -333,7 +329,6 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek { +const DialogUserGantt = ({ openDialog, closeDialog, toggleDialog, idGantt}) => { const token = localStorage.getItem("token") const HEADER = { headers: { @@ -16,6 +16,7 @@ const DialogUserGantt = ({ openDialog, closeDialog, toggleDialog, idGantt, human } const [id, setId] = useState(0) const [targetKeys, setTargetKeys] = useState([]) + const [humanResource, setHumanResource] = useState([]) const handleCLearData = () => { @@ -26,6 +27,8 @@ const DialogUserGantt = ({ openDialog, closeDialog, toggleDialog, idGantt, human useEffect(() => { if(!openDialog){ handleCLearData() + } else { + getDataHumanResource(); } }, [openDialog]) @@ -35,6 +38,31 @@ const DialogUserGantt = ({ openDialog, closeDialog, toggleDialog, idGantt, human } }, [idGantt]) + const getDataHumanResource = async () => { + const result = await axios + .get(USER_LIST, HEADER) + .then(res => res) + .catch((error) => error.response); + + if (result && result.status == 200) { + setTransferUser(result.data.data); + } else { + + } + } + + const setTransferUser = (data) => { + const finalData = [] + data.map((val, index) => { + let data = { + key: val.id, + title: val.name + } + finalData.push(data) + }); + setHumanResource(finalData) + } + const getUserGantt = async () => { const payload = { "columns": [ @@ -139,4 +167,4 @@ const DialogUserGantt = ({ openDialog, closeDialog, toggleDialog, idGantt, human } -export default DialogUserGantt; \ No newline at end of file +export default DialogUserGantt; diff --git a/src/views/SimproV2/CreatedProyek/index.js b/src/views/SimproV2/CreatedProyek/index.js index 13deced..b2c667e 100644 --- a/src/views/SimproV2/CreatedProyek/index.js +++ b/src/views/SimproV2/CreatedProyek/index.js @@ -133,17 +133,33 @@ const CreatedProyek = ({ params, ...props }) => { const [dataHierarchy, setDataHierarchy] = useState([]); const pageName = params.name; - - useEffect(() => { - // getDataUserResource() - getDataMaterialResource(); - getDataToolsResource(); - handleGetTipeProject(); - handleGetPhaseProject(); - handleGetDivisions(); - handleGetDataPm(); - getDataK3(); - }, []); + + useEffect(() => { + if (openDialogMaterial) { + getDataMaterialResource(); + } + }, [openDialogMaterial]); + + useEffect(() => { + if (openDialogTools) { + getDataToolsResource(); + } + }, [openDialogTools]); + + useEffect(() => { + if (openDialogAssignK3) { + getDataK3(); + } + }, [openDialogAssignK3]); + + useEffect(() => { + if (openDialogProyek) { + handleGetTipeProject(); + handleGetPhaseProject(); + handleGetDivisions(); + handleGetDataPm(); + } + }, [openDialogProyek]) useEffect(() => { getDataProyek(); @@ -307,32 +323,6 @@ const CreatedProyek = ({ params, ...props }) => { } }; - const getdataHierarchy = async (idTask) => { - setLoadHierarchy(true); - const payload = { - columns: [ - { - name: "project_id", - logic_operator: "=", - value: idTask, - operator: "AND", - }, - ], - }; - const result = await axios - .post(HIERARCHY_FTTH_SEARCH, payload, HEADER) - .then((res) => res) - .catch((error) => error.response); - if (result && result.status == 200) { - setDataHierarchy(result.data.data); - setLoadHierarchy(false); - } else { - NotificationManager.error( - `Data gantt project gagal terload silahkan coba lagi!`, - "Failed!!" - ); - } - }; const getDataToolsResource = async () => { const result = await axios .get(TOOLS_RESOURCE_LIST, HEADER) @@ -843,9 +833,28 @@ const CreatedProyek = ({ params, ...props }) => { ["Project Name", "Budget", "Project Type", "PM", "Time Project"], ]; const payload = { - paging: { start: 0, length: -1 }, - joins: [], - orders: { columns: ["id"], ascending: false }, + columns: [ + { + name: "nama", + logic_operator: "ilike", + value: search, + operator: "AND", + }, + ], + joins: [ + { + name: "m_users", + column_join: "pm_id", + column_results: ["name", "username"], + }, + { + name: "m_type_proyek", + column_join: "type_proyek_id", + column_results: ["name", "description"], + }, + // { "name": "subproyeks.m_subproyek", "column_join": "parent_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual"] } + ], + orders: { columns: ["id"], ascending: false }, }; const result = await axios @@ -1084,7 +1093,6 @@ const CreatedProyek = ({ params, ...props }) => { { text.type_proyek_id == 9 ? }{" "} {!record.isDir && - + }{" "} {record.isDir && @@ -337,4 +338,4 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN } -export default DialogDocument; \ No newline at end of file +export default DialogDocument; From 8cad4f2902e6924004f62ec794fce7d8d9632791 Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Wed, 10 May 2023 10:55:09 +0700 Subject: [PATCH 3/4] remove math rounding --- .../CreatedProyek/ImportActivity/index.js | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/views/SimproV2/CreatedProyek/ImportActivity/index.js b/src/views/SimproV2/CreatedProyek/ImportActivity/index.js index 48e8000..4661d3d 100644 --- a/src/views/SimproV2/CreatedProyek/ImportActivity/index.js +++ b/src/views/SimproV2/CreatedProyek/ImportActivity/index.js @@ -57,9 +57,8 @@ const columnToIndexs = { weight: 4, start_date: 5, end_date: 6, - picKit: 7, - picOwner: 8, - duration: 9 + nik: 7, + duration: 8 } const ExcelDateToJSDate = (date) => { @@ -133,7 +132,7 @@ const ImportActivity = ({ params }) => { } if(prop == 'weight'){ - columnData = Math.round(columnData * 100) + columnData = columnData * 100 } extractedRow[prop] = columnData @@ -238,18 +237,13 @@ const ImportActivity = ({ params }) => { title: 'Duration', dataIndex: 'duration', key: 'duration', - align: 'right', - }, - { - title: 'PIC KIT', - dataIndex: 'picKit', - key: 'picKit', }, { - title: 'PIC Owner', - dataIndex: 'picOwner', - key: 'picOwner', - }, + title: 'NIK', + dataIndex: 'nik', + key: 'nik', + align: 'right', + } ]; if (isMovePage) { From d15b1b25362d6311c488b5fdd3ad7202dd449fbb Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Fri, 12 May 2023 10:27:38 +0700 Subject: [PATCH 4/4] Handling null weight --- src/views/SimproV2/CreatedProyek/ImportActivity/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/views/SimproV2/CreatedProyek/ImportActivity/index.js b/src/views/SimproV2/CreatedProyek/ImportActivity/index.js index 4661d3d..4e78542 100644 --- a/src/views/SimproV2/CreatedProyek/ImportActivity/index.js +++ b/src/views/SimproV2/CreatedProyek/ImportActivity/index.js @@ -132,6 +132,9 @@ const ImportActivity = ({ params }) => { } if(prop == 'weight'){ + if (columnData == null) { + columnData = 0; + } columnData = columnData * 100 }