diff --git a/src/const/ApiConst.js b/src/const/ApiConst.js index 4e82340..cc1a72b 100644 --- a/src/const/ApiConst.js +++ b/src/const/ApiConst.js @@ -126,11 +126,11 @@ export let BASE_OSPRO = "https://si-api.ospro.id"; 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`; -export let BASE_SIMPRO_LUMEN_FILE_COMPANY = (file, company_name, dateFile) => { - return `${BASE_OSPRO}/assets/${company_name}/${dateFile}/file/project/${file}`; +export let BASE_SIMPRO_LUMEN_FILE_COMPANY = (file) => { + return `${BASE_OSPRO}/assets/file/project/${file}`; } -export let BASE_SIMPRO_LUMEN_IMAGE_COMPANY = (file, company_name, dateFile) => { - return `${BASE_OSPRO}/assets/${company_name}/${dateFile}/image/${file}`; +export let BASE_SIMPRO_LUMEN_IMAGE_COMPANY = (file) => { + return `${BASE_OSPRO}/assets/image/${file}`; } export const USERROLE_ADD = `${BASE_SIMPRO}/user-role/add`; @@ -289,9 +289,7 @@ export const TRANSACTION_DELETE = (id) => { }; export const TRANSACTION_LIST = `${BASE_SIMPRO_LUMEN}/product-transaction/list`; -export const STORAGE_LIMIT_INFORMATION = (company_name) => { - return `${BASE_SIMPRO_LUMEN}/information-storage/${company_name}`; -}; +export const STORAGE_LIMIT_INFORMATION = `${BASE_SIMPRO_LUMEN}/information-storage`; export const STORAGE_LIMIT_INFORMATION_ALL_COMPANY = `${BASE_SIMPRO_LUMEN}/information-storage-all-company` export const ABSENSI_ADD = `${BASE_SIMPRO_LUMEN}/permit/add`; @@ -320,11 +318,11 @@ 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, company_id) => { - return `${BASE_SIMPRO_LUMEN}/document-project/delete/${id}/${company_id}`; +export const DOCUMENT_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/document-project/delete/${id}`; }; -export const DOCUMENT_DOWNLOAD = (id, company_id) => { - return `${BASE_SIMPRO_LUMEN}/document-project/download/${id}/${company_id}`; +export const DOCUMENT_DOWNLOAD = (id) => { + return `${BASE_SIMPRO_LUMEN}/document-project/download/${id}`; }; export const ROLE_ADD = `${BASE_SIMPRO_LUMEN}/role/add`; @@ -436,8 +434,8 @@ export const PROYEK_GET_ID = (id) => { export const PROYEK_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/project/update/${id}`; }; -export const PROYEK_DELETE = (id, company_id) => { - return `${BASE_SIMPRO_LUMEN}/project/delete/${id}/${company_id}`; +export const PROYEK_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/project/delete/${id}`; }; export const PROJECT_ROLE_ADD = `${BASE_SIMPRO_LUMEN}/project-role/add`; @@ -722,8 +720,8 @@ export const ASSIGN_HR_PROJECT_SEARCH = `${BASE_SIMPRO_LUMEN}/user-to-proyek/sea export const ASSIGN_HR_PROJECT_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/user-to-proyek/update/${id}`; }; -export const ASSIGN_HR_PROJECT_DELETE = (id, company_id) => { - return `${BASE_SIMPRO_LUMEN}/user-to-proyek/delete/${id}/${company_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`; @@ -741,8 +739,8 @@ export const FOLDER_DOCUMENT_PROYEK_ADD = `${BASE_SIMPRO_LUMEN}/folder-document- 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, company_id) => - `${BASE_SIMPRO_LUMEN}/folder-document-proyek/delete/${id}/${company_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}`; @@ -793,11 +791,11 @@ export const IMAGE_SEARCH = `${BASE_SIMPRO_LUMEN}/image/search`; export const OSPRO_BASE_IMAGE = `${BASE_OSPRO}/api/assets/image`; export const IMAGE_UPLOAD = `${BASE_SIMPRO_LUMEN}/image/upload`; export const IMAGE_MULTIPLE_UPLOAD = `${BASE_SIMPRO_LUMEN}/image/multiple-upload`; -export const IMAGE_MULTIPLE_DELETE = (id, category, company_id) => { - return `${BASE_SIMPRO_LUMEN}/image/multiple-delete/${id}/${category}/${company_id}`; +export const IMAGE_MULTIPLE_DELETE = (id, category) => { + return `${BASE_SIMPRO_LUMEN}/image/multiple-delete/${id}/${category}`; } -export const IMAGE_DELETE = (id, category, company_id) => { - return `${BASE_SIMPRO_LUMEN}/image/delete/${id}/${category}/${company_id}`; +export const IMAGE_DELETE = (id, category) => { + return `${BASE_SIMPRO_LUMEN}/image/delete/${id}/${category}`; } diff --git a/src/containers/DefaultLayout/DefaultLayout.js b/src/containers/DefaultLayout/DefaultLayout.js index ef4d6af..f056a50 100644 --- a/src/containers/DefaultLayout/DefaultLayout.js +++ b/src/containers/DefaultLayout/DefaultLayout.js @@ -39,16 +39,14 @@ class DefaultLayout extends Component { constructor(props) { super(props); - let role_id = '', token = '', company_id = 0, menu = '' + let role_id = '', token = '', menu = '' if (props.location.state && props.location.state.role_id) { role_id = props.location.state.role_id; token = props.location.state.token; - company_id = props.location.state.company_id; menu = props.location.state.menu_login; } else { role_id = localStorage.getItem("role_id"); token = localStorage.getItem("token"); - company_id = localStorage.getItem('company_id'); menu = localStorage.getItem("menu_login"); } @@ -59,8 +57,7 @@ class DefaultLayout extends Component { routes2: routes, finalRoutes: [], breadrCrumbReady: false, - minimized: true, - company_id: company_id + minimized: true }; } async componentDidMount() { @@ -70,6 +67,7 @@ class DefaultLayout extends Component { if (!localStorage.getItem("token")) { this.signOut(); } + this.getQueryParams(); window.myData = "Data dari komponen React"; try { const storedData = localStorage.getItem('configApp'); @@ -136,6 +134,12 @@ class DefaultLayout extends Component { LayoutHelper.sidebarToggle(!this.state.minimized); }; + getQueryParams() { + const searchParams = new URLSearchParams(this.props.location.search); + const dashboardGantt = searchParams.get('dashboardGantt'); + this.setState({ dashboardGantt }); + } + setFinalRoutes = () => { const { routes2 } = this.state; if (routes2) { @@ -161,7 +165,6 @@ class DefaultLayout extends Component { e.preventDefault() } await localStorage.removeItem("role_id"); - await localStorage.removeItem("company_id"); document.getElementById('title').innerText = 'OSPRO'; this.setFavicon(`${process.env.PUBLIC_URL}/OSPRO.ico`); await window.localStorage.clear(); @@ -267,7 +270,7 @@ class DefaultLayout extends Component { } getAppBreadcrumb = () => { - const { u_group } = this.state; + const { u_group, dashboardGantt } = this.state; if (u_group == 'kominfo') { routes.map((route, idx) => { if (route.path == '/dashboard-kominfo') { @@ -279,7 +282,7 @@ class DefaultLayout extends Component { }); } else { - if (!window.location.href.includes("dashboard")) { + if (!window.location.href.includes("dashboard") || window.location.href.includes("dashboard-project") && !dashboardGantt) { return } } @@ -299,12 +302,11 @@ class DefaultLayout extends Component { const { location } = this.props; const { pathname } = location; let renderSidebar = false - + const isDashboardProject = this.props.location.pathname.startsWith('/dashboard-project/'); if (pathname.includes("/dashboard-project")) { // Remove the base URL and hash const path = pathname.replace("/dashboard-project/", ""); - - // Split the remaining path by "/" + // Split the remaining path by "/" const parts = path.split("/"); if (parts[2] == "1") { renderSidebar = true @@ -313,37 +315,33 @@ class DefaultLayout extends Component { return (
- {!window.location.href.includes("false-header") && ( - - - - ) - }
- {!window.location.href.includes("dashboard-project") || renderSidebar ? ( - - - - - + {(isDashboardProject ? true : !window.location.href.includes("dashboard-project")) || renderSidebar ? ( + (!this.state.dashboardGantt ? ( + +
+ + + {this.getMenu()} - - - {this.state.minimized ? null : +
+ + {this.state.minimized ? null : - {localStorage.getItem('user_name')} + {localStorage.getItem('user_name')} - handleChangeLng("id")}>ID - handleChangeLng("en")}>EN - Profile - this.signOut(e)}> Logout + handleChangeLng("id")}>ID + handleChangeLng("en")}>EN + Profile + this.signOut(e)}> Logout } - -
+ + + ) : null) ) : null}
{this.state.breadrCrumbReady ? this.getAppBreadcrumb() : null} @@ -364,7 +362,6 @@ class DefaultLayout extends Component { user_id={props.location.state ? props.location.state.user_id : localStorage.getItem("user_id")} role_id={props.location.state ? props.location.state.role_id : localStorage.getItem("role_id")} isLogin={props.location.state ? props.location.state.isLogin : localStorage.getItem("isLogin")} - company_id={props.location.state ? props.location.state.company_id : localStorage.getItem("company_id")} role_name={props.location.state ? props.location.state.role_name : localStorage.getItem("role_name")} all_project={props.location.state ? props.location.state.all_project : localStorage.getItem("all_project")} token={props.location.state ? props.location.state.token : localStorage.getItem("token")} diff --git a/src/routes.js b/src/routes.js index 8f4040b..93dc146 100644 --- a/src/routes.js +++ b/src/routes.js @@ -68,7 +68,7 @@ const routes = [ { path: '/dashboard', name: 'DashboardBOD', component: DashboardBOD }, { path: '/dashboard-dyna', name: 'DashboardBOD', component: DashboardDyna }, { path: '/dashboard-customer/:PROJECT_ID/:GANTT_ID/:SCURVE', name: 'DashboardCustomer', component: DashboardCustomer }, - { path: '/dashboard-project/:PROJECT_ID/:GANTT_ID/:Header', exact: true, name: 'Dashboard Project', component: DashboardProject }, + { path: '/dashboard-project/:PROJECT_ID/:GANTT_ID', exact: true, name: 'Dashboard Project', component: DashboardProject }, { path: '/dashboard-perproject', exact: true, name: 'Dashboard Project Carousell', component: DashboardProjectCarousell }, { path: '/dashboard-project/:PROJECT_ID/:GANTT_ID/:SCURVE', exact: true, name: 'Dashboard Project', component: DashboardProject }, { path: '/projects', exact: true, name: 'Projects', component: CreatedProyek }, diff --git a/src/views/Dashboard/DashboardBOD.js b/src/views/Dashboard/DashboardBOD.js index 822de60..b662d7c 100644 --- a/src/views/Dashboard/DashboardBOD.js +++ b/src/views/Dashboard/DashboardBOD.js @@ -15,13 +15,12 @@ import { HealthByBudget, HealthBySchedule } from './Components'; import { Link } from 'react-router-dom'; import { Card, CardBody, CardHeader, Input } from "reactstrap"; const DashboardBOD = (props) => { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = ''; + let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name = '', hierarchy = [], user_name = ''; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; token = props.token; isLogin = props.isLogin; - company_id = props.company_id; all_project = props.all_project; role_name = props.role_name; isLogin = props.isLogin; @@ -81,7 +80,7 @@ const DashboardBOD = (props) => { // project expenditure const getCompanyCashFlow = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-company-cashflow/${company_id}/${all_project}/${hierarchy}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-company-cashflow/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project Expenditure."; @@ -107,31 +106,31 @@ const DashboardBOD = (props) => { // Project Expenditure Color const getCompanyExpenditureColor = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-detail-expenditure-color/${company_id}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-detail-expenditure-color/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) SET_PROJECT_EXPENDITURE_COLOR(result.data.data) } const getCompanyFinancialHealthColor = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-detail-financial-health-color/${company_id}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-detail-financial-health-color/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) SET_PROJECT_FINANCIAL_HEALTH_COLOR(result.data.data) } const getCompanyScheduleHealthColor = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-detail-schedule-health-color/${company_id}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-detail-schedule-health-color/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) SET_PROJECT_SCHEDULE_HEALTH_COLOR(result.data.data) } const getCompanyInvoiceColor = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-detail-invoice-color/${company_id}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-detail-invoice-color/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) SET_PROJECT_INVOICE_COLOR(result.data.data) } const getInvoiceOutstanding = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-invoice-outstanding/${company_id}/${all_project}/${hierarchy}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-invoice-outstanding/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project Invoice vs Cash In."; @@ -154,7 +153,7 @@ const DashboardBOD = (props) => { } const getProjectPerScheduleHealth = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-schedule-health/${company_id}/${all_project}/${hierarchy}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-schedule-health/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project by Schedule Health."; @@ -178,7 +177,7 @@ const DashboardBOD = (props) => { } const getProjectPerBudgetHealth = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-budget-health/${company_id}/${all_project}/${hierarchy}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-budget-health/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project by Budget Health."; @@ -201,7 +200,7 @@ const DashboardBOD = (props) => { } const getProjectBudgetHealthPerDivision = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-budget-health-per-division/${company_id}/${all_project}/${hierarchy}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-budget-health-per-division/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project by Schedule Health per Division."; @@ -225,7 +224,7 @@ const DashboardBOD = (props) => { } const getProjectScheduleHealthPerDivision = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-schedule-health-per-division/${company_id}/${all_project}/${hierarchy}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-schedule-health-per-division/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project by Schedule Health."; @@ -248,7 +247,7 @@ const DashboardBOD = (props) => { } const getProjectPerPhase = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-phase/${company_id}/${all_project}/${hierarchy}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-phase/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project by Phase."; @@ -273,7 +272,7 @@ const DashboardBOD = (props) => { } const getTotalProjectPerDivision = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-division/${company_id}/${all_project}/${hierarchy}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-division/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project by Division."; @@ -298,7 +297,7 @@ const DashboardBOD = (props) => { } const getTotalProjectValuePerDivision = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-value-per-division/${company_id}/${all_project}/${hierarchy}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-value-per-division/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project Value by Division"; @@ -327,7 +326,7 @@ const DashboardBOD = (props) => { return; } setOpenDetailedView(true); - const URL = `${BASE_OSPRO}/api/dashboard/get-detail-expenditure/${company_id}/${all_project}/${hierarchy}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-detail-expenditure/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Detail Expenditure"; diff --git a/src/views/Dashboard/DashboardCustomer.js b/src/views/Dashboard/DashboardCustomer.js index 8f0f5f6..5f70574 100644 --- a/src/views/Dashboard/DashboardCustomer.js +++ b/src/views/Dashboard/DashboardCustomer.js @@ -26,13 +26,12 @@ const center = { } const DashboardCustomer = (props) => { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name='', hierarchy=[], user_name=''; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; token = props.token; isLogin = props.isLogin; - company_id = props.company_id; all_project = props.all_project; role_name = props.role_name; isLogin = props.isLogin; diff --git a/src/views/Dashboard/DashboardProject.js b/src/views/Dashboard/DashboardProject.js index a843992..551d630 100644 --- a/src/views/Dashboard/DashboardProject.js +++ b/src/views/Dashboard/DashboardProject.js @@ -31,57 +31,39 @@ import { import { Fab, Action } from "react-tiny-fab"; import "react-tiny-fab/dist/styles.css"; import { useHistory, useLocation, useParams } from "react-router-dom"; +import { Icon } from '@iconify/react'; +import arrowLeft from '@iconify/icons-ion/ios-arrow-back'; + 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 }, -}; const center = { lat: -6.2, lng: 106.816666, }; + const DashboardProject = (props) => { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = ''; + let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name = '', hierarchy = [], user_name = ''; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; token = props.token; isLogin = props.isLogin; - company_id = props.company_id; all_project = props.all_project; role_name = props.role_name; isLogin = props.isLogin; hierarchy = props.hierarchy; user_name = props.user_name; } + const HEADER = { headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}`, }, }; + const { PROJECT_ID, GANTT_ID, SCURVE } = useParams(); - const URL_GANTT = `https://project-gantt.ospro.id/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1&role_name=${role_name}&company_id=${company_id}`; - // const URL_GANTT = `http://localhost:8444/generic-ospro-gantt/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1&role_name=${role_name}&company_id=${company_id}`; + const URL_GANTT = `https://project-gantt.ospro.id/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1&role_name=${role_name}`; + // const URL_GANTT = `http://localhost:8444/generic-ospro-gantt/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1&role_name=${role_name}`; const mapRef = useRef(); const [projectName, setProjectName] = useState(""); @@ -98,6 +80,7 @@ const DashboardProject = (props) => { const [activeTabIdx, setActiveTabIdx] = useState(0); const [activeTabCommentIdx, setActiveTabCommentIdx] = useState(0); const [planningProgress, setPlanningProgress] = useState(0); + const [planningProgressToDay, setPlanningProgressToDay] = useState(0); const [actualProgress, setActualProgress] = useState(0); const [currentBudget, setCurrentBudget] = useState(null); const [addCostToComplete, setAddCostToComplete] = useState(null); @@ -135,6 +118,7 @@ const DashboardProject = (props) => { const [isReadyGanttParents, setIsReadyGanttParents] = useState(false); const [calculationStatus, setCalculationStatus] = useState(false); const [isHierarchy, setIsHierarchy] = useState(null); + const [dashboardGantt, setDashboardStatus] = useState(false); let history = useHistory(); useEffect(() => { getProjectDetail(); @@ -143,9 +127,11 @@ const DashboardProject = (props) => { getComments(); getGantt(); getGanttParents(); + getQueryParams(); return () => { }; }, []); + useEffect(() => { if (isHierarchy != null) { getSCurve(); @@ -155,11 +141,13 @@ const DashboardProject = (props) => { window.removeEventListener("message", handleIframeMessage); }; }, [isHierarchy]); + useEffect(() => { if (activeTabIdx === 1) { initMap(); } }, [activeTabIdx]); + useEffect(() => { async function fetchData() { await Promise.all([ @@ -170,6 +158,7 @@ const DashboardProject = (props) => { } fetchData(); }, []); + useEffect(() => { let deviation = 0; if (plannedCost && totalCost) { @@ -177,9 +166,11 @@ const DashboardProject = (props) => { } setRemToComplete(deviation.toString()); }, [plannedCost, totalCost]); + const handleRedirect = () => { history.push("/projects/" + GANTT_ID + "/" + PROJECT_ID + "/gantt"); }; + const getManpower = async () => { const url = `${BASE_OSPRO}/api/project/manpower/${PROJECT_ID}`; try { @@ -188,6 +179,7 @@ const DashboardProject = (props) => { } catch (error) { } }; + const getGantt = async () => { setIsReadyGantt(false); const url = `${BASE_OSPRO}/api/version-gantt/edit/${GANTT_ID}`; @@ -204,6 +196,7 @@ const DashboardProject = (props) => { setIsReadyGantt(true); } }; + const getGanttParents = async () => { setIsReadyGanttParents(false); const url = `${BASE_OSPRO}/api/hierarchy-ftths/tree-gantt/${GANTT_ID}`; @@ -215,6 +208,7 @@ const DashboardProject = (props) => { setIsReadyGanttParents(true); } }; + const getAssignedHR = async () => { const url = `${BASE_OSPRO}/api/project/manpower/assigned/${GANTT_ID}`; try { @@ -230,6 +224,7 @@ const DashboardProject = (props) => { } catch (error) { } }; + const getActualHR = async () => { const dateStart = moment().startOf("day").toDate(); const dateEnd = moment().endOf("day").toDate(); @@ -269,6 +264,7 @@ const DashboardProject = (props) => { console.error("Failed to get actual HR:", error); } }; + const getProjectDetail = async () => { setIsReadyProjectDetail(false); let URL = `${BASE_OSPRO}/api/project/detail/${PROJECT_ID}`; @@ -353,6 +349,7 @@ const DashboardProject = (props) => { } } }; + const getSCurve = async () => { setIsReadySCurve(false); let URL = `${BASE_OSPRO}/api/project/get-s-curve`; @@ -385,6 +382,7 @@ const DashboardProject = (props) => { let selisihProgress = 0; let planningProgress = 0; let actualProgress = 0; + let progressPlanToDay = 0; let statusHealthBySchedule = "behind-schedule"; if ( result.data.data.length > 0 && @@ -424,6 +422,14 @@ const DashboardProject = (props) => { planningProgress = result.data.data[0].data?.percentagePlan[n]; setPlanningProgress(planningProgress); } + if ( + result.data.data.length > 0 && + result.data.data[0].data?.progressPlanToDay && + result.data.data[0].data?.progressPlanToDay != null + ) { + progressPlanToDay = result.data.data[0].data?.progressPlanToDay; + setPlanningProgressToDay(+(Math.round(progressPlanToDay + "e+2") + "e-2")); + } if ( result.data.data.length > 0 && result.data.data[0].data?.percentageReal && @@ -445,6 +451,7 @@ const DashboardProject = (props) => { setIsReadySCurve(true); } }; + const getOverdueActivities = async () => { setIsReadyOverdueActivities(false); const URL = `${BASE_OSPRO}/api/project/get-overdue-activities`; @@ -478,6 +485,7 @@ const DashboardProject = (props) => { setIsReadyOverdueActivities(true); } }; + const getIntegrationInvoice = async (kode_sortname, id, gantt_id = null) => { setIsReadyIntegrationInvoice(false); const URL = `${BASE_OSPRO}/api/project/get-integration-invoice`; @@ -521,6 +529,7 @@ const DashboardProject = (props) => { setIsReadyIntegrationInvoice(true); } }; + const getReportDistribution = async () => { setIsReadyReportDistribution(false); const URL = `${BASE_OSPRO}/api/project/get-report-distribution`; @@ -553,6 +562,7 @@ const DashboardProject = (props) => { setIsReadyReportDistribution(true); } }; + const getComments = async () => { setIsReadyComments(false); const URL = `${BASE_OSPRO}/api/project-comment/search`; @@ -581,6 +591,7 @@ const DashboardProject = (props) => { orders: { columns: ["created_at"], ascending: false }, paging: { start: 0, length: -1 }, }; + const result = await axios .post(URL, payload, HEADER) .then((res) => res) @@ -602,6 +613,7 @@ const DashboardProject = (props) => { setIsReadyComments(true); } }; + const handleSendComment = async () => { setIsSendingComment(true); if (comment === "") { @@ -641,10 +653,23 @@ const DashboardProject = (props) => { getComments(); } }; + const resetInputComment = () => { setComment(""); setIsSendingComment(false); }; + + const getQueryParams = () => { + const searchParams = new URLSearchParams(props.location.search); + const dashboardGantt = searchParams.get('dashboardGantt'); + setDashboardStatus(dashboardGantt); + } + + const handleBack = async () => { + const domainUrl = window.location.origin; + !SCURVE ? (dashboardGantt ? window.parent.location.reload() : window.location.replace(`${domainUrl}/#/projects/${GANTT_ID}/${PROJECT_ID}/gantt`)) : window.history.go(-1); + }; + const initMap = () => { let mymap = L.map("map-area", { center: center, @@ -656,6 +681,7 @@ const DashboardProject = (props) => { '© OpenStreetMap contributors', }).addTo(mymap); }; + useEffect(() => { if (mymap) { if (reportDistribution.length > 0) { @@ -667,6 +693,7 @@ const DashboardProject = (props) => { } } }, [mymap, reportDistribution]); + useEffect(() => { // Add event listener for receiving messages from the iframe window.addEventListener("message", handleIframeMessage); @@ -675,6 +702,7 @@ const DashboardProject = (props) => { window.removeEventListener("message", handleIframeMessage); }; }, []); + const handleIframeMessage = (event) => { if (event.data && event.data.action === "getUrl") { const childUrl = window.location.href; @@ -685,6 +713,7 @@ const DashboardProject = (props) => { ); } }; + const RenderGantt = useMemo( () => (