Browse Source

add button edit

pull/2/head
wahyuun 1 year ago
parent
commit
4618751b15
  1. 23
      src/views/SimproV2/CreatedProyek/DialogGantt.js

23
src/views/SimproV2/CreatedProyek/DialogGantt.js

@ -29,6 +29,8 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName
const [idDelete, setIdDelete] = useState(0) const [idDelete, setIdDelete] = useState(0)
const [idGantt, setIdGantt] = useState(0) const [idGantt, setIdGantt] = useState(0)
const [humanResource, setHumanResource] = useState([]) const [humanResource, setHumanResource] = useState([])
const [dataEdit, setDataEdit] = useState([])
const [typeDialog, setTypeDialog] = useState('')
useEffect(() => { useEffect(() => {
if (openDialog && hierarchyId > 0 || idTask > 0 && !openDialogHierarchy) { if (openDialog && hierarchyId > 0 || idTask > 0 && !openDialogHierarchy) {
@ -104,6 +106,11 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName
setAlertDelete(true) setAlertDelete(true)
} }
const handleEdit = (data) => {
setDataEdit(data)
handleOpenDialogForm('Edit');
}
const handleUserGant = (id) => { const handleUserGant = (id) => {
setIdGantt(id) setIdGantt(id)
setOpenDialogUserGantt(true) setOpenDialogUserGantt(true)
@ -121,6 +128,9 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName
<Tooltip title="Delete Gantt"> <Tooltip title="Delete Gantt">
<Button size={"sm"} color='danger' onClick={() => handleDelete(text.id)}><i className="fa fa-trash"></i></Button> <Button size={"sm"} color='danger' onClick={() => handleDelete(text.id)}><i className="fa fa-trash"></i></Button>
</Tooltip>{" "} </Tooltip>{" "}
<Tooltip title="Edit Gantt">
<Button size={"sm"} color='success' onClick={() => handleEdit(text)}><i className="fa fa-edit"></i></Button>
</Tooltip>{" "}
<Tooltip title="Gantt Permission"> <Tooltip title="Gantt Permission">
<Button size={"sm"} color='success' onClick={() => handleUserGant(text.id)}><i className="fa fa-users"></i></Button> <Button size={"sm"} color='success' onClick={() => handleUserGant(text.id)}><i className="fa fa-users"></i></Button>
</Tooltip>{" "} </Tooltip>{" "}
@ -181,8 +191,9 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName
} }
} }
const handleOpenDialogForm = () => { const handleOpenDialogForm = async (type) => {
setOpenDialogForm(true) await setTypeDialog(type);
setOpenDialogForm(true);
} }
const toggleDialogForm = () => { const toggleDialogForm = () => {
@ -190,12 +201,16 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName
} }
const closeDialogForm = (status) => { const closeDialogForm = (status) => {
if (status == "success") { if (status == "Save") {
getdataGantt() getdataGantt()
NotificationManager.success(`Gantt berhasil dibuat!`, 'Success!!'); NotificationManager.success(`Gantt berhasil dibuat!`, 'Success!!');
}else if (status == "Edit") {
getdataGantt()
NotificationManager.success(`Gantt berhasil dibubah!`, 'Failed!!');
}else if (status == "failed") { }else if (status == "failed") {
NotificationManager.error(`Gantt gagal dibuat!`, 'Failed!!'); NotificationManager.error(`Gantt gagal dibuat!`, 'Failed!!');
} }
setDataEdit([])
setOpenDialogForm(false) setOpenDialogForm(false)
} }
@ -260,6 +275,8 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName
openDialog={openDialogForm} openDialog={openDialogForm}
toggleDialog={toggleDialogForm} toggleDialog={toggleDialogForm}
closeDialog={closeDialogForm} closeDialog={closeDialogForm}
typeDialog={typeDialog}
dataEdit={dataEdit}
/> />
<DialogUserGantt <DialogUserGantt

Loading…
Cancel
Save