diff --git a/src/const/ApiConst.js b/src/const/ApiConst.js
index 9d0f30e..8000af6 100644
--- a/src/const/ApiConst.js
+++ b/src/const/ApiConst.js
@@ -745,3 +745,17 @@ export const COMPANY_MANAGEMENT_DELETE = (id) => {
return `${BASE_SIMPRO_LUMEN}/company-management/delete/${id}`;
};
export const COMPANY_MANAGEMENT_LIST = `${BASE_SIMPRO_LUMEN}/company-management/list`;
+
+
+export const MENU_COMPANY_ADD = `${BASE_SIMPRO_LUMEN}/menu-company/add-multiple`;
+export const MENU_COMPANY_MANAGEMENT = (id) => {
+ return `${BASE_SIMPRO_LUMEN}/menu-company/management/${id}`;
+};
+export const MENU_COMPANY_SEARCH = `${BASE_SIMPRO_LUMEN}/menu-company/search`;
+export const MENU_COMPANY_LIST = `${BASE_SIMPRO_LUMEN}/menu-company/list`;
+export const MENU_COMPANY_EDIT = (id) => {
+ return `${BASE_SIMPRO_LUMEN}/menu-company/update/${id}`;
+};
+export const MENU_COMPANY_DELETE = (id) => {
+ return `${BASE_SIMPRO_LUMEN}/menu-company/delete/${id}`;
+};
diff --git a/src/routes.js b/src/routes.js
index 7fdb466..4d0ba98 100644
--- a/src/routes.js
+++ b/src/routes.js
@@ -54,7 +54,7 @@ const routes = [
{ path: '/', exact: true, name: 'Home' },
// { path: '/dashboard', name: 'Dashboard', component: Dashboard},
{ path: '/dashboard', name: 'DashboardBOD', component: DashboardBOD },
- { path: '/dashboard-customer/:PROJECT_ID/:GANTT_ID', name: 'DashboardCustomer', component: DashboardCustomer },
+ // { path: '/dashboard-customer/:PROJECT_ID/:GANTT_ID', name: 'DashboardCustomer', component: DashboardCustomer },
{ path: '/dashboard-customer/:PROJECT_ID/:GANTT_ID/:SCURVE', name: 'DashboardCustomer', component: DashboardCustomer },
{ path: '/dashboard-project/:PROJECT_ID/:GANTT_ID', exact: true, name: 'Dashboard Project', component: DashboardProject },
{ path: '/dashboard-project/:PROJECT_ID/:GANTT_ID/:SCURVE', exact: true, name: 'Dashboard Project', component: DashboardProject },
diff --git a/src/views/Dashboard/DashboardBOD.js b/src/views/Dashboard/DashboardBOD.js
index 344faf5..74e64d0 100644
--- a/src/views/Dashboard/DashboardBOD.js
+++ b/src/views/Dashboard/DashboardBOD.js
@@ -13,8 +13,21 @@ import toRupiah from '@develoka/angka-rupiah-js';
import Icon from '@iconify/react';
import { HealthByBudget, HealthBySchedule } from './Components';
-const DashboardBOD = () => {
- const token = localStorage.getItem("token")
+const DashboardBOD = (props) => {
+ let role_id = '', user_id='',isLogin='',token='';
+ 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;
+ console.log('props.location.state success');
+ } else {
+ role_id = localStorage.getItem("role_id");
+ user_id = localStorage.getItem("user_id");
+ token = localStorage.getItem("token");
+ isLogin = localStorage.getItem("isLogin");
+ console.error('undefined in props.location.state');
+ }
const HEADER = {
headers: {
"Content-Type": "application/json",
diff --git a/src/views/Dashboard/DashboardCustomer.js b/src/views/Dashboard/DashboardCustomer.js
index 63ee536..7d482e8 100644
--- a/src/views/Dashboard/DashboardCustomer.js
+++ b/src/views/Dashboard/DashboardCustomer.js
@@ -25,8 +25,21 @@ const center = {
lng: 106.816666
}
-const DashboardCustomer = () => {
- const token = localStorage.getItem("token")
+const DashboardCustomer = (props) => {
+ let role_id = '', user_id='',isLogin='',token='';
+ 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;
+ console.log('props.location.state success');
+ } else {
+ role_id = localStorage.getItem("role_id");
+ user_id = localStorage.getItem("user_id");
+ token = localStorage.getItem("token");
+ isLogin = localStorage.getItem("isLogin");
+ console.error('Undefined in props.location.state');
+ }
const HEADER = {
headers: {
"Content-Type": "application/json",
@@ -34,8 +47,7 @@ const DashboardCustomer = () => {
}
}
const { PROJECT_ID, GANTT_ID, SCURVE } = useParams();
- const URL_GANTT = `https://adw-gantt.ospro.id/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1`;
- const mapRef = useRef()
+ const URL_GANTT = `https://adw-gantt.ospro.id/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1`; const mapRef = useRef()
const [projectName, setProjectName] = useState("");
const [projectManagerName, setProjectManagerName] = useState('');
const [customerName, setCustomerName] = useState("");
diff --git a/src/views/Master/MasterCompany/DialogForm.js b/src/views/Master/MasterCompany/DialogForm.js
index 9b39d14..936a6c2 100644
--- a/src/views/Master/MasterCompany/DialogForm.js
+++ b/src/views/Master/MasterCompany/DialogForm.js
@@ -1,17 +1,18 @@
import React, { useState, useMemo, useEffect } from 'react'
import {
Modal, ModalHeader, ModalBody, ModalFooter,
- Button, Form, FormGroup, Label, Input, Col, Row, Card, CardBody, Fade
+ Button, Form, FormGroup, Row, Col, Label, Input,
} from 'reactstrap';
-import { Pagination, Table, Tooltip, Select, Input as InputAntd } from 'antd';
-import moment from 'moment';
+import { Pagination, Table, Tooltip, Select } from 'antd';
+import SweetAlert from 'react-bootstrap-sweetalert';
import { NotificationContainer, NotificationManager } from 'react-notifications';
-import DialogFormUser from './DialogFormUser';
+import DialogFormUser from './FormUser';
+import DialogFormMenu from './FormMenu';
import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next';
import axios from "../../../const/interceptorApi"
import {
- USER_SEARCH, USER_EDIT, USER_DELETE, ROLE_SEARCH, DIVISI_SEARCH,
+ USER_SEARCH, USER_EDIT, USER_DELETE, ROLE_SEARCH, DIVISI_SEARCH, MENU_COMPANY_SEARCH
} from '../../../const/ApiConst';
const token = window.localStorage.getItem('token');
const config = {
@@ -21,8 +22,8 @@ const config = {
"Content-type": `application/json`
}
};
-const { Option } = Select
-const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, roleList, companyID }) => {
+const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, companyID, companyNameProp }) => {
+ const { Option } = Select
const { t } = useTranslation()
const [registrationnumber, setRegistrationNumber] = useState('')
const [companyName, setCompanyName] = useState('')
@@ -38,8 +39,10 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const [htmlTitle, setHtmlTitle] = useState('')
const [appName, setAppName] = useState('')
const [baseUrl, setBaseUrl] = useState([])
- const [statusCompany, setStatusCompany] = useState('active')
+ const [statusCompany, setStatusCompany] = useState(true)
const [template, setTemplate] = useState('')
+ const [lastIdxURL, setLastIdxURL] = useState(0);
+
const [dataTable, setDatatable] = useState([])
const [openDialogUser, setOpenDialogUser] = useState(false)
@@ -48,12 +51,27 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const [rowsPerPage, setRowsPerPage] = useState(10)
const [totalPage, setTotalPage] = useState(0)
const [search, setSearch] = useState('')
-
+ const [idDelete, setIdDelete] = useState(0)
+ const [alertDelete, setAlertDelete] = useState(false)
+ const [dataEdit, setDataEdit] = useState([])
+ const [roleList, setRoleList] = useState([])
+
+
+ const [dataTableMenu, setDatatableMenu] = useState([])
+ const [currentPageMenu, setCurrentPageMenu] = useState(1)
+ const [rowsPerPageMenu, setRowsPerPageMenu] = useState(10)
+ const [totalPageMenu, setTotalPageMenu] = useState(0)
+ const [openDialogMenu, setOpenDialogMenu] = useState(false)
+ const [typeDialogMenu, setTypeDialogMenu] = useState("add")
useEffect(() => {
- if (companyID) {
+ if (companyID && typeDialog === 'Set') {
getDataUser()
+ getRoleList()
+ } else {
+ getDataMenu()
}
- }, [companyID, rowsPerPage, currentPage])
+ }, [typeDialog, companyID, rowsPerPage, currentPage, rowsPerPageMenu, currentPageMenu])
+
const onShowSizeChange = (current, pageSize) => {
setRowsPerPage(pageSize)
@@ -62,6 +80,30 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const onPagination = (current, pageSize) => {
setCurrentPage(current)
}
+ const onShowSizeChangeMenu = (current, pageSize) => {
+ setRowsPerPageMenu(pageSize)
+ }
+
+ const onPaginationMenu = (current, pageSize) => {
+ setCurrentPageMenu(current)
+ }
+
+ const getRoleList = async () => {
+ const formData = {
+ "paging": { "start": 0, "length": -1 },
+
+ "orders": { "columns": ["id"], "ascending": false }
+ }
+
+ const result = await axios
+ .post(ROLE_SEARCH, formData, config)
+ .then(res => res)
+ .catch((error) => error.response);
+
+ if (result && result.data && result.data.code == 200) {
+ setRoleList(result.data.data);
+ }
+ }
const getDataUser = async () => {
let start = 0;
@@ -167,6 +209,46 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
}
}
+ const getDataMenu = async () => {
+ let start = 0;
+
+ if (currentPage !== 1 && currentPage > 1) {
+ start = (currentPage * rowsPerPage) - rowsPerPage
+ }
+
+ const payload = {
+ "paging": {
+ "start": start,
+ "length": rowsPerPage
+ },
+ "columns": [{
+ "name": "company_id",
+ "logic_operator": "=",
+ "value": companyID,
+ "operator": "AND"
+ }],
+ "joins": [{
+ "name": "m_menu",
+ "column_join": "menu_id",
+ "column_results": [
+ "name"
+ ]
+ }],
+ "orders": { "columns": ["id"], "ascending": false }
+ }
+
+ const result = await axios
+ .post(MENU_COMPANY_SEARCH, payload, config)
+ .then(res => res)
+ .catch((error) => error.response);
+
+ if (result && result.data && result.data.code == 200) {
+ setDatatableMenu(result.data.data);
+ setTotalPageMenu(result.data.totalRecord);
+ } else {
+ NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
+ }
+ }
const handleAddUser = async () => {
@@ -174,8 +256,51 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setOpenDialogUser(true)
}
- const closeDialogUser = () => {
+ const handleEditUser = async (data) => {
+ setDataEdit(data)
+ await setTypeDialogUser('Edit')
+ setOpenDialogUser(true)
+ }
+ const handleDeleteUser = async (id) => {
+ await setAlertDelete(true)
+ await setIdDelete(id)
+ }
+
+ const closeDialogUser = (type, message) => {
setOpenDialogUser(false);
+ if (type == 'success') {
+ NotificationManager.success(`${message}`, "Success!!");
+ getDataUser()
+ } else if (type == 'Failed') {
+ NotificationManager.error(`${message}`, "Failed!!");
+ }
+ };
+
+ const handleAddMenu = async () => {
+ await setTypeDialogMenu("Save")
+ setOpenDialogMenu(true)
+ }
+
+ const handleEditMenu = async (data) => {
+ setDataEdit(data)
+ await setTypeDialogMenu('Edit')
+ setOpenDialogMenu(true)
+ }
+
+ const handleDeleteMenu = async (id) => {
+ await setAlertDelete(true)
+ await setIdDelete(id)
+ }
+
+ const closeDialogMenu = (type, message) => {
+ setOpenDialogMenu(false);
+ if (type == 'success') {
+ NotificationManager.success(`${message}`, "Success!!");
+ getDataMenu()
+ } else if (type == 'Failed') {
+ NotificationManager.error(`${message}`, "Failed!!");
+ }
+
};
const handleSave = () => {
@@ -263,27 +388,114 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
}
}
+ const isValidEmail = (email) => {
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
+ return emailRegex.test(email);
+ };
+
const handleCancel = () => {
closeDialog('cancel', 'none')
+ setDatatable([])
}
- const isValidEmail = (email) => {
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
- return emailRegex.test(email);
+ const onConfirmDelete = async () => {
+ let url = USER_DELETE(idDelete);
+
+ const result = await axios.delete(url, config)
+ .then(res => res)
+ .catch((error) => error.response);
+
+ if (result && result.data && result.data.code === 200) {
+ getDataUser()
+ setIdDelete(0)
+ setAlertDelete(false)
+ NotificationManager.success(`Data user berhasil dihapus!`, 'Success!!');
+ } else {
+ setIdDelete(0)
+ setAlertDelete(false)
+ NotificationManager.error(`Data user gagal dihapus!`, 'Failed!!');
+ }
+ }
+
+ const cancelDelete = () => {
+ setAlertDelete(false)
+ setIdDelete(0)
+ }
+
+ const addBaseUrl = () => {
+ baseUrl.push({
+ id: lastIdxURL + 1,
+ url: "",
+ });
+ setBaseUrl(baseUrl);
+ setLastIdxURL(lastIdxURL + 1);
};
- const setupSelectRole = () => {
- return (
- <>
- {roleList.map((val, index) => {
- return (
-
- )
- })}
- >
- )
+ const handleChangeBaseURL = (value, index) => {
+ const newBaseURL = [...baseUrl];
+ newBaseURL[index] = value;
+ setBaseUrl(newBaseURL);
+ }
+
+ const deleteBaseURL = (id) => {
+ if (baseUrl && baseUrl.length > 0) {
+ let checkIdx = baseUrl.findIndex((o) => o.id === id);
+ if (checkIdx > -1) {
+ baseUrl.splice(checkIdx, 1);
+ setBaseUrl(baseUrl.filter((_, i2) => i2 !== id));
+ }
+ }
}
+ const handleLogoHeader = (content) => {
+ const newLogoHeader = [...logoHeader, {
+ type: "image",
+ content: content,
+ }];
+ setLogoHeader(newLogoHeader);
+ }
+
+ const RenderBaseURL = () => {
+ if (baseUrl.length > 0) {
+ return baseUrl.map((item, index) => {
+ return (
+
+
+ handleChangeBaseURL(e, index)}
+ />
+
+
+
+
+
+ );
+ });
+ } else if (baseUrl.length < 1) {
+ return (
+
+ No Base URL found
+
+ );
+ }
+ };
+
const renderFromCompany = () => {
return (
@@ -293,14 +505,169 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
*required.
+
+
+
+
+ setRegistrationNumber(e.target.value)} placeholder='Input Number Registration' />
+
+
+
+
+
+ setCompanyName(e.target.value)} placeholder=' Input Company Name' />
+
+
+
+
+
+
+
+ setEmailCompany(e.target.value)} placeholder={t('inputEmail')}
+ onBlur={(e) => {
+ if (!isValidEmail(e.target.value)) {
+ alert("Masukkan email yang valid.");
+ }
+ }}
+ />
+
+
+
+
+
+ setPhoneNumber(e.target.value.replace(/[^0-9]/g, ''))} placeholder={t('inputNoPhone')} maxLength="15" />
+
+
+
+
+
+
+
+ setAddressCompany(e.target.value)} placeholder=' Input Address' />
+
+
+
+
+
+ setAbout(e.target.value)} placeholder=' Input Company Name' />
+
+
+
+
+
+
+
+ setAppName(e.target.value)} placeholder=' Input App Name' />
+
+
+
+
+
+ setHtmlTitle(e.target.value)} placeholder=' Input HTML Title' />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ URL
+
+
+ Action
+
+
+
+
+
+
+
+ {RenderBaseURL()}
+
+
+
+
+
+
+ handleLogoHeader(e.target.files[0])}
+ />
+
+
+
+
+
+ handleLogoHeader(e.target.files[0])}
+ />
+
+
+
+
+
+ setProjectStructureOrg(e.target.files[0])}
+ />
+
+
+
+
)
}
- const RenderTable = useMemo(() => {
+ const RenderTableUser = useMemo(() => {
const columns = [
+ {
+ title: t('action'),
+ dataIndex: '',
+ key: 'x',
+ render: (text, record) => <>
+
+
+ {" "}
+
+
+
+ >,
+ },
+
{ title: t('nik'), dataIndex: 'ktp_number', key: 'ktp_number' },
{ title: t('nameHR'), dataIndex: 'name', key: 'name' },
@@ -314,28 +681,6 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
{ title: 'Phone No.', dataIndex: 'phone_number', key: 'phone_number' },
{ title: 'Email', dataIndex: 'email', key: 'email' },
{ title: 'Status', dataIndex: 'status_resource', key: 'status_status' }
- // title: t('action'),
- // dataIndex: '',
- // key: 'x',
- // render: (text, record) => <>
- //
- //
- //
-
- //
- //
- //
- //
- //
- //
- // >,
- // },
-
- // { title: "Number Registration", dataIndex: 'registration_no', key: 'registration_no' },
- // { title: "Name", dataIndex: 'company_name', key: 'company_name' },
- // { title: 'Phone No.', dataIndex: 'phone_no', key: 'phone_no' },
- // { title: 'Email', dataIndex: 'email', key: 'email' },
- // { title: 'Status', dataIndex: 'is_active', key: 'is_active', render: (text, record) => <>{text && text !== false ? "Active" : 'Inactive'}> }
];
return (
{
+ const columns = [
+ {
+ title: t('action'),
+ dataIndex: '',
+ key: 'x',
+ render: (text, record) => <>
+
+ handleDeleteMenu(text.id)}>
+
+
+ handleEditMenu(text)}>
+
+ >,
+ },
+ { title: t('name'), dataIndex: 'join_first_name', key: 'join_first_name' },
+ { title: 'Url', dataIndex: 'url', key: 'url' },
+ { title: t('icon'), dataIndex: 'icon', key: 'icon' },
+ { title: 'Alias', dataIndex: 'alias_name', key: 'alias_name' },
+ { title: t('order'), dataIndex: 'sequence', key: 'sequence' },
+ { title: t('parentMenu'), dataIndex: 'join_first_name', key: 'join_first_name', render: (text, record) => (text ? text : "-") }
+ ];
+ return (
+
+ )
+ }, [dataTableMenu])
+
return (
<>
+
+ cancelDelete()}
+ focusCancelBtn
+ >
+ {t('deleteMsg')}
+
+
- {typeDialog === "Save" ? `Add` : typeDialog === "Set" ? "Manage Admin" : "Edit"} Company
- {typeDialog === "Set" && (
-
+ {typeDialog === "Set-Menu" ? `Menu ${companyNameProp}` : typeDialog === "Save" ? `Add Data Company` : typeDialog === "Set" ? `Manage User ${companyNameProp}` : `Edit ${companyNameProp}`}
+ {typeDialog === "Set" ? (
+
- )}
+ ) :
+ (
+
+
+
+ )}
- {typeDialog !== "Set" && renderFromCompany()}
+ {typeDialog !== "Set" && typeDialog !== "Set-Menu" && renderFromCompany()}
{typeDialog === "Set" && (
<>
- {RenderTable}
+ {RenderTableUser}
>
)}
+ {typeDialog === "Set-Menu" && (
+ <>
+ {renderTableMenu}
+
+ >
+ )}
- {typeDialog !== "Set" && (
+ {typeDialog !== "Set" && typeDialog !== "Set-Menu" && (
)}
diff --git a/src/views/Master/MasterCompany/FormMenu.js b/src/views/Master/MasterCompany/FormMenu.js
new file mode 100644
index 0000000..a7178d2
--- /dev/null
+++ b/src/views/Master/MasterCompany/FormMenu.js
@@ -0,0 +1,285 @@
+import React, { useState, useEffect } from 'react'
+import {
+ Modal, ModalHeader, ModalBody, ModalFooter,
+ Button, Form, FormGroup, Label, Input, Col, Row
+} from 'reactstrap';
+import { Transfer, Select } from 'antd';
+import 'antd/dist/antd.css';
+import { useTranslation } from 'react-i18next';
+import { MENU_LIST, MENU_COMPANY_ADD, MENU_COMPANY_EDIT } from '../../../const/ApiConst.js';
+import { NotificationContainer, NotificationManager } from 'react-notifications';
+import axios from 'axios';
+const token = window.localStorage.getItem('token');
+const FormMenu = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, companyName, companyID }) => {
+ const { Option } = Select
+ const [targetKeys, setTargetKeys] = useState([])
+ const [menuResource, setmenuResource] = useState([])
+ const [id, setId] = useState(0)
+ const [name, setName] = useState('')
+ const [url, setUrl] = useState('')
+ const [aliasName, setAliasName] = useState('')
+ const [icon, setIcon] = useState('')
+ const [sequence, setSequence] = useState(0)
+ const [parentId, setParentId] = useState(null)
+ const { t } = useTranslation()
+ const config = {
+ headers:
+ {
+ Authorization: `Bearer ${token}`,
+ "Content-type": `application/json`
+ }
+ };
+
+ const handleCLearData = () => {
+ // setId(0)
+ setTargetKeys([])
+ }
+
+ useEffect(() => {
+ if (!openDialog) {
+ handleCLearData()
+ } else {
+ getDataAllMenu();
+ }
+ }, [openDialog])
+
+ const getDataAllMenu = async () => {
+ const result = await axios
+ .get(MENU_LIST, config)
+ .then(res => res)
+ .catch((error) => error.response);
+
+ if (result && result.data && result.data.code == 200) {
+ setTransferMenu(result.data.data);
+ } else {
+ NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
+ }
+ }
+
+ const setTransferMenu = (data) => {
+ const finalData = []
+ data.map((val, index) => {
+ let data = {
+ key: val.id,
+ name: val.name,
+ url: val.url,
+ alias_name: val.alias_name,
+ icon: val.icon,
+ parent_id: val.parent_id,
+ sequence: val.sequence,
+ }
+ finalData.push(data)
+ });
+ setmenuResource(finalData)
+ }
+
+
+ const handleSave = async () => {
+ await saveMenuCompany()
+ handleCLearData()
+ }
+
+ useEffect(() => {
+ if (typeDialog === "Edit") {
+ setId(dataEdit.id)
+ setIcon(dataEdit.icon)
+ setParentId(dataEdit.parent_id)
+ setSequence(dataEdit.sequence)
+ } else {
+ setId(0)
+ setName('')
+ setUrl('')
+ setIcon('')
+ setParentId(null)
+ setSequence(0)
+ setAliasName('')
+ }
+ }, [dataEdit, openDialog])
+
+ const validation = () => {
+ if (!icon || icon === "") {
+ alert("Icon cannot be empty!");
+ return true;
+ }
+ if (sequence < 0) {
+ alert("Order cannot be empty!");
+ return true;
+ }
+ }
+
+ const saveMenuCompany = async () => {
+ let data = '';
+ const err = validation();
+ if (!err) {
+ if (typeDialog === "Edit") {
+ data = {
+ id,
+ sequence: parseInt(sequence),
+ icon,
+ }
+
+ if (parentId && parentId > 0) {
+ data['parent_id'] = parentId
+ }
+
+ const formData = data
+ const url = MENU_COMPANY_EDIT(data.id)
+ const result = await axios.put(url, formData, config)
+ .then(res => res)
+ .catch((error) => error.response);
+
+ if (result && result.data && result.data.code === 200) {
+ closeDialog('success', 'Data menu berhasil diubah')
+ } else {
+ closeDialog('failed', 'Data menu gagal diubah')
+ }
+ }
+ setId(0)
+ setName('')
+ setUrl('')
+ setIcon('')
+ setParentId(null)
+ setSequence(0)
+ setAliasName('')
+ } else {
+ const selectedData = menuResource.filter(item => targetKeys.includes(item.key));
+ const formDatas = selectedData.map(data => ({
+ menu_id: data.key,
+ parent_id: data.parent_id,
+ company_id: companyID,
+ icon: data.icon,
+ alias_name: data.alias_name,
+ url: data.url,
+ sequence: data.sequence
+ }));
+ const result = await axios
+ .post(MENU_COMPANY_ADD, formDatas, config)
+ .then(res => res)
+ .catch((error) => error.response);
+ if (result && result.status == 200) {
+ closeDialog('success', result.data.message)
+ } else {
+ closeDialog('failed', result.data.message)
+ }
+ }
+ }
+
+ const handleCancel = () => {
+ closeDialog('cancel', 'none')
+ setId(0)
+ setName('')
+ setUrl('')
+ setIcon('')
+ setParentId(null)
+ setSequence(0)
+ setAliasName('')
+ }
+
+ const handleChange = targetKeys => {
+ setTargetKeys(targetKeys)
+ };
+
+ const onChangeParent = (val) => {
+ setParentId(val)
+ }
+
+ const setupSelectParent = () => {
+ return (
+ <>
+ {menuResource.map((val, index) => {
+ return (
+
+ )
+ })}
+ >
+ )
+ }
+
+ const renderForm = () => {
+ return (
+
+ )
+ }
+ const renderFormEdit = () => {
+ return (
+
+ )
+ }
+ return (
+ <>
+
+
+ Add Data Menu
+
+
+ {typeDialog !== 'Edit' ? renderForm() : renderFormEdit()}
+
+
+ {''}
+
+
+
+ >
+ )
+
+}
+export default FormMenu;
\ No newline at end of file
diff --git a/src/views/Master/MasterCompany/DialogFormUser.js b/src/views/Master/MasterCompany/FormUser.js
similarity index 62%
rename from src/views/Master/MasterCompany/DialogFormUser.js
rename to src/views/Master/MasterCompany/FormUser.js
index d95e4a3..e4d1fc5 100644
--- a/src/views/Master/MasterCompany/DialogFormUser.js
+++ b/src/views/Master/MasterCompany/FormUser.js
@@ -1,107 +1,122 @@
-import React, { useState, useMemo } from 'react'
+import React, { useState, useEffect } from 'react'
import {
Modal, ModalHeader, ModalBody, ModalFooter,
- Button, Form, FormGroup, Label, Input, Col, Row, Card, CardBody, Fade
+ Button, Form, FormGroup, Label, Input, Col, Row
} from 'reactstrap';
-import { DatePicker, Table, Tooltip, Select, Input as InputAntd } from 'antd';
-import moment from 'moment';
+import { Select } from 'antd';
+import { USER_ADD, USER_EDIT } from '../../../const/ApiConst.js';
import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next';
+import axios from 'axios';
const { Option } = Select
-const DialogFormUser = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, roleList }) => {
+const token = window.localStorage.getItem('token');
+const config = {
+ headers:
+ {
+ Authorization: `Bearer ${token}`,
+ "Content-type": `application/json`
+ }
+};
+const FormUser = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, roleList, companyID }) => {
const { t } = useTranslation()
-
+ const [id, setId] = useState('')
const [resourceName, setResourceName] = useState('')
const [username, setUsername] = useState('')
const [password, setPassword] = useState('')
- const [retryPassword, setRetryPassword] = useState('')
const [employeeType, setEmployeeType] = useState('')
const [phoneNo, setPhoneNo] = useState('')
const [email, setEmail] = useState('')
const [gender, setGender] = useState('')
- const [birthDate, setBirthDate] = useState('')
- const [birthPlace, setBirthPlace] = useState('')
const [ktpNumber, setKtpNumber] = useState('')
const [roleId, setRoleId] = useState('')
- const [address, setAddress] = useState('')
const [statusResource, setStatusResource] = useState('active')
- const [statusRestriction, setStatusRestriction] = useState(false)
+ useEffect(() => {
+ if (typeDialog === "Edit") {
+ console.log(dataEdit);
+ setId(dataEdit.id)
+ setResourceName(dataEdit.name)
+ setUsername(dataEdit.username)
+ setPassword('')
+ setEmployeeType(dataEdit.employee_type)
+ setPhoneNo(dataEdit.phone_number)
+ setEmail(dataEdit.email)
+ setGender(dataEdit.gender)
+ setKtpNumber(dataEdit.ktp_number ? dataEdit.ktp_number : '')
+ setRoleId(dataEdit.role_id)
+ } else {
+ setId(0)
+ setResourceName('')
+ setUsername('')
+ setPassword('')
+ setEmployeeType('')
+ setPhoneNo('')
+ setEmail('')
+ setGender('')
+ setRoleId('')
+ }
+ }, [dataEdit, openDialog])
- const handleSave = () => {
+ const handleSave = async () => {
let data = '';
-
if (typeDialog === "Save") {
data = {
- // registration_no: registrationnumber,
- // company_name: companyName,
- // address: addressCompany,
- // phone_no: phoneNumber,
- // email: emailCompany,
- // description: description,
- // logo_login: logoLogin,
- // logo_header: logoHeader,
- // favicon_image: favIcon,
- // login_instruction: loginInstruction,
- // about: about,
- // html_title: htmlTitle,
- // app_name: appName,
- // base_url: baseUrl,
- // is_active: statusCompany,
- // template_id: template
+ name: resourceName,
+ employee_type: employeeType,
+ phone_number: phoneNo,
+ email,
+ gender,
+ ktp_number: ktpNumber,
+ role_id: roleId,
+ status_resource: statusResource,
+ company_id: companyID,
+ username,
+ password,
}
- console.log(data)
-
- closeDialog('save', data);
- } else if (typeDialog === "Set") {
- // if (!password && password === "") {
- // alert("Please fill password");
- // return;
- // }
- // if (password !== retryPassword) {
- // alert("Password doesn't match");
- // return;
- // }
- // if (password.length < 8) {
- // alert("Password minimum 8 character");
- // return;
- // }
- // data = {
- // id,
- // username,
- // password,
- // email,
- // }
+ const formData = data
+ const result = await axios.post(USER_ADD, formData, config)
+ .then(res => res)
+ .catch((error) => error.response);
- closeDialog('edit', data);
+ if (result && result.data && result.data.code === 200) {
+ closeDialog('success', `Data resource berhasil ditambah`)
+ } else {
+ closeDialog('failed', result.data.message)
+ }
} else {
- // data = {
- // id,
- // name: resourceName,
- // username,
- // employee_type: employeeType,
- // phone_number: phoneNo,
- // email,
- // gender,
- // birth_place: birthPlace,
- // blood_type: bloodType,
- // ktp_number: ktpNumber,
- // biaya_per_jam: biayaPerJam.replace('.', ''),
- // role_id: roleId,
- // divisi_id: divisionId,
- // address,
- // status_resource: statusResource,
- // status_boundary: statusRestriction,
- // company_id: company_id
- // }
+ data = {
+ id,
+ name: resourceName,
+ username,
+ employee_type: employeeType,
+ phone_number: phoneNo,
+ email,
+ gender,
+ ktp_number: ktpNumber,
+ role_id: roleId,
+ status_resource: statusResource,
+ company_id: companyID,
+ username,
+ password,
+ }
+ if (password == '') {
+ data.password = dataEdit.password;
+ }
+ let urlEdit = USER_EDIT(data.id)
+ const formData = data
- // if (birthDate && birthDate != "") {
- // data['birth_date'] = birthDate;
- // }
+ const result = await axios.put(urlEdit, formData, config)
+ .then(res => res)
+ .catch((error) => error.response);
+
+ if (result && result.data && result.data.code === 200) {
+ closeDialog('success', `Data resource berhasil diedit`)
+ } else {
+ closeDialog('failed', result.data.message)
+ }
- closeDialog('edit', data);
}
}
@@ -195,43 +210,37 @@ const DialogFormUser = ({ openDialog, closeDialog, toggleDialog, typeDialog, dat
-
- setBirthPlace(e.target.value)} placeholder={t('inputBrithPlace')} />
+
+
-
- setBirthDate(date)} />
+
+
-
-
+
+ setUsername(e.target.value)} placeholder={`Username...`} />
-
-
-
-
-
-
- setAddress(e.target.value)} placeholder={t('inputAddress')} />
+
+ setPassword(e.target.value)} placeholder={`Password...`} />
-
)
@@ -255,4 +264,4 @@ const DialogFormUser = ({ openDialog, closeDialog, toggleDialog, typeDialog, dat
)
}
-export default DialogFormUser;
\ No newline at end of file
+export default FormUser;
\ No newline at end of file
diff --git a/src/views/Master/MasterCompany/index.js b/src/views/Master/MasterCompany/index.js
index c3d692a..e48af19 100644
--- a/src/views/Master/MasterCompany/index.js
+++ b/src/views/Master/MasterCompany/index.js
@@ -2,19 +2,14 @@ import * as XLSX from 'xlsx';
import React, { useState, useEffect, useMemo } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi"
-import moment from 'moment'
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import DialogForm from './DialogForm'
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Table, Button, Tooltip } from 'antd';
import {
- COMPANY_MANAGEMENT_SEARCH, USER_ADD, USER_SEARCH, USER_EDIT, USER_DELETE, ROLE_SEARCH, DIVISI_SEARCH, USER_SHIFT_ADD, USER_SYNC
+ COMPANY_MANAGEMENT_SEARCH, USER_ADD, USER_SEARCH, USER_EDIT, USER_DELETE, DIVISI_SEARCH, USER_SHIFT_ADD, USER_SYNC
} from '../../../const/ApiConst';
import { useTranslation } from 'react-i18next';
-const url = "";
-const proyek_id = localStorage.getItem('proyek_id');
-const role_id = localStorage.getItem('role_id');
-const format = "DD-MM-YYYY";
const token = window.localStorage.getItem('token');
const config = {
headers:
@@ -23,8 +18,7 @@ const config = {
"Content-type": `application/json`
}
};
-const role_name = window.localStorage.getItem('role_name');
-const company_id = window.localStorage.getItem('company_id');
+
const MasterCompany = ({ params }) => {
const token = localStorage.getItem("token")
const company_id = localStorage.getItem("company_id")
@@ -45,17 +39,16 @@ const MasterCompany = ({ params }) => {
const [idDelete, setIdDelete] = useState(0)
const [openDialog, setOpenDialog] = useState(false)
const [openDialogShift, setOpenDialogShift] = useState(false)
- const [roleList, setRoleList] = useState([])
const [rowsPerPage, setRowsPerPage] = useState(10)
const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
const [typeDialogShift, setTypeDialogShift] = useState('Save')
const [companyID, setCompanyID] = useState('')
+ const [companyName, setCompanyName] = useState('')
const pageName = params.name;
const { t } = useTranslation();
useEffect(() => {
- getRoleList()
getDivisiList()
}, [])
@@ -63,12 +56,7 @@ const MasterCompany = ({ params }) => {
getDataUser()
}, [search, rowsPerPage, currentPage])
- useEffect(() => {
- const cekData = dataExport || []
- if (cekData.length > 0) {
- exportExcel()
- }
- }, [dataExport])
+
const onShowSizeChange = (current, pageSize) => {
setRowsPerPage(pageSize)
@@ -78,22 +66,6 @@ const MasterCompany = ({ params }) => {
setCurrentPage(current)
}
- const getRoleList = async () => {
- const formData = {
- "paging": { "start": 0, "length": -1 },
- "orders": { "columns": ["id"], "ascending": false }
- }
-
- const result = await axios
- .post(ROLE_SEARCH, formData, config)
- .then(res => res)
- .catch((error) => error.response);
-
- if (result && result.data && result.data.code == 200) {
- setRoleList(result.data.data);
- }
- }
-
const getDivisiList = async () => {
const formData = {
"paging": { "start": 0, "length": -1 },
@@ -188,122 +160,7 @@ const MasterCompany = ({ params }) => {
}
- const handleOpenDialogShift = async (type) => {
- await setTypeDialogShift(type)
- setOpenDialogShift(true)
-
- }
-
- const handleSync = async () => {
- await axios.get(USER_SYNC, HEADER)
- .then(res => res)
- .catch((error) => error.response)
- }
-
- const handleExportExcel = async () => {
-
- let start = 0;
-
- if (currentPage !== 1 && currentPage > 1) {
- start = (currentPage * rowsPerPage) - rowsPerPage
- }
-
- const payload = {
- "paging": {
- "start": start,
- "length": -1
- },
- "columns": [],
- "group_column": {
- "operator": "AND",
- "group_operator": "OR",
- "where": [
- {
- "name": "name",
- "logic_operator": "~*",
- "value": search
- },
-
- {
- "name": "name",
- "logic_operator": "~*",
- "value": search,
- "table_name": "m_divisi"
- },
- {
- "name": "name",
- "logic_operator": "~*",
- "value": search,
- "table_name": "m_roles"
- },
- {
- "name": "phone_number",
- "logic_operator": "~*",
- "value": search
- },
- {
- "name": "email",
- "logic_operator": "~*",
- "value": search
- },
- {
- "name": "status_resource",
- "logic_operator": "~*",
- "value": search
- },
- ]
- },
- "joins": [
- {
- "name": "m_roles",
- "column_join": "role_id",
- "column_results": [
- "name",
- "description"
- ]
- }
- ],
- "orders": {
- "columns": [
- "id"
- ],
- "ascending": false
- }
- }
- const result = await axios
- .post(USER_SEARCH, payload, HEADER)
- .then(res => res)
- .catch((error) => error.response);
-
- if (result && result.data && result.data.code == 200) {
- let resData = result.data.data;
- const excelData = [];
- resData.map((n, index) => {
- let dataRow = {
- "NIK (Nomor Induk Karyawan)": n.ktp_number,
- "Employee Name": n.name,
- "Divisi": n.join_second_name,
- "Employee Type": n.employee_type,
- "Role": n.join_first_name,
- "Phone No": n.phone_number,
- }
- excelData.push(dataRow)
- })
- await setDataExport(excelData);
- } else {
- NotificationManager.error('Gagal Export Data!!', 'Failed');
- }
- }
- const exportExcel = () => {
- const dataExcel = dataExport || [];
- const fileName = `Data ${pageName}.xlsx`;
- const ws = XLSX.utils.json_to_sheet(dataExcel);
- const wb = XLSX.utils.book_new();
- XLSX.utils.book_append_sheet(wb, ws, `Data ${pageName}`);
- XLSX.writeFile(wb, fileName);
- setDataExport([])
- }
const handleEdit = (data) => {
setDataEdit(data)
@@ -312,15 +169,19 @@ const MasterCompany = ({ params }) => {
const handleSetWorker = async (data) => {
setCompanyID(data.id)
+ setCompanyName(data.company_name)
await setDataEdit(data)
handleOpenDialog('Set');
}
- const handleSetUserShift = async (data) => {
+ const handleSetMenu = async (data) => {
+ setCompanyID(data.id)
+ setCompanyName(data.company_name)
await setDataEdit(data)
- handleOpenDialogShift('Save');
+ handleOpenDialog('Set-Menu');
}
+
const handleDelete = async (id) => {
await setAlertDelete(true)
await setIdDelete(id)
@@ -336,13 +197,6 @@ const MasterCompany = ({ params }) => {
setOpenDialog(false)
}
- const handleCloseDialogShift = (type, data) => {
- if (type === "save") {
- saveUserShift(data);
- }
- setDataEdit([])
- setOpenDialogShift(false)
- }
const saveUser = async (data) => {
const formData = data
@@ -358,20 +212,6 @@ const MasterCompany = ({ params }) => {
}
}
- const saveUserShift = async (data) => {
- const formData = data
- const result = await axios.post(USER_SHIFT_ADD, formData, HEADER)
- .then(res => res)
- .catch((error) => error.response);
-
- if (result && result.data && result.data.code === 200) {
- getDataUser();
- NotificationManager.success(`Data resource berhasil ditambah`, 'Success!!');
- } else {
- NotificationManager.error(`${result.data.message}`, 'Failed!!');
- }
- }
-
const editUser = async (data) => {
let urlEdit = USER_EDIT(data.id)
@@ -393,9 +233,7 @@ const MasterCompany = ({ params }) => {
setOpenDialog(!openDialog)
}
- const toggleAddDialogShift = () => {
- setOpenDialogShift(!openDialogShift)
- }
+
const onConfirmDelete = async () => {
let url = USER_DELETE(idDelete);
@@ -431,13 +269,15 @@ const MasterCompany = ({ params }) => {
-
+
+
+
>,
},
@@ -481,9 +321,9 @@ const MasterCompany = ({ params }) => {
typeDialog={typeDialog}
dataEdit={dataEdit}
clickOpenModal={clickOpenModal}
- roleList={roleList}
divisiList={divisiList}
companyID={companyID}
+ companyNameProp={companyName}
/>
@@ -497,12 +337,6 @@ const MasterCompany = ({ params }) => {
- {/*
-
-
-
-
- */}
diff --git a/src/views/Pages/Login/Login.js b/src/views/Pages/Login/Login.js
index 7973899..3d74ebc 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) => {
+ getDataMenu = async (token, role_id, user_id) => {
const config = {
headers:
{
@@ -157,15 +157,28 @@ class Login extends Component {
this.props.history.push("/dashboard-customer/58/63");
}
else {
- this.props.history.push("/dashboard");
+ this.props.history.push({
+ pathname: "/dashboard",
+ state: { role_id: role_id, user_id: user_id, token: token, isLogin: true }
+ });
}
if (this.state.defaultPage) {
- this.props.history.push(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 }
+ });
+ } else {
+ this.props.history.push(this.state.defaultPage);
+ }
} else if (role_id == 28) {
this.props.history.push("/dashboard-customer/58/63");
}
else {
- this.props.history.push("/dashboard");
+ this.props.history.push({
+ pathname: "/dashboard",
+ state: { role_id: role_id, user_id: user_id, token: token, isLogin: true }
+ });
}
} else {
NotificationManager.error('Login Failed', 'Failed');
@@ -209,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)
+ this.getDataMenu(access_token, data_user.role_id, data_user.id)
window.localStorage.setItem('isLogin', true);
window.localStorage.setItem('token', access_token);
window.localStorage.setItem('user_id', data_user.id);
@@ -217,8 +230,8 @@ 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('hierarchy', JSON.stringify(data_user.hierarchy));
} else {
- console.log("kode : ", doLogin.data.code);
// NotificationManager.error('Cek username atau password anda!', 'Gagal Login!');
NotificationManager.error(doLogin.data.message, 'Login Failed!');
this.setState({ loader: false });
diff --git a/src/views/SimproV2/CreatedProyek/DialogGantt.js b/src/views/SimproV2/CreatedProyek/DialogGantt.js
index e2ce30c..3af6883 100644
--- a/src/views/SimproV2/CreatedProyek/DialogGantt.js
+++ b/src/views/SimproV2/CreatedProyek/DialogGantt.js
@@ -13,8 +13,20 @@ import DialogUserGantt from './DialogUserGantt';
import { Link } from 'react-router-dom';
-const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, hierarchyId, hierarchyName, openDialogHierarchy }) => {
- const token = localStorage.getItem("token")
+const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, hierarchyId, hierarchyName, openDialogHierarchy, isLogin, token, role_id, user_id }) => {
+ if (role_id && user_id && token && isLogin) {
+ role_id = role_id;
+ user_id = user_id;
+ token = token;
+ isLogin = isLogin;
+ console.log('props.location.state success');
+ } else {
+ role_id = localStorage.getItem("role_id");
+ user_id = localStorage.getItem("user_id");
+ token = localStorage.getItem("token");
+ isLogin = localStorage.getItem("isLogin");
+ console.error('Undefined in props.location.state');
+ }
const HEADER = {
headers: {
"Content-Type": "application/json",
@@ -35,6 +47,7 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName
useEffect(() => {
if (openDialog && hierarchyId > 0 || idTask > 0 && !openDialogHierarchy) {
+ setLoading(true);
getdataGantt();
}
if (!openDialog) {
@@ -150,7 +163,15 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName
{" "}
-
+
{" "}
diff --git a/src/views/SimproV2/CreatedProyek/DialogHierarchy.js b/src/views/SimproV2/CreatedProyek/DialogHierarchy.js
index a6ac1b1..feeedf9 100644
--- a/src/views/SimproV2/CreatedProyek/DialogHierarchy.js
+++ b/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 } from 'antd';
+import { Space, Table, Tooltip, Spin } from 'antd';
import 'antd/dist/antd.css';
import moment from 'moment';
import SweetAlert from 'react-bootstrap-sweetalert';
@@ -41,8 +41,10 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
const [idGantt, setIdGantt] = useState(0)
const [humanResource, setHumanResource] = useState([])
const { t } = useTranslation();
+ const [loading, setLoading] = useState(true);
useEffect(() => {
if (idTask > 0) {
+ setLoading(true);
getdataHierarchy();
}
}, [saveHierarchy, idTask, openDialog, closeDialog, openDialogFormGantt])
@@ -157,7 +159,9 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
if (result && result.status == 200) {
const sortedData = _.orderBy(result.data.data, ['name'], ['asc']);
setDataHierarchy(sortedData);
+ setLoading(false);
} else {
+ setLoading(false);
NotificationManager.error(`Data gantt project gagal terload silahkan coba lagi!`, 'Failed!!');
}
}
@@ -285,9 +289,11 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
-
- {RenderTable}
-
+
+
+ {RenderTable}
+
+
{/*
diff --git a/src/views/SimproV2/CreatedProyek/index.js b/src/views/SimproV2/CreatedProyek/index.js
index b29b17a..f331f84 100644
--- a/src/views/SimproV2/CreatedProyek/index.js
+++ b/src/views/SimproV2/CreatedProyek/index.js
@@ -89,19 +89,29 @@ import AssignK3Project from "./AssignK3Project";
import ViewProject from "./ViewProject";
import ReportAnalysis from "./ReportAnalysis";
import { Icon } from "@iconify/react";
-// import { Link } from 'react-router-dom';
// import SubProyekComp from './SubProyekComp';
-import { Link, useHistory } from "react-router-dom";
+import { Link, useHistory, withRouter } from "react-router-dom";
const url = "";
-const proyek_id = localStorage.getItem("proyek_id");
-const role_id = localStorage.getItem("role_id");
-const user_id = localStorage.getItem("user_id");
const format = "DD-MM-YYYY";
const CreatedProyek = ({ params, ...props }) => {
+ let role_id = '', user_id='',proyek_id='',isLogin='',token='';
+ 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;
+ console.log('props.location.state success');
+ } else {
+ role_id = localStorage.getItem("role_id");
+ proyek_id = localStorage.getItem("proyek_id");
+ user_id = localStorage.getItem("user_id");
+ token = localStorage.getItem("token");
+ isLogin = localStorage.getItem("isLogin");
+ console.error('Undefined in props.location.state');
+ }
const history = useHistory();
- const token = localStorage.getItem("token");
const HEADER = {
headers: {
"Content-Type": "application/json",
@@ -200,7 +210,7 @@ const CreatedProyek = ({ params, ...props }) => {
}, [openDialogProyek]);
useEffect(() => {
- role_id !== "44" ? getDataProyek() : getDataProyekByCustomer();
+ parseInt(role_id) !== 44 ? getDataProyek() : getDataProyekByCustomer();
}, [search, rowsPerPage, currentPage]);
useEffect(() => {
@@ -284,15 +294,17 @@ const CreatedProyek = ({ params, ...props }) => {
);
return;
} else if (result.status == 200 && result.data.data) {
- history.push(
- `/dashboard-customer/${id}/${result.data.gantt}/1`
- );
+ history.push({
+ pathname: `/dashboard-customer/${id}/${result.data.gantt}/1`,
+ state: { role_id: role_id, user_id: user_id, token: token, isLogin: true }
+ });
}
};
const getDataProyek = async () => {
let start = 0;
-
+ let hierarchy = [];
+ hierarchy.push(JSON.parse(localStorage.getItem("hierarchy")));
if (currentPage !== 1 && currentPage > 1) {
start = currentPage * rowsPerPage - rowsPerPage;
}
@@ -335,6 +347,7 @@ const CreatedProyek = ({ params, ...props }) => {
if (parseInt(role_id) !== 1) {
payload["columns"] = [
{ name: "id", logic_operator: "=", value: proyek_id, operator: "AND" },
+ { name: "created_by_id", logic_operator: "IN", value: hierarchy, operator: "AND" }
];
}
@@ -575,7 +588,7 @@ const CreatedProyek = ({ params, ...props }) => {
"checklist_k3_id"
],
"columns": [
- { "name": "proyek_id", "logic_operator": "=", "value": id, "operator": "AND" }
+ { "name": "proyek_id", "logic_operator": "=", "value": id, "operator": "AND" }
]
}
const URL = `${BASE_OSPRO}/api/project-to-checklist-k3/search`;
@@ -584,11 +597,11 @@ const CreatedProyek = ({ params, ...props }) => {
.then(res => res)
.catch((error) => error.response);
- if(result && result.status==200){
- console.log("cek get project to checklist k3",result.data.data)
+ if (result && result.status == 200) {
+ console.log("cek get project to checklist k3", result.data.data)
let dataRes = result.data.data;
if (dataRes.length > 0) {
- setK3Search(dataRes);
+ setK3Search(dataRes);
}
}
}
@@ -616,8 +629,8 @@ const CreatedProyek = ({ params, ...props }) => {
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
- const {value_proyek,area_kerja,scoupe_of_work, kode_sortname,nama,mulai_proyek,rencana_biaya,keterangan,durasi_proyek,project_objectives,potential_risk,currency_symbol, nama_divisi, late_consequence, assumtion, considered_success_when} = result.data.data;
- const dataToSend = {value_proyek,area_kerja,scoupe_of_work, kode_sortname, nama, mulai_proyek, rencana_biaya, keterangan, durasi_proyek, project_objectives, potential_risk, currency_symbol, nama_divisi, late_consequence, assumtion, considered_success_when};
+ const { value_proyek, area_kerja, scoupe_of_work, kode_sortname, nama, mulai_proyek, rencana_biaya, keterangan, durasi_proyek, project_objectives, potential_risk, currency_symbol, nama_divisi, late_consequence, assumtion, considered_success_when } = result.data.data;
+ const dataToSend = { value_proyek, area_kerja, scoupe_of_work, kode_sortname, nama, mulai_proyek, rencana_biaya, keterangan, durasi_proyek, project_objectives, potential_risk, currency_symbol, nama_divisi, late_consequence, assumtion, considered_success_when };
setProjectCharter(dataToSend);
} else {
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
@@ -894,7 +907,7 @@ const CreatedProyek = ({ params, ...props }) => {
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
- role_id !== "44" ? getDataProyek() : getDataProyekByCustomer();
+ parseInt(role_id) !== 44 ? getDataProyek() : getDataProyekByCustomer();
getProjectImage(idDelete);
deleteImage(idDelete);
setIdDelete(0);
@@ -965,7 +978,7 @@ const CreatedProyek = ({ params, ...props }) => {
NotificationManager.success(`${result.data.message}`, "Success!!");
}
- role_id !== "44" ? getDataProyek() : getDataProyekByCustomer();
+ parseInt(role_id) !== 44 ? getDataProyek() : getDataProyekByCustomer();
} else {
NotificationManager.error(`${result.data.message}`, "Failed!!");
}
@@ -1104,7 +1117,7 @@ const CreatedProyek = ({ params, ...props }) => {
.post(IMAGE_UPLOAD, formData, HEADER_MULTIPART)
.then(res => res)
.catch((error) => error.response);
- return "berhasil";
+ return "berhasil";
};
const deleteImage = async (id) => {
@@ -1114,7 +1127,7 @@ const CreatedProyek = ({ params, ...props }) => {
.delete(URL, HEADER)
.then(res => res)
.catch((error) => error.response);
- return "berhasil";
+ return "berhasil";
};
const editProyek = async (data) => {
@@ -1144,7 +1157,7 @@ const CreatedProyek = ({ params, ...props }) => {
);
}
if (result && result.status === 200) {
- role_id !== "44" ? getDataProyek() : getDataProyekByCustomer();
+ parseInt(role_id) !== 44 ? getDataProyek() : getDataProyekByCustomer();
NotificationManager.success(`Data proyek berhasil Ubah`, "Success!!");
} else {
NotificationManager.error(`${result.data.message}`, "Failed!!");
@@ -1509,16 +1522,16 @@ const CreatedProyek = ({ params, ...props }) => {
Request Tools
*/}
{/* */}
- {
- /*text.type_proyek_id != 9 ?*/
- handleOpenDialogGantt(text)}>
-
-
-
- Gantt
-
- /*: null*/
- }
+ {
+ /*text.type_proyek_id != 9 ?*/
+ handleOpenDialogGantt(text)}>
+
+
+
+ Gantt
+
+ /*: null*/
+ }
handleSCurve(text)}>
@@ -1618,7 +1631,7 @@ const CreatedProyek = ({ params, ...props }) => {
dataIndex: "",
key: "x",
render: (text, record) =>
- role_id == "44" ? (
+ parseInt(role_id) == 44 ? (
<>
);
};
-
-export default CreatedProyek;
+export default withRouter(CreatedProyek);
diff --git a/src/views/SimproV2/Gantt/GanttFrame.js b/src/views/SimproV2/Gantt/GanttFrame.js
index f175154..ec90a85 100644
--- a/src/views/SimproV2/Gantt/GanttFrame.js
+++ b/src/views/SimproV2/Gantt/GanttFrame.js
@@ -1,16 +1,30 @@
import React, { useEffect, useState } from 'react';
-import { useHistory } from 'react-router-dom';
+import { useHistory, withRouter } from 'react-router-dom';
import { BASE_SIMPRO_LUMEN } from '../../../const/ApiConst';
const GanttFrame = React.memo((props) => {
+ let role_id = '', user_id='',proyek_id='',isLogin='',token='';
+ 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;
+ isLogin = props.location.state.isLogin;
+ token = props.location.state.token;
+ console.log('props.location.state success');
+ } else {
+ role_id = localStorage.getItem("role_id");
+ proyek_id = localStorage.getItem("proyek_id");
+ user_id = localStorage.getItem("user_id");
+ isLogin = localStorage.getItem("isLogin");
+ token = localStorage.getItem("token");
+ console.error('Undefined in props.location.state');
+ }
const history = useHistory();
- const { versionGanttId, idProject, token, ro, timestamp } = props;
+ const { versionGanttId, idProject, ro, timestamp } = props;
const iframeSrc = `https://adw-gantt.ospro.id/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}×tamp=${timestamp}`;
-
const [batchEntityData, setBatchEntityData] = useState(null);
-
+
useEffect(() => {
const handleMessage = (event) => {
if (event.data && event.data.batchEntity) {
@@ -46,4 +60,4 @@ const GanttFrame = React.memo((props) => {
);
});
-export default GanttFrame;
+export default withRouter(GanttFrame);
diff --git a/src/views/SimproV2/Gantt/index.js b/src/views/SimproV2/Gantt/index.js
index c1c2dda..b46b34d 100644
--- a/src/views/SimproV2/Gantt/index.js
+++ b/src/views/SimproV2/Gantt/index.js
@@ -11,18 +11,30 @@ import { Fab, Action } from "react-tiny-fab";
import "react-tiny-fab/dist/styles.css";
import { useHistory } from "react-router-dom";
import GanttFrame from "./GanttFrame";
-const token = localStorage.getItem("token");
-const userId = parseInt(localStorage.getItem("user_id"));
-const HEADER = {
- headers: {
- "Content-Type": "application/json",
- Authorization: `Bearer ${token}`,
- },
-};
let roCount = 0;
const Gantt = (props) => {
+ let role_id = '', userId='',isLogin='',token='';
+ if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
+ role_id = props.location.state.role_id;
+ userId = props.location.state.user_id;
+ token = props.location.state.token;
+ isLogin = props.location.state.isLogin;
+ console.log('props.location.state success');
+ } else {
+ role_id = localStorage.getItem("role_id");
+ userId = localStorage.getItem("user_id");
+ token = localStorage.getItem("token");
+ isLogin = localStorage.getItem("isLogin");
+ console.error('Undefined in props.location.state');
+ }
+ const HEADER = {
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${token}`,
+ },
+ };
const versionGanttId = props.match.params ? props.match.params.id : 0;
const idProject = props.match.params.project ? props.match.params.project : 0;
const timestamp = props.match.params.timestamp