Browse Source

fix: add props & adding multi location hierarchy

pull/1/head
wahyun 8 months ago
parent
commit
075f6bbda4
  1. 3
      src/views/SimproV2/CreatedProyek/DialogFormHierarchy.js
  2. 57
      src/views/SimproV2/CreatedProyek/DialogHierarchy.js
  3. 22
      src/views/SimproV2/CreatedProyek/index.js

3
src/views/SimproV2/CreatedProyek/DialogFormHierarchy.js

@ -3,9 +3,6 @@ import {
Modal, ModalHeader, ModalBody, ModalFooter,
Button, Form, FormGroup, Label, Input, Col, Row
} from 'reactstrap';
import { DatePicker, Tooltip, Select } from 'antd';
import { formatRupiah, formatNumber } from '../../../const/CustomFunc'
import moment from 'moment';
import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next';

57
src/views/SimproV2/CreatedProyek/DialogHierarchy.js

@ -1,7 +1,7 @@
import React, { useEffect, useState, useMemo } from 'react'
import { Modal, ModalHeader, ModalBody, } from 'reactstrap';
import { Button } from 'reactstrap';
import { Space, Table, Tooltip, Spin } from 'antd';
import { Table, Tooltip, Spin } from 'antd';
import 'antd/dist/antd.css';
import moment from 'moment';
import SweetAlert from 'react-bootstrap-sweetalert';
@ -14,8 +14,7 @@ import DialogFormGantt from './DialogFormGantt';
import DialogGantt from './DialogGantt';
import { useTranslation } from 'react-i18next';
import _ from 'lodash';
const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, dataViewStartDate }) => {
const token = localStorage.getItem("token")
const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, dataViewStartDate, token, role_id, user_id, companyName, companyId, isLogin }) => {
const HEADER = {
headers: {
"Content-Type": "application/json",
@ -26,7 +25,6 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
const [id, setId] = useState(0)
const [parentId, setParentId] = useState(0)
const [parentName, setParentName] = useState(null)
const [dataGantt, setDataGantt] = useState([])
const [typeDialog, setTypeDialog] = useState("add")
const [openDialogForm, setOpenDialogForm] = useState(false)
const [openDialogGantt, setOpenDialogGantt] = useState(false)
@ -36,7 +34,6 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
const [alertDelete, setAlertDelete] = useState(false)
const [idDelete, setIdDelete] = useState(0)
const [idGantt, setIdGantt] = useState(0)
const [humanResource, setHumanResource] = useState([])
const { t } = useTranslation();
const [loading, setLoading] = useState(true);
useEffect(() => {
@ -44,40 +41,11 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
setLoading(true);
getdataHierarchy();
}
}, [idTask, openDialog, closeDialog, openDialogFormGantt])
}, [idTask, openDialog, openDialogFormGantt])
useEffect(() => {
if (!openDialog) {
setDataHierarchy([]);
} else {
}
}, [openDialog, closeDialog])
const getDataHumanResource = async () => {
const result = await axios
.get(USER_LIST, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.status == 200) {
setTransferUser(result.data.data);
} else {
}
}
const setTransferUser = (data) => {
const finalData = []
data.map((val, index) => {
let data = {
key: val.id,
title: val.name
}
finalData.push(data)
});
setHumanResource(finalData)
}
}, [openDialog])
const handleAdd = async () => {
await setTypeDialog("Save")
@ -137,8 +105,6 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
const closeDialogFromHierarchy = (type, data) => {
if (type == 'save') {
saveHierarchy(data)
} else {
updateHierarchy(data)
}
setId(0);
setOpenDialogForm(false);
@ -157,11 +123,6 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
}
}
const updateHierarchy = async (data) => {
}
const getdataHierarchy = async () => {
const url = HIERARCHY_FTTH_TREE(idTask)
const result = await axios
@ -311,9 +272,6 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
</div>
</Spin>
</ModalBody>
{/* <ModalFooter>
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button>
</ModalFooter> */}
</Modal>
<NotificationContainer />
<SweetAlert
@ -335,6 +293,13 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
hierarchyId={parentId}
hierarchyName={parentName}
idTask={idTask}
role_id={role_id}
user_id={user_id}
token={token}
isLogin={isLogin}
companyName={companyName}
proyekName={proyekName}
companyId={companyId}
openDialogHierarchy={openDialog}
dataViewStartDate={dataViewStartDate}
/>

22
src/views/SimproV2/CreatedProyek/index.js

@ -428,7 +428,7 @@ const CreatedProyek = ({ params, ...props }) => {
{
name: "m_type_proyek",
column_join: "type_proyek_id",
column_results: ["name", "description"],
column_results: ["name", "description", "is_multiLocation"],
}
],
orders: { columns: ["nama"], ascending: true },
@ -583,6 +583,7 @@ const CreatedProyek = ({ params, ...props }) => {
setDataViewStartDate(data.mulai_proyek)
setidTask(data.id);
setProyekName(data.nama);
setCompanyName(role_name === 'Super Admin' ? data.join_third_company_name : JSON.parse(configApp).company_name);
setCompanyId(data.company_id);
setOpenDialogGantt(true);
};
@ -1686,13 +1687,13 @@ const CreatedProyek = ({ params, ...props }) => {
const popupMenuGantt = (text, record) => {
return (
<div>
{text.type_proyek_id !== 9 && loadVersionGantt && (
{text.join_second_is_multiLocation !== true && loadVersionGantt && (
<div className="menu-list">
<Skeleton active />
</div>
)}
{!loadVersionGantt && text.type_proyek_id !== 9 && (
{!loadVersionGantt && text.join_second_is_multiLocation !== true && (
<>
{dataVersionGantt.slice(0, 8).map((res) => (
<Link to={{
@ -1704,7 +1705,7 @@ const CreatedProyek = ({ params, ...props }) => {
user_id,
company_id: text.company_id,
dataViewStartDate,
configApp
companyName: (role_name === 'Super Admin' ? text.join_third_company_name : JSON.parse(configApp).company_name)
}
}}>
<div className="menu-list">
@ -1729,7 +1730,7 @@ const CreatedProyek = ({ params, ...props }) => {
)}
</>
)}
{text.type_proyek_id == 9 ? (
{text.join_second_is_multiLocation == true ? (
<div
className="menu-list"
onClick={() => handleOpenDialogHierarchy(text)}
@ -1799,7 +1800,7 @@ const CreatedProyek = ({ params, ...props }) => {
content={popupMenuGantt(text, record)}
trigger="click"
>
{text.type_proyek_id == 9 ? (
{text.join_second_is_multiLocation == true ? (
<Button size="small" type="link" style={{ color: "green" }}>
<i className="fa fa-bars"></i>
</Button>
@ -2103,6 +2104,7 @@ const CreatedProyek = ({ params, ...props }) => {
closeDialog={handleCloseReport}
toggleDialog={toggleAddDialogRA}
projectId={projectId}
token={token}
proyekName={proyekName}
/>
),
@ -2119,7 +2121,7 @@ const CreatedProyek = ({ params, ...props }) => {
user_id={user_id}
token={token}
isLogin={isLogin}
configApp={configApp}
companyName={companyName}
proyekName={proyekName}
companyId={companyId}
dataViewStartDate={dataViewStartDate}
@ -2135,7 +2137,13 @@ const CreatedProyek = ({ params, ...props }) => {
closeDialog={closeDialogHierarchy}
toggleDialog={toggleDialogHierarchy}
idTask={idTask}
role_id={role_id}
user_id={user_id}
token={token}
isLogin={isLogin}
companyName={companyName}
proyekName={proyekName}
companyId={companyId}
dataViewStartDate={dataViewStartDate}
/>
),

Loading…
Cancel
Save