|
|
|
@ -1,6 +1,5 @@
|
|
|
|
|
import React, { useState, useEffect, useMemo } from "react"; |
|
|
|
|
import { Card, CardBody, CardHeader, Col, Row, Input } from "reactstrap"; |
|
|
|
|
// import { DownloadOutlined } from '@ant-design/icons';
|
|
|
|
|
import axios from "../../../const/interceptorApi"; |
|
|
|
|
import jsPDF from "jspdf"; |
|
|
|
|
import autoTable from "jspdf-autotable"; |
|
|
|
@ -51,6 +50,7 @@ import {
|
|
|
|
|
CHECKLIST_K3_LIST, |
|
|
|
|
VERSION_GANTT_SEARCH, |
|
|
|
|
PHASE_PROYEK, |
|
|
|
|
DIVISI_LIST |
|
|
|
|
} from "../../../const/ApiConst"; |
|
|
|
|
import { |
|
|
|
|
formatNumber, |
|
|
|
@ -90,7 +90,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
|
|
|
|
|
const [idTask, setidTask] = useState(0); |
|
|
|
|
const [dataTable, setDatatable] = useState([]); |
|
|
|
|
console.log(`dataTable`, dataTable); |
|
|
|
|
const [search, setSearch] = useState(""); |
|
|
|
|
const [currentPage, setCurrentPage] = useState(1); |
|
|
|
|
const [totalPage, setTotalPage] = useState(0); |
|
|
|
@ -114,6 +113,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
const [toolsResource, setToolsResource] = useState([]); |
|
|
|
|
const [dataTypeProyek, setDataTypeProyek] = useState([]); |
|
|
|
|
const [dataPhaseProject, setDataPhaseProject] = useState([]); |
|
|
|
|
const [dataDivisions, setDataDivisions] = useState([]); |
|
|
|
|
const [dataPm, setDataPM] = useState([]); |
|
|
|
|
const [openDialogDoc, setOpenDialogDoc] = useState(false); |
|
|
|
|
const [proyekName, setProyekName] = useState(""); |
|
|
|
@ -135,6 +135,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
getDataToolsResource(); |
|
|
|
|
handleGetTipeProject(); |
|
|
|
|
handleGetPhaseProject(); |
|
|
|
|
handleGetDivisions(); |
|
|
|
|
handleGetDataPm(); |
|
|
|
|
getDataK3(); |
|
|
|
|
}, []); |
|
|
|
@ -166,7 +167,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
.get(TYPE_PROYEK, HEADER) |
|
|
|
|
.then((res) => res) |
|
|
|
|
.catch((err) => err.response); |
|
|
|
|
console.log(result); |
|
|
|
|
if (result && result.data && result.data.code === 200) { |
|
|
|
|
setDataTypeProyek(result.data.data); |
|
|
|
|
} else { |
|
|
|
@ -178,19 +178,26 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
.get(PHASE_PROYEK, HEADER) |
|
|
|
|
.then((res) => res) |
|
|
|
|
.catch((err) => err.response); |
|
|
|
|
console.log("PHASEEEE", result); |
|
|
|
|
if (result && result.data && result.data.code === 200) { |
|
|
|
|
setDataPhaseProject(result.data.data); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const handleGetDivisions = async () => { |
|
|
|
|
const result = await axios |
|
|
|
|
.get(DIVISI_LIST, HEADER) |
|
|
|
|
.then((res) => res) |
|
|
|
|
.catch((err) => err.response); |
|
|
|
|
if (result && result.data && result.data.code === 200) { |
|
|
|
|
setDataDivisions(result.data.data); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const handleGetDataPm = async () => { |
|
|
|
|
const result = await axios |
|
|
|
|
.get(USER_LIST, HEADER) |
|
|
|
|
.then((res) => res) |
|
|
|
|
.catch((err) => err.response); |
|
|
|
|
console.log(result); |
|
|
|
|
if (result && result.data && result.data.code === 200) { |
|
|
|
|
setDataPM(result.data.data); |
|
|
|
|
} else { |
|
|
|
@ -208,7 +215,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
columns: [ |
|
|
|
|
{ |
|
|
|
|
name: "nama", |
|
|
|
|
logic_operator: "like", |
|
|
|
|
logic_operator: "ilike", |
|
|
|
|
value: search, |
|
|
|
|
operator: "AND", |
|
|
|
|
}, |
|
|
|
@ -244,7 +251,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
|
// console.log("cek proyek", result)
|
|
|
|
|
let dataRes = result.data.data || []; |
|
|
|
|
|
|
|
|
|
setDatatable(dataRes); |
|
|
|
@ -261,7 +267,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
|
console.log("cek material resource", result.data.data); |
|
|
|
|
let dataRes = result.data.data || []; |
|
|
|
|
setMaterialResource(dataRes); |
|
|
|
|
} else { |
|
|
|
@ -304,7 +309,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
|
console.log("cek tools resource", result.data.data); |
|
|
|
|
let dataRes = result.data.data || []; |
|
|
|
|
setToolsResource(dataRes); |
|
|
|
|
} else { |
|
|
|
@ -319,7 +323,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
|
console.log("cek k3 list", result.data.data); |
|
|
|
|
let dataRes = result.data.data || []; |
|
|
|
|
const finalData = []; |
|
|
|
|
if (dataRes.length > 0) { |
|
|
|
@ -343,7 +346,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const handleOpenDialogProyek = (id) => { |
|
|
|
|
console.log("handleOpenDialogProyek", id); |
|
|
|
|
setOpenDialogProyek(true); |
|
|
|
|
setidTask(id); |
|
|
|
|
}; |
|
|
|
@ -382,14 +384,12 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
|
|
|
|
|
const handleOpenDialogTools = (data) => { |
|
|
|
|
setOpenDialogTools(true); |
|
|
|
|
console.log("handleOpenDialogTools", data); |
|
|
|
|
setidTask(data.id); |
|
|
|
|
setProyekName(data.nama); |
|
|
|
|
setUserProyek(data.user_proyeks); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const handleOpenDialogViewDetail = async (data) => { |
|
|
|
|
// console.log('handleOpenDialogViewDetail', data);
|
|
|
|
|
setidTask(data.id); |
|
|
|
|
// setDataView(data)
|
|
|
|
|
await getDataProject(data.id); |
|
|
|
@ -541,7 +541,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
.post(PROYEK_ADD, formData, HEADER) |
|
|
|
|
.then((res) => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
console.log(result); |
|
|
|
|
if (result && result.data && result.data.code === 200) { |
|
|
|
|
const { participants, milestones, approval } = data.projectCharter; |
|
|
|
|
const resultParticipant = await saveParticipant( |
|
|
|
@ -556,7 +555,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
result.data.data_result.id, |
|
|
|
|
approval |
|
|
|
|
); |
|
|
|
|
console.log({ resultApproval, resultMilestone, resultParticipant }); |
|
|
|
|
if ( |
|
|
|
|
resultParticipant === "berhasil" && |
|
|
|
|
resultMilestone === "berhasil" && |
|
|
|
@ -586,11 +584,9 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
}; |
|
|
|
|
return axios.post(PROJECT_PARTICIPANT_ADD, payload, HEADER); |
|
|
|
|
}); |
|
|
|
|
console.log(request); |
|
|
|
|
const arr = await Promise.all(request) |
|
|
|
|
.then((values) => values) |
|
|
|
|
.catch((err) => err.response); |
|
|
|
|
console.log("result participant", arr); |
|
|
|
|
const result = arr.map((res) => res.data.code == 200); |
|
|
|
|
if (result.length > 0) { |
|
|
|
|
return "gagal"; |
|
|
|
@ -609,11 +605,9 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
}; |
|
|
|
|
return axios.post(PROJECT_MILESTONE_ADD, payload, HEADER); |
|
|
|
|
}); |
|
|
|
|
console.log(request); |
|
|
|
|
const arr = await Promise.all(request) |
|
|
|
|
.then((values) => values) |
|
|
|
|
.catch((err) => err.response); |
|
|
|
|
console.log("result milestone", arr); |
|
|
|
|
const result = arr.map((res) => res.data.code !== 200); |
|
|
|
|
if (result.length > 0) { |
|
|
|
|
return "gagal"; |
|
|
|
@ -632,11 +626,9 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
}; |
|
|
|
|
return axios.post(PROJECT_APPROVAL_ADD, payload, HEADER); |
|
|
|
|
}); |
|
|
|
|
console.log(request); |
|
|
|
|
const arr = await Promise.all(request) |
|
|
|
|
.then((values) => values) |
|
|
|
|
.catch((err) => err.response); |
|
|
|
|
console.log("result approval", arr); |
|
|
|
|
const result = arr.map((res) => res.data.code !== 200); |
|
|
|
|
if (result.length > 0) { |
|
|
|
|
return "gagal"; |
|
|
|
@ -654,7 +646,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
.put(urlEdit, formData, HEADER) |
|
|
|
|
.then((res) => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
console.log("cek result", result); |
|
|
|
|
const resultParticipant = await editParticipant(data.id, participants); |
|
|
|
|
const resultMilestone = await editMilestone(data.id, milestones); |
|
|
|
|
const resultApproval = await editApproval(data.id, approval); |
|
|
|
@ -677,12 +668,9 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
}; |
|
|
|
|
return axios.post(PROJECT_PARTICIPANT_ADD, payload, HEADER); |
|
|
|
|
}); |
|
|
|
|
console.log(request); |
|
|
|
|
const arr = await Promise.all(request) |
|
|
|
|
.then((values) => values) |
|
|
|
|
.catch((err) => err.response); |
|
|
|
|
console.log("result participant", arr); |
|
|
|
|
// let dataTittle = arr.data.tittle
|
|
|
|
|
const result = arr.map((res) => res.data.code !== 200); |
|
|
|
|
if (result.length > 0) { |
|
|
|
|
return "gagal"; |
|
|
|
@ -693,7 +681,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
|
|
|
|
|
const editMilestone = async (id, data) => { |
|
|
|
|
await axios.delete(PROJECT_MILESTONE_DELETE_BY_PROYEK(id), HEADER); |
|
|
|
|
console.log("res due", data); |
|
|
|
|
const request = data.map((res) => { |
|
|
|
|
const payload = { |
|
|
|
|
proyek_id: parseInt(id), |
|
|
|
@ -703,11 +690,9 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
}; |
|
|
|
|
return axios.post(PROJECT_MILESTONE_ADD, payload, HEADER); |
|
|
|
|
}); |
|
|
|
|
console.log(request); |
|
|
|
|
const arr = await Promise.all(request) |
|
|
|
|
.then((values) => values) |
|
|
|
|
.catch((err) => err.response); |
|
|
|
|
console.log("result milestone", arr); |
|
|
|
|
const result = arr.map((res) => res.data.code !== 200); |
|
|
|
|
if (result.length > 0) { |
|
|
|
|
return "gagal"; |
|
|
|
@ -716,7 +701,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const editApproval = async (id, data) => { |
|
|
|
|
console.log("cek data edit approval", data); |
|
|
|
|
await axios.delete(PROJECT_APPROVAL_DELETE_BY_PROYEK(id), HEADER); |
|
|
|
|
const request = data.map((res) => { |
|
|
|
|
const payload = { |
|
|
|
@ -727,11 +711,9 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
}; |
|
|
|
|
return axios.post(PROJECT_APPROVAL_ADD, payload, HEADER); |
|
|
|
|
}); |
|
|
|
|
console.log(request); |
|
|
|
|
const arr = await Promise.all(request) |
|
|
|
|
.then((values) => values) |
|
|
|
|
.catch((err) => err.response); |
|
|
|
|
console.log("result approval", arr); |
|
|
|
|
// if(arr)
|
|
|
|
|
|
|
|
|
|
// const result = arr.map(res => res.data.code !== 200)
|
|
|
|
@ -742,7 +724,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const handleDelete = async (id) => { |
|
|
|
|
// console.log('Delete')
|
|
|
|
|
await setAlertDelete(true); |
|
|
|
|
await setIdDelete(id); |
|
|
|
|
}; |
|
|
|
@ -758,9 +739,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
const handleExportExcel = async () => { |
|
|
|
|
const payload = { |
|
|
|
|
paging: { start: 0, length: -1 }, |
|
|
|
|
// "columns": [
|
|
|
|
|
// { "name": "nama", "logic_operator": "like", "value": search, "operator": "AND" }
|
|
|
|
|
// ],
|
|
|
|
|
joins: [], |
|
|
|
|
orders: { columns: ["id"], ascending: false }, |
|
|
|
|
}; |
|
|
|
@ -807,7 +785,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
}; |
|
|
|
|
excelData.push(dataRow); |
|
|
|
|
}); |
|
|
|
|
// console.log("cek excel data", excelData)
|
|
|
|
|
await setDataExport(excelData); |
|
|
|
|
} else { |
|
|
|
|
NotificationManager.error("Gagal Export Data!!", "Failed"); |
|
|
|
@ -1151,6 +1128,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
idTask={idTask} |
|
|
|
|
dataTypeProyek={dataTypeProyek} |
|
|
|
|
dataPhaseProject={dataPhaseProject} |
|
|
|
|
dataDivisions={dataDivisions} |
|
|
|
|
dataPM={dataPm} |
|
|
|
|
/> |
|
|
|
|
), |
|
|
|
|