diff --git a/src/const/ApiConst.js b/src/const/ApiConst.js
index b62ce17..70a9742 100644
--- a/src/const/ApiConst.js
+++ b/src/const/ApiConst.js
@@ -1,10 +1,10 @@
import { appConfig, MAP_ID } from './MapConst';
const roleName = window.localStorage.getItem('role_name');
-
-
-
const HOST = "https://osmap.id"; // online
+export const API_ADW = "http://ospro-api.adyawinsa.com:9083/api/";
+export const TOKEN_ADW = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIxMjAyIiwiZXhwIjoxNjkxODMwNDkzfQ.DvBQIOZsdFndWsliPCZT65Y6G5Xx4vWBKz8Rhe7rvRA";
+
export const BASE_URL_GEOHR_API = "https://oslog.id/geohr-api";
export const BASE_URL_GEOHR_API2 = "http://siopas.co.id/custom-php/api/geohr";
diff --git a/src/views/SimproV2/CreatedProyek/AsignHrProject.js b/src/views/SimproV2/CreatedProyek/AsignHrProject.js
index 8fa7560..a6e6cb5 100644
--- a/src/views/SimproV2/CreatedProyek/AsignHrProject.js
+++ b/src/views/SimproV2/CreatedProyek/AsignHrProject.js
@@ -4,7 +4,7 @@ import { Button, Form } from 'reactstrap';
import { Table, Tooltip } from 'antd';
import 'antd/dist/antd.css';
import moment from 'moment';
-import { 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 { 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 axios from "../../../const/interceptorApi"
import { NotificationContainer, NotificationManager } from 'react-notifications';
import SweetAlert from 'react-bootstrap-sweetalert';
@@ -12,287 +12,291 @@ import FormAsignHr from './FormAsignHr';
import { formatThousand } from '../../../const/CustomFunc';
const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsResource, proyekName }) => {
- const token = localStorage.getItem("token")
- const HEADER = {
- headers: {
- "Content-Type": "application/json",
- "Authorization": `Bearer ${token}`
- }
- }
- const [dataUserToProject, setdataUserToProject] = useState([])
- 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) {
- getDataAssignHr();
- }
- }, [openDialog]);
-
- useEffect(() => {
- getDataUser();
- getDataProjectRole();
- }, [])
-
- const getDataAssignHr = async () => {
- const payload = {
- "paging": {
- "start": 0,
- "length": -1
- },
- "columns": [
- { "name": "name", "logic_operator": "ilike", "value": "", "table_name": "m_users" },
- { "name": "proyek_id", "logic_operator": "=", "value": idTask }
- ],
- "joins": [
- { "name": "m_users", "column_join": "user_id", "column_results": ["name"] },
- { "name": "m_role_proyek", "column_join": "project_role", "column_results": ["name"] },
- ],
- "orders": {
- "columns": [
- "id"
- ],
- "ascending": false
- }
- }
- const URL = ASSIGN_HR_PROJECT_SEARCH
- const result = await axios
- .post(URL, payload, HEADER)
- .then(res => res)
- .catch((error) => error.response);
-
- if (result && result.data && result.data.code == 200) {
- let dataRes = result.data.data || []
-
- setdataUserToProject(dataRes);
- } else {
- NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
- }
- }
-
- const getDataUser = async () => {
- const result = await axios
- .get(USER_LIST, HEADER)
- .then(res => res)
- .catch((error) => error.response);
-
- if (result && result.data && result.data.code == 200) {
- let dataRes = result.data.data
- setListUser(dataRes)
- } else {
- }
- }
-
- 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)
- }
-
- const cancelDelete = () => {
- setAlertDelete(false)
- setIdDelete(0)
- }
-
- const onConfirmDelete = async () => {
- let urlDel = ASSIGN_HR_PROJECT_DELETE(idDelete)
- const result = await axios.delete(urlDel, HEADER)
- .then(res => res)
- .catch((error) => error.response);
-
- if (result && result.data && result.data.code === 200) {
- getDataAssignHr()
- setIdDelete(0)
- setAlertDelete(false)
- NotificationManager.success(`Data assign human resource berhasil dihapus`, 'Success!!');
- } else {
- setIdDelete(0)
- setAlertDelete(false)
- NotificationManager.error(`Data assign human resource gagal dihapus`, 'Failed!!');
- }
- }
-
- const handleEdit = async (data) => {
- await setDataEdit(data)
- setOpenDialogFormTools(true)
- }
-
- const handleOpenDialogFormTools = () => {
- setOpenDialogFormTools(true)
- }
-
- const handleCancel = () => {
- closeDialog('cancel', 'none')
- }
-
-
- const RenderTable = useMemo(() => {
- const columns = [
- {
- title: 'Action',
- dataIndex: '',
- key: 'x',
- className: "nowrap",
- render: (text, record) => <>
-
- {" "}
-
- >,
- },
- { 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" },
-
- ];
-
- return (
-
- )
- }, [dataUserToProject])
-
- const renderForm = () => {
- return (
-
- {RenderTable}
-
- )
- }
-
- 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)
- setOpenDialogFormTools(false)
- } else {
- NotificationManager.error('assign human resource gagal diedit!!', 'Failed');
- }
- }
-
- const toogleDialogFormTools = () => {
- if (openDialogFormTools) {
- setDataEdit(null)
- }
- setOpenDialogFormTools(!openDialogFormTools)
- }
-
-
- return (
- <>
-
- cancelDelete()}
- focusCancelBtn
- >
- Delete this data
-
-
-
-
- Assign Human Resource - {proyekName}
-
-
- {renderForm()}
-
- {/*
-
- */}
-
-
- >
- )
+ const token = localStorage.getItem("token")
+ const HEADER = {
+ headers: {
+ "Content-Type": "application/json",
+ "Authorization": `Bearer ${token}`
+ }
+ }
+ const [dataUserToProject, setdataUserToProject] = useState([])
+ 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) {
+ getDataAssignHr();
+ }
+ }, [openDialog]);
+
+ useEffect(() => {
+ getDataUser();
+ getDataProjectRole();
+ }, [])
+
+ const getDataAssignHr = async () => {
+ const payload = {
+ "paging": {
+ "start": 0,
+ "length": -1
+ },
+ "columns": [
+ { "name": "name", "logic_operator": "ilike", "value": "", "table_name": "m_users" },
+ { "name": "proyek_id", "logic_operator": "=", "value": idTask }
+ ],
+ "joins": [
+ { "name": "m_users", "column_join": "user_id", "column_results": ["name"] },
+ { "name": "m_role_proyek", "column_join": "project_role", "column_results": ["name"] },
+ ],
+ "orders": {
+ "columns": [
+ "id"
+ ],
+ "ascending": false
+ }
+ }
+ const URL = ASSIGN_HR_PROJECT_SEARCH
+ const result = await axios
+ .post(URL, payload, HEADER)
+ .then(res => res)
+ .catch((error) => error.response);
+
+ if (result && result.data && result.data.code == 200) {
+ let dataRes = result.data.data || []
+
+ setdataUserToProject(dataRes);
+ } else {
+ NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
+ }
+ }
+
+ const getDataUser = async () => {
+ const HEADER_ADW = {
+ headers: {
+ "Authorization": `${TOKEN_ADW}`
+ }
+ }
+ const result = await axios
+ .get(`${API_ADW}employees`, HEADER_ADW)
+ // .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)
+ }
+
+ const cancelDelete = () => {
+ setAlertDelete(false)
+ setIdDelete(0)
+ }
+
+ const onConfirmDelete = async () => {
+ let urlDel = ASSIGN_HR_PROJECT_DELETE(idDelete)
+ const result = await axios.delete(urlDel, HEADER)
+ .then(res => res)
+ .catch((error) => error.response);
+
+ if (result && result.data && result.data.code === 200) {
+ getDataAssignHr()
+ setIdDelete(0)
+ setAlertDelete(false)
+ NotificationManager.success(`Data assign human resource berhasil dihapus`, 'Success!!');
+ } else {
+ setIdDelete(0)
+ setAlertDelete(false)
+ NotificationManager.error(`Data assign human resource gagal dihapus`, 'Failed!!');
+ }
+ }
+
+ const handleEdit = async (data) => {
+ await setDataEdit(data)
+ setOpenDialogFormTools(true)
+ }
+
+ const handleOpenDialogFormTools = () => {
+ setOpenDialogFormTools(true)
+ }
+
+ const handleCancel = () => {
+ closeDialog('cancel', 'none')
+ }
+
+
+ const RenderTable = useMemo(() => {
+ const columns = [
+ {
+ title: 'Action',
+ dataIndex: '',
+ key: 'x',
+ className: "nowrap",
+ render: (text, record) => <>
+
+ {" "}
+
+ >,
+ },
+ { 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" },
+
+ ];
+
+ return (
+
+ )
+ }, [dataUserToProject])
+
+ const renderForm = () => {
+ return (
+
+ {RenderTable}
+
+ )
+ }
+
+ 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)
+ setOpenDialogFormTools(false)
+ } else {
+ NotificationManager.error('assign human resource gagal diedit!!', 'Failed');
+ }
+ }
+
+ const toogleDialogFormTools = () => {
+ if (openDialogFormTools) {
+ setDataEdit(null)
+ }
+ setOpenDialogFormTools(!openDialogFormTools)
+ }
+
+
+ return (
+ <>
+
+ cancelDelete()}
+ focusCancelBtn
+ >
+ Delete this data
+
+
+
+
+ Assign Human Resource - {proyekName}
+
+
+ {renderForm()}
+
+ {/*
+
+ */}
+
+
+ >
+ )
}
-export default AssignHrProject;
\ No newline at end of file
+export default AssignHrProject;
diff --git a/src/views/SimproV2/CreatedProyek/DialogFormResource.js b/src/views/SimproV2/CreatedProyek/DialogFormResource.js
index d788e6e..da37687 100644
--- a/src/views/SimproV2/CreatedProyek/DialogFormResource.js
+++ b/src/views/SimproV2/CreatedProyek/DialogFormResource.js
@@ -110,7 +110,6 @@ const DialogFormResource = ({ openDialog, closeDialog, toggleDialog, idTask, use
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
- console.log("cek user resource", result.data.data)
let dataRes = result.data.data || []
setUserToProyek(dataRes);
@@ -304,4 +303,4 @@ const DialogFormResource = ({ openDialog, closeDialog, toggleDialog, idTask, use
}
-export default DialogFormResource;
\ No newline at end of file
+export default DialogFormResource;