|
|
|
@ -55,6 +55,9 @@ import {
|
|
|
|
|
PHASE_PROYEK, |
|
|
|
|
DIVISI_LIST, |
|
|
|
|
BASE_OSPRO, |
|
|
|
|
IMAGE_UPLOAD, |
|
|
|
|
IMAGE_GET_BY_ID, |
|
|
|
|
IMAGE_DELETE, |
|
|
|
|
} from "../../../const/ApiConst"; |
|
|
|
|
import { |
|
|
|
|
formatNumber, |
|
|
|
@ -96,6 +99,13 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const HEADER_MULTIPART = { |
|
|
|
|
headers: { |
|
|
|
|
"Content-Type": "multipart/form-data", |
|
|
|
|
Authorization: `Bearer ${token}`, |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const [idTask, setidTask] = useState(0); |
|
|
|
|
const [dataTable, setDatatable] = useState([]); |
|
|
|
|
const [search, setSearch] = useState(""); |
|
|
|
@ -136,6 +146,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
const [projectPM, setPM] = useState(null); |
|
|
|
|
const [projectK3Search, setK3Search] = useState(null); |
|
|
|
|
const [projectAssignHR, setProjectAssignHR] = useState(null); |
|
|
|
|
const [image, setProjectImage] = useState(null); |
|
|
|
|
|
|
|
|
|
const [loadVersionGantt, setLoadVersionGantt] = useState(false); |
|
|
|
|
const [loadHierarchy, setLoadHierarchy] = useState(false); |
|
|
|
@ -431,9 +442,10 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
setidTask(id); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const handleOpenDialogProyek = (id) => { |
|
|
|
|
const handleOpenDialogProyek = async (id) => { |
|
|
|
|
setOpenDialogProyek(true); |
|
|
|
|
setidTask(id); |
|
|
|
|
await getProjectImage(id); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const handleOpenDialogGantt = (data) => { |
|
|
|
@ -504,6 +516,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
await getProjectApproval(data.id); |
|
|
|
|
await getK3toProject(data.id); |
|
|
|
|
await getProjectAssignHR(data.id); |
|
|
|
|
await getProjectImage(data.id); |
|
|
|
|
// await handleGetDataPm(data.id);
|
|
|
|
|
setPM(data.join_first_name); |
|
|
|
|
setOpenDialogViewDetail(true); |
|
|
|
@ -571,8 +584,8 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
|
const {kode_sortname,nama,mulai_proyek,rencana_biaya,keterangan,durasi_proyek,project_objectives,potential_risk,currency_symbol} = result.data.data; |
|
|
|
|
const dataToSend = { kode_sortname, nama, mulai_proyek, rencana_biaya, keterangan, durasi_proyek, project_objectives, potential_risk, currency_symbol }; |
|
|
|
|
const {kode_sortname,nama,mulai_proyek,rencana_biaya,keterangan,durasi_proyek,project_objectives,potential_risk,currency_symbol, nama_divisi, late_consequence, assumtion, considered_success_when} = result.data.data; |
|
|
|
|
const dataToSend = { kode_sortname, nama, mulai_proyek, rencana_biaya, keterangan, durasi_proyek, project_objectives, potential_risk, currency_symbol, nama_divisi, late_consequence, assumtion, considered_success_when}; |
|
|
|
|
setProjectCharter(dataToSend); |
|
|
|
|
} else { |
|
|
|
|
NotificationManager.error("Gagal Mengambil Data!!", "Failed"); |
|
|
|
@ -647,6 +660,17 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const getProjectImage = async (id) => { |
|
|
|
|
const url = IMAGE_GET_BY_ID(id, "project_structure_organization"); |
|
|
|
|
const result = await axios |
|
|
|
|
.get(url, HEADER) |
|
|
|
|
.then((res) => res) |
|
|
|
|
.catch((err) => err.response); |
|
|
|
|
if (result && result.data && result.data.code === 200) { |
|
|
|
|
setProjectImage(result.data.data); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const getProjectParticipant = async (id) => { |
|
|
|
|
const payload = { |
|
|
|
|
select: [ |
|
|
|
@ -720,6 +744,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
setProjectCharter(null); |
|
|
|
|
setK3Search(null); |
|
|
|
|
setProjectAssignHR(null); |
|
|
|
|
setProjectImage(null); |
|
|
|
|
setOpenDialogViewDetail(false); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -733,6 +758,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
setProjectCharter(null); |
|
|
|
|
setK3Search(null); |
|
|
|
|
setProjectAssignHR(null); |
|
|
|
|
setProjectImage(null); |
|
|
|
|
} |
|
|
|
|
setOpenDialogViewDetail(!openDialogViewDetail); |
|
|
|
|
}; |
|
|
|
@ -746,7 +772,8 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
|
|
|
|
|
if (result && result.data && result.data.code === 200) { |
|
|
|
|
role_id !== "44" ? getDataProyek() : getDataProyekByCustomer(); |
|
|
|
|
|
|
|
|
|
getProjectImage(idDelete); |
|
|
|
|
deleteImage(idDelete); |
|
|
|
|
setIdDelete(0); |
|
|
|
|
setAlertDelete(false); |
|
|
|
|
NotificationManager.success(`Data proyek berhasil dihapus`, "Success!!"); |
|
|
|
@ -766,6 +793,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
if (result && result.data && result.data.code === 200) { |
|
|
|
|
const { participants, milestones, approval } = data.projectCharter; |
|
|
|
|
const imageObject = data.imageStructureOrg; |
|
|
|
|
const resultParticipant = await saveParticipant( |
|
|
|
|
result.data.data_result.id, |
|
|
|
|
participants |
|
|
|
@ -778,12 +806,18 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
result.data.data_result.id, |
|
|
|
|
approval |
|
|
|
|
); |
|
|
|
|
if (imageObject) { |
|
|
|
|
await saveImage( |
|
|
|
|
result.data.data_result.id, |
|
|
|
|
imageObject |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
resultParticipant === "berhasil" && |
|
|
|
|
resultMilestone === "berhasil" && |
|
|
|
|
resultApproval === "berhasil" |
|
|
|
|
) { |
|
|
|
|
// getDataProyek();
|
|
|
|
|
NotificationManager.success( |
|
|
|
|
`Data proyek berhasil ditambah`, |
|
|
|
|
"Success!!" |
|
|
|
@ -860,8 +894,33 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
return "berhasil"; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const saveImage = async (id, data) => { |
|
|
|
|
const formData = new FormData; |
|
|
|
|
formData.append('ref_id', id); |
|
|
|
|
formData.append('category', 'project_structure_organization'); |
|
|
|
|
formData.append('files', data); |
|
|
|
|
|
|
|
|
|
await axios |
|
|
|
|
.post(IMAGE_UPLOAD, formData, HEADER_MULTIPART) |
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
return "berhasil"; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const deleteImage = async (id) => { |
|
|
|
|
const URL = IMAGE_DELETE(id, 'project_structure_organization'); |
|
|
|
|
|
|
|
|
|
await axios |
|
|
|
|
.delete(URL, HEADER) |
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
return "berhasil"; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const editProyek = async (data) => { |
|
|
|
|
const { participants, milestones, approval } = data.projectCharter; |
|
|
|
|
const imageObject = data.imageStructureOrg; |
|
|
|
|
|
|
|
|
|
let urlEdit = PROYEK_EDIT(data.id); |
|
|
|
|
const formData = data; |
|
|
|
|
|
|
|
|
@ -872,6 +931,15 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
const resultParticipant = await editParticipant(data.id, participants); |
|
|
|
|
const resultMilestone = await editMilestone(data.id, milestones); |
|
|
|
|
const resultApproval = await editApproval(data.id, approval); |
|
|
|
|
if (imageObject) { |
|
|
|
|
await deleteImage( |
|
|
|
|
data.id |
|
|
|
|
); |
|
|
|
|
await saveImage( |
|
|
|
|
data.id, |
|
|
|
|
imageObject |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
if (result && result.status === 200) { |
|
|
|
|
role_id !== "44" ? getDataProyek() : getDataProyekByCustomer(); |
|
|
|
|
NotificationManager.success(`Data proyek berhasil Ubah`, "Success!!"); |
|
|
|
@ -882,7 +950,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
|
|
|
|
|
const editParticipant = async (id, data) => { |
|
|
|
|
await axios.delete(PROJECT_PARTICIPANT_DELETE_BY_PROYEK(id), HEADER); |
|
|
|
|
// if (restDelete){
|
|
|
|
|
const request = data.map((res) => { |
|
|
|
|
const payload = { |
|
|
|
|
proyek_id: parseInt(id), |
|
|
|
@ -1432,6 +1499,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
dataPhaseProject={dataPhaseProject} |
|
|
|
|
dataDivisions={dataDivisions} |
|
|
|
|
dataPM={dataPm} |
|
|
|
|
projectImage={image} |
|
|
|
|
/> |
|
|
|
|
), |
|
|
|
|
[ |
|
|
|
@ -1441,6 +1509,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
dataPhaseProject, |
|
|
|
|
dataTypeProyek, |
|
|
|
|
idTask, |
|
|
|
|
image |
|
|
|
|
] |
|
|
|
|
); |
|
|
|
|
|
|
|
|
@ -1559,6 +1628,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
projectManager={projectPM} |
|
|
|
|
projectK3={projectK3Search} |
|
|
|
|
assignHR={projectAssignHR} |
|
|
|
|
projectImage={image} |
|
|
|
|
/> |
|
|
|
|
), |
|
|
|
|
[openDialogViewDetail] |
|
|
|
|