root 1 year ago
parent
commit
ae3521baf7
  1. 10
      src/views/Dashboard/DashboardBOD.js
  2. 18
      src/views/Dashboard/DashboardProjectCarousell.js
  3. 2
      src/views/Master/MasterBroadcast/DialogDetail.js
  4. 139
      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'; import { Link } from 'react-router-dom';
const DashboardBOD = (props) => { 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) { if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id; role_id = props.location.state.role_id;
user_id = props.location.state.user_id; user_id = props.location.state.user_id;
token = props.location.state.token; token = props.location.state.token;
isLogin = props.location.state.isLogin; isLogin = props.location.state.isLogin;
company_id = props.location.state.company_id;
all_project = props.location.state.all_project;
} else { } else {
role_id = localStorage.getItem("role_id"); role_id = localStorage.getItem("role_id");
user_id = localStorage.getItem("user_id"); user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token"); token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin"); 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 = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -74,7 +80,7 @@ const DashboardBOD = (props) => {
// project expenditure // project expenditure
const getCompanyCashFlow = async () => { 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 result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
const content = "Get Project Expenditure."; const content = "Get Project Expenditure.";

18
src/views/Dashboard/DashboardProjectCarousell.js

@ -93,8 +93,19 @@ const DashboardProject = (args) => {
const [activeIndex, setActiveIndex] = useState(0); const [activeIndex, setActiveIndex] = useState(0);
const [animating, setAnimating] = useState(false); const [animating, setAnimating] = useState(false);
const [loading, setLoading] = useState(true); 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(() => { useEffect(() => {
setLoading(true); setLoading(true);
@ -398,7 +409,7 @@ const DashboardProject = (args) => {
</Col> </Col>
<Col span={12} style={{ fontSize: 11 }}> <Col span={12} style={{ fontSize: 11 }}>
{item.project ? ( {item.project ? (
item.project.mulai_proyek moment(item.project.mulai_proyek).format("DD MMMM YYYY")
) : ( ) : (
<SingleTextLoader width={100} height={10} /> <SingleTextLoader width={100} height={10} />
)} )}
@ -411,7 +422,7 @@ const DashboardProject = (args) => {
</Col> </Col>
<Col span={12} style={{ fontSize: 11 }}> <Col span={12} style={{ fontSize: 11 }}>
{item.project ? ( {item.project ? (
item.project.akhir_proyek moment(item.project.akhir_proyek).format("DD MMMM YYYY")
) : ( ) : (
<SingleTextLoader width={100} height={10} /> <SingleTextLoader width={100} height={10} />
)} )}
@ -781,7 +792,6 @@ const DashboardProject = (args) => {
<Col span={24}> <Col span={24}>
<Spin tip="Loading..." spinning={loading} style={{ marginTop: 120 }}> <Spin tip="Loading..." spinning={loading} style={{ marginTop: 120 }}>
<Carousel <Carousel
pause={true}
activeIndex={activeIndex} activeIndex={activeIndex}
next={next} next={next}
previous={previous} previous={previous}

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

@ -37,7 +37,6 @@ class DialogDetail extends Component {
async componentDidUpdate() { async componentDidUpdate() {
if (this.state.isParentClick === true) { if (this.state.isParentClick === true) {
const { dataDetail } = this.props const { dataDetail } = this.props
console.log("cek data detail", dataDetail)
this.setState({ this.setState({
id: dataDetail.id id: dataDetail.id
}, () => { }, () => {
@ -88,7 +87,6 @@ class DialogDetail extends Component {
.post(url, payload, config) .post(url, payload, config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
console.log('cek data detail', result.data)
if (result && result.data && result.data.code === 200) { if (result && result.data && result.data.code === 200) {
if (result.data.data && result.data.data) { if (result.data.data && result.data.data) {

139
src/views/Master/UserWaspang/DialogProyek.js

@ -1,12 +1,12 @@
import React, { useEffect, useState } from 'react' 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 { Button, Form, FormGroup, Label, Input } from 'reactstrap';
import { Select,DatePicker } from 'antd'; import { Select, DatePicker } from 'antd';
import moment from 'moment'; import moment from 'moment';
import 'antd/dist/antd.css'; import 'antd/dist/antd.css';
const proyekId = localStorage.getItem('proyek_id'); const proyekId = localStorage.getItem('proyek_id');
const { Option } = Select; 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 [id, setId] = useState(0)
const [proyek_id, setProyekId] = useState(null) const [proyek_id, setProyekId] = useState(null)
const [user_id, setUserId] = 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')) const [role_id, setRoleId] = useState(localStorage.getItem('role_id'))
useEffect(() => { useEffect(() => {
if(waspangId){ if (waspangId) {
setUserIdAdd(waspangId) setUserIdAdd(waspangId)
} }
},[waspangId]) }, [waspangId])
useEffect(()=> { useEffect(() => {
let data = dataWaspangProyek || [] let data = dataWaspangProyek || []
console.log("waspang id", waspangId) console.log("waspang id", waspangId)
console.log("role_id", role_id) console.log("role_id", role_id)
if(data.length > 0){ if (data.length > 0) {
console.log("cek data waspang proyek",data) let dataObj = data[0]
let dataObj = data[0] setType("edit")
setType("edit") setProyekId(dataObj.proyek_id)
setProyekId(dataObj.proyek_id) if (dataObj.mulai) {
if(dataObj.mulai){ setStartDate(moment(moment(dataObj.mulai)))
setStartDate(moment(moment(dataObj.mulai))) } else {
}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)
setStartDate(moment(moment())) setStartDate(moment(moment()))
}
if (dataObj.mulai) {
setEndDate(moment(moment(dataObj.akhir)))
} else {
setEndDate(moment(moment())) 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){ if (parseInt(role_id) === 2) {
setProyekId(parseInt(proyekId)) setProyekId(parseInt(proyekId))
setDisableSelectProyek(true) setDisableSelectProyek(true)
} }
},[dataWaspangProyek,openDialog]) }, [dataWaspangProyek, openDialog])
useEffect(() => { useEffect(() => {
if(parseInt(role_id)===2){ if (parseInt(role_id) === 2) {
setProyekId(parseInt(proyekId)) setProyekId(parseInt(proyekId))
setDisableSelectProyek(true) setDisableSelectProyek(true)
} }
},[role_id]) }, [role_id])
const handleCancel = () => { const handleCancel = () => {
closeDialog('cancel', 'none') closeDialog('cancel', 'none')
setId(0) setId(0)
@ -77,13 +76,13 @@ const DialogProyek = ({openDialog, closeDialog, toggleDialog, dataWaspangProyek,
} }
const setupOption = () => { const setupOption = () => {
return( return (
<> <>
{dataProyek.map((val, index)=> { {dataProyek.map((val, index) => {
return( return (
<Option key={index} value={val.id}>{val.nama}</Option> <Option key={index} value={val.id}>{val.nama}</Option>
) )
})} })}
</> </>
) )
} }
@ -97,42 +96,42 @@ const DialogProyek = ({openDialog, closeDialog, toggleDialog, dataWaspangProyek,
} }
const handleSave = () => { const handleSave = () => {
let data ={ let data = {
type, type,
mulai:startDate, mulai: startDate,
akhir:endDate, akhir: endDate,
proyek_id, proyek_id,
user_id user_id
} }
if(type==="add"){ if (type === "add") {
data['user_id'] = userIdAdd data['user_id'] = userIdAdd
} }
if(type==="edit"){ if (type === "edit") {
data['id'] = id data['id'] = id
} }
closeDialog("save", data) closeDialog("save", data)
} }
const renderForm = () => { const renderForm = () => {
return( return (
<Form> <Form>
<FormGroup> <FormGroup>
<Label className="capitalize">Proyek</Label> <Label className="capitalize">Proyek</Label>
{/* <Input type="text" value={alias} onChange={(e)=> setAlias(e.target.value)} placeholder={`Icon..`} /> */} {/* <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}> <Select showSearch value={proyek_id} onChange={onChangeParent} placeholder="Select Proyek .." style={{ width: '100%' }} disabled={disableSelectProyek}>
{setupOption()} {setupOption()}
</Select> </Select>
</FormGroup> </FormGroup>
<FormGroup> <FormGroup>
<Label className="capitalize">Tanggal Mulai</Label> <Label className="capitalize">Tanggal Mulai</Label>
<DatePicker style={{width:"100%"}} value={startDate} onChange={handleStartDate} allowClear={false} /> <DatePicker style={{ width: "100%" }} value={startDate} onChange={handleStartDate} allowClear={false} />
</FormGroup> </FormGroup>
<FormGroup> <FormGroup>
<Label className="capitalize">Tanggal</Label> <Label className="capitalize">Tanggal</Label>
<DatePicker style={{width:"100%"}} value={endDate} onChange={handleEndDate} allowClear={false} /> <DatePicker style={{ width: "100%" }} value={endDate} onChange={handleEndDate} allowClear={false} />
</FormGroup> </FormGroup>
</Form> </Form>
) )
@ -141,9 +140,9 @@ const DialogProyek = ({openDialog, closeDialog, toggleDialog, dataWaspangProyek,
return ( return (
<Modal isOpen={openDialog} toggle={toggleDialog}> <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> <ModalBody>
{renderForm()} {renderForm()}
</ModalBody> </ModalBody>
<ModalFooter> <ModalFooter>
<Button color="primary" onClick={() => handleSave()}>Save</Button>{' '} <Button color="primary" onClick={() => handleSave()}>Save</Button>{' '}

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 = { const config = {
headers: headers:
{ {
@ -159,14 +159,14 @@ class Login extends Component {
else { else {
this.props.history.push({ this.props.history.push({
pathname: "/dashboard", 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 (this.state.defaultPage) {
if (role_id === 44) { if (role_id === 44) {
this.props.history.push({ this.props.history.push({
pathname: this.state.defaultPage, 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 { } else {
this.props.history.push(this.state.defaultPage); this.props.history.push(this.state.defaultPage);
@ -222,7 +222,7 @@ class Login extends Component {
if (doLogin && doLogin.data && doLogin.data.code === 200) { if (doLogin && doLogin.data && doLogin.data.code === 200) {
const { access_token, data_user } = doLogin.data.data const { access_token, data_user } = doLogin.data.data
this.getDataRole(access_token, data_user.role_id) 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('isLogin', true);
window.localStorage.setItem('token', access_token); window.localStorage.setItem('token', access_token);
window.localStorage.setItem('user_id', data_user.id); 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('role_id', data_user.role_id);
window.localStorage.setItem('company_id', data_user.company_id); window.localStorage.setItem('company_id', data_user.company_id);
window.localStorage.setItem('role_name', data_user.role.name); 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)); window.localStorage.setItem('hierarchy', JSON.stringify(data_user.hierarchy));
} else { } else {
// NotificationManager.error('Cek username atau password anda!', 'Gagal Login!'); // NotificationManager.error('Cek username atau password anda!', 'Gagal Login!');

5
src/views/SimproV2/CreatedProyek/DialogFormProyek.js

@ -34,7 +34,8 @@ const DialogFormProyek = ({
dataPhaseProject, dataPhaseProject,
dataDivisions, dataDivisions,
dataPM, dataPM,
projectImage projectImage,
company_id
}) => { }) => {
const token = localStorage.getItem("token"); const token = localStorage.getItem("token");
const HEADER = { const HEADER = {
@ -274,6 +275,7 @@ const DialogFormProyek = ({
currency_symbol: currencySymbol, currency_symbol: currencySymbol,
currency_code: currencyCode, currency_code: currencyCode,
currency_name: currencyName, currency_name: currencyName,
company_id: parseInt(company_id)
}; };
data.projectCharter = { checklist, issue, potentialRisks, participants, milestones, approval }; data.projectCharter = { checklist, issue, potentialRisks, participants, milestones, approval };
data.imageStructureOrg = organization ? organization : null; data.imageStructureOrg = organization ? organization : null;
@ -304,6 +306,7 @@ const DialogFormProyek = ({
currency_symbol: currencySymbol, currency_symbol: currencySymbol,
currency_code: currencyCode, currency_code: currencyCode,
currency_name: currencyName, currency_name: currencyName,
company_id: parseInt(company_id)
}; };
data.projectCharter = { checklist, issue, potentialRisks, participants, milestones, approval }; data.projectCharter = { checklist, issue, potentialRisks, participants, milestones, approval };
data.imageStructureOrg = organization ? organization : null; 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; user_id = props.location.state.user_id;
token = props.location.state.token; token = props.location.state.token;
isLogin = props.location.state.isLogin; isLogin = props.location.state.isLogin;
company_id = props.location.state.company_id;
} else { } else {
role_id = localStorage.getItem("role_id"); role_id = localStorage.getItem("role_id");
@ -139,7 +140,7 @@ const CreatedProyek = ({ params, ...props }) => {
const [userProyek, setUserProyek] = useState([]); const [userProyek, setUserProyek] = useState([]);
const [materialProyek, setMaterialProyek] = useState([]); const [materialProyek, setMaterialProyek] = useState([]);
const [dataCharter, setDataCharter] = useState(null); const [dataCharter, setDataCharter] = useState(null);
const [dataView, setDataView] = useState([]); const [dataViewStartDate, setDataViewStartDate] = useState([]);
const [materialResource, setMaterialResource] = useState([]); const [materialResource, setMaterialResource] = useState([]);
const [toolsResource, setToolsResource] = useState([]); const [toolsResource, setToolsResource] = useState([]);
const [dataTypeProyek, setDataTypeProyek] = useState([]); const [dataTypeProyek, setDataTypeProyek] = useState([]);
@ -166,7 +167,7 @@ const CreatedProyek = ({ params, ...props }) => {
const [loadHierarchy, setLoadHierarchy] = useState(false); const [loadHierarchy, setLoadHierarchy] = useState(false);
const [dataVersionGantt, setDataVersionGantt] = useState([]); const [dataVersionGantt, setDataVersionGantt] = useState([]);
const [dataHierarchy, setDataHierarchy] = useState([]); const [dataHierarchy, setDataHierarchy] = useState([]);
const [dataDetail, setDataDetail] = useState(null); const [dataDetail, setDataDetail] = useState([]);
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const pageName = params.name; const pageName = params.name;
@ -1809,6 +1810,7 @@ const CreatedProyek = ({ params, ...props }) => {
dataDivisions={dataDivisions} dataDivisions={dataDivisions}
dataPM={dataPm} dataPM={dataPm}
projectImage={image} projectImage={image}
company_id={company_id}
/> />
), ),
[ [

Loading…
Cancel
Save