Browse Source

update filter and add project by company

pull/1/head
farhantock 11 months ago
parent
commit
bac0ead8a4
  1. 10
      src/views/Dashboard/DashboardBOD.js
  2. 18
      src/views/Dashboard/DashboardProjectCarousell.js
  3. 2
      src/views/Master/MasterBroadcast/DialogDetail.js
  4. 149
      src/views/Master/UserWaspang/DialogProyek.js
  5. 9
      src/views/Pages/Login/Login.js
  6. 5
      src/views/SimproV2/CreatedProyek/DialogFormProyek.js
  7. 6
      src/views/SimproV2/CreatedProyek/index.js

10
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.";

18
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) => {
</Col>
<Col span={12} style={{ fontSize: 11 }}>
{item.project ? (
item.project.mulai_proyek
moment(item.project.mulai_proyek).format("DD MMMM YYYY")
) : (
<SingleTextLoader width={100} height={10} />
)}
@ -410,7 +421,7 @@ const DashboardProject = (args) => {
</Col>
<Col span={12} style={{ fontSize: 11 }}>
{item.project ? (
item.project.akhir_proyek
moment(item.project.akhir_proyek).format("DD MMMM YYYY")
) : (
<SingleTextLoader width={100} height={10} />
)}
@ -780,7 +791,6 @@ const DashboardProject = (args) => {
<Col span={24}>
<Spin tip="Loading..." spinning={loading} style={{ marginTop: 120 }}>
<Carousel
pause={true}
activeIndex={activeIndex}
next={next}
previous={previous}

2
src/views/Master/MasterBroadcast/DialogDetail.js

@ -37,7 +37,6 @@ class DialogDetail extends Component {
async componentDidUpdate() {
if (this.state.isParentClick === true) {
const { dataDetail } = this.props
console.log("cek data detail", dataDetail)
this.setState({
id: dataDetail.id
}, () => {
@ -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) {

149
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(
<Option key={index} value={val.id}>{val.nama}</Option>
)
})}
{dataProyek.map((val, index) => {
return (
<Option key={index} value={val.id}>{val.nama}</Option>
)
})}
</>
)
}
@ -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(
<Form>
return (
<Form>
<FormGroup>
<Label className="capitalize">Proyek</Label>
{/* <Input type="text" value={alias} onChange={(e)=> setAlias(e.target.value)} placeholder={`Icon..`} /> */}
<Select showSearch value={proyek_id} onChange={onChangeParent} placeholder="Select Proyek .." style={{width:'100%'}} disabled={disableSelectProyek}>
{setupOption()}
</Select>
</FormGroup>
<Label className="capitalize">Proyek</Label>
{/* <Input type="text" value={alias} onChange={(e)=> setAlias(e.target.value)} placeholder={`Icon..`} /> */}
<Select showSearch value={proyek_id} onChange={onChangeParent} placeholder="Select Proyek .." style={{ width: '100%' }} disabled={disableSelectProyek}>
{setupOption()}
</Select>
</FormGroup>
<FormGroup>
<Label className="capitalize">Tanggal Mulai</Label>
<DatePicker style={{width:"100%"}} value={startDate} onChange={handleStartDate} allowClear={false} />
<Label className="capitalize">Tanggal Mulai</Label>
<DatePicker style={{ width: "100%" }} value={startDate} onChange={handleStartDate} allowClear={false} />
</FormGroup>
<FormGroup>
<Label className="capitalize">Tanggal</Label>
<DatePicker style={{width:"100%"}} value={endDate} onChange={handleEndDate} allowClear={false} />
<Label className="capitalize">Tanggal</Label>
<DatePicker style={{ width: "100%" }} value={endDate} onChange={handleEndDate} allowClear={false} />
</FormGroup>
</Form>
)
}
return (
<Modal isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize" toggle={() =>closeDialog("none", "none")}>Save User Proyek</ModalHeader>
<ModalHeader className="capitalize" toggle={() => closeDialog("none", "none")}>Save User Proyek</ModalHeader>
<ModalBody>
{renderForm()}
{renderForm()}
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => handleSave()}>Save</Button>{' '}
@ -151,7 +150,7 @@ const DialogProyek = ({openDialog, closeDialog, toggleDialog, dataWaspangProyek,
</ModalFooter>
</Modal>
)
}
export default DialogProyek;

9
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!');

5
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;

6
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}
/>
),
[

Loading…
Cancel
Save