@ -25,6 +25,9 @@ import {
PROJECT _APPROVAL _ADD ,
PROJECT _APPROVAL _EDIT ,
PROJECT _PARTICIPANT _ADD ,
PROJECT _CHECKLIST _ADD ,
PROJECT _ISSUE _ADD ,
PROJECT _RISK _ADD ,
PROJECT _PARTICIPANT _EDIT ,
PROJECT _MILESTONE _ADD ,
PROJECT _MILESTONE _EDIT ,
@ -37,12 +40,19 @@ import {
PROYEK _SEARCH ,
PROYEK _SEARCH _BY _USER ,
PROYEK _EDIT ,
ASSIGN _HR _PROJECT _SEARCH ,
PROJECT _CHECKLIST _SEARCH ,
PROYEK _DELETE ,
TOOLS _RESOURCE _SEARCH ,
MATERIAL _RESOURCE _SEARCH ,
USER _SEARCH ,
PROJECT _CHARTER _SEARCH ,
HIERARCHY _FTTH _SEARCH ,
PROJECT _ISSUE _SEARCH ,
PROJECT _RISK _SEARCH ,
PROJECT _CHECKLIST _DELETE _BY _PROYEK ,
PROJECT _ISSUE _DELETE _BY _PROYEK ,
PROJECT _RISK _DELETE _BY _PROYEK ,
TOOLS _RESOURCE _LIST ,
MATERIAL _RESOURCE _LIST ,
PROYEK _GET _ID ,
@ -54,6 +64,9 @@ import {
PHASE _PROYEK ,
DIVISI _LIST ,
BASE _OSPRO ,
IMAGE _UPLOAD ,
IMAGE _GET _BY _ID ,
IMAGE _DELETE ,
} from "../../../const/ApiConst" ;
import {
formatNumber ,
@ -95,6 +108,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 ( "" ) ;
@ -130,8 +150,15 @@ const CreatedProyek = ({ params, ...props }) => {
// project charter
const [ projectCharter , setProjectCharter ] = useState ( null ) ;
const [ projectParticipant , setProjectParticipant ] = useState ( null ) ;
const [ projectChecklist , setProjectChecklist ] = useState ( null ) ;
const [ projectIssue , setProjectIssue ] = useState ( null ) ;
const [ projectRisk , setProjectRisk ] = useState ( null ) ;
const [ projectMilestone , setProjectMilestone ] = useState ( null ) ;
const [ projectApproval , setProjectApproval ] = useState ( null ) ;
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 ) ;
@ -222,13 +249,14 @@ const CreatedProyek = ({ params, ...props }) => {
}
} ;
const handleGetDataPm = async ( ) => {
const handleGetDataPm = async ( text ) => {
const result = await axios
. get ( USER _LIST , HEADER )
. then ( ( res ) => res )
. catch ( ( err ) => err . response ) ;
if ( result && result . data && result . data . code === 200 ) {
setDataPM ( result . data . data ) ;
const dataRes = result . data . data ;
setDataPM ( dataRes ) ;
} else {
}
} ;
@ -426,9 +454,10 @@ const CreatedProyek = ({ params, ...props }) => {
setidTask ( id ) ;
} ;
const handleOpenDialogProyek = ( id ) => {
const handleOpenDialogProyek = async ( id ) => {
setOpenDialogProyek ( true ) ;
setidTask ( id ) ;
await getProjectImage ( id ) ;
} ;
const handleOpenDialogGantt = ( data ) => {
@ -496,8 +525,15 @@ const CreatedProyek = ({ params, ...props }) => {
await getDataProject ( data . id ) ;
await getProjectMilestone ( data . id ) ;
await getProjectParticipant ( data . id ) ;
await getProjectChecklist ( data . id ) ;
await getProjectIssue ( data . id ) ;
await getProjectRisk ( data . id ) ;
await getProjectApproval ( data . id ) ;
// await getDataProjectCharter(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 ) ;
} ;
@ -525,6 +561,32 @@ const CreatedProyek = ({ params, ...props }) => {
}
} ;
const getK3toProject = async ( id ) => {
const payload = {
"select" : [
"id" ,
"proyek_id" ,
"checklist_k3_id"
] ,
"columns" : [
{ "name" : "proyek_id" , "logic_operator" : "=" , "value" : id , "operator" : "AND" }
]
}
const URL = ` ${ BASE _OSPRO } /api/project-to-checklist-k3/search ` ;
const result = await axios
. post ( URL , payload , HEADER )
. then ( res => res )
. catch ( ( error ) => error . response ) ;
if ( result && result . status == 200 ) {
console . log ( "cek get project to checklist k3" , result . data . data )
let dataRes = result . data . data ;
if ( dataRes . length > 0 ) {
setK3Search ( dataRes ) ;
}
}
}
const handleSCurve = async ( data ) => {
getProjectDetail ( data . id ) ;
} ;
@ -537,8 +599,9 @@ const CreatedProyek = ({ params, ...props }) => {
. catch ( ( error ) => error . response ) ;
if ( result && result . data && result . data . code == 200 ) {
let dataRes = result . data . data ;
setProjectCharter ( dataRes ) ;
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" ) ;
}
@ -546,6 +609,13 @@ const CreatedProyek = ({ params, ...props }) => {
const getProjectMilestone = async ( id ) => {
const payload = {
select : [
'id' ,
'proyek_id' ,
'status' ,
'due_date' ,
'deadline'
] ,
columns : [ { name : "proyek_id" , logic _operator : "=" , value : id } ] ,
joins : [ ] ,
orders : { columns : [ "id" ] , ascending : true } ,
@ -559,20 +629,76 @@ const CreatedProyek = ({ params, ...props }) => {
if ( result && result . data && result . data . code == 200 ) {
let dataRes = result . data . data ;
setProjectMilestone ( dataRes ) ;
const filteredData = dataRes . filter ( item => item . proyek _id === parseInt ( id ) ) ;
setProjectMilestone ( filteredData ) ;
} else {
NotificationManager . error ( "Gagal Mengambil Data!!" , "Failed" ) ;
}
} ;
const getProjectAssignHR = async ( id ) => {
const payload = {
select : [
"id" ,
"proyek_id" ,
"user_id" ,
"project_role"
] ,
columns : [ { name : "proyek_id" , logic _operator : "=" , value : id } ] ,
joins : [
{
name : "m_users" ,
column _join : "user_id" ,
column _results : [ "name" ] ,
} ,
{
name : "m_role_proyek" ,
column _join : "project_role" ,
column _results : [ "name" , "description" ] ,
}
] ,
orders : { columns : [ "id" ] , ascending : true } ,
paging : { start : 0 , length : - 1 } ,
} ;
// const url = PROJECT_MI(proyek_id)
const result = await axios
. post ( ASSIGN _HR _PROJECT _SEARCH , payload , HEADER )
. then ( ( res ) => res )
. catch ( ( error ) => error . response ) ;
if ( result && result . data && result . data . code == 200 ) {
let dataRes = result . data . data ;
const filteredData = dataRes . filter ( item => item . proyek _id === parseInt ( id ) ) ;
setProjectAssignHR ( filteredData ) ;
} else {
NotificationManager . error ( "Gagal Mengambil Data!!" , "Failed" ) ;
}
} ;
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 : [
"id" ,
"proyek_id" ,
"tittle" ,
"name"
] ,
columns : [ { name : "proyek_id" , logic _operator : "=" , value : id } ] ,
joins : [ ] ,
orders : { columns : [ "id" ] , ascending : true } ,
paging : { start : 0 , length : - 1 } ,
} ;
// const url = PROJECT_MI(proyek_id)
const result = await axios
. post ( PROJECT _PARTICIPANT _SEARCH , payload , HEADER )
. then ( ( res ) => res )
@ -580,7 +706,90 @@ const CreatedProyek = ({ params, ...props }) => {
if ( result && result . data && result . data . code == 200 ) {
let dataRes = result . data . data ;
setProjectParticipant ( dataRes ) ;
const filteredData = dataRes . filter ( item => item . proyek _id === parseInt ( id ) ) ;
setProjectParticipant ( filteredData ) ;
} else {
NotificationManager . error ( "Gagal Mengambil Data!!" , "Failed" ) ;
}
} ;
const getProjectChecklist = async ( id ) => {
const payload = {
select : [
"id" ,
"proyek_id" ,
"item" ,
"status_exist"
] ,
columns : [ { name : "proyek_id" , logic _operator : "=" , value : parseInt ( id ) } ] ,
joins : [ ] ,
orders : { columns : [ "id" ] , ascending : true } ,
paging : { start : 0 , length : - 1 } ,
} ;
const result = await axios
. post ( PROJECT _CHECKLIST _SEARCH , payload , HEADER )
. then ( ( res ) => res )
. catch ( ( error ) => error . response ) ;
if ( result && result . data && result . data . code == 200 ) {
let dataRes = result . data . data ;
const filteredData = dataRes . filter ( item => item . proyek _id === parseInt ( id ) ) ;
setProjectChecklist ( filteredData ) ;
} else {
NotificationManager . error ( "Gagal Mengambil Data!!" , "Failed" ) ;
}
} ;
const getProjectIssue = async ( id ) => {
const payload = {
select : [
"id" ,
"proyek_id" ,
"description" ,
"level_issue"
] ,
columns : [ { name : "proyek_id" , logic _operator : "=" , value : parseInt ( id ) } ] ,
joins : [ ] ,
orders : { columns : [ "id" ] , ascending : true } ,
paging : { start : 0 , length : - 1 } ,
} ;
const result = await axios
. post ( PROJECT _ISSUE _SEARCH , payload , HEADER )
. then ( ( res ) => res )
. catch ( ( error ) => error . response ) ;
if ( result && result . data && result . data . code == 200 ) {
let dataRes = result . data . data ;
const filteredData = dataRes . filter ( item => item . proyek _id === parseInt ( id ) ) ;
setProjectIssue ( filteredData ) ;
} else {
NotificationManager . error ( "Gagal Mengambil Data!!" , "Failed" ) ;
}
} ;
const getProjectRisk = async ( id ) => {
const payload = {
select : [
"id" ,
"proyek_id" ,
"description" ,
"preventive_risk" ,
"level_risk"
] ,
columns : [ { name : "proyek_id" , logic _operator : "=" , value : parseInt ( id ) } ] ,
joins : [ ] ,
orders : { columns : [ "id" ] , ascending : true } ,
paging : { start : 0 , length : - 1 } ,
} ;
const result = await axios
. post ( PROJECT _RISK _SEARCH , payload , HEADER )
. then ( ( res ) => res )
. catch ( ( error ) => error . response ) ;
if ( result && result . data && result . data . code == 200 ) {
let dataRes = result . data . data ;
const filteredData = dataRes . filter ( item => item . proyek _id === parseInt ( id ) ) ;
setProjectRisk ( filteredData ) ;
} else {
NotificationManager . error ( "Gagal Mengambil Data!!" , "Failed" ) ;
}
@ -601,7 +810,8 @@ const CreatedProyek = ({ params, ...props }) => {
if ( result && result . data && result . data . code == 200 ) {
let dataRes = result . data . data ;
setProjectApproval ( dataRes ) ;
const filteredData = dataRes . filter ( item => item . proyek _id === parseInt ( id ) ) ;
setProjectApproval ( filteredData ) ;
} else {
NotificationManager . error ( "Gagal Mengambil Data!!" , "Failed" ) ;
}
@ -626,8 +836,14 @@ const CreatedProyek = ({ params, ...props }) => {
const handleCloseDialogView = ( ) => {
setProjectApproval ( null ) ;
setProjectParticipant ( null ) ;
setProjectChecklist ( null ) ;
setProjectIssue ( null ) ;
setProjectRisk ( null ) ;
setProjectMilestone ( null ) ;
setProjectCharter ( null ) ;
setK3Search ( null ) ;
setProjectAssignHR ( null ) ;
setProjectImage ( null ) ;
setOpenDialogViewDetail ( false ) ;
} ;
@ -637,8 +853,14 @@ const CreatedProyek = ({ params, ...props }) => {
if ( openDialogViewDetail ) {
setProjectApproval ( null ) ;
setProjectParticipant ( null ) ;
setProjectChecklist ( null ) ;
setProjectIssue ( null ) ;
setProjectRisk ( null ) ;
setProjectMilestone ( null ) ;
setProjectCharter ( null ) ;
setK3Search ( null ) ;
setProjectAssignHR ( null ) ;
setProjectImage ( null ) ;
}
setOpenDialogViewDetail ( ! openDialogViewDetail ) ;
} ;
@ -652,7 +874,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!!" ) ;
@ -671,11 +894,25 @@ const CreatedProyek = ({ params, ...props }) => {
. then ( ( res ) => res )
. catch ( ( error ) => error . response ) ;
if ( result && result . data && result . data . code === 200 ) {
const { participants , milestones , approval } = data . projectCharter ;
const { checklist , issue , potentialRisks , participants , milestones , approval } = data . projectCharter ;
const imageObject = data . imageStructureOrg ;
const resultParticipant = await saveParticipant (
result . data . data _result . id ,
participants
) ;
const resultChecklist = await saveChecklist (
result . data . data _result . id ,
checklist
) ;
const resultIssue = await saveIssue (
result . data . data _result . id ,
issue
) ;
const resultRisk = await saveRisk (
result . data . data _result . id ,
potentialRisks
) ;
const resultMilestone = await saveMilestone (
result . data . data _result . id ,
milestones
@ -684,12 +921,21 @@ const CreatedProyek = ({ params, ...props }) => {
result . data . data _result . id ,
approval
) ;
if ( imageObject ) {
await saveImage (
result . data . data _result . id ,
imageObject
) ;
}
if (
resultChecklist === "berhasil" &&
resultIssue === "berhasil" &&
resultRisk === "berhasil" &&
resultParticipant === "berhasil" &&
resultMilestone === "berhasil" &&
resultApproval === "berhasil"
) {
// getDataProyek();
NotificationManager . success (
` Data proyek berhasil ditambah ` ,
"Success!!"
@ -724,6 +970,67 @@ const CreatedProyek = ({ params, ...props }) => {
return "berhasil" ;
} ;
const saveChecklist = async ( id , data ) => {
const request = data . map ( ( res ) => {
const payload = {
proyek _id : parseInt ( id ) ,
item : res . item ,
status _exist : res . status _exist ,
} ;
return axios . post ( PROJECT _CHECKLIST _ADD , payload , HEADER ) ;
} ) ;
const arr = await Promise . all ( request )
. then ( ( values ) => values )
. catch ( ( err ) => err . response ) ;
const result = arr . map ( ( res ) => res . data . code == 200 ) ;
if ( result . length > 0 ) {
return "gagal" ;
}
return "berhasil" ;
} ;
const saveIssue = async ( id , data ) => {
const request = data . map ( ( res ) => {
const payload = {
proyek _id : parseInt ( id ) ,
description : res . description ,
level _issue : res . level _issue ,
} ;
return axios . post ( PROJECT _ISSUE _ADD , payload , HEADER ) ;
} ) ;
const arr = await Promise . all ( request )
. then ( ( values ) => values )
. catch ( ( err ) => err . response ) ;
const result = arr . map ( ( res ) => res . data . code == 200 ) ;
if ( result . length > 0 ) {
return "gagal" ;
}
return "berhasil" ;
} ;
const saveRisk = async ( id , data ) => {
const request = data . map ( ( res ) => {
const payload = {
proyek _id : parseInt ( id ) ,
level _risk : res . level _risk ,
description : res . description ,
preventive _risk : res . preventive _risk ,
} ;
return axios . post ( PROJECT _RISK _ADD , payload , HEADER ) ;
} ) ;
const arr = await Promise . all ( request )
. then ( ( values ) => values )
. catch ( ( err ) => err . response ) ;
const result = arr . map ( ( res ) => res . data . code == 200 ) ;
if ( result . length > 0 ) {
return "gagal" ;
}
return "berhasil" ;
} ;
const saveMilestone = async ( id , data ) => {
const request = data . map ( ( res ) => {
const payload = {
@ -766,8 +1073,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 { checklist , issue , potentialRisks , participants , milestones , approval } = data . projectCharter ;
const imageObject = data . imageStructureOrg ;
let urlEdit = PROYEK _EDIT ( data . id ) ;
const formData = data ;
@ -778,6 +1110,18 @@ 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 ) ;
const resultChecklist = await editChecklist ( data . id , checklist ) ;
const resultIssue = await editIssue ( data . id , issue ) ;
const resultRisk = await editRisk ( data . id , potentialRisks ) ;
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!!" ) ;
@ -786,13 +1130,76 @@ const CreatedProyek = ({ params, ...props }) => {
}
} ;
const editChecklist = async ( id , data ) => {
await axios . delete ( PROJECT _CHECKLIST _DELETE _BY _PROYEK ( id ) , HEADER ) ;
const request = data . map ( ( res ) => {
const payload = {
proyek _id : parseInt ( id ) ,
item : res . item ? res . item : res . item ,
status _exist : res . status _exist ,
} ;
return axios . post ( PROJECT _CHECKLIST _ADD , payload , HEADER ) ;
} ) ;
const arr = await Promise . all ( request )
. then ( ( values ) => values )
. catch ( ( err ) => err . response ) ;
const result = arr . map ( ( res ) => res . data . code !== 200 ) ;
if ( result . length > 0 ) {
return "gagal" ;
}
return "berhasil" ;
} ;
const editIssue = async ( id , data ) => {
await axios . delete ( PROJECT _ISSUE _DELETE _BY _PROYEK ( id ) , HEADER ) ;
const request = data . map ( ( res ) => {
const payload = {
proyek _id : parseInt ( id ) ,
description : res . description ? res . description : res . description ,
level _issue : res . level _issue ,
} ;
return axios . post ( PROJECT _ISSUE _ADD , payload , HEADER ) ;
} ) ;
const arr = await Promise . all ( request )
. then ( ( values ) => values )
. catch ( ( err ) => err . response ) ;
const result = arr . map ( ( res ) => res . data . code !== 200 ) ;
if ( result . length > 0 ) {
return "gagal" ;
}
return "berhasil" ;
} ;
const editRisk = async ( id , data ) => {
await axios . delete ( PROJECT _RISK _DELETE _BY _PROYEK ( id ) , HEADER ) ;
const request = data . map ( ( res ) => {
const payload = {
proyek _id : parseInt ( id ) ,
level _risk : res . level _risk ,
description : res . description ? res . description : res . description ,
preventive _risk : res . preventive _risk ? res . preventive _risk : res . preventive _risk
} ;
return axios . post ( PROJECT _RISK _ADD , payload , HEADER ) ;
} ) ;
const arr = await Promise . all ( request )
. then ( ( values ) => values )
. catch ( ( err ) => err . response ) ;
const result = arr . map ( ( res ) => res . data . code !== 200 ) ;
if ( result . length > 0 ) {
return "gagal" ;
}
return "berhasil" ;
} ;
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 ) ,
tittle : res . tittle ? res . tittle : res . title ,
tittle : res . tittle ? res . tittle : res . titt le ,
name : res . name ,
} ;
return axios . post ( PROJECT _PARTICIPANT _ADD , payload , HEADER ) ;
@ -1342,6 +1749,7 @@ const CreatedProyek = ({ params, ...props }) => {
dataPhaseProject = { dataPhaseProject }
dataDivisions = { dataDivisions }
dataPM = { dataPm }
projectImage = { image }
/ >
) ,
[
@ -1351,6 +1759,7 @@ const CreatedProyek = ({ params, ...props }) => {
dataPhaseProject ,
dataTypeProyek ,
idTask ,
image
]
) ;
@ -1464,8 +1873,15 @@ const CreatedProyek = ({ params, ...props }) => {
toggleDialog = { toggleAddDialogView }
projectCharter = { projectCharter }
projectParticipant = { projectParticipant }
projectChecklist = { projectChecklist }
projectIssue = { projectIssue }
projectRisk = { projectRisk }
projectMilestone = { projectMilestone }
projectApproval = { projectApproval }
projectManager = { projectPM }
projectK3 = { projectK3Search }
assignHR = { projectAssignHR }
projectImage = { image }
/ >
) ,
[ openDialogViewDetail ]