From bac0ead8a4ca3eb3f55616d728741cfbe7b4a547 Mon Sep 17 00:00:00 2001 From: farhantock Date: Wed, 6 Dec 2023 16:37:41 +0700 Subject: [PATCH] update filter and add project by company --- src/views/Dashboard/DashboardBOD.js | 10 +- .../Dashboard/DashboardProjectCarousell.js | 18 ++- .../Master/MasterBroadcast/DialogDetail.js | 2 - src/views/Master/UserWaspang/DialogProyek.js | 149 +++++++++--------- src/views/Pages/Login/Login.js | 9 +- .../CreatedProyek/DialogFormProyek.js | 5 +- src/views/SimproV2/CreatedProyek/index.js | 6 +- 7 files changed, 109 insertions(+), 90 deletions(-) diff --git a/src/views/Dashboard/DashboardBOD.js b/src/views/Dashboard/DashboardBOD.js index 5653697..f4935b7 100644 --- a/src/views/Dashboard/DashboardBOD.js +++ b/src/views/Dashboard/DashboardBOD.js @@ -15,18 +15,24 @@ import { HealthByBudget, HealthBySchedule } from './Components'; import { Link } from 'react-router-dom'; const DashboardBOD = (props) => { - let role_id = '', user_id = '', isLogin = '', token = ''; + let role_id = '', user_id = '', isLogin = '', token = '', company_id = 0, all_project = ''; if (props.location.state && props.location.state.role_id && props.location.state.user_id) { role_id = props.location.state.role_id; user_id = props.location.state.user_id; token = props.location.state.token; isLogin = props.location.state.isLogin; + company_id = props.location.state.company_id; + all_project = props.location.state.all_project; } else { role_id = localStorage.getItem("role_id"); user_id = localStorage.getItem("user_id"); token = localStorage.getItem("token"); isLogin = localStorage.getItem("isLogin"); + company_id = localStorage.getItem('company_id'); + all_project = localStorage.getItem('all_project'); } + let hierarchy = []; + hierarchy.push(JSON.parse(localStorage.getItem("hierarchy"))); const HEADER = { headers: { "Content-Type": "application/json", @@ -74,7 +80,7 @@ const DashboardBOD = (props) => { // project expenditure const getCompanyCashFlow = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-company-cashflow/${moment().format('YYYY')}` + const URL = `${BASE_OSPRO}/api/dashboard/get-company-cashflow/${moment().format('YYYY')}/${company_id}/${all_project}/${hierarchy}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project Expenditure."; diff --git a/src/views/Dashboard/DashboardProjectCarousell.js b/src/views/Dashboard/DashboardProjectCarousell.js index 9b21734..090e950 100644 --- a/src/views/Dashboard/DashboardProjectCarousell.js +++ b/src/views/Dashboard/DashboardProjectCarousell.js @@ -93,8 +93,19 @@ const DashboardProject = (args) => { const [activeIndex, setActiveIndex] = useState(0); const [animating, setAnimating] = useState(false); const [loading, setLoading] = useState(true); - const [carouselPaused, setCarouselPaused] = useState(false); + const [carouselInterval, setCarouselInterval] = useState(null); + useEffect(() => { + const intervalId = setInterval(() => { + next(); + }, 180000); + + setCarouselInterval(intervalId); + + return () => { + clearInterval(intervalId); + }; + }, [activeIndex]); useEffect(() => { setLoading(true); @@ -397,7 +408,7 @@ const DashboardProject = (args) => { {item.project ? ( - item.project.mulai_proyek + moment(item.project.mulai_proyek).format("DD MMMM YYYY") ) : ( )} @@ -410,7 +421,7 @@ const DashboardProject = (args) => { {item.project ? ( - item.project.akhir_proyek + moment(item.project.akhir_proyek).format("DD MMMM YYYY") ) : ( )} @@ -780,7 +791,6 @@ const DashboardProject = (args) => { { @@ -88,7 +87,6 @@ class DialogDetail extends Component { .post(url, payload, config) .then(res => res) .catch((error) => error.response); - console.log('cek data detail', result.data) if (result && result.data && result.data.code === 200) { if (result.data.data && result.data.data) { diff --git a/src/views/Master/UserWaspang/DialogProyek.js b/src/views/Master/UserWaspang/DialogProyek.js index 2a14751..c7c1fca 100644 --- a/src/views/Master/UserWaspang/DialogProyek.js +++ b/src/views/Master/UserWaspang/DialogProyek.js @@ -1,12 +1,12 @@ import React, { useEffect, useState } from 'react' -import { Modal, ModalHeader, ModalBody, ModalFooter,Row,Col } from 'reactstrap'; +import { Modal, ModalHeader, ModalBody, ModalFooter, Row, Col } from 'reactstrap'; import { Button, Form, FormGroup, Label, Input } from 'reactstrap'; -import { Select,DatePicker } from 'antd'; +import { Select, DatePicker } from 'antd'; import moment from 'moment'; import 'antd/dist/antd.css'; const proyekId = localStorage.getItem('proyek_id'); const { Option } = Select; -const DialogProyek = ({openDialog, closeDialog, toggleDialog, dataWaspangProyek, dataProyek, waspangId}) => { +const DialogProyek = ({ openDialog, closeDialog, toggleDialog, dataWaspangProyek, dataProyek, waspangId }) => { const [id, setId] = useState(0) const [proyek_id, setProyekId] = useState(null) const [user_id, setUserId] = useState(null) @@ -18,54 +18,53 @@ const DialogProyek = ({openDialog, closeDialog, toggleDialog, dataWaspangProyek, const [role_id, setRoleId] = useState(localStorage.getItem('role_id')) useEffect(() => { - if(waspangId){ - setUserIdAdd(waspangId) + if (waspangId) { + setUserIdAdd(waspangId) } - },[waspangId]) + }, [waspangId]) - useEffect(()=> { + useEffect(() => { let data = dataWaspangProyek || [] console.log("waspang id", waspangId) console.log("role_id", role_id) - if(data.length > 0){ - console.log("cek data waspang proyek",data) - let dataObj = data[0] - setType("edit") - setProyekId(dataObj.proyek_id) - if(dataObj.mulai){ - setStartDate(moment(moment(dataObj.mulai))) - }else{ - setStartDate(moment(moment())) - } - - if(dataObj.mulai){ - setEndDate(moment(moment(dataObj.akhir))) - }else{ - setEndDate(moment(moment())) - } - - - setUserId(dataObj.user_id) - setId(dataObj.id) - }else{ - setProyekId(null) + if (data.length > 0) { + let dataObj = data[0] + setType("edit") + setProyekId(dataObj.proyek_id) + if (dataObj.mulai) { + setStartDate(moment(moment(dataObj.mulai))) + } else { setStartDate(moment(moment())) + } + + if (dataObj.mulai) { + setEndDate(moment(moment(dataObj.akhir))) + } else { setEndDate(moment(moment())) - setType("add") + } + + + setUserId(dataObj.user_id) + setId(dataObj.id) + } else { + setProyekId(null) + setStartDate(moment(moment())) + setEndDate(moment(moment())) + setType("add") } - - if(parseInt(role_id)===2){ - setProyekId(parseInt(proyekId)) - setDisableSelectProyek(true) + + if (parseInt(role_id) === 2) { + setProyekId(parseInt(proyekId)) + setDisableSelectProyek(true) } - },[dataWaspangProyek,openDialog]) + }, [dataWaspangProyek, openDialog]) useEffect(() => { - if(parseInt(role_id)===2){ - setProyekId(parseInt(proyekId)) - setDisableSelectProyek(true) + if (parseInt(role_id) === 2) { + setProyekId(parseInt(proyekId)) + setDisableSelectProyek(true) } - },[role_id]) + }, [role_id]) const handleCancel = () => { closeDialog('cancel', 'none') setId(0) @@ -77,13 +76,13 @@ const DialogProyek = ({openDialog, closeDialog, toggleDialog, dataWaspangProyek, } const setupOption = () => { - return( + return ( <> - {dataProyek.map((val, index)=> { - return( - - ) - })} + {dataProyek.map((val, index) => { + return ( + + ) + })} ) } @@ -97,53 +96,53 @@ const DialogProyek = ({openDialog, closeDialog, toggleDialog, dataWaspangProyek, } const handleSave = () => { - let data ={ - type, - mulai:startDate, - akhir:endDate, - proyek_id, - user_id - } + let data = { + type, + mulai: startDate, + akhir: endDate, + proyek_id, + user_id + } - if(type==="add"){ - data['user_id'] = userIdAdd - } + if (type === "add") { + data['user_id'] = userIdAdd + } - if(type==="edit"){ - data['id'] = id - } + if (type === "edit") { + data['id'] = id + } - closeDialog("save", data) + closeDialog("save", data) } const renderForm = () => { - return( -
+ return ( + - - {/* setAlias(e.target.value)} placeholder={`Icon..`} /> */} - - + + {/* setAlias(e.target.value)} placeholder={`Icon..`} /> */} + + - - + + - - + +
) } - + return ( - closeDialog("none", "none")}>Save User Proyek + closeDialog("none", "none")}>Save User Proyek - {renderForm()} + {renderForm()} {' '} @@ -151,7 +150,7 @@ const DialogProyek = ({openDialog, closeDialog, toggleDialog, dataWaspangProyek, ) - + } export default DialogProyek; \ No newline at end of file diff --git a/src/views/Pages/Login/Login.js b/src/views/Pages/Login/Login.js index f3c7379..c39bb51 100644 --- a/src/views/Pages/Login/Login.js +++ b/src/views/Pages/Login/Login.js @@ -133,7 +133,7 @@ class Login extends Component { } } - getDataMenu = async (token, role_id, user_id, company_id, role_name) => { + getDataMenu = async (token, role_id, user_id, company_id, role_name, all_project) => { const config = { headers: { @@ -159,14 +159,14 @@ class Login extends Component { else { this.props.history.push({ pathname: "/dashboard", - state: { role_id: role_id, user_id: user_id, token: token, isLogin: true, company_id: company_id, role_name: role_name } + state: { role_id: role_id, user_id: user_id, token: token, isLogin: true, company_id: company_id, role_name: role_name, all_project: all_project } }); } if (this.state.defaultPage) { if (role_id === 44) { this.props.history.push({ pathname: this.state.defaultPage, - state: { role_id: role_id, user_id: user_id, token: token, isLogin: true, company_id: company_id, role_name: role_name } + state: { role_id: role_id, user_id: user_id, token: token, isLogin: true, company_id: company_id, role_name: role_name, all_project: all_project } }); } else { this.props.history.push(this.state.defaultPage); @@ -222,7 +222,7 @@ class Login extends Component { if (doLogin && doLogin.data && doLogin.data.code === 200) { const { access_token, data_user } = doLogin.data.data this.getDataRole(access_token, data_user.role_id) - this.getDataMenu(access_token, data_user.role_id, data_user.id, data_user.company_id, data_user.role.name) + this.getDataMenu(access_token, data_user.role_id, data_user.id, data_user.company_id, data_user.role.name, data_user.role.all_project) window.localStorage.setItem('isLogin', true); window.localStorage.setItem('token', access_token); window.localStorage.setItem('user_id', data_user.id); @@ -230,6 +230,7 @@ class Login extends Component { window.localStorage.setItem('role_id', data_user.role_id); window.localStorage.setItem('company_id', data_user.company_id); window.localStorage.setItem('role_name', data_user.role.name); + window.localStorage.setItem('all_project', data_user.role.all_project); window.localStorage.setItem('hierarchy', JSON.stringify(data_user.hierarchy)); } else { // NotificationManager.error('Cek username atau password anda!', 'Gagal Login!'); diff --git a/src/views/SimproV2/CreatedProyek/DialogFormProyek.js b/src/views/SimproV2/CreatedProyek/DialogFormProyek.js index 053bb14..f504751 100644 --- a/src/views/SimproV2/CreatedProyek/DialogFormProyek.js +++ b/src/views/SimproV2/CreatedProyek/DialogFormProyek.js @@ -34,7 +34,8 @@ const DialogFormProyek = ({ dataPhaseProject, dataDivisions, dataPM, - projectImage + projectImage, + company_id }) => { const token = localStorage.getItem("token"); const HEADER = { @@ -274,6 +275,7 @@ const DialogFormProyek = ({ currency_symbol: currencySymbol, currency_code: currencyCode, currency_name: currencyName, + company_id: parseInt(company_id) }; data.projectCharter = { checklist, issue, potentialRisks, participants, milestones, approval }; data.imageStructureOrg = organization ? organization : null; @@ -304,6 +306,7 @@ const DialogFormProyek = ({ currency_symbol: currencySymbol, currency_code: currencyCode, currency_name: currencyName, + company_id: parseInt(company_id) }; data.projectCharter = { checklist, issue, potentialRisks, participants, milestones, approval }; data.imageStructureOrg = organization ? organization : null; diff --git a/src/views/SimproV2/CreatedProyek/index.js b/src/views/SimproV2/CreatedProyek/index.js index 1827630..521ee44 100644 --- a/src/views/SimproV2/CreatedProyek/index.js +++ b/src/views/SimproV2/CreatedProyek/index.js @@ -91,6 +91,7 @@ const CreatedProyek = ({ params, ...props }) => { user_id = props.location.state.user_id; token = props.location.state.token; isLogin = props.location.state.isLogin; + company_id = props.location.state.company_id; } else { role_id = localStorage.getItem("role_id"); @@ -139,7 +140,7 @@ const CreatedProyek = ({ params, ...props }) => { const [userProyek, setUserProyek] = useState([]); const [materialProyek, setMaterialProyek] = useState([]); const [dataCharter, setDataCharter] = useState(null); - const [dataView, setDataView] = useState([]); + const [dataViewStartDate, setDataViewStartDate] = useState([]); const [materialResource, setMaterialResource] = useState([]); const [toolsResource, setToolsResource] = useState([]); const [dataTypeProyek, setDataTypeProyek] = useState([]); @@ -166,7 +167,7 @@ const CreatedProyek = ({ params, ...props }) => { const [loadHierarchy, setLoadHierarchy] = useState(false); const [dataVersionGantt, setDataVersionGantt] = useState([]); const [dataHierarchy, setDataHierarchy] = useState([]); - const [dataDetail, setDataDetail] = useState(null); + const [dataDetail, setDataDetail] = useState([]); const [loading, setLoading] = useState(true); const pageName = params.name; @@ -1809,6 +1810,7 @@ const CreatedProyek = ({ params, ...props }) => { dataDivisions={dataDivisions} dataPM={dataPm} projectImage={image} + company_id={company_id} /> ), [