diff --git a/src/routes.js b/src/routes.js index 669c3db..2537fb9 100644 --- a/src/routes.js +++ b/src/routes.js @@ -95,7 +95,7 @@ const routes = [ { path: '/user-admin', exact: true, name: 'User Admin', component: UserAdmin }, { path: '/user-shift', exact: true, name: 'Shift', component: UserShift }, { path: '/working-hour', exact: true, name: 'Working Hour', component: Shift }, - { path: '/dashboard-project/:id', exact: true, name: 'Dashboard Project', component: DashboardProject }, + { path: '/dashboard-project/:ID', exact: true, name: 'Dashboard Project', component: DashboardProject }, ]; export default routes; diff --git a/src/views/DashboardProject/index.js b/src/views/DashboardProject/index.js index 92869ba..ee01862 100644 --- a/src/views/DashboardProject/index.js +++ b/src/views/DashboardProject/index.js @@ -1,10 +1,13 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import { Row, Col, Select, Divider } from 'antd'; import moment from 'moment' import Gantt from './ganttDashboard'; import TableDashboard from './tableDashboard'; import ChatDashboard from './chatDashboard'; +import axios from 'axios' +import { NotificationContainer, NotificationManager } from 'react-notifications'; import { useParams } from 'react-router-dom'; +import { BASE_OSPRO } from '../../const/ApiConst'; function BoxDashboard({ value, title, secondaryTitle, icon, bgColor }) { return ( @@ -19,30 +22,75 @@ function BoxDashboard({ value, title, secondaryTitle, icon, bgColor }) { } const DashboardProject = () => { - const { id } = useParams(); - console.log("test ", id) + const { ID } = useParams(); + const [STATUSPROJECT, SET_STATUSPROJECT] = useState([]) + const [PROJECTMGR, SET_PROJECTMGR] = useState([]) + const [RO, SET_RO] = useState([]) + // Schedule + const [STARTDATE, SET_STARTDATE] = useState([]) + const [BASELINEFINISHDATE, SET_BASELINEFINISHDATE] = useState([]) + const [ESTFINISHDATE, SET_ESTFINISHDATE] = useState([]) + // Financials + const [BCWP, SET_BCWP] = useState([]) + const [ACWP, SET_ACWP] = useState([]) + const [VARIANCE, SET_VARIANCE] = useState([]) + const [BUDGET, SET_BUDGET] = useState([]) + const [PROJECTNAME, SET_PROJECTNAME] = useState([]) + + + + const token = localStorage.getItem("token") + const HEADER = { + headers: { + "Content-Type": "application/json", + "Authorization": `Bearer ${token}` + } + } + + const getProjectDetail = async () => { + const URL = `${BASE_OSPRO}/api/project/dashboard/${ID}` + const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) + if (result.data.code !== 200) { + NotificationManager.error('Belum ada data proyek!', 'Failed'); + } + let resData; + result.data.data.map(datas => resData = datas); + SET_BUDGET(resData.rencana_biaya) + SET_PROJECTMGR(resData.pm) + SET_RO(resData.company) + SET_PROJECTNAME(resData.name_project) + SET_STARTDATE(resData.start) + SET_BASELINEFINISHDATE(resData.finish) + } + + useEffect(() => { + getProjectDetail(); + }, []) + + return (