From 3f4f5ee2016c69f5e6f955199a196bcd12020f8b Mon Sep 17 00:00:00 2001 From: wahyuun Date: Wed, 2 Aug 2023 16:02:58 +0700 Subject: [PATCH 1/6] perubahan api --- .env | 7 +- src/const/ApiConst.js | 1147 ++++++----- src/views/Dashboard/DashboardProject.js | 2464 +++++++++++++++-------- src/views/SimproV2/Gantt/index.js | 227 ++- 4 files changed, 2379 insertions(+), 1466 deletions(-) diff --git a/.env b/.env index 495d264..1925e46 100644 --- a/.env +++ b/.env @@ -1,3 +1,4 @@ -PORT=3000 -CHOKIDAR_USEPOLLING=true -GENERATE_SOURCEMAP=false \ No newline at end of file +PORT=3000 +CHOKIDAR_USEPOLLING=true +GENERATE_SOURCEMAP=false +SKIP_PREFLIGHT_CHECK=true diff --git a/src/const/ApiConst.js b/src/const/ApiConst.js index 07b56d8..3cbc0b6 100644 --- a/src/const/ApiConst.js +++ b/src/const/ApiConst.js @@ -1,471 +1,676 @@ -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 BASE_URL_GEOHR_API = "https://oslog.id/geohr-api"; -export const BASE_URL_GEOHR_API2 = "http://siopas.co.id/custom-php/api/geohr"; - -export const BASE_API = `${HOST}/osmap-php/index.php`; - -export const BASE_IMAGE = `${HOST}/osmap-php`; -export const BASE_IMAGE_EMPLOYEE = "https://oslog.id/geohr-api/assets/images/employee/" - -export const SIOPAS_API = `${BASE_API}/siopas` - -export const API_LOGIN = `${SIOPAS_API}/user/login` - -export const API_LOG = `${SIOPAS_API}/user/log` - -export const API_USER_SESSION = `${SIOPAS_API}/user/get_valid_session` - -export const API_GET_COLUMN_TABLE = `${BASE_API}/map/getColumnNameAndType` -export const API_CREATE_NEW_LAYER = `${BASE_API}/map/createlayer` - -export const API_LOAD_MAP = `${SIOPAS_API}/map/load/${MAP_ID}` -export const API_UPDATE_MAP = `${SIOPAS_API}/map/update` - -export const API_UPLOAD_IMAGE = `${SIOPAS_API}/feature/uploadimage` -export const API_GET_IMAGE = `${SIOPAS_API}/feature/getimage` - -export const API_UPDATE_FEATURE = `${SIOPAS_API}/feature/update` - -export const API_GET_CHART_TIPE_GEOMETRY = `${SIOPAS_API}/dashboard/chart/tipe-geometry?map_id=${MAP_ID}` -export const API_GET_CHART_KATEGORI = `${SIOPAS_API}/dashboard/chart/tipe-kategori?map_id=${MAP_ID}` - -export const API_LIST_DATA_COUNTRY = `${SIOPAS_API}/country` -export const API_INSERT_DATA_COUNTRY = `${API_LIST_DATA_COUNTRY}/insertDataCountry` -export const API_UPDATE_DATA_COUNTRY = `${API_LIST_DATA_COUNTRY}/updateDataCountry` -export const API_DELETE_DATA_COUNTRY = `${API_LIST_DATA_COUNTRY}/deleteDataCountry` - -export const API_LIST_DATA_DISTRICT = `${SIOPAS_API}/district` -export const API_INSERT_DATA_DISTRICT = `${API_LIST_DATA_DISTRICT}/insertDataDistrict` -export const API_UPDATE_DATA_DISTRICT = `${API_LIST_DATA_DISTRICT}/updateDataDistrict` -export const API_DELETE_DATA_DISTRICT = `${API_LIST_DATA_DISTRICT}/deleteDataDistrict` - -export const API_LIST_DATA_SUBDISTRICT = `${SIOPAS_API}/subdistrict` -export const API_INSERT_DATA_SUBDISTRICT = `${API_LIST_DATA_SUBDISTRICT}/insertDataSubdistrict` -export const API_UPDATE_DATA_SUBDISTRICT = `${API_LIST_DATA_SUBDISTRICT}/updateDataSubdistrict` -export const API_DELETE_DATA_SUBDISTRICT = `${API_LIST_DATA_SUBDISTRICT}/deleteDataSubdistrict` - -export const API_LIST_DATA_PROVINCE = `${SIOPAS_API}/province` -export const API_UPDATE_DATA_PROVINCE = `${API_LIST_DATA_PROVINCE}/updateDataProvince` -export const API_INSERT_DATA_PROVINCE = `${API_LIST_DATA_PROVINCE}/insertDataProvince` -export const API_DELETE_DATA_PROVINCE = `${API_LIST_DATA_PROVINCE}/deleteDataProvince` - -export const API_LIST_DATA_VILLAGE = `${SIOPAS_API}/village` -export const API_UPDATE_DATA_VILLAGE = `${API_LIST_DATA_VILLAGE}/updateDataVillage` -export const API_INSERT_DATA_VILLAGE = `${API_LIST_DATA_VILLAGE}/insertDataVillage` -export const API_DELETE_DATA_VILLAGE = `${API_LIST_DATA_VILLAGE}/deleteDataVillage` - -export const API_LIST_DATA_USERS = `${SIOPAS_API}/user?group_id=${window.localStorage.getItem('group_id')}` -export const API_INSERT_DATA_USERS = `${API_LIST_DATA_USERS}/insertDataUser` -export const API_UPDATE_DATA_USERS = `${API_LIST_DATA_USERS}/updateDataUser` -export const API_DELETE_DATA_USERS = `${API_LIST_DATA_USERS}/deleteDataUser` - -export const API_LAYER_LIST = `${SIOPAS_API}/layer?workspace=${appConfig.workspace_name}` -export const API_LAYER_LABEL = `${SIOPAS_API}/layer/getsearchlabel` -export const API_LAYER_DETAIL = `${SIOPAS_API}/layer/?resourcebase_ptr_id=` -export const API_LAYER_DETAIL_UPDATE = `${SIOPAS_API}/layer/updatelayerdetail` -export const API_LAYER_ATTRIBUTE = `${SIOPAS_API}/layer/getlayerattribute/` -export const API_LAYER_ATTRIBUTE_UPDATE = `${SIOPAS_API}/layer/updatelayerattribute` -export const API_LAYER_ATTRIBUTE_BY_LAYERNAME = `${SIOPAS_API}/layer/getlayerattribute?name=` -export const API_LAYER_SEARCH_LABEL = `${SIOPAS_API}/layer/getsearchlabel/` -export const API_LAYER_SEARCH_LABEL_UPDATE = `${SIOPAS_API}/layer/updatelayersearchlabel` - - - - -export const API_GEOHR_GROUP_SALES_SEARCH = `${BASE_URL_GEOHR_API}/group-sales/search`; -export const API_GEOHR_SALES_MONITORING = `${BASE_URL_GEOHR_API}/sales/monitoring`; -export const API_GEOHR_SALES_SEARCH = `${BASE_URL_GEOHR_API}/sales/search`; -export const API_GEOHR_OFFICE_MONITORING = `${BASE_URL_GEOHR_API}/office/monitoring`; -export const API_GEOHR_CUSTOMER_MONITORING = `${BASE_URL_GEOHR_API}/customer/monitoring`; -export const API_GEOHR_EMPLOYEE_MONITORING = `${BASE_URL_GEOHR_API}/employee/monitoring`; -export const API_GEOHR_WAYPOINT_SALES_MONITORING = (salesId) => `${BASE_URL_GEOHR_API}/waypoint-sales/monitoring?salesId=${salesId}`; -export const API_GEOHR_WAYPOINT_EMPLOYEE_MONITORING = (employeeId) => `${BASE_URL_GEOHR_API}/waypoint-employee/monitoring?employeeId=${employeeId}`; -export const API_GEOHR_DAILY_INFO = `${BASE_URL_GEOHR_API}/dashboard-status-sales`; -export const API_BROADCAST = `${BASE_URL_GEOHR_API}/broadcast` - -export const API_GEOHR_EMPLOYEE_DIVISION_LIST = `${BASE_URL_GEOHR_API2}/employee_devision.php?act=get_data`; -export const API_GEOHR_KARYAWAN = `${BASE_URL_GEOHR_API2}/employee.php?`; -export const API_GEOHR_ROLES = `${BASE_URL_GEOHR_API2}/roles.php?`; -export const API_GEOHR_MENU = `${BASE_URL_GEOHR_API2}/menu.php?`; -export const API_GEOHR_TASK = `${BASE_URL_GEOHR_API2}/task_report.php?`; -export const API_GEOHR_DIVISI_KARYAWAN = `${BASE_URL_GEOHR_API2}/employee_devision.php?`; -export const API_GEOHR_IZIN = `${BASE_URL_GEOHR_API2}/paid_leave.php?`; -export const API_GEOHR_PRESENSI = `${BASE_URL_GEOHR_API2}/clock_in_out.php?`; -export const API_GET_DATA_OFFICE_HOURS = `${BASE_URL_GEOHR_API2}/employee_office_hours.php?`; -export const API_GEOHR_SETTING_OFFICE_HOURS = (type) => `${BASE_URL_GEOHR_API2}/employee_office_hours.php?act=setting&type=${type}`; -export const API_GEOHR_EDIT_OFFICE_HOURS = (id) => `${BASE_URL_GEOHR_API2}/employee_office_hours.php?act=edit&id=${id}`; -export const API_DAILY_INFO = `${BASE_URL_GEOHR_API2}/employee.php?act=get_daily&role_name=${roleName}`; -export const API_DAILY_INFO_DETAIL = (start, length) => `${BASE_URL_GEOHR_API2}/employee.php?act=get_daily_detail&start=${start}&length=${length}&role_name=${roleName}`; - - - -export const APP_MODE = 'ADW' // KIT / ADW / NAWAKARA / IU -export const BASE_SIMPRO = "https://oslog.id/simpro-api/v1"; -export const BASE_SIMPRO_V2 = "https://oslog.id/simpro-api/v2"; -export const BASE_SIMPRO_LUMENNIAGA = "https://ospro-api.odm-iu.com/api"; -export const BASE_INTEGRATION_V1 = "http://ospro-api.adyawinsa.com:9083"; -export const TOKEN_ADW = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIxMjAyIiwiZXhwIjoxNjkxODMwNDkzfQ.DvBQIOZsdFndWsliPCZT65Y6G5Xx4vWBKz8Rhe7rvRA"; - -// export let BASE_OSPRO = "https://ospro-api.ospro.id"; -export let BASE_OSPRO = "https://adw-api.ospro.id"; -// export let BASE_OSPRO = "http://localhost:8444/adw-backend"; -// export let BASE_OSPRO = "http://192.168.1.123:8444"; // local -// export let BASE_OSPRO = "http://103.73.125.81:8444"; // ip public adw -export let BASE_SIMPRO_LUMEN = `${BASE_OSPRO}/api`; -export let BASE_SIMPRO_LUMEN_IMAGE = `${BASE_OSPRO}/assets/image`; -export let BASE_SIMPRO_LUMEN_FILE = `${BASE_OSPRO}/assets/file/project`; - -// switch (APP_MODE) { -// case 'KIT': -// BASE_OSPRO = "https://kit-api.oslogdev.com" - -// //for KIT server -// // BASE_SIMPRO_LUMEN = `${BASE_OSPRO}/api`; -// // BASE_SIMPRO_LUMEN_IMAGE = `${BASE_SIMPRO_LUMEN}/assets/image`; -// // BASE_SIMPRO_LUMEN_FILE = `${BASE_SIMPRO_LUMEN}/assets/file/project`; - -// break; -// case 'ADW': -// // BASE_OSPRO = "https://adw-api.ospro.id" -// BASE_OSPRO = "http://103.73.125.81:8444"; - -// BASE_SIMPRO_LUMEN = `${BASE_OSPRO}/api`; -// BASE_SIMPRO_LUMEN_IMAGE = `${BASE_OSPRO}/assets/image`; -// BASE_SIMPRO_LUMEN_FILE = `${BASE_OSPRO}/assets/file/project`; - -// break; -// case 'IU': -// BASE_OSPRO = "https://api-iu.ospro.id" - -// BASE_SIMPRO_LUMEN = `${BASE_OSPRO}/api`; -// BASE_SIMPRO_LUMEN_IMAGE = `${BASE_OSPRO}/assets/image`; -// BASE_SIMPRO_LUMEN_FILE = `${BASE_OSPRO}/assets/file/project`; - -// break; -// default: -// BASE_OSPRO = "https://ospro-api.ospro.id" -// } - -export const USERROLE_ADD = `${BASE_SIMPRO}/user-role/add` -export const USERROLE_SEARCH = `${BASE_SIMPRO}/user-role/search` -export const USERROLE_EDIT = (id) => { return `${BASE_SIMPRO}/user-role/edit/${id}` } -export const USERROLE_DELETE = (id) => { return `${BASE_SIMPRO}/user-role/delete/${id}` } - -export const USERPROYEK_ADD = `${BASE_SIMPRO}/user-to-proyek/add` -export const USERPROYEK_ADD_DETAIL = `${BASE_SIMPRO}/user-to-proyek/add-detail` -export const USERPROYEK_LIST = `${BASE_SIMPRO}/user-to-proyek/list` -export const USERPROYEK_SEARCH = `${BASE_SIMPRO}/user-to-proyek/search` -export const USERPROYEK_EDIT = (id) => { return `${BASE_SIMPRO}/user-to-proyek/edit/${id}` } -export const USERPROYEK_DELETE = (id) => { return `${BASE_SIMPRO}/user-to-proyek/delete/${id}` } - - - - -export const PRESENSI_ADD = `${BASE_SIMPRO}/clock-in-out/add` -export const PRESENSI_SEARCH = `${BASE_SIMPRO}/clock-in-out/search` -export const PRESENSI_EDIT = (id) => { return `${BASE_SIMPRO}/clock-in-out/edit/${id}` } -export const PRESENSI_DELETE = (id) => { return `${BASE_SIMPRO}/clock-in-out/delete/${id}` } - - -export const PLANNING_ADD = `${BASE_SIMPRO}/laporan-planning/add` -export const PLANNING_SEARCH = `${BASE_SIMPRO}/laporan-planning/search` -export const PLANNING_EDIT = (id) => { return `${BASE_SIMPRO}/laporan-planning/edit/${id}` } -export const PLANNING_DELETE = (id) => { return `${BASE_SIMPRO}/laporan-planning/delete/${id}` } - - - -export const ALERT_ADD = `${BASE_SIMPRO}/alert/add` -export const ALERT_SEARCH = `${BASE_SIMPRO}/alert/search` -export const ALERT_EDIT = (id) => { return `${BASE_SIMPRO}/alert/edit/${id}` } -export const ALERT_DELETE = (id) => { return `${BASE_SIMPRO}/alert/delete/${id}` } - -export const ALERTUSER_ADD = `${BASE_SIMPRO}/alert-to-user/add` -export const ALERTUSER_SEARCH = `${BASE_SIMPRO}/alert-to-user/search` -export const ALERTUSER_EDIT = (id) => { return `${BASE_SIMPRO}/alert-to-user/edit/${id}` } -export const ALERTUSER_DELETE = (id) => { return `${BASE_SIMPRO}/alert-to-user/delete/${id}` } - -export const ALERTUSER_STATUSVIEW = (id) => { return `${BASE_SIMPRO}/alert-to-user/edit-status-view/${id}` } -export const ALERT_STATUSVIEW = (id) => { return `${BASE_SIMPRO}/alert/edit-status-view/${id}` } - -export const SUBPROYEK_ADD = `${BASE_SIMPRO}/sub-proyek/add` -export const SUBPROYEK_SEARCH = `${BASE_SIMPRO}/sub-proyek/search` -export const SUBPROYEK_EDIT = (id) => { return `${BASE_SIMPRO}/sub-proyek/edit/${id}` } -export const SUBPROYEK_DELETE = (id) => { return `${BASE_SIMPRO}/sub-proyek/delete/${id}` } - -export const USER_PROYEK_SEARCH = `${BASE_SIMPRO}/user-proyek/search` -export const PLANNING_REALISASI_SEARCH = `${BASE_SIMPRO}/planning-realisasi/search` - -export const DASHBOARD_PROYEK = `${BASE_SIMPRO}/dashboard-proyek/list` -export const DASHBOARD_PROYEK_SEARCH = `${BASE_SIMPRO}/dashboard-proyek/search` -export const SIMPRO_BASE_IMAGE = `https://oslog.id/simpro-api/assets/images` - -export const API_BROADCAST_SIMPRO = `${BASE_SIMPRO}/broadcast` -export const USER_WASPANG = `${BASE_SIMPRO}/user-role/search` -export const USER_TO_PROYEK_SEARCH = `${BASE_SIMPRO}/user-to-proyek` -export const API_SIMPRO_WAYPOINT_WASPANG_MONITORING = (userId) => `${BASE_SIMPRO}/waypoint-monitoring/${userId}/search`; - - -export const SATUAN_KERJA_GET = `${BASE_SIMPRO}/satuan/list` - -export const DASHBOARD_STATUS_SEARCH = `${BASE_SIMPRO}/dashboard-status/search` -export const GANTT_CONTROL_MONITORING_SEARCH = `${BASE_SIMPRO}/proyek-monitoring/search-detail` - -export const MATERIAL_TO_PROYEK_ADD = `${BASE_SIMPRO}/material-to-proyek/add` -export const MATERIAL_TO_PROYEK_ADD_DETAIL = `${BASE_SIMPRO}/material-to-proyek/add-detail` -export const MATERIAL_TO_PROYEK_SEARCH = `${BASE_SIMPRO}/material-to-proyek/search` -export const MATERIAL_TO_PROYEK_EDIT = (id) => { return `${BASE_SIMPRO}/material-to-proyek/edit/${id}` } -export const MATERIAL_TO_PROYEK_DELETE = (id) => { return `${BASE_SIMPRO}/material-to-proyek/delete/${id}` } - -export const TOOLS_TO_PROYEK_ADD = `${BASE_SIMPRO}/tools-to-proyek/add` -export const TOOLS_TO_PROYEK_ADD_DETAIL = `${BASE_SIMPRO}/tools-to-proyek/add-detail` -export const TOOLS_TO_PROYEK_SEARCH = `${BASE_SIMPRO}/tools-to-proyek/search` -export const TOOLS_TO_PROYEK_EDIT = (id) => { return `${BASE_SIMPRO}/tools-to-proyek/edit/${id}` } -export const TOOLS_TO_PROYEK_DELETE = (id) => { return `${BASE_SIMPRO}/tools-to-proyek/delete/${id}` } - -export const USER_LOGIN_V2 = `${BASE_SIMPRO_LUMEN}/login` -export const USER_TO_PROYEK = `${BASE_SIMPRO_LUMEN}/user-to-project/assign` -export const TOOLS_ASSIGN_PROYEK = `${BASE_SIMPRO_LUMEN}/tools-to-project/assign` -export const MATERIAL_ASSIGN_PROYEK = `${BASE_SIMPRO_LUMEN}/material-to-project/assign` -export const TOOLS_CREATE = `${BASE_SIMPRO_LUMEN}/req-tools/create` - -export const USER_ADD = `${BASE_SIMPRO_LUMEN}/human-resource/add` -export const USER_SEARCH = `${BASE_SIMPRO_LUMEN}/human-resource/search` -export const USER_LIST = `${BASE_SIMPRO_LUMEN}/human-resource/list` -export const USER_SYNC = `${BASE_SIMPRO_LUMEN}/human-resource/sync` -export const USER_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/human-resource/update/${id}` } -export const USER_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/human-resource/delete/${id}` } - -export const ABSENSI_ADD = `${BASE_SIMPRO_LUMEN}/permit/add` -export const ABSENSI_SEARCH = `${BASE_SIMPRO_LUMEN}/permit/search` -export const ABSENSI_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/permit/edit/${id}` } -export const ABSENSI_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/permit/delete/${id}` } - -export const K3_ADD = `${BASE_SIMPRO_LUMEN}/report-k3/add` -export const K3_SEARCH = `${BASE_SIMPRO_LUMEN}/report-k3/search` -export const K3_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/report-k3/edit/${id}` } -export const K3_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/report-k3/delete/${id}` } - -export const DOCUMENT_ADD = `${BASE_SIMPRO_LUMEN}/document-project/upload` -export const DOCUMENT_GET = (id) => { return `${BASE_SIMPRO_LUMEN}/document-project/get/${id}` } -export const DOCUMENT_SEARCH = `${BASE_SIMPRO_LUMEN}/document-project/search` -export const DOCUMENT_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/document-project/update/${id}` } -export const DOCUMENT_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/document-project/delete/${id}` } -export const DOCUMENT_DOWNLOAD = (id) => { return `${BASE_SIMPRO_LUMEN}/document-project/download/${id}` } - -export const ROLE_ADD = `${BASE_SIMPRO_LUMEN}/role/add` -export const ROLE_SEARCH = `${BASE_SIMPRO_LUMEN}/role/search` -export const ROLE_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/role/update/${id}` } -export const ROLE_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/role/delete/${id}` } - -export const REQUEST_MATERIAL_ADD = `${BASE_SIMPRO_LUMEN}/request-material/add` -export const REQUEST_MATERIAL_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/request-material/update/${id}` } -export const REQUEST_MATERIAL_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/request-material/delete/${id}` } -export const REQUEST_MATERIAL_SEARCH = `${BASE_SIMPRO_LUMEN}/request-material/search` -export const REQUEST_MATERIAL_UPDATE_WAREHOUSE_SITE = (id) => { return `${BASE_SIMPRO_LUMEN}/request-material/update-warehouse-site/${id}` } - -export const MENU_ADD = `${BASE_SIMPRO_LUMEN}/menu/add` -export const MENU_MANAGEMENT = (id) => { return `${BASE_SIMPRO_LUMEN}/menu/management/${id}` } -export const MENU_SEARCH = `${BASE_SIMPRO_LUMEN}/menu/search` -export const MENU_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/menu/update/${id}` } -export const MENU_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/menu/delete/${id}` } - -export const ROLEMENU_ADD = `${BASE_SIMPRO_LUMEN}/role-menu/add` -export const ROLEMENU_SEARCH = `${BASE_SIMPRO_LUMEN}/role-menu/search` -export const ROLEMENU_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/role-menu/update/${id}` } -export const ROLEMENU_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/role-menu/delete/${id}` } -export const ROLEMENU_DELETE_ROLE = (id) => { return `${BASE_SIMPRO_LUMEN}/role-menu/delete-byrole/${id}` } - -export const PROYEK_ADD = `${BASE_SIMPRO_LUMEN}/project/add` -export const PROYEK_LIST = `${BASE_SIMPRO_LUMEN}/project/list` -export const PROYEK_SEARCH = `${BASE_SIMPRO_LUMEN}/project/search` -export const PROYEK_SEARCH_DETAIL = `${BASE_SIMPRO_LUMEN}/project/search` -export const PROYEK_GET_ID = (id) => { return `${BASE_SIMPRO_LUMEN}/project/edit/${id}` } -export const PROYEK_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/project/update/${id}` } -export const PROYEK_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/project/delete/${id}` } - -export const PROJECT_ROLE_ADD = `${BASE_SIMPRO_LUMEN}/project-role/add` -export const PROJECT_ROLE_SEARCH = `${BASE_SIMPRO_LUMEN}/project-role/search` -export const PROJECT_ROLE_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/project-role/update/${id}` } -export const PROJECT_ROLE_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/project-role/delete/${id}` } - -export const PROJECT_TYPE_ADD = `${BASE_SIMPRO_LUMEN}/project-type/add` -export const PROJECT_TYPE_SEARCH = `${BASE_SIMPRO_LUMEN}/project-type/search` -export const PROJECT_TYPE_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/project-type/update/${id}` } -export const PROJECT_TYPE_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/project-type/delete/${id}` } -export const TYPE_PROYEK = `${BASE_SIMPRO_LUMEN}/project-type/list` - -export const PROJECT_PHASE_ADD = `${BASE_SIMPRO_LUMEN}/project-phase/add` -export const PROJECT_PHASE_SEARCH = `${BASE_SIMPRO_LUMEN}/project-phase/search` -export const PROJECT_PHASE_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/project-phase/update/${id}` } -export const PROJECT_PHASE_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/project-phase/delete/${id}` } -export const PHASE_PROYEK = `${BASE_SIMPRO_LUMEN}/project-phase/list` - -export const PROJECT_CHARTER_ADD = `${BASE_SIMPRO_LUMEN}/project-charter/add` -export const PROJECT_CHARTER_SEARCH = `${BASE_SIMPRO_LUMEN}/project-charter/search` -export const PROJECT_CHARTER_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/project-charter/update/${id}` } - -export const CONFIGALERT_ADD = `${BASE_SIMPRO_LUMEN}/config-alert/add` -export const CONFIGALERT_SEARCH = `${BASE_SIMPRO_LUMEN}/config-alert/search` -export const CONFIGALERT_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/config-alert/update/${id}` } -export const CONFIGALERT_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/config-alert/delete/${id}` } - -export const CALERTUSER_ADD = `${BASE_SIMPRO_LUMEN}/config-alert-to-user/add` -export const CALERTUSER_SEARCH = `${BASE_SIMPRO_LUMEN}/config-alert-to-user/search` -export const CALERTUSER_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/config-alert-to-user/update/${id}` } -export const CALERTUSER_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/config-alert-to-user/delete/${id}` } - -export const MATERIAL_RESOURCE_ADD = `${BASE_SIMPRO_LUMEN}/material-resource/add` -export const MATERIAL_RESOURCE_SEARCH = `${BASE_SIMPRO_LUMEN}/material-resource/search` -export const MATERIAL_RESOURCE_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/material-resource/update/${id}` } -export const MATERIAL_RESOURCE_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/material-resource/delete/${id}` } -export const MATERIAL_RESOURCE_LIST = `${BASE_SIMPRO_LUMEN}/material-resource/list` - -export const TOOLS_RESOURCE_ADD = `${BASE_SIMPRO_LUMEN}/tools-resource/add` -export const TOOLS_RESOURCE_SEARCH = `${BASE_SIMPRO_LUMEN}/tools-resource/search` -export const TOOLS_RESOURCE_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/tools-resource/update/${id}` } -export const TOOLS_RESOURCE_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/tools-resource/delete/${id}` } -export const TOOLS_RESOURCE_LIST = `${BASE_SIMPRO_LUMEN}/tools-resource/list` - -export const VERSION_GANTT_ADD = `${BASE_SIMPRO_LUMEN}/version-gantt/add` -export const VERSION_GANTT_SEARCH = `${BASE_SIMPRO_LUMEN}/version-gantt/search` -export const VERSION_GANTT_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/version-gantt/update/${id}` } -export const VERSION_GANTT_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/version-gantt/delete/${id}` } -export const VERSION_GANTT_LIST = `${BASE_SIMPRO_LUMEN}/version-gantt/list` - -export const USER_VERSION_GANTT_ADD = `${BASE_SIMPRO_LUMEN}/user-to-version-gantt/add` -export const USER_VERSION_GANTT_ADDS = `${BASE_SIMPRO_LUMEN}/user-to-version-gantt/add-multiple` -export const USER_VERSION_GANTT_SEARCH = `${BASE_SIMPRO_LUMEN}/user-to-version-gantt/search` -export const USER_VERSION_GANTT_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/user-to-version-gantt/update/${id}` } -export const USER_VERSION_GANTT_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/user-to-version-gantt/delete/${id}` } -export const USER_VERSION_GANTT_LIST = `${BASE_SIMPRO_LUMEN}/user-to-version-gantt/list` - -export const REQUEST_TOOLS_ADD = `${BASE_SIMPRO_LUMEN}/req-tools/add` -export const REQUEST_TOOLS_SEARCH = `${BASE_SIMPRO_LUMEN}/req-tools/search` -export const REQUEST_TOOLS_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/req-tools/update/${id}` } -export const REQUEST_TOOLS_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/req-tools/delete/${id}` } - -export const DIVISI_ADD = `${BASE_SIMPRO_LUMEN}/divisi/add` -export const DIVISI_SEARCH = `${BASE_SIMPRO_LUMEN}/divisi/search` -export const DIVISI_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/divisi/update/${id}` } -export const DIVISI_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/divisi/delete/${id}` } -export const DIVISI_LIST = `${BASE_SIMPRO_LUMEN}/divisi/list` - -export const SHIFT_ADD = `${BASE_SIMPRO_LUMEN}/shift/add` -export const SHIFT_SEARCH = `${BASE_SIMPRO_LUMEN}/shift/search` -export const SHIFT_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/shift/update/${id}` } -export const SHIFT_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/shift/delete/${id}` } -export const SHIFT_LIST = `${BASE_SIMPRO_LUMEN}/shift/list` - -export const USER_SHIFT_ADD = `${BASE_SIMPRO_LUMEN}/user-to-shift/add` -export const USER_SHIFT_SEARCH = `${BASE_SIMPRO_LUMEN}/user-to-shift/search` -export const USER_SHIFT_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/user-to-shift/delete/${id}` } -export const USER_SHIFT_LIST = `${BASE_SIMPRO_LUMEN}/user-to-shift/list` - -export const RATE_SALLARY_ADD = `${BASE_SIMPRO_LUMEN}/rate-sallary/add` -export const RATE_SALLARY_SEARCH = `${BASE_SIMPRO_LUMEN}/rate-sallary/search` -export const RATE_SALLARY_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/rate-sallary/update/${id}` } -export const RATE_SALLARY_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/rate-sallary/delete/${id}` } -export const RATE_SALLARY_LIST = `${BASE_SIMPRO_LUMEN}/rate-sallary/list` - -export const TEMPLATE_GANTT_ADD = `${BASE_SIMPRO_LUMEN}/template-gantt/add` -export const TEMPLATE_GANTT_SEARCH = `${BASE_SIMPRO_LUMEN}/template-gantt/search` -export const TEMPLATE_GANTT_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/template-gantt/update/${id}` } -export const TEMPLATE_GANTT_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/template-gantt/delete/${id}` } -export const TEMPLATE_GANTT_LIST = `${BASE_SIMPRO_LUMEN}/template-gantt/list` -export const TEMPLATE_GANTT_TREE = (id) => { return `${BASE_SIMPRO_LUMEN}/template-gantt/get-tree/${id}` } - -export const PROJECT_PARTICIPANT_ADD = `${BASE_SIMPRO_LUMEN}/project-participants/add` -export const PROJECT_PARTICIPANT_SEARCH = `${BASE_SIMPRO_LUMEN}/project-participants/search` -export const PROJECT_PARTICIPANT_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/project-participants/update/${id}` } -export const PROJECT_PARTICIPANT_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/project-participants/delete/${id}` } -export const PROJECT_PARTICIPANT_DELETE_BY_PROYEK = (id) => { return `${BASE_SIMPRO_LUMEN}/project-participants/delete-by-proyek/${id}` } -export const PROJECT_PARTICIPANT_LIST = `${BASE_SIMPRO_LUMEN}/project-participants/list` -export const PROJECT_PARTICIPANT_WHERE_CUSTOM = (where, id) => { return `${BASE_SIMPRO_LUMEN}/project-participants/${where}/${id}` } - -export const PROJECT_APPROVAL_ADD = `${BASE_SIMPRO_LUMEN}/project-approval/add` -export const PROJECT_APPROVAL_SEARCH = `${BASE_SIMPRO_LUMEN}/project-approval/search` -export const PROJECT_APPROVAL_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/project-approval/update/${id}` } -export const PROJECT_APPROVAL_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/project-approval/delete/${id}` } -export const PROJECT_APPROVAL_DELETE_BY_PROYEK = (id) => { return `${BASE_SIMPRO_LUMEN}/project-approval/delete-by-proyek/${id}` } -export const PROJECT_APPROVAL_LIST = `${BASE_SIMPRO_LUMEN}/project-approval/list` -export const PROJECT_APPROVAL_WHERE_CUSTOM = (where, id) => { return `${BASE_SIMPRO_LUMEN}/project-approval/${where}/${id}` } - -export const PROJECT_MILESTONE_ADD = `${BASE_SIMPRO_LUMEN}/project-milestone/add` -export const PROJECT_MILESTONE_SEARCH = `${BASE_SIMPRO_LUMEN}/project-milestone/search` -export const PROJECT_MILESTONE_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/project-milestone/update/${id}` } -export const PROJECT_MILESTONE_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/project-milestone/delete/${id}` } -export const PROJECT_MILESTONE_DELETE_BY_PROYEK = (id) => { return `${BASE_SIMPRO_LUMEN}/project-milestone/delete-by-proyek/${id}` } -export const PROJECT_MILESTONE_LIST = `${BASE_SIMPRO_LUMEN}/project-milestone/list` -export const PROJECT_MILESTONE_WHERE_CUSTOM = (where, id) => { return `${BASE_SIMPRO_LUMEN}/project-milestone/${where}/${id}` } - - -export const PRESENCE_ADD = `${BASE_SIMPRO_LUMEN}/presence/add` -export const PRESENCE_SEARCH = `${BASE_SIMPRO_LUMEN}/presence/search` -export const PRESENCE_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/presence/update/${id}` } -export const PRESENCE_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/presence/delete/${id}` } -export const PRESENCE_LIST = `${BASE_SIMPRO_LUMEN}/presence/list` - -export const SATUAN_ADD = `${BASE_SIMPRO_LUMEN}/satuan/add` -export const SATUAN_SEARCH = `${BASE_SIMPRO_LUMEN}/satuan/search` -export const SATUAN_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/satuan/update/${id}` } -export const SATUAN_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/satuan/delete/${id}` } -export const SATUAN_LIST = `${BASE_SIMPRO_LUMEN}/satuan/list` - -export const CHECKLIST_K3_ADD = `${BASE_SIMPRO_LUMEN}/checklist-k3/add` -export const CHECKLIST_K3_SEARCH = `${BASE_SIMPRO_LUMEN}/checklist-k3/search` -export const CHECKLIST_K3_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/checklist-k3/update/${id}` } -export const CHECKLIST_K3_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/checklist-k3/delete/${id}` } -export const CHECKLIST_K3_LIST = `${BASE_SIMPRO_LUMEN}/checklist-k3/list` - -export const ASSIGN_HR_PROJECT_ADD = `${BASE_SIMPRO_LUMEN}/user-to-proyek/add` -export const ASSIGN_HR_PROJECT_SEARCH = `${BASE_SIMPRO_LUMEN}/user-to-proyek/search` -export const ASSIGN_HR_PROJECT_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/user-to-proyek/update/${id}` } -export const ASSIGN_HR_PROJECT_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/user-to-proyek/delete/${id}` } -export const ASSIGN_HR_PROJECT_LIST = `${BASE_SIMPRO_LUMEN}/user-to-proyek/list` - -export const IMAGE_GET_BY_ID = (id, category) => { return `${BASE_SIMPRO_LUMEN}/image/${id}/${category}` } -export const IMAGE_SEARCH = `${BASE_SIMPRO_LUMEN}/image/search` -export const OSPRO_BASE_IMAGE = `${BASE_OSPRO}/api/assets/image` - -export const DASHBOARD_COST_PLANNING_ACTUAL = `${BASE_SIMPRO_LUMEN}/dashboard/cost-planning-actual` -export const DASHBOARD_PERSENTASE_PROGRESS_PROYEK = `${BASE_SIMPRO_LUMEN}/dashboard/percentage-planning-actual` -export const DASHBOARD_REPORT_POINTS = `${BASE_SIMPRO_LUMEN}/report-activity/search-point` -export const DASHBOARD_STATUS_PROYEK = `${BASE_SIMPRO_LUMEN}/dashboard/status-proyek` -export const DASHBOARD_KURVA_S = `${BASE_SIMPRO_LUMEN}/activity/get-curva-s` - -export const CURRENCY_LIST = `${BASE_SIMPRO_LUMEN}/currency/list` - -export const GET_PERCENTAGE_PERDAY = `${BASE_SIMPRO_LUMEN}/activity/get-percentage` - -export const FOLDER_DOCUMENT_PROYEK_ADD = `${BASE_SIMPRO_LUMEN}/folder-document-proyek/add` -export const FOLDER_DOCUMENT_PROYEK_SEARCH = `${BASE_SIMPRO_LUMEN}/folder-document-proyek/search` -export const FOLDER_DOCUMENT_PROYEK_UPDATE = (id) => `${BASE_SIMPRO_LUMEN}/folder-document-proyek/update/${id}` -export const FOLDER_DOCUMENT_PROYEK_DELETE = (id) => `${BASE_SIMPRO_LUMEN}/folder-document-proyek/delete/${id}` -export const FOLDER_DOCUMENT_PROYEK_GET_TREE = (proyek_id) => `${BASE_SIMPRO_LUMEN}/folder-document-proyek/get-tree/${proyek_id}` - -export const PROJECT_TO_CHECKLIST_K3_ADD = `${BASE_SIMPRO_LUMEN}/project-to-checklist-k3/add` -export const PROJECT_TO_CHECKLIST_K3_ADDS = `${BASE_SIMPRO_LUMEN}/project-to-checklist-k3/add-multiple` -export const PROJECT_TO_CHECKLIST_K3_SEARCH = `${BASE_SIMPRO_LUMEN}/project-to-checklist-k3/search` -export const PROJECT_TO_CHECKLIST_K3_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/project-to-checklist-k3/update/${id}` } -export const PROJECT_TO_CHECKLIST_K3_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/project-to-checklist-k3/delete/${id}` } -export const PROJECT_TO_CHECKLIST_K3_LIST = `${BASE_SIMPRO_LUMEN}/project-to-checklist-k3/list` - - -export const CONTROL_MONITORING_SEARCH = `${BASE_SIMPRO_LUMEN}/control-monitoring/search` -export const API_PANIC_BUTTON_SIMPRO = `${BASE_SIMPRO_LUMEN}/panic-button` -export const PANIC_BUTTON_SEARCH = `${BASE_SIMPRO_LUMEN}/panic-button/search`; -export const PANIC_BUTTON_UPDATE = (id) => { return `${BASE_SIMPRO_LUMEN}/panic-button/update/${id}` } - -export const HIERARCHY_FTTH_GET = `${BASE_SIMPRO_LUMEN}/hierarchy-ftths` -export const HIERARCHY_FTTH_ADD = `${BASE_SIMPRO_LUMEN}/hierarchy-ftths` -export const HIERARCHY_FTTH_SEARCH = `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/search` -export const HIERARCHY_FTTH_SHOW = (id) => { return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/${id}` } -export const HIERARCHY_FTTH_UPDATE = (id) => { return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/${id}` } -export const HIERARCHY_FTTH_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/${id}` } -export const HIERARCHY_FTTH_TREE = (id) => { return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/tree/${id}` } -export const WAYPOINT_SEARCH = `${BASE_SIMPRO_LUMEN}/waypoint/search` +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 BASE_URL_GEOHR_API = "https://oslog.id/geohr-api"; +export const BASE_URL_GEOHR_API2 = "http://siopas.co.id/custom-php/api/geohr"; + +export const BASE_API = `${HOST}/osmap-php/index.php`; + +export const BASE_IMAGE = `${HOST}/osmap-php`; +export const BASE_IMAGE_EMPLOYEE = + "https://oslog.id/geohr-api/assets/images/employee/"; + +export const SIOPAS_API = `${BASE_API}/siopas`; + +export const API_LOGIN = `${SIOPAS_API}/user/login`; + +export const API_LOG = `${SIOPAS_API}/user/log`; + +export const API_USER_SESSION = `${SIOPAS_API}/user/get_valid_session`; + +export const API_GET_COLUMN_TABLE = `${BASE_API}/map/getColumnNameAndType`; +export const API_CREATE_NEW_LAYER = `${BASE_API}/map/createlayer`; + +export const API_LOAD_MAP = `${SIOPAS_API}/map/load/${MAP_ID}`; +export const API_UPDATE_MAP = `${SIOPAS_API}/map/update`; + +export const API_UPLOAD_IMAGE = `${SIOPAS_API}/feature/uploadimage`; +export const API_GET_IMAGE = `${SIOPAS_API}/feature/getimage`; + +export const API_UPDATE_FEATURE = `${SIOPAS_API}/feature/update`; + +export const API_GET_CHART_TIPE_GEOMETRY = `${SIOPAS_API}/dashboard/chart/tipe-geometry?map_id=${MAP_ID}`; +export const API_GET_CHART_KATEGORI = `${SIOPAS_API}/dashboard/chart/tipe-kategori?map_id=${MAP_ID}`; + +export const API_LIST_DATA_COUNTRY = `${SIOPAS_API}/country`; +export const API_INSERT_DATA_COUNTRY = `${API_LIST_DATA_COUNTRY}/insertDataCountry`; +export const API_UPDATE_DATA_COUNTRY = `${API_LIST_DATA_COUNTRY}/updateDataCountry`; +export const API_DELETE_DATA_COUNTRY = `${API_LIST_DATA_COUNTRY}/deleteDataCountry`; + +export const API_LIST_DATA_DISTRICT = `${SIOPAS_API}/district`; +export const API_INSERT_DATA_DISTRICT = `${API_LIST_DATA_DISTRICT}/insertDataDistrict`; +export const API_UPDATE_DATA_DISTRICT = `${API_LIST_DATA_DISTRICT}/updateDataDistrict`; +export const API_DELETE_DATA_DISTRICT = `${API_LIST_DATA_DISTRICT}/deleteDataDistrict`; + +export const API_LIST_DATA_SUBDISTRICT = `${SIOPAS_API}/subdistrict`; +export const API_INSERT_DATA_SUBDISTRICT = `${API_LIST_DATA_SUBDISTRICT}/insertDataSubdistrict`; +export const API_UPDATE_DATA_SUBDISTRICT = `${API_LIST_DATA_SUBDISTRICT}/updateDataSubdistrict`; +export const API_DELETE_DATA_SUBDISTRICT = `${API_LIST_DATA_SUBDISTRICT}/deleteDataSubdistrict`; + +export const API_LIST_DATA_PROVINCE = `${SIOPAS_API}/province`; +export const API_UPDATE_DATA_PROVINCE = `${API_LIST_DATA_PROVINCE}/updateDataProvince`; +export const API_INSERT_DATA_PROVINCE = `${API_LIST_DATA_PROVINCE}/insertDataProvince`; +export const API_DELETE_DATA_PROVINCE = `${API_LIST_DATA_PROVINCE}/deleteDataProvince`; + +export const API_LIST_DATA_VILLAGE = `${SIOPAS_API}/village`; +export const API_UPDATE_DATA_VILLAGE = `${API_LIST_DATA_VILLAGE}/updateDataVillage`; +export const API_INSERT_DATA_VILLAGE = `${API_LIST_DATA_VILLAGE}/insertDataVillage`; +export const API_DELETE_DATA_VILLAGE = `${API_LIST_DATA_VILLAGE}/deleteDataVillage`; + +export const API_LIST_DATA_USERS = `${SIOPAS_API}/user?group_id=${window.localStorage.getItem( + "group_id" +)}`; +export const API_INSERT_DATA_USERS = `${API_LIST_DATA_USERS}/insertDataUser`; +export const API_UPDATE_DATA_USERS = `${API_LIST_DATA_USERS}/updateDataUser`; +export const API_DELETE_DATA_USERS = `${API_LIST_DATA_USERS}/deleteDataUser`; + +export const API_LAYER_LIST = `${SIOPAS_API}/layer?workspace=${appConfig.workspace_name}`; +export const API_LAYER_LABEL = `${SIOPAS_API}/layer/getsearchlabel`; +export const API_LAYER_DETAIL = `${SIOPAS_API}/layer/?resourcebase_ptr_id=`; +export const API_LAYER_DETAIL_UPDATE = `${SIOPAS_API}/layer/updatelayerdetail`; +export const API_LAYER_ATTRIBUTE = `${SIOPAS_API}/layer/getlayerattribute/`; +export const API_LAYER_ATTRIBUTE_UPDATE = `${SIOPAS_API}/layer/updatelayerattribute`; +export const API_LAYER_ATTRIBUTE_BY_LAYERNAME = `${SIOPAS_API}/layer/getlayerattribute?name=`; +export const API_LAYER_SEARCH_LABEL = `${SIOPAS_API}/layer/getsearchlabel/`; +export const API_LAYER_SEARCH_LABEL_UPDATE = `${SIOPAS_API}/layer/updatelayersearchlabel`; + +export const API_GEOHR_GROUP_SALES_SEARCH = `${BASE_URL_GEOHR_API}/group-sales/search`; +export const API_GEOHR_SALES_MONITORING = `${BASE_URL_GEOHR_API}/sales/monitoring`; +export const API_GEOHR_SALES_SEARCH = `${BASE_URL_GEOHR_API}/sales/search`; +export const API_GEOHR_OFFICE_MONITORING = `${BASE_URL_GEOHR_API}/office/monitoring`; +export const API_GEOHR_CUSTOMER_MONITORING = `${BASE_URL_GEOHR_API}/customer/monitoring`; +export const API_GEOHR_EMPLOYEE_MONITORING = `${BASE_URL_GEOHR_API}/employee/monitoring`; +export const API_GEOHR_WAYPOINT_SALES_MONITORING = (salesId) => + `${BASE_URL_GEOHR_API}/waypoint-sales/monitoring?salesId=${salesId}`; +export const API_GEOHR_WAYPOINT_EMPLOYEE_MONITORING = (employeeId) => + `${BASE_URL_GEOHR_API}/waypoint-employee/monitoring?employeeId=${employeeId}`; +export const API_GEOHR_DAILY_INFO = `${BASE_URL_GEOHR_API}/dashboard-status-sales`; +export const API_BROADCAST = `${BASE_URL_GEOHR_API}/broadcast`; + +export const API_GEOHR_EMPLOYEE_DIVISION_LIST = `${BASE_URL_GEOHR_API2}/employee_devision.php?act=get_data`; +export const API_GEOHR_KARYAWAN = `${BASE_URL_GEOHR_API2}/employee.php?`; +export const API_GEOHR_ROLES = `${BASE_URL_GEOHR_API2}/roles.php?`; +export const API_GEOHR_MENU = `${BASE_URL_GEOHR_API2}/menu.php?`; +export const API_GEOHR_TASK = `${BASE_URL_GEOHR_API2}/task_report.php?`; +export const API_GEOHR_DIVISI_KARYAWAN = `${BASE_URL_GEOHR_API2}/employee_devision.php?`; +export const API_GEOHR_IZIN = `${BASE_URL_GEOHR_API2}/paid_leave.php?`; +export const API_GEOHR_PRESENSI = `${BASE_URL_GEOHR_API2}/clock_in_out.php?`; +export const API_GET_DATA_OFFICE_HOURS = `${BASE_URL_GEOHR_API2}/employee_office_hours.php?`; +export const API_GEOHR_SETTING_OFFICE_HOURS = (type) => + `${BASE_URL_GEOHR_API2}/employee_office_hours.php?act=setting&type=${type}`; +export const API_GEOHR_EDIT_OFFICE_HOURS = (id) => + `${BASE_URL_GEOHR_API2}/employee_office_hours.php?act=edit&id=${id}`; +export const API_DAILY_INFO = `${BASE_URL_GEOHR_API2}/employee.php?act=get_daily&role_name=${roleName}`; +export const API_DAILY_INFO_DETAIL = (start, length) => + `${BASE_URL_GEOHR_API2}/employee.php?act=get_daily_detail&start=${start}&length=${length}&role_name=${roleName}`; + +export const APP_MODE = "ADW"; // KIT / ADW / NAWAKARA / IU +export const BASE_SIMPRO = "https://oslog.id/simpro-api/v1"; +export const BASE_SIMPRO_V2 = "https://oslog.id/simpro-api/v2"; +export const BASE_SIMPRO_LUMENNIAGA = "https://ospro-api.odm-iu.com/api"; +export const BASE_INTEGRATION_V1 = "http://ospro-api.adyawinsa.com:9083"; +export const TOKEN_ADW = + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIxMjAyIiwiZXhwIjoxNjkxODMwNDkzfQ.DvBQIOZsdFndWsliPCZT65Y6G5Xx4vWBKz8Rhe7rvRA"; + +// export let BASE_OSPRO = "https://ospro-api.ospro.id"; +// export let BASE_OSPRO = "https://adw-api.ospro.id"; +export let BASE_OSPRO = "http://localhost:8444/adw-backend"; +// export let BASE_OSPRO = "http://192.168.1.123:8444"; // local +// export let BASE_OSPRO = "http://103.73.125.81:8444"; // ip public adw +export let BASE_SIMPRO_LUMEN = `${BASE_OSPRO}/api`; +export let BASE_SIMPRO_LUMEN_IMAGE = `${BASE_OSPRO}/assets/image`; +export let BASE_SIMPRO_LUMEN_FILE = `${BASE_OSPRO}/assets/file/project`; + +// switch (APP_MODE) { +// case 'KIT': +// BASE_OSPRO = "https://kit-api.oslogdev.com" + +// //for KIT server +// // BASE_SIMPRO_LUMEN = `${BASE_OSPRO}/api`; +// // BASE_SIMPRO_LUMEN_IMAGE = `${BASE_SIMPRO_LUMEN}/assets/image`; +// // BASE_SIMPRO_LUMEN_FILE = `${BASE_SIMPRO_LUMEN}/assets/file/project`; + +// break; +// case 'ADW': +// // BASE_OSPRO = "https://adw-api.ospro.id" +// BASE_OSPRO = "http://103.73.125.81:8444"; + +// BASE_SIMPRO_LUMEN = `${BASE_OSPRO}/api`; +// BASE_SIMPRO_LUMEN_IMAGE = `${BASE_OSPRO}/assets/image`; +// BASE_SIMPRO_LUMEN_FILE = `${BASE_OSPRO}/assets/file/project`; + +// break; +// case 'IU': +// BASE_OSPRO = "https://api-iu.ospro.id" + +// BASE_SIMPRO_LUMEN = `${BASE_OSPRO}/api`; +// BASE_SIMPRO_LUMEN_IMAGE = `${BASE_OSPRO}/assets/image`; +// BASE_SIMPRO_LUMEN_FILE = `${BASE_OSPRO}/assets/file/project`; + +// break; +// default: +// BASE_OSPRO = "https://ospro-api.ospro.id" +// } + +export const USERROLE_ADD = `${BASE_SIMPRO}/user-role/add`; +export const USERROLE_SEARCH = `${BASE_SIMPRO}/user-role/search`; +export const USERROLE_EDIT = (id) => { + return `${BASE_SIMPRO}/user-role/edit/${id}`; +}; +export const USERROLE_DELETE = (id) => { + return `${BASE_SIMPRO}/user-role/delete/${id}`; +}; + +export const USERPROYEK_ADD = `${BASE_SIMPRO}/user-to-proyek/add`; +export const USERPROYEK_ADD_DETAIL = `${BASE_SIMPRO}/user-to-proyek/add-detail`; +export const USERPROYEK_LIST = `${BASE_SIMPRO}/user-to-proyek/list`; +export const USERPROYEK_SEARCH = `${BASE_SIMPRO}/user-to-proyek/search`; +export const USERPROYEK_EDIT = (id) => { + return `${BASE_SIMPRO}/user-to-proyek/edit/${id}`; +}; +export const USERPROYEK_DELETE = (id) => { + return `${BASE_SIMPRO}/user-to-proyek/delete/${id}`; +}; + +export const PRESENSI_ADD = `${BASE_SIMPRO}/clock-in-out/add`; +export const PRESENSI_SEARCH = `${BASE_SIMPRO}/clock-in-out/search`; +export const PRESENSI_EDIT = (id) => { + return `${BASE_SIMPRO}/clock-in-out/edit/${id}`; +}; +export const PRESENSI_DELETE = (id) => { + return `${BASE_SIMPRO}/clock-in-out/delete/${id}`; +}; + +export const PLANNING_ADD = `${BASE_SIMPRO}/laporan-planning/add`; +export const PLANNING_SEARCH = `${BASE_SIMPRO}/laporan-planning/search`; +export const PLANNING_EDIT = (id) => { + return `${BASE_SIMPRO}/laporan-planning/edit/${id}`; +}; +export const PLANNING_DELETE = (id) => { + return `${BASE_SIMPRO}/laporan-planning/delete/${id}`; +}; + +export const ALERT_ADD = `${BASE_SIMPRO}/alert/add`; +export const ALERT_SEARCH = `${BASE_SIMPRO}/alert/search`; +export const ALERT_EDIT = (id) => { + return `${BASE_SIMPRO}/alert/edit/${id}`; +}; +export const ALERT_DELETE = (id) => { + return `${BASE_SIMPRO}/alert/delete/${id}`; +}; + +export const ALERTUSER_ADD = `${BASE_SIMPRO}/alert-to-user/add`; +export const ALERTUSER_SEARCH = `${BASE_SIMPRO}/alert-to-user/search`; +export const ALERTUSER_EDIT = (id) => { + return `${BASE_SIMPRO}/alert-to-user/edit/${id}`; +}; +export const ALERTUSER_DELETE = (id) => { + return `${BASE_SIMPRO}/alert-to-user/delete/${id}`; +}; + +export const ALERTUSER_STATUSVIEW = (id) => { + return `${BASE_SIMPRO}/alert-to-user/edit-status-view/${id}`; +}; +export const ALERT_STATUSVIEW = (id) => { + return `${BASE_SIMPRO}/alert/edit-status-view/${id}`; +}; + +export const SUBPROYEK_ADD = `${BASE_SIMPRO}/sub-proyek/add`; +export const SUBPROYEK_SEARCH = `${BASE_SIMPRO}/sub-proyek/search`; +export const SUBPROYEK_EDIT = (id) => { + return `${BASE_SIMPRO}/sub-proyek/edit/${id}`; +}; +export const SUBPROYEK_DELETE = (id) => { + return `${BASE_SIMPRO}/sub-proyek/delete/${id}`; +}; + +export const USER_PROYEK_SEARCH = `${BASE_SIMPRO}/user-proyek/search`; +export const PLANNING_REALISASI_SEARCH = `${BASE_SIMPRO}/planning-realisasi/search`; + +export const DASHBOARD_PROYEK = `${BASE_SIMPRO}/dashboard-proyek/list`; +export const DASHBOARD_PROYEK_SEARCH = `${BASE_SIMPRO}/dashboard-proyek/search`; +export const SIMPRO_BASE_IMAGE = `https://oslog.id/simpro-api/assets/images`; + +export const API_BROADCAST_SIMPRO = `${BASE_SIMPRO}/broadcast`; +export const USER_WASPANG = `${BASE_SIMPRO}/user-role/search`; +export const USER_TO_PROYEK_SEARCH = `${BASE_SIMPRO}/user-to-proyek`; +export const API_SIMPRO_WAYPOINT_WASPANG_MONITORING = (userId) => + `${BASE_SIMPRO}/waypoint-monitoring/${userId}/search`; + +export const SATUAN_KERJA_GET = `${BASE_SIMPRO}/satuan/list`; + +export const DASHBOARD_STATUS_SEARCH = `${BASE_SIMPRO}/dashboard-status/search`; +export const GANTT_CONTROL_MONITORING_SEARCH = `${BASE_SIMPRO}/proyek-monitoring/search-detail`; + +export const MATERIAL_TO_PROYEK_ADD = `${BASE_SIMPRO}/material-to-proyek/add`; +export const MATERIAL_TO_PROYEK_ADD_DETAIL = `${BASE_SIMPRO}/material-to-proyek/add-detail`; +export const MATERIAL_TO_PROYEK_SEARCH = `${BASE_SIMPRO}/material-to-proyek/search`; +export const MATERIAL_TO_PROYEK_EDIT = (id) => { + return `${BASE_SIMPRO}/material-to-proyek/edit/${id}`; +}; +export const MATERIAL_TO_PROYEK_DELETE = (id) => { + return `${BASE_SIMPRO}/material-to-proyek/delete/${id}`; +}; + +export const TOOLS_TO_PROYEK_ADD = `${BASE_SIMPRO}/tools-to-proyek/add`; +export const TOOLS_TO_PROYEK_ADD_DETAIL = `${BASE_SIMPRO}/tools-to-proyek/add-detail`; +export const TOOLS_TO_PROYEK_SEARCH = `${BASE_SIMPRO}/tools-to-proyek/search`; +export const TOOLS_TO_PROYEK_EDIT = (id) => { + return `${BASE_SIMPRO}/tools-to-proyek/edit/${id}`; +}; +export const TOOLS_TO_PROYEK_DELETE = (id) => { + return `${BASE_SIMPRO}/tools-to-proyek/delete/${id}`; +}; + +export const USER_LOGIN_V2 = `${BASE_SIMPRO_LUMEN}/login`; +export const USER_TO_PROYEK = `${BASE_SIMPRO_LUMEN}/user-to-project/assign`; +export const TOOLS_ASSIGN_PROYEK = `${BASE_SIMPRO_LUMEN}/tools-to-project/assign`; +export const MATERIAL_ASSIGN_PROYEK = `${BASE_SIMPRO_LUMEN}/material-to-project/assign`; +export const TOOLS_CREATE = `${BASE_SIMPRO_LUMEN}/req-tools/create`; + +export const USER_ADD = `${BASE_SIMPRO_LUMEN}/human-resource/add`; +export const USER_SEARCH = `${BASE_SIMPRO_LUMEN}/human-resource/search`; +export const USER_LIST = `${BASE_SIMPRO_LUMEN}/human-resource/list`; +export const USER_SYNC = `${BASE_SIMPRO_LUMEN}/human-resource/sync`; +export const USER_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/human-resource/update/${id}`; +}; +export const USER_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/human-resource/delete/${id}`; +}; + +export const ABSENSI_ADD = `${BASE_SIMPRO_LUMEN}/permit/add`; +export const ABSENSI_SEARCH = `${BASE_SIMPRO_LUMEN}/permit/search`; +export const ABSENSI_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/permit/edit/${id}`; +}; +export const ABSENSI_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/permit/delete/${id}`; +}; + +export const K3_ADD = `${BASE_SIMPRO_LUMEN}/report-k3/add`; +export const K3_SEARCH = `${BASE_SIMPRO_LUMEN}/report-k3/search`; +export const K3_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/report-k3/edit/${id}`; +}; +export const K3_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/report-k3/delete/${id}`; +}; + +export const DOCUMENT_ADD = `${BASE_SIMPRO_LUMEN}/document-project/upload`; +export const DOCUMENT_GET = (id) => { + return `${BASE_SIMPRO_LUMEN}/document-project/get/${id}`; +}; +export const DOCUMENT_SEARCH = `${BASE_SIMPRO_LUMEN}/document-project/search`; +export const DOCUMENT_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/document-project/update/${id}`; +}; +export const DOCUMENT_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/document-project/delete/${id}`; +}; +export const DOCUMENT_DOWNLOAD = (id) => { + return `${BASE_SIMPRO_LUMEN}/document-project/download/${id}`; +}; + +export const ROLE_ADD = `${BASE_SIMPRO_LUMEN}/role/add`; +export const ROLE_SEARCH = `${BASE_SIMPRO_LUMEN}/role/search`; +export const ROLE_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/role/update/${id}`; +}; +export const ROLE_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/role/delete/${id}`; +}; + +export const REQUEST_MATERIAL_ADD = `${BASE_SIMPRO_LUMEN}/request-material/add`; +export const REQUEST_MATERIAL_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/request-material/update/${id}`; +}; +export const REQUEST_MATERIAL_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/request-material/delete/${id}`; +}; +export const REQUEST_MATERIAL_SEARCH = `${BASE_SIMPRO_LUMEN}/request-material/search`; +export const REQUEST_MATERIAL_UPDATE_WAREHOUSE_SITE = (id) => { + return `${BASE_SIMPRO_LUMEN}/request-material/update-warehouse-site/${id}`; +}; + +export const MENU_ADD = `${BASE_SIMPRO_LUMEN}/menu/add`; +export const MENU_MANAGEMENT = (id) => { + return `${BASE_SIMPRO_LUMEN}/menu/management/${id}`; +}; +export const MENU_SEARCH = `${BASE_SIMPRO_LUMEN}/menu/search`; +export const MENU_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/menu/update/${id}`; +}; +export const MENU_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/menu/delete/${id}`; +}; + +export const ROLEMENU_ADD = `${BASE_SIMPRO_LUMEN}/role-menu/add`; +export const ROLEMENU_SEARCH = `${BASE_SIMPRO_LUMEN}/role-menu/search`; +export const ROLEMENU_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/role-menu/update/${id}`; +}; +export const ROLEMENU_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/role-menu/delete/${id}`; +}; +export const ROLEMENU_DELETE_ROLE = (id) => { + return `${BASE_SIMPRO_LUMEN}/role-menu/delete-byrole/${id}`; +}; + +export const PROYEK_ADD = `${BASE_SIMPRO_LUMEN}/project/add`; +export const PROYEK_LIST = `${BASE_SIMPRO_LUMEN}/project/list`; +export const PROYEK_SEARCH = `${BASE_SIMPRO_LUMEN}/project/search`; +export const PROYEK_SEARCH_DETAIL = `${BASE_SIMPRO_LUMEN}/project/search`; +export const PROYEK_GET_ID = (id) => { + return `${BASE_SIMPRO_LUMEN}/project/edit/${id}`; +}; +export const PROYEK_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/project/update/${id}`; +}; +export const PROYEK_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/project/delete/${id}`; +}; + +export const PROJECT_ROLE_ADD = `${BASE_SIMPRO_LUMEN}/project-role/add`; +export const PROJECT_ROLE_SEARCH = `${BASE_SIMPRO_LUMEN}/project-role/search`; +export const PROJECT_ROLE_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/project-role/update/${id}`; +}; +export const PROJECT_ROLE_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/project-role/delete/${id}`; +}; + +export const PROJECT_TYPE_ADD = `${BASE_SIMPRO_LUMEN}/project-type/add`; +export const PROJECT_TYPE_SEARCH = `${BASE_SIMPRO_LUMEN}/project-type/search`; +export const PROJECT_TYPE_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/project-type/update/${id}`; +}; +export const PROJECT_TYPE_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/project-type/delete/${id}`; +}; +export const TYPE_PROYEK = `${BASE_SIMPRO_LUMEN}/project-type/list`; + +export const PROJECT_PHASE_ADD = `${BASE_SIMPRO_LUMEN}/project-phase/add`; +export const PROJECT_PHASE_SEARCH = `${BASE_SIMPRO_LUMEN}/project-phase/search`; +export const PROJECT_PHASE_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/project-phase/update/${id}`; +}; +export const PROJECT_PHASE_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/project-phase/delete/${id}`; +}; +export const PHASE_PROYEK = `${BASE_SIMPRO_LUMEN}/project-phase/list`; + +export const PROJECT_CHARTER_ADD = `${BASE_SIMPRO_LUMEN}/project-charter/add`; +export const PROJECT_CHARTER_SEARCH = `${BASE_SIMPRO_LUMEN}/project-charter/search`; +export const PROJECT_CHARTER_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/project-charter/update/${id}`; +}; + +export const CONFIGALERT_ADD = `${BASE_SIMPRO_LUMEN}/config-alert/add`; +export const CONFIGALERT_SEARCH = `${BASE_SIMPRO_LUMEN}/config-alert/search`; +export const CONFIGALERT_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/config-alert/update/${id}`; +}; +export const CONFIGALERT_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/config-alert/delete/${id}`; +}; + +export const CALERTUSER_ADD = `${BASE_SIMPRO_LUMEN}/config-alert-to-user/add`; +export const CALERTUSER_SEARCH = `${BASE_SIMPRO_LUMEN}/config-alert-to-user/search`; +export const CALERTUSER_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/config-alert-to-user/update/${id}`; +}; +export const CALERTUSER_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/config-alert-to-user/delete/${id}`; +}; + +export const MATERIAL_RESOURCE_ADD = `${BASE_SIMPRO_LUMEN}/material-resource/add`; +export const MATERIAL_RESOURCE_SEARCH = `${BASE_SIMPRO_LUMEN}/material-resource/search`; +export const MATERIAL_RESOURCE_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/material-resource/update/${id}`; +}; +export const MATERIAL_RESOURCE_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/material-resource/delete/${id}`; +}; +export const MATERIAL_RESOURCE_LIST = `${BASE_SIMPRO_LUMEN}/material-resource/list`; + +export const TOOLS_RESOURCE_ADD = `${BASE_SIMPRO_LUMEN}/tools-resource/add`; +export const TOOLS_RESOURCE_SEARCH = `${BASE_SIMPRO_LUMEN}/tools-resource/search`; +export const TOOLS_RESOURCE_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/tools-resource/update/${id}`; +}; +export const TOOLS_RESOURCE_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/tools-resource/delete/${id}`; +}; +export const TOOLS_RESOURCE_LIST = `${BASE_SIMPRO_LUMEN}/tools-resource/list`; + +export const VERSION_GANTT_ADD = `${BASE_SIMPRO_LUMEN}/version-gantt/add`; +export const VERSION_GANTT_SEARCH = `${BASE_SIMPRO_LUMEN}/version-gantt/search`; +export const VERSION_GANTT_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/version-gantt/update/${id}`; +}; +export const VERSION_GANTT_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/version-gantt/delete/${id}`; +}; +export const VERSION_GANTT_LIST = `${BASE_SIMPRO_LUMEN}/version-gantt/list`; + +export const USER_VERSION_GANTT_ADD = `${BASE_SIMPRO_LUMEN}/user-to-version-gantt/add`; +export const USER_VERSION_GANTT_ADDS = `${BASE_SIMPRO_LUMEN}/user-to-version-gantt/add-multiple`; +export const USER_VERSION_GANTT_SEARCH = `${BASE_SIMPRO_LUMEN}/user-to-version-gantt/search`; +export const USER_VERSION_GANTT_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/user-to-version-gantt/update/${id}`; +}; +export const USER_VERSION_GANTT_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/user-to-version-gantt/delete/${id}`; +}; +export const USER_VERSION_GANTT_LIST = `${BASE_SIMPRO_LUMEN}/user-to-version-gantt/list`; + +export const REQUEST_TOOLS_ADD = `${BASE_SIMPRO_LUMEN}/req-tools/add`; +export const REQUEST_TOOLS_SEARCH = `${BASE_SIMPRO_LUMEN}/req-tools/search`; +export const REQUEST_TOOLS_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/req-tools/update/${id}`; +}; +export const REQUEST_TOOLS_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/req-tools/delete/${id}`; +}; + +export const DIVISI_ADD = `${BASE_SIMPRO_LUMEN}/divisi/add`; +export const DIVISI_SEARCH = `${BASE_SIMPRO_LUMEN}/divisi/search`; +export const DIVISI_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/divisi/update/${id}`; +}; +export const DIVISI_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/divisi/delete/${id}`; +}; +export const DIVISI_LIST = `${BASE_SIMPRO_LUMEN}/divisi/list`; + +export const SHIFT_ADD = `${BASE_SIMPRO_LUMEN}/shift/add`; +export const SHIFT_SEARCH = `${BASE_SIMPRO_LUMEN}/shift/search`; +export const SHIFT_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/shift/update/${id}`; +}; +export const SHIFT_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/shift/delete/${id}`; +}; +export const SHIFT_LIST = `${BASE_SIMPRO_LUMEN}/shift/list`; + +export const USER_SHIFT_ADD = `${BASE_SIMPRO_LUMEN}/user-to-shift/add`; +export const USER_SHIFT_SEARCH = `${BASE_SIMPRO_LUMEN}/user-to-shift/search`; +export const USER_SHIFT_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/user-to-shift/delete/${id}`; +}; +export const USER_SHIFT_LIST = `${BASE_SIMPRO_LUMEN}/user-to-shift/list`; + +export const RATE_SALLARY_ADD = `${BASE_SIMPRO_LUMEN}/rate-sallary/add`; +export const RATE_SALLARY_SEARCH = `${BASE_SIMPRO_LUMEN}/rate-sallary/search`; +export const RATE_SALLARY_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/rate-sallary/update/${id}`; +}; +export const RATE_SALLARY_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/rate-sallary/delete/${id}`; +}; +export const RATE_SALLARY_LIST = `${BASE_SIMPRO_LUMEN}/rate-sallary/list`; + +export const TEMPLATE_GANTT_ADD = `${BASE_SIMPRO_LUMEN}/template-gantt/add`; +export const TEMPLATE_GANTT_SEARCH = `${BASE_SIMPRO_LUMEN}/template-gantt/search`; +export const TEMPLATE_GANTT_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/template-gantt/update/${id}`; +}; +export const TEMPLATE_GANTT_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/template-gantt/delete/${id}`; +}; +export const TEMPLATE_GANTT_LIST = `${BASE_SIMPRO_LUMEN}/template-gantt/list`; +export const TEMPLATE_GANTT_TREE = (id) => { + return `${BASE_SIMPRO_LUMEN}/template-gantt/get-tree/${id}`; +}; + +export const PROJECT_PARTICIPANT_ADD = `${BASE_SIMPRO_LUMEN}/project-participants/add`; +export const PROJECT_PARTICIPANT_SEARCH = `${BASE_SIMPRO_LUMEN}/project-participants/search`; +export const PROJECT_PARTICIPANT_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/project-participants/update/${id}`; +}; +export const PROJECT_PARTICIPANT_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/project-participants/delete/${id}`; +}; +export const PROJECT_PARTICIPANT_DELETE_BY_PROYEK = (id) => { + return `${BASE_SIMPRO_LUMEN}/project-participants/delete-by-proyek/${id}`; +}; +export const PROJECT_PARTICIPANT_LIST = `${BASE_SIMPRO_LUMEN}/project-participants/list`; +export const PROJECT_PARTICIPANT_WHERE_CUSTOM = (where, id) => { + return `${BASE_SIMPRO_LUMEN}/project-participants/${where}/${id}`; +}; + +export const PROJECT_APPROVAL_ADD = `${BASE_SIMPRO_LUMEN}/project-approval/add`; +export const PROJECT_APPROVAL_SEARCH = `${BASE_SIMPRO_LUMEN}/project-approval/search`; +export const PROJECT_APPROVAL_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/project-approval/update/${id}`; +}; +export const PROJECT_APPROVAL_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/project-approval/delete/${id}`; +}; +export const PROJECT_APPROVAL_DELETE_BY_PROYEK = (id) => { + return `${BASE_SIMPRO_LUMEN}/project-approval/delete-by-proyek/${id}`; +}; +export const PROJECT_APPROVAL_LIST = `${BASE_SIMPRO_LUMEN}/project-approval/list`; +export const PROJECT_APPROVAL_WHERE_CUSTOM = (where, id) => { + return `${BASE_SIMPRO_LUMEN}/project-approval/${where}/${id}`; +}; + +export const PROJECT_MILESTONE_ADD = `${BASE_SIMPRO_LUMEN}/project-milestone/add`; +export const PROJECT_MILESTONE_SEARCH = `${BASE_SIMPRO_LUMEN}/project-milestone/search`; +export const PROJECT_MILESTONE_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/project-milestone/update/${id}`; +}; +export const PROJECT_MILESTONE_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/project-milestone/delete/${id}`; +}; +export const PROJECT_MILESTONE_DELETE_BY_PROYEK = (id) => { + return `${BASE_SIMPRO_LUMEN}/project-milestone/delete-by-proyek/${id}`; +}; +export const PROJECT_MILESTONE_LIST = `${BASE_SIMPRO_LUMEN}/project-milestone/list`; +export const PROJECT_MILESTONE_WHERE_CUSTOM = (where, id) => { + return `${BASE_SIMPRO_LUMEN}/project-milestone/${where}/${id}`; +}; + +export const PRESENCE_ADD = `${BASE_SIMPRO_LUMEN}/presence/add`; +export const PRESENCE_SEARCH = `${BASE_SIMPRO_LUMEN}/presence/search`; +export const PRESENCE_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/presence/update/${id}`; +}; +export const PRESENCE_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/presence/delete/${id}`; +}; +export const PRESENCE_LIST = `${BASE_SIMPRO_LUMEN}/presence/list`; + +export const SATUAN_ADD = `${BASE_SIMPRO_LUMEN}/satuan/add`; +export const SATUAN_SEARCH = `${BASE_SIMPRO_LUMEN}/satuan/search`; +export const SATUAN_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/satuan/update/${id}`; +}; +export const SATUAN_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/satuan/delete/${id}`; +}; +export const SATUAN_LIST = `${BASE_SIMPRO_LUMEN}/satuan/list`; + +export const CHECKLIST_K3_ADD = `${BASE_SIMPRO_LUMEN}/checklist-k3/add`; +export const CHECKLIST_K3_SEARCH = `${BASE_SIMPRO_LUMEN}/checklist-k3/search`; +export const CHECKLIST_K3_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/checklist-k3/update/${id}`; +}; +export const CHECKLIST_K3_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/checklist-k3/delete/${id}`; +}; +export const CHECKLIST_K3_LIST = `${BASE_SIMPRO_LUMEN}/checklist-k3/list`; + +export const ASSIGN_HR_PROJECT_ADD = `${BASE_SIMPRO_LUMEN}/user-to-proyek/add`; +export const ASSIGN_HR_PROJECT_SEARCH = `${BASE_SIMPRO_LUMEN}/user-to-proyek/search`; +export const ASSIGN_HR_PROJECT_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/user-to-proyek/update/${id}`; +}; +export const ASSIGN_HR_PROJECT_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/user-to-proyek/delete/${id}`; +}; +export const ASSIGN_HR_PROJECT_LIST = `${BASE_SIMPRO_LUMEN}/user-to-proyek/list`; + +export const IMAGE_GET_BY_ID = (id, category) => { + return `${BASE_SIMPRO_LUMEN}/image/${id}/${category}`; +}; +export const IMAGE_SEARCH = `${BASE_SIMPRO_LUMEN}/image/search`; +export const OSPRO_BASE_IMAGE = `${BASE_OSPRO}/api/assets/image`; + +export const DASHBOARD_COST_PLANNING_ACTUAL = `${BASE_SIMPRO_LUMEN}/dashboard/cost-planning-actual`; +export const DASHBOARD_PERSENTASE_PROGRESS_PROYEK = `${BASE_SIMPRO_LUMEN}/dashboard/percentage-planning-actual`; +export const DASHBOARD_REPORT_POINTS = `${BASE_SIMPRO_LUMEN}/report-activity/search-point`; +export const DASHBOARD_STATUS_PROYEK = `${BASE_SIMPRO_LUMEN}/dashboard/status-proyek`; +export const DASHBOARD_KURVA_S = `${BASE_SIMPRO_LUMEN}/activity/get-curva-s`; + +export const CURRENCY_LIST = `${BASE_SIMPRO_LUMEN}/currency/list`; + +export const GET_PERCENTAGE_PERDAY = `${BASE_SIMPRO_LUMEN}/activity/get-percentage`; + +export const FOLDER_DOCUMENT_PROYEK_ADD = `${BASE_SIMPRO_LUMEN}/folder-document-proyek/add`; +export const FOLDER_DOCUMENT_PROYEK_SEARCH = `${BASE_SIMPRO_LUMEN}/folder-document-proyek/search`; +export const FOLDER_DOCUMENT_PROYEK_UPDATE = (id) => + `${BASE_SIMPRO_LUMEN}/folder-document-proyek/update/${id}`; +export const FOLDER_DOCUMENT_PROYEK_DELETE = (id) => + `${BASE_SIMPRO_LUMEN}/folder-document-proyek/delete/${id}`; +export const FOLDER_DOCUMENT_PROYEK_GET_TREE = (proyek_id) => + `${BASE_SIMPRO_LUMEN}/folder-document-proyek/get-tree/${proyek_id}`; + +export const PROJECT_TO_CHECKLIST_K3_ADD = `${BASE_SIMPRO_LUMEN}/project-to-checklist-k3/add`; +export const PROJECT_TO_CHECKLIST_K3_ADDS = `${BASE_SIMPRO_LUMEN}/project-to-checklist-k3/add-multiple`; +export const PROJECT_TO_CHECKLIST_K3_SEARCH = `${BASE_SIMPRO_LUMEN}/project-to-checklist-k3/search`; +export const PROJECT_TO_CHECKLIST_K3_EDIT = (id) => { + return `${BASE_SIMPRO_LUMEN}/project-to-checklist-k3/update/${id}`; +}; +export const PROJECT_TO_CHECKLIST_K3_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/project-to-checklist-k3/delete/${id}`; +}; +export const PROJECT_TO_CHECKLIST_K3_LIST = `${BASE_SIMPRO_LUMEN}/project-to-checklist-k3/list`; + +export const CONTROL_MONITORING_SEARCH = `${BASE_SIMPRO_LUMEN}/control-monitoring/search`; +export const API_PANIC_BUTTON_SIMPRO = `${BASE_SIMPRO_LUMEN}/panic-button`; +export const PANIC_BUTTON_SEARCH = `${BASE_SIMPRO_LUMEN}/panic-button/search`; +export const PANIC_BUTTON_UPDATE = (id) => { + return `${BASE_SIMPRO_LUMEN}/panic-button/update/${id}`; +}; + +export const HIERARCHY_FTTH_GET = `${BASE_SIMPRO_LUMEN}/hierarchy-ftths`; +export const HIERARCHY_FTTH_ADD = `${BASE_SIMPRO_LUMEN}/hierarchy-ftths`; +export const HIERARCHY_FTTH_SEARCH = `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/search`; +export const HIERARCHY_FTTH_SHOW = (id) => { + return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/${id}`; +}; +export const HIERARCHY_FTTH_UPDATE = (id) => { + return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/${id}`; +}; +export const HIERARCHY_FTTH_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/${id}`; +}; +export const HIERARCHY_FTTH_TREE = (id) => { + return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/tree/${id}`; +}; +export const WAYPOINT_SEARCH = `${BASE_SIMPRO_LUMEN}/waypoint/search`; diff --git a/src/views/Dashboard/DashboardProject.js b/src/views/Dashboard/DashboardProject.js index 24b6428..5687f2f 100644 --- a/src/views/Dashboard/DashboardProject.js +++ b/src/views/Dashboard/DashboardProject.js @@ -1,961 +1,1657 @@ -import React, { useEffect, useMemo, useRef, useState } from 'react'; -import axios from 'axios' -import { Row, Col, Button, Input } from 'antd'; -import { CardDashboard, CardExpenditure, CardScheduleHealthPerDivision } from '../../components/CardDashboard/CardDashboard'; -import L from 'leaflet'; -import { useParams } from 'react-router-dom'; -import '../../assets/css/customscroll.css' -import moment from 'moment'; -import { renderFormatRupiah } from '../../const/CustomFunc'; -import { BASE_OSPRO } from '../../const/ApiConst'; -import { SendOutlined } from '@ant-design/icons'; -import { NotificationContainer, NotificationManager } from 'react-notifications'; -import ContentLoader from 'react-content-loader'; -import { BehindTaskItem, Comment, HealthByBudget, HealthBySchedule, ListLoader, PopupContent, ProgressActualBar, ProgressPlanningBar, SingleTextLoader } from './Components'; -import { Fab, Action } from 'react-tiny-fab'; -import 'react-tiny-fab/dist/styles.css'; +import React, { useEffect, useMemo, useRef, useState } from "react"; +import axios from "axios"; +import { Row, Col, Button, Input } from "antd"; +import { + CardDashboard, + CardExpenditure, + CardScheduleHealthPerDivision, +} from "../../components/CardDashboard/CardDashboard"; +import L from "leaflet"; +import { useParams } from "react-router-dom"; +import "../../assets/css/customscroll.css"; +import moment from "moment"; +import { renderFormatRupiah } from "../../const/CustomFunc"; +import { BASE_OSPRO } from "../../const/ApiConst"; +import { SendOutlined } from "@ant-design/icons"; +import { + NotificationContainer, + NotificationManager, +} from "react-notifications"; +import ContentLoader from "react-content-loader"; +import { + BehindTaskItem, + Comment, + HealthByBudget, + HealthBySchedule, + ListLoader, + PopupContent, + ProgressActualBar, + ProgressPlanningBar, + SingleTextLoader, +} from "./Components"; +import { Fab, Action } from "react-tiny-fab"; +import "react-tiny-fab/dist/styles.css"; import { useHistory } from "react-router-dom"; const { TextArea } = Input; const styles = { - cardContainer: { backgroundColor: '#F8F8F8', margin: 2, paddingLeft: 20, paddingRight: 20, paddingTop: 10 }, - cardHeaderContainer: { display: 'flex', flexDirection: 'row', marginBottom: 10 }, - cardChartContainer: { position: 'relative', height: '21vh', margin: 'auto', paddingBottom: 10, justifyContent: 'center' }, - cardTitle: { color: '#444444', fontSize: 16, fontWeight: 'bold' }, - cardSubtitle: { color: '#888888', fontSize: 12 } -} + cardContainer: { + backgroundColor: "#F8F8F8", + margin: 2, + paddingLeft: 20, + paddingRight: 20, + paddingTop: 10, + }, + cardHeaderContainer: { + display: "flex", + flexDirection: "row", + marginBottom: 10, + }, + cardChartContainer: { + position: "relative", + height: "21vh", + margin: "auto", + paddingBottom: 10, + justifyContent: "center", + }, + cardTitle: { color: "#444444", fontSize: 16, fontWeight: "bold" }, + cardSubtitle: { color: "#888888", fontSize: 12 }, +}; const center = { - lat: -6.200000, - lng: 106.816666 -} + lat: -6.2, + lng: 106.816666, +}; const DashboardProject = () => { - const token = localStorage.getItem("token") - const HEADER = { - headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${token}` - } - } - const { PROJECT_ID, GANTT_ID, SCURVE } = useParams(); - const URL_GANTT = `https://adw-gantt.ospro.id/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1`; - const mapRef = useRef() - const [projectName, setProjectName] = useState(""); - const [projectManagerName, setProjectManagerName] = useState(""); - const [customerName, setCustomerName] = useState(""); - const [plannedStart, setPlannedStart] = useState(null) - const [plannedFinish, setPlannedFinish] = useState(null) - const [plannedCost, setPlannedCost] = useState(null) - const [totalCost, setTotalCost] = useState(null) - const [actualStart, setActualStart] = useState(null) - const [actualFinish, setActualFinish] = useState(null) - const [estimatedFinish, setEstimatedFinish] = useState(null) - const [mymap, setMymap] = useState(null); - const [activeTabIdx, setActiveTabIdx] = useState(0); - const [activeTabCommentIdx, setActiveTabCommentIdx] = useState(0); - const [planningProgress, setPlanningProgress] = useState(0); - const [actualProgress, setActualProgress] = useState(0); - const [currentBudget, setCurrentBudget] = useState(null) - const [addCostToComplete, setAddCostToComplete] = useState(null) - const [actualToDate, setActualToDate] = useState(null) - const [estAtCompletion, setEstAtCompletion] = useState(null) - const [bcwp, setBcwp] = useState(null) - const [costDeviation, setCostDeviation] = useState(null) - const [remToComplete, setRemToComplete] = useState(0) - const [totalInvoice, setTotalInvoice] = useState(null) - const [cashIn, setCashIn] = useState(null) - const [outstandingBalance, setOutstandingBalance] = useState(null) - const [comment, setComment] = useState(''); - const [comments, setComments] = useState([]); - const [isReadyComments, setIsReadyComments] = useState(false); - const [isSendingComment, setIsSendingComment] = useState(false); - const [isReadyProjectDetail, setIsReadyProjectDetail] = useState(false); - const [isReadySCurve, setIsReadySCurve] = useState(false); - const [isReadyGantt, setIsReadyGantt] = useState(false); - const [isReadyOverdueActivities, setIsReadyOverdueActivities] = useState(false); - const [isReadyIntegrationInvoice, setIsReadyIntegrationInvoice] = useState(false); - const [isReadyReportDistribution, setIsReadyReportDistribution] = useState(false); - const [overdueActivities, setOverdueActivities] = useState([]); - const [healthBySchedule, setHealthBySchedule] = useState('-') - const [healthByBudget, setHealthByBudget] = useState('-') - const [reportDistribution, setReportDistribution] = useState([]); - const [manPower, setManPower] = useState(0); - const [assignedHr, setAssignedHr] = useState([]); - const [assignedHrCount, setAssignedHrCount] = useState(0); - const [actualHrCount, setActualHrCount] = useState(0); - const [dataGantt, setDataGantt] = useState({}); - const [dataGanttParents, setDataGanttParents] = useState({}); - const [isReadyGanttParents, setIsReadyGanttParents] = useState(false); - const [calculationStatus, setCalculationStatus] = useState(false); - let history = useHistory(); - - - useEffect(() => { - getProjectDetail() - getSCurve() - getOverdueActivities() - getReportDistribution() - getComments() - getGantt() - getGanttParents() - return () => { - console.log('unmount RenderMap'); - } - }, []) + const token = localStorage.getItem("token"); + const HEADER = { + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${token}`, + }, + }; + const { PROJECT_ID, GANTT_ID, SCURVE } = useParams(); + const URL_GANTT = `http://localhost:8444/adw-gantt/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1`; + const mapRef = useRef(); + const [projectName, setProjectName] = useState(""); + const [projectManagerName, setProjectManagerName] = useState(""); + const [customerName, setCustomerName] = useState(""); + const [plannedStart, setPlannedStart] = useState(null); + const [plannedFinish, setPlannedFinish] = useState(null); + const [plannedCost, setPlannedCost] = useState(null); + const [totalCost, setTotalCost] = useState(null); + const [actualStart, setActualStart] = useState(null); + const [actualFinish, setActualFinish] = useState(null); + const [estimatedFinish, setEstimatedFinish] = useState(null); + const [mymap, setMymap] = useState(null); + const [activeTabIdx, setActiveTabIdx] = useState(0); + const [activeTabCommentIdx, setActiveTabCommentIdx] = useState(0); + const [planningProgress, setPlanningProgress] = useState(0); + const [actualProgress, setActualProgress] = useState(0); + const [currentBudget, setCurrentBudget] = useState(null); + const [addCostToComplete, setAddCostToComplete] = useState(null); + const [actualToDate, setActualToDate] = useState(null); + const [estAtCompletion, setEstAtCompletion] = useState(null); + const [bcwp, setBcwp] = useState(null); + const [costDeviation, setCostDeviation] = useState(null); + const [remToComplete, setRemToComplete] = useState(0); + const [totalInvoice, setTotalInvoice] = useState(null); + const [cashIn, setCashIn] = useState(null); + const [outstandingBalance, setOutstandingBalance] = useState(null); + const [comment, setComment] = useState(""); + const [comments, setComments] = useState([]); + const [isReadyComments, setIsReadyComments] = useState(false); + const [isSendingComment, setIsSendingComment] = useState(false); + const [isReadyProjectDetail, setIsReadyProjectDetail] = useState(false); + const [isReadySCurve, setIsReadySCurve] = useState(false); + const [isReadyGantt, setIsReadyGantt] = useState(false); + const [isReadyOverdueActivities, setIsReadyOverdueActivities] = + useState(false); + const [isReadyIntegrationInvoice, setIsReadyIntegrationInvoice] = + useState(false); + const [isReadyReportDistribution, setIsReadyReportDistribution] = + useState(false); + const [overdueActivities, setOverdueActivities] = useState([]); + const [healthBySchedule, setHealthBySchedule] = useState("-"); + const [healthByBudget, setHealthByBudget] = useState("-"); + const [reportDistribution, setReportDistribution] = useState([]); + const [manPower, setManPower] = useState(0); + const [assignedHr, setAssignedHr] = useState([]); + const [assignedHrCount, setAssignedHrCount] = useState(0); + const [actualHrCount, setActualHrCount] = useState(0); + const [dataGantt, setDataGantt] = useState({}); + const [dataGanttParents, setDataGanttParents] = useState({}); + const [isReadyGanttParents, setIsReadyGanttParents] = useState(false); + const [calculationStatus, setCalculationStatus] = useState(false); + let history = useHistory(); - useEffect(() => { - if (activeTabIdx === 1) { - initMap(); - } - }, [activeTabIdx]); - - useEffect(() => { - async function fetchData() { - await Promise.all([ - getManpower(), - getAssignedHR(), - ...(assignedHr.length > 0 ? [getActualHR()] : []) - ]) - } - fetchData() - }, []) + useEffect(() => { + getProjectDetail(); + getSCurve(); + getOverdueActivities(); + getReportDistribution(); + getComments(); + getGantt(); + getGanttParents(); + return () => { + console.log("unmount RenderMap"); + }; + }, []); - useEffect(() => { - let deviation = 0; - if (plannedCost && totalCost) { - deviation = plannedCost - totalCost; - } - setRemToComplete(deviation.toString()) + useEffect(() => { + if (activeTabIdx === 1) { + initMap(); + } + }, [activeTabIdx]); - }, [plannedCost, totalCost]); + useEffect(() => { + async function fetchData() { + await Promise.all([ + getManpower(), + getAssignedHR(), + ...(assignedHr.length > 0 ? [getActualHR()] : []), + ]); + } + fetchData(); + }, []); - const handleRedirect = () => { - history.push("/projects/" + GANTT_ID + "/" + PROJECT_ID + "/gantt"); + useEffect(() => { + let deviation = 0; + if (plannedCost && totalCost) { + deviation = plannedCost - totalCost; } + setRemToComplete(deviation.toString()); + }, [plannedCost, totalCost]); - const getManpower = async () => { - const url = `${BASE_OSPRO}/api/project/manpower/${PROJECT_ID}` - try { - const response = await axios.get(url, HEADER) - setManPower(response.data.totalRecord) - } catch (error) { - console.error('Failed to get manpower:', error) - } + const handleRedirect = () => { + history.push("/projects/" + GANTT_ID + "/" + PROJECT_ID + "/gantt"); + }; + + const getManpower = async () => { + const url = `${BASE_OSPRO}/api/project/manpower/${PROJECT_ID}`; + try { + const response = await axios.get(url, HEADER); + setManPower(response.data.totalRecord); + } catch (error) { + console.error("Failed to get manpower:", error); } + }; - const getGantt = async () => { - setIsReadyGantt(false) - const url = `${BASE_OSPRO}/api/version-gantt/edit/${GANTT_ID}` - try { - const response = await axios.get(url, HEADER) - setDataGantt(response) - setIsReadyGantt(true) - } catch (error) { - console.error('Failed to get gantt data:', error) - setIsReadyGantt(true) - } + const getGantt = async () => { + setIsReadyGantt(false); + const url = `${BASE_OSPRO}/api/version-gantt/edit/${GANTT_ID}`; + try { + const response = await axios.get(url, HEADER); + setDataGantt(response); + setIsReadyGantt(true); + } catch (error) { + console.error("Failed to get gantt data:", error); + setIsReadyGantt(true); } + }; - const getGanttParents = async () => { - setIsReadyGanttParents(false) - const url = `${BASE_OSPRO}/api/hierarchy-ftths/tree-gantt/${GANTT_ID}` - try { - const response = await axios.get(url, HEADER) - setDataGanttParents(response) - setIsReadyGanttParents(true) - } catch (error) { - console.error('Failed to get gantt data:', error) - setIsReadyGanttParents(true) - } + const getGanttParents = async () => { + setIsReadyGanttParents(false); + const url = `${BASE_OSPRO}/api/hierarchy-ftths/tree-gantt/${GANTT_ID}`; + try { + const response = await axios.get(url, HEADER); + setDataGanttParents(response); + setIsReadyGanttParents(true); + } catch (error) { + console.error("Failed to get gantt data:", error); + setIsReadyGanttParents(true); } + }; - const getAssignedHR = async () => { - const url = `${BASE_OSPRO}/api/project/manpower/assigned/${GANTT_ID}` - try { - const response = await axios.get(url, HEADER) - const today = moment() - const assignedList = response.data.data - .filter(item => today.isBetween(moment(item.start_date), moment(item.end_date))) - .map(item => item.user_id) - setAssignedHrCount(assignedList.length) - setAssignedHr(assignedList) - } catch (error) { - console.error('Failed to get assigned HR:', error) - } + const getAssignedHR = async () => { + const url = `${BASE_OSPRO}/api/project/manpower/assigned/${GANTT_ID}`; + try { + const response = await axios.get(url, HEADER); + const today = moment(); + const assignedList = response.data.data + .filter((item) => + today.isBetween(moment(item.start_date), moment(item.end_date)) + ) + .map((item) => item.user_id); + setAssignedHrCount(assignedList.length); + setAssignedHr(assignedList); + } catch (error) { + console.error("Failed to get assigned HR:", error); } + }; - const getActualHR = async () => { - const dateStart = moment().startOf('day').toDate() - const dateEnd = moment().endOf('day').toDate() - try { - const payload = { - paging: { start: 0, length: -1 }, - columns: [ - { name: 'name', logic_operator: 'ilike', value: '', table_name: 'm_users' }, - { name: 'clock_in', logic_operator: 'range', value: dateStart, value1: dateEnd }, - ], - joins: [{ - name: 'm_users', - column_join: 'user_id', - column_results: ['name', 'ktp_number'], - }], - orders: { columns: ['id'], ascending: false }, - } - const url = `${BASE_OSPRO}/api/presence/search` - const response = await axios.post(url, payload, HEADER) - const actualHrCount = response.data.data.filter(item => assignedHr.includes(item.user_id)).length - setActualHrCount(actualHrCount) - } catch (error) { - console.error('Failed to get actual HR:', error) - } - } - - const getProjectDetail = async () => { - setIsReadyProjectDetail(false); - const URL = `${BASE_OSPRO}/api/project/detail/${PROJECT_ID}`; - const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) - console.log('getProjectDetail', result); - if (!result) { - NotificationManager.error(`Could not connect to internet.`, "Failed"); - setIsReadyProjectDetail(true); - return; - } + const getActualHR = async () => { + const dateStart = moment().startOf("day").toDate(); + const dateEnd = moment().endOf("day").toDate(); + try { + const payload = { + paging: { start: 0, length: -1 }, + columns: [ + { + name: "name", + logic_operator: "ilike", + value: "", + table_name: "m_users", + }, + { + name: "clock_in", + logic_operator: "range", + value: dateStart, + value1: dateEnd, + }, + ], + joins: [ + { + name: "m_users", + column_join: "user_id", + column_results: ["name", "ktp_number"], + }, + ], + orders: { columns: ["id"], ascending: false }, + }; + const url = `${BASE_OSPRO}/api/presence/search`; + const response = await axios.post(url, payload, HEADER); + const actualHrCount = response.data.data.filter((item) => + assignedHr.includes(item.user_id) + ).length; + setActualHrCount(actualHrCount); + } catch (error) { + console.error("Failed to get actual HR:", error); + } + }; - if (result.status !== 200) { - NotificationManager.error(`Get project detail failed, ${result.data.message}`, "Failed"); - setIsReadyProjectDetail(true); - return; - } - else if (result.status == 200 && result.data.data) { - console.log(result.data.data); - // setComments(result.data.data); - setProjectName(result.data.data.nama ? result.data.data.nama : '-'); - setProjectManagerName(result.data.data.projectManager ? result.data.data.projectManager : '-'); - setCustomerName(result.data.data.company ? result.data.data.company : '-') - setPlannedStart(result.data.data?.mulai_proyek ? result.data.data.mulai_proyek : null) - setPlannedFinish(result.data.data?.akhir_proyek ? result.data.data.akhir_proyek : null) - setActualStart(result.data.data.header?.start_date ? result.data.data.header.start_date : null) - setEstimatedFinish(result.data.data.header?.end_date ? result.data.data.header.end_date : null) - setPlannedCost(result.data.data.rencana_biaya ? result.data.data.rencana_biaya : null) - setIsReadyProjectDetail(true); - setCalculationStatus(result.data.data.calculation_status ? result.data.data.calculation_status : false) - - if (result.data.data.kode_sortname && result.data.data.kode_sortname !== '') { - getIntegrationInvoice(result.data.data.kode_sortname) - } - } + const getProjectDetail = async () => { + setIsReadyProjectDetail(false); + const URL = `${BASE_OSPRO}/api/project/detail/${PROJECT_ID}`; + const result = await axios + .get(URL, HEADER) + .then((res) => res) + .catch((err) => err.response); + console.log("getProjectDetail", result); + if (!result) { + NotificationManager.error(`Could not connect to internet.`, "Failed"); + setIsReadyProjectDetail(true); + return; } - const getSCurve = async () => { - setIsReadySCurve(false); - let URL = `${BASE_OSPRO}/api/project/get-s-curve`; - if(SCURVE && SCURVE == "1"){ - URL = `${BASE_OSPRO}/api/project/calculate-s-curve`; - } - - const payload = { - "project_id": PROJECT_ID.toString(), - "gantt_id": GANTT_ID.toString(), - "period": "week", - // "end_date": moment(new Date()).format('YYYY-MM-DD') - } - const result = await axios.post(URL, payload, HEADER).then(res => res).catch(err => err.response) - if (!result) { - NotificationManager.error(`Could not connect to internet.`, "Failed"); - setIsReadySCurve(true); - return; - } + if (result.status !== 200) { + NotificationManager.error( + `Get project detail failed, ${result.data.message}`, + "Failed" + ); + setIsReadyProjectDetail(true); + return; + } else if (result.status == 200 && result.data.data) { + console.log(result.data.data); + // setComments(result.data.data); + setProjectName(result.data.data.nama ? result.data.data.nama : "-"); + setProjectManagerName( + result.data.data.projectManager ? result.data.data.projectManager : "-" + ); + setCustomerName( + result.data.data.company ? result.data.data.company : "-" + ); + setPlannedStart( + result.data.data?.mulai_proyek ? result.data.data.mulai_proyek : null + ); + setPlannedFinish( + result.data.data?.akhir_proyek ? result.data.data.akhir_proyek : null + ); + setActualStart( + result.data.data.header?.start_date + ? result.data.data.header.start_date + : null + ); + setEstimatedFinish( + result.data.data.header?.end_date + ? result.data.data.header.end_date + : null + ); + setPlannedCost( + result.data.data.rencana_biaya ? result.data.data.rencana_biaya : null + ); + setIsReadyProjectDetail(true); + setCalculationStatus( + result.data.data.calculation_status + ? result.data.data.calculation_status + : false + ); - if (result.status !== 200) { - NotificationManager.error(`Get S Curve failed, ${result.data.message}`, "Failed"); - setIsReadySCurve(true); - return; - } - else if (result.status == 200 && result.data.data) { - let selisihProgress = 0; - let planningProgress = 0; - let actualProgress = 0; - let statusHealthBySchedule = 'on-schedule'; - if (result.data.data.length > 0 && result.data.data[0].data?.budget_control) { - setCurrentBudget(result.data.data[0].data.budget_control.current_budget?.toString()) - setActualToDate(result.data.data[0].data.budget_control.acwp?.toString()) - setBcwp(result.data.data[0].data.budget_control.current_budget?.toString()) - // setRemToComplete(result.data.data[0].data.budget_control.rem_to_complete?.toString()) - setAddCostToComplete(result.data.data[0].data.budget_control.add_cost_to_complete?.toString()) - setEstAtCompletion(result.data.data[0].data.budget_control.estimated_at_completion?.toString()) - setCostDeviation(result.data.data[0].data.budget_control.cost_deviation?.toString()) - } - let now = new Date().toISOString().slice(0, 10); - let dates = result.data.data[0].data?.date; - let n = dates.findIndex(element => new Date(now) < new Date(element[0])) - 1; - if (n < 0) { - n = dates.length - 1; - } - if (result.data.data.length > 0 && result.data.data[0].data?.percentagePlan && result.data.data[0].data?.percentagePlan.length > 0) { - if(SCURVE && SCURVE == "1"){ - planningProgress = result.data.data[0].data?.percentagePlan[result.data.data[0].data?.percentagePlan.length - 1]; - } else { - planningProgress = result.data.data[0].data?.percentagePlan[n]; - } - setPlanningProgress(planningProgress); - } - if (result.data.data.length > 0 && result.data.data[0].data?.percentageReal && result.data.data[0].data?.percentageReal.length > 0) { - actualProgress = result.data.data[0].data?.percentageReal[result.data.data[0].data?.percentageReal.length - 1]; - setActualProgress(actualProgress); - } + if ( + result.data.data.kode_sortname && + result.data.data.kode_sortname !== "" + ) { + getIntegrationInvoice(result.data.data.kode_sortname); + } + } + }; - selisihProgress = planningProgress - actualProgress; - if (selisihProgress > 0 && selisihProgress <= 5) { - statusHealthBySchedule = 'warning' - } - else if (selisihProgress > 5) { - statusHealthBySchedule = 'danger' - } + const getSCurve = async () => { + setIsReadySCurve(false); + let URL = `${BASE_OSPRO}/api/project/get-s-curve`; + if (SCURVE && SCURVE == "1") { + URL = `${BASE_OSPRO}/api/project/calculate-s-curve`; + } - setHealthBySchedule(statusHealthBySchedule) - setIsReadySCurve(true); - } + const payload = { + project_id: PROJECT_ID.toString(), + gantt_id: GANTT_ID.toString(), + period: "week", + // "end_date": moment(new Date()).format('YYYY-MM-DD') + }; + const result = await axios + .post(URL, payload, HEADER) + .then((res) => res) + .catch((err) => err.response); + if (!result) { + NotificationManager.error(`Could not connect to internet.`, "Failed"); + setIsReadySCurve(true); + return; } - const getOverdueActivities = async () => { - setIsReadyOverdueActivities(false); - const URL = `${BASE_OSPRO}/api/project/get-overdue-activities`; - const payload = { - "id": PROJECT_ID.toString(), - "till_date": moment(new Date()).format('YYYY-MM-DD') - } - const result = await axios.post(URL, payload, HEADER).then(res => res).catch(err => err.response) - console.log('getOverdueActivities', result); - if (!result) { - NotificationManager.error(`Could not connect to internet.`, "Failed"); - setIsReadyOverdueActivities(true); - return; + if (result.status !== 200) { + NotificationManager.error( + `Get S Curve failed, ${result.data.message}`, + "Failed" + ); + setIsReadySCurve(true); + return; + } else if (result.status == 200 && result.data.data) { + let selisihProgress = 0; + let planningProgress = 0; + let actualProgress = 0; + let statusHealthBySchedule = "on-schedule"; + if ( + result.data.data.length > 0 && + result.data.data[0].data?.budget_control + ) { + setCurrentBudget( + result.data.data[0].data.budget_control.current_budget?.toString() + ); + setActualToDate( + result.data.data[0].data.budget_control.acwp?.toString() + ); + setBcwp( + result.data.data[0].data.budget_control.current_budget?.toString() + ); + // setRemToComplete(result.data.data[0].data.budget_control.rem_to_complete?.toString()) + setAddCostToComplete( + result.data.data[0].data.budget_control.add_cost_to_complete?.toString() + ); + setEstAtCompletion( + result.data.data[0].data.budget_control.estimated_at_completion?.toString() + ); + setCostDeviation( + result.data.data[0].data.budget_control.cost_deviation?.toString() + ); + } + let now = new Date().toISOString().slice(0, 10); + let dates = result.data.data[0].data?.date; + let n = + dates.findIndex((element) => new Date(now) < new Date(element[0])) - 1; + if (n < 0) { + n = dates.length - 1; + } + if ( + result.data.data.length > 0 && + result.data.data[0].data?.percentagePlan && + result.data.data[0].data?.percentagePlan.length > 0 + ) { + if (SCURVE && SCURVE == "1") { + planningProgress = + result.data.data[0].data?.percentagePlan[ + result.data.data[0].data?.percentagePlan.length - 1 + ]; + } else { + planningProgress = result.data.data[0].data?.percentagePlan[n]; } + setPlanningProgress(planningProgress); + } + if ( + result.data.data.length > 0 && + result.data.data[0].data?.percentageReal && + result.data.data[0].data?.percentageReal.length > 0 + ) { + actualProgress = + result.data.data[0].data?.percentageReal[ + result.data.data[0].data?.percentageReal.length - 1 + ]; + setActualProgress(actualProgress); + } - if (result.status !== 200) { - NotificationManager.error(`Get Overdue Activities failed, ${result.data.message}`, "Failed"); - setIsReadyOverdueActivities(true); - return; - } - else if (result.status == 200 && result.data.data) { - if (result.data.data.overdueActivities) { - setOverdueActivities(result.data.data.overdueActivities) - } - setHealthByBudget(result.data.data.budget_health) - setIsReadyOverdueActivities(true); - } - } + selisihProgress = planningProgress - actualProgress; + if (selisihProgress > 0 && selisihProgress <= 5) { + statusHealthBySchedule = "warning"; + } else if (selisihProgress > 5) { + statusHealthBySchedule = "danger"; + } - const getIntegrationInvoice = async (kode_sortname) => { - setIsReadyIntegrationInvoice(false); - const URL = `${BASE_OSPRO}/api/project/get-integration-invoice`; - const payload = { - "search": kode_sortname - } - const result = await axios.post(URL, payload, HEADER).then(res => res).catch(err => err.response) - console.log('getIntegrationInvoice', result); - if (!result) { - NotificationManager.error(`Could not connect to internet.`, "Failed"); - setIsReadyIntegrationInvoice(true); - return; - } + setHealthBySchedule(statusHealthBySchedule); + setIsReadySCurve(true); + } + }; - if (result.status !== 200) { - NotificationManager.error(`Get integration invoice failed, ${result.data.message}`, "Failed"); - setIsReadyIntegrationInvoice(true); - return; - } - else if (result.status == 200 && result.data.data) { - if (result.data.data.data) { - let total_invoice = result.data.data.data.total_invoice_amount; - let cash_in = result.data.data.data.total_invoice_paid_amount; - let total_cost = result.data.data.data.total_cost; - let outstanding_balance = total_invoice - cash_in; - setTotalInvoice(total_invoice ? total_invoice.toString() : null); - setCashIn(cash_in ? cash_in.toString() : null) - total_cost = total_cost.toString().split('.')[0] - setTotalCost(total_cost ? total_cost.toString() : null) - setOutstandingBalance(outstanding_balance ? outstanding_balance.toString() : null); - } - setIsReadyIntegrationInvoice(true); - } + const getOverdueActivities = async () => { + setIsReadyOverdueActivities(false); + const URL = `${BASE_OSPRO}/api/project/get-overdue-activities`; + const payload = { + id: PROJECT_ID.toString(), + till_date: moment(new Date()).format("YYYY-MM-DD"), + }; + const result = await axios + .post(URL, payload, HEADER) + .then((res) => res) + .catch((err) => err.response); + console.log("getOverdueActivities", result); + if (!result) { + NotificationManager.error(`Could not connect to internet.`, "Failed"); + setIsReadyOverdueActivities(true); + return; } - const getReportDistribution = async () => { - setIsReadyReportDistribution(false); - const URL = `${BASE_OSPRO}/api/project/get-report-distribution`; - const payload = { - "project_id": PROJECT_ID, - "start_date": moment().startOf('month').subtract(1, 'years').format('YYYY-MM-DD'), - "end_date": moment(new Date()).subtract(1, 'years').format('YYYY-MM-DD') - } - const result = await axios.post(URL, payload, HEADER).then(res => res).catch(err => err.response) - console.log('getReportDistribution', result); - if (!result) { - NotificationManager.error(`Could not connect to internet.`, "Failed"); - setIsReadyReportDistribution(true); - return; - } + if (result.status !== 200) { + NotificationManager.error( + `Get Overdue Activities failed, ${result.data.message}`, + "Failed" + ); + setIsReadyOverdueActivities(true); + return; + } else if (result.status == 200 && result.data.data) { + if (result.data.data.overdueActivities) { + setOverdueActivities(result.data.data.overdueActivities); + } + setHealthByBudget(result.data.data.budget_health); + setIsReadyOverdueActivities(true); + } + }; - if (result.status !== 200) { - NotificationManager.error(`Get report distribution failed, ${result.data.message}`, "Failed"); - setIsReadyReportDistribution(true); - return; - } - else if (result.status == 200 && result.data.data) { - setReportDistribution(result.data.data); - setIsReadyReportDistribution(true); - } + const getIntegrationInvoice = async (kode_sortname) => { + setIsReadyIntegrationInvoice(false); + const URL = `${BASE_OSPRO}/api/project/get-integration-invoice`; + const payload = { + search: kode_sortname, + }; + const result = await axios + .post(URL, payload, HEADER) + .then((res) => res) + .catch((err) => err.response); + console.log("getIntegrationInvoice", result); + if (!result) { + NotificationManager.error(`Could not connect to internet.`, "Failed"); + setIsReadyIntegrationInvoice(true); + return; } - const getComments = async () => { - setIsReadyComments(false); - const URL = `${BASE_OSPRO}/api/project-comment/search`; - const payload = { - columns: [ - { - name: "project_id", - logic_operator: "=", - value: PROJECT_ID.toString(), - operator: "AND", - }, - { - name: "gantt_id", - logic_operator: "=", - value: GANTT_ID.toString(), - operator: "AND", - } - ], - joins: [ - { - name: "m_users", - column_join: "sender_id", - column_results: ["name", "username"], - } - ], - orders: { columns: ["created_at"], ascending: false }, - paging: { start: 0, length: -1 }, - }; - - const result = await axios.post(URL, payload, HEADER).then(res => res).catch(err => err.response) - console.log('getComments', result); - if (!result) { - NotificationManager.error(`Could not connect to internet.`, "Failed"); - setIsReadyComments(true); - return; - } + if (result.status !== 200) { + NotificationManager.error( + `Get integration invoice failed, ${result.data.message}`, + "Failed" + ); + setIsReadyIntegrationInvoice(true); + return; + } else if (result.status == 200 && result.data.data) { + if (result.data.data.data) { + let total_invoice = result.data.data.data.total_invoice_amount; + let cash_in = result.data.data.data.total_invoice_paid_amount; + let total_cost = result.data.data.data.total_cost; + let outstanding_balance = total_invoice - cash_in; + setTotalInvoice(total_invoice ? total_invoice.toString() : null); + setCashIn(cash_in ? cash_in.toString() : null); + total_cost = total_cost.toString().split(".")[0]; + setTotalCost(total_cost ? total_cost.toString() : null); + setOutstandingBalance( + outstanding_balance ? outstanding_balance.toString() : null + ); + } + setIsReadyIntegrationInvoice(true); + } + }; - if (result.status !== 200) { - NotificationManager.error(`Get comments failed, ${result.data.message}`, "Failed"); - setIsReadyComments(true); - return; - } - else if (result.status == 200 && result.data.data) { - setComments(result.data.data); - setIsReadyComments(true); - } + const getReportDistribution = async () => { + setIsReadyReportDistribution(false); + const URL = `${BASE_OSPRO}/api/project/get-report-distribution`; + const payload = { + project_id: PROJECT_ID, + start_date: moment() + .startOf("month") + .subtract(1, "years") + .format("YYYY-MM-DD"), + end_date: moment(new Date()).subtract(1, "years").format("YYYY-MM-DD"), + }; + const result = await axios + .post(URL, payload, HEADER) + .then((res) => res) + .catch((err) => err.response); + console.log("getReportDistribution", result); + if (!result) { + NotificationManager.error(`Could not connect to internet.`, "Failed"); + setIsReadyReportDistribution(true); + return; } - const handleSendComment = async () => { - // console.log('handleSendComment', comment); - setIsSendingComment(true); - if (comment === '') { - NotificationManager.error("Please leave a comment before you send it.", "Failed"); - setIsSendingComment(false); - return; - } - const URL = `${BASE_OSPRO}/api/project-comment/add`; - const payload = { - "sender_id": localStorage.getItem('user_id'), - "project_id": PROJECT_ID, - "gantt_id": GANTT_ID, - "comment": comment - } - const result = await axios.post(URL, payload, HEADER).then(res => res).catch(err => err.response) + if (result.status !== 200) { + NotificationManager.error( + `Get report distribution failed, ${result.data.message}`, + "Failed" + ); + setIsReadyReportDistribution(true); + return; + } else if (result.status == 200 && result.data.data) { + setReportDistribution(result.data.data); + setIsReadyReportDistribution(true); + } + }; - if (!result) { - NotificationManager.error(`Could not connect to internet.`, "Failed"); - setIsSendingComment(false); - return; - } + const getComments = async () => { + setIsReadyComments(false); + const URL = `${BASE_OSPRO}/api/project-comment/search`; + const payload = { + columns: [ + { + name: "project_id", + logic_operator: "=", + value: PROJECT_ID.toString(), + operator: "AND", + }, + { + name: "gantt_id", + logic_operator: "=", + value: GANTT_ID.toString(), + operator: "AND", + }, + ], + joins: [ + { + name: "m_users", + column_join: "sender_id", + column_results: ["name", "username"], + }, + ], + orders: { columns: ["created_at"], ascending: false }, + paging: { start: 0, length: -1 }, + }; - if (result.status !== 200) { - NotificationManager.error(`Post comment failed, ${result.data.message}`, "Failed"); - setIsSendingComment(false); - return; - } - else if (result.status === 200) { - NotificationManager.success(`Post comment success`, "Success"); - resetInputComment(); - getComments(); - } + const result = await axios + .post(URL, payload, HEADER) + .then((res) => res) + .catch((err) => err.response); + console.log("getComments", result); + if (!result) { + NotificationManager.error(`Could not connect to internet.`, "Failed"); + setIsReadyComments(true); + return; } - const resetInputComment = () => { - setComment(''); - setIsSendingComment(false); + if (result.status !== 200) { + NotificationManager.error( + `Get comments failed, ${result.data.message}`, + "Failed" + ); + setIsReadyComments(true); + return; + } else if (result.status == 200 && result.data.data) { + setComments(result.data.data); + setIsReadyComments(true); } + }; - const initMap = () => { - let mymap = L.map('map-area', { - center: center, - zoom: 13 - }); + const handleSendComment = async () => { + // console.log('handleSendComment', comment); + setIsSendingComment(true); + if (comment === "") { + NotificationManager.error( + "Please leave a comment before you send it.", + "Failed" + ); + setIsSendingComment(false); + return; + } + const URL = `${BASE_OSPRO}/api/project-comment/add`; + const payload = { + sender_id: localStorage.getItem("user_id"), + project_id: PROJECT_ID, + gantt_id: GANTT_ID, + comment: comment, + }; + const result = await axios + .post(URL, payload, HEADER) + .then((res) => res) + .catch((err) => err.response); - setMymap(mymap); - L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(mymap); + if (!result) { + NotificationManager.error(`Could not connect to internet.`, "Failed"); + setIsSendingComment(false); + return; } - useEffect(() => { - if (mymap) { - if (reportDistribution.length > 0) { - reportDistribution.map((item, idx) => { - L.marker([item.lat, item.lon]).addTo(mymap).bindPopup(PopupContent(item)); - }); - } - } - }, [mymap, reportDistribution]) + if (result.status !== 200) { + NotificationManager.error( + `Post comment failed, ${result.data.message}`, + "Failed" + ); + setIsSendingComment(false); + return; + } else if (result.status === 200) { + NotificationManager.success(`Post comment success`, "Success"); + resetInputComment(); + getComments(); + } + }; - useEffect(() => { - // Add event listener for receiving messages from the iframe - window.addEventListener('message', handleIframeMessage); + const resetInputComment = () => { + setComment(""); + setIsSendingComment(false); + }; - // Clean up the event listener on component unmount - return () => { - window.removeEventListener('message', handleIframeMessage); - }; - }, []); + const initMap = () => { + let mymap = L.map("map-area", { + center: center, + zoom: 13, + }); - const handleIframeMessage = (event) => { - if (event.data && event.data.action === 'getUrl') { - const childUrl = window.location.href; + setMymap(mymap); + L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { + attribution: + '© OpenStreetMap contributors', + }).addTo(mymap); + }; - // Send the URL back to the iframe - event.source.postMessage({ action: 'sendUrl', url: childUrl }, event.origin); + useEffect(() => { + if (mymap) { + if (reportDistribution.length > 0) { + reportDistribution.map((item, idx) => { + L.marker([item.lat, item.lon]) + .addTo(mymap) + .bindPopup(PopupContent(item)); + }); } + } + }, [mymap, reportDistribution]); + + useEffect(() => { + // Add event listener for receiving messages from the iframe + window.addEventListener("message", handleIframeMessage); + + // Clean up the event listener on component unmount + return () => { + window.removeEventListener("message", handleIframeMessage); }; + }, []); - const RenderGantt = useMemo(() => ( - - ), [activeTabIdx]) - - - const RenderComments = useMemo(() => { - return ( - <> -
-