@ -4,14 +4,16 @@ import { Button, Form } from 'reactstrap';
import { Table , Tooltip } from 'antd' ;
import 'antd/dist/antd.css' ;
import moment from 'moment' ;
import { API _ADW , TOKEN _ADW , ASSIGN _HR _PROJECT _SEARCH , ASSIGN _HR _PROJECT _DELETE , USER _LIST , PROJECT _ROLE _SEARCH , ASSIGN _HR _PROJECT _ADD , ASSIGN _HR _PROJECT _EDIT } from '../../../const/ApiConst' ;
import {
ASSIGN _HR _PROJECT _SEARCH ,
ASSIGN _HR _PROJECT _DELETE
} from '../../../const/ApiConst' ;
import axios from "../../../const/interceptorApi"
import { NotificationContainer , NotificationManager } from 'react-notifications' ;
import SweetAlert from 'react-bootstrap-sweetalert' ;
import FormAsignCust from './DialogAssignCust' ;
import { formatThousand } from '../../../const/CustomFunc' ;
const AssignHr Project = ( { openDialog , closeDialog , toggleDialog , idTask , toolsResource , proyekName } ) => {
const AssignCust Project = ( { openDialog , closeDialog , toggleDialog , idTask , proyekName } ) => {
const token = localStorage . getItem ( "token" )
const HEADER = {
headers : {
@ -23,9 +25,6 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsR
const [ alertDelete , setAlertDelete ] = useState ( false )
const [ idDelete , setIdDelete ] = useState ( 0 )
const [ openDialogFormTools , setOpenDialogFormTools ] = useState ( false )
const [ dataEdit , setDataEdit ] = useState ( null )
const [ listUser , setListUser ] = useState ( [ ] )
const [ listRole , setListRole ] = useState ( [ ] )
useEffect ( ( ) => {
if ( idTask > 0 ) {
@ -35,8 +34,6 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsR
useEffect ( ( ) => {
if ( openDialog ) {
getDataProjectRole ( ) ;
getDataUser ( ) ;
}
} , [ dataUserToProject ] )
@ -76,52 +73,6 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsR
}
}
const getDataUser = async ( ) => {
const HEADER _ADW = {
headers : {
"Authorization" : ` ${ TOKEN _ADW } `
}
}
const result = await axios
. get ( USER _LIST , HEADER )
. then ( res => res )
. catch ( ( error ) => error . response ) ;
if ( result && result . data && result . data . data . length != 0 ) {
let dataRes = result . data . data
setListUser ( dataRes )
}
}
const getDataProjectRole = async ( ) => {
const payload = {
"paging" : {
"start" : 0 ,
"length" : - 1
} ,
"columns" : [
{ "name" : "created_by" , "logic_operator" : "ilike" , "value" : "" } ,
] ,
"joins" : [ ] ,
"orders" : {
"columns" : [
"id"
] ,
"ascending" : false
}
}
const result = await axios
. post ( PROJECT _ROLE _SEARCH , payload , HEADER )
. then ( res => res )
. catch ( ( error ) => error . response ) ;
if ( result && result . data && result . data . code == 200 ) {
let dataRes = result . data . data || [ ]
setListRole ( dataRes ) ;
} else {
}
}
const handleDelete = ( id ) => {
setIdDelete ( id )
setAlertDelete ( true )
@ -142,11 +93,11 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsR
getDataAssignHr ( )
setIdDelete ( 0 )
setAlertDelete ( false )
NotificationManager . success ( ` Data assign human resource berhasil dihapus ` , 'Success!!' ) ;
NotificationManager . success ( ` Data assign customer berhasil dihapus ` , 'Success!!' ) ;
} else {
setIdDelete ( 0 )
setAlertDelete ( false )
NotificationManager . error ( ` Data assign human resource gagal dihapus ` , 'Failed!!' ) ;
NotificationManager . error ( ` Data assign customer gagal dihapus ` , 'Failed!!' ) ;
}
}
@ -167,18 +118,11 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsR
dataIndex : '' ,
key : 'x' ,
className : "nowrap" ,
render : ( text , record ) => < > < Tooltip title = "Delete Request Resource" >
render : ( text , record ) => < > < Tooltip title = { ` Delete Request Resource ${ text . id } ` } >
< Button size = { "sm" } color = 'danger' onClick = { ( ) => handleDelete ( text . id ) } > < i className = "fa fa-trash" > < / i > < / B u t t o n >
< /Tooltip>{" "}</ > ,
} ,
{ title : 'Name Human Resource' , dataIndex : 'join_first_name' , key : 'join_first_name' , className : "nowrap" } ,
{ title : 'Role Human Resource' , dataIndex : 'join_second_name' , key : 'join_second_name' , className : "nowrap" } ,
{ title : 'Percentage Available User' , dataIndex : 'max_used' , key : 'max_used' , className : "nowrap" , render : ( text , record ) => record . max _used ? formatThousand ( record . max _used ) : '-' } ,
{ title : 'Standard Rate' , dataIndex : 'standart_rate' , key : 'standart_rate' , className : "nowrap" , render : ( text , record ) => record . standart _rate ? formatThousand ( record . standart _rate ) : '-' } ,
{ title : 'UOM Standard Rate' , dataIndex : 'uom_standart_rate' , key : 'uom_standart_rate' , className : "nowrap" } ,
{ title : 'Overtime Rate' , dataIndex : 'overtime_rate' , key : 'overtime_rate' , className : "nowrap" , render : ( text , record ) => record . overtime _rate ? formatThousand ( record . overtime _rate ) : '-' } ,
{ title : 'UOM Overtime Rate' , dataIndex : 'uom_overtime_rate' , key : 'uom_overtime_rate' , className : "nowrap" } ,
{ title : 'Name Human Resource' , dataIndex : 'join_first_name' , key : 'join_first_name' , className : "nowrap" }
] ;
return (
@ -199,53 +143,24 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsR
)
}
const handleCloseDialogFormTools = ( type , data ) => {
if ( type == "add" ) {
addDataAssignHr ( data ) ;
} else if ( type == "edit" ) {
editDataAssignHr ( data ) ;
} else {
setDataEdit ( null )
setOpenDialogFormTools ( false )
}
}
const addDataAssignHr = async ( payload ) => {
const result = await axios
. post ( ASSIGN _HR _PROJECT _ADD , payload , HEADER )
. then ( res => res )
. catch ( ( error ) => error . response ) ;
if ( result && result . data && result . data . code == 200 ) {
getDataAssignHr ( ) ;
NotificationManager . success ( 'assign human resource berhasil!!' , 'Success' ) ;
setDataEdit ( null )
setOpenDialogFormTools ( false )
} else {
NotificationManager . error ( 'assign human resource gagal!!' , 'Failed' ) ;
}
}
const editDataAssignHr = async ( payload ) => {
let url = ASSIGN _HR _PROJECT _EDIT ( payload . id )
const result = await axios
. put ( url , payload , HEADER )
. then ( res => res )
. catch ( ( error ) => error . response ) ;
if ( result && result . data && result . data . code == 200 ) {
getDataAssignHr ( ) ;
NotificationManager . success ( 'assign human resource berhasil diedit!!' , 'Success' ) ;
setDataEdit ( null )
const handleCloseDialogFormTools = ( type , data ) => {
if ( type === "add" ) getDataAssignHr ( ) ;
if ( type === "success" ) {
NotificationManager . success (
` Assign Customer Project berhasil disimpan! ` ,
"Success!!"
) ;
} else if ( type === "failed" ) {
NotificationManager . error (
` Assign Customer Project gagal disimpan! ` ,
"Failed!!"
) ;
}
setOpenDialogFormTools ( false )
} else {
NotificationManager . error ( 'assign human resource gagal diedit!!' , 'Failed' ) ;
}
}
const toogleDialogFormTools = ( ) => {
if ( openDialogFormTools ) {
setDataEdit ( null )
}
setOpenDialogFormTools ( ! openDialogFormTools )
}
@ -281,14 +196,10 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsR
closeDialog = { handleCloseDialogFormTools }
toggleDialog = { toogleDialogFormTools }
idTask = { idTask }
dataEdit = { dataEdit }
dataHr = { listUser }
dataRole = { listRole }
dataCurrentHr = { dataUserToProject }
/ >
< / >
)
}
export default AssignHr Project ;
export default AssignCust Project ;