|
|
|
@ -332,18 +332,35 @@ const DialogFormProyek = ({
|
|
|
|
|
setHealthBudget(val); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const onChangePm = (val) => { |
|
|
|
|
let data = [...dataPM]; |
|
|
|
|
var item = data.find((item) => item.id === val); |
|
|
|
|
participants.push({ |
|
|
|
|
id: lastIdxParticipants + 1, |
|
|
|
|
title: "PM", |
|
|
|
|
name: item.name, |
|
|
|
|
}); |
|
|
|
|
setParticipants(participants); |
|
|
|
|
setLastIdxParticipants(lastIdxParticipants + 1); |
|
|
|
|
setPic(val); |
|
|
|
|
}; |
|
|
|
|
const onChangePm = (val) => { |
|
|
|
|
const item = dataPM.find((item) => item.id === val); |
|
|
|
|
const existingParticipant = participants.find((participant) => participant.tittle === "PM"); |
|
|
|
|
if (existingParticipant) { |
|
|
|
|
setParticipants((prevParticipants) => { |
|
|
|
|
return prevParticipants.map((participant) => { |
|
|
|
|
if (participant.tittle === "PM") { |
|
|
|
|
return { |
|
|
|
|
...participant, |
|
|
|
|
name: item.name, |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
return participant; |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
setParticipants((prevParticipants) => [ |
|
|
|
|
...prevParticipants, |
|
|
|
|
{ |
|
|
|
|
id: item.id, |
|
|
|
|
tittle: "PM", |
|
|
|
|
name: item.name, |
|
|
|
|
}, |
|
|
|
|
]); |
|
|
|
|
setLastIdxParticipants(lastIdxParticipants + 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
setPic(val); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const onChangeCurrency = (val) => { |
|
|
|
|
let curr = val.split("|"); // code|symbol|name
|
|
|
|
@ -399,7 +416,7 @@ const DialogFormProyek = ({
|
|
|
|
|
const addParticipant = () => { |
|
|
|
|
participants.push({ |
|
|
|
|
id: lastIdxParticipants + 1, |
|
|
|
|
title: "", |
|
|
|
|
tittle: "", |
|
|
|
|
name: "", |
|
|
|
|
}); |
|
|
|
|
setParticipants(participants); |
|
|
|
@ -438,7 +455,24 @@ const DialogFormProyek = ({
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const handleInputChangeParticipants = (e, index) => { |
|
|
|
|
const { name, value } = e.target; |
|
|
|
|
const { name, value } = e.target; |
|
|
|
|
const existingParticipant = participants.find((participant) => participant.tittle === "PM"); |
|
|
|
|
if(value.toLowerCase() === "pm" && name === "tittle" && existingParticipant) |
|
|
|
|
{ |
|
|
|
|
alert('PM is already exist!'); |
|
|
|
|
setParticipants((prevParticipants) => |
|
|
|
|
prevParticipants.map((participant, i) => { |
|
|
|
|
if (i === index) { |
|
|
|
|
return { |
|
|
|
|
...participant, |
|
|
|
|
tittle: "", |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
return participant; |
|
|
|
|
}) |
|
|
|
|
); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
const newParticipants = [...participants]; |
|
|
|
|
newParticipants[index][name] = value; |
|
|
|
|
setParticipants(newParticipants); |
|
|
|
@ -566,7 +600,7 @@ const DialogFormProyek = ({
|
|
|
|
|
const addApproval = () => { |
|
|
|
|
approval.push({ |
|
|
|
|
id: lastIdxApproval + 1, |
|
|
|
|
title: "", |
|
|
|
|
tittle: "", |
|
|
|
|
name: "", |
|
|
|
|
date: moment(), |
|
|
|
|
}); |
|
|
|
@ -1321,8 +1355,8 @@ const DialogFormProyek = ({
|
|
|
|
|
<Col md={4}> |
|
|
|
|
<Input |
|
|
|
|
type="text" |
|
|
|
|
value={item.tittle ? item.tittle : "-"} |
|
|
|
|
name="title" |
|
|
|
|
value={item.tittle} |
|
|
|
|
name="tittle" |
|
|
|
|
onChange={(e) => handleInputChangeParticipants(e, index)} |
|
|
|
|
/> |
|
|
|
|
</Col> |
|
|
|
@ -1421,7 +1455,7 @@ const DialogFormProyek = ({
|
|
|
|
|
<Col md={3}> |
|
|
|
|
<Input |
|
|
|
|
type="text" |
|
|
|
|
value={item.tittle ? item.tittle : item.title} |
|
|
|
|
value={item.tittle ? item.tittle : item.tittle} |
|
|
|
|
name="title" |
|
|
|
|
onChange={(e) => handleInputChangeApproval(e, index)} |
|
|
|
|
/> |
|
|
|
|