Browse Source

merge

pull/2/head
root 1 year ago
parent
commit
b032aefa59
  1. 14
      src/const/ApiConst.js
  2. 2
      src/routes.js
  3. 17
      src/views/Dashboard/DashboardBOD.js
  4. 17
      src/views/Dashboard/DashboardCustomer.js
  5. 533
      src/views/Master/MasterCompany/DialogForm.js
  6. 285
      src/views/Master/MasterCompany/FormMenu.js
  7. 199
      src/views/Master/MasterCompany/FormUser.js
  8. 196
      src/views/Master/MasterCompany/index.js
  9. 25
      src/views/Pages/Login/Login.js
  10. 27
      src/views/SimproV2/CreatedProyek/DialogGantt.js
  11. 14
      src/views/SimproV2/CreatedProyek/DialogHierarchy.js
  12. 94
      src/views/SimproV2/CreatedProyek/index.js
  13. 24
      src/views/SimproV2/Gantt/GanttFrame.js
  14. 28
      src/views/SimproV2/Gantt/index.js

14
src/const/ApiConst.js

@ -745,3 +745,17 @@ export const COMPANY_MANAGEMENT_DELETE = (id) => {
return `${BASE_SIMPRO_LUMEN}/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 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}`;
};

2
src/routes.js

@ -54,7 +54,7 @@ const routes = [
{ path: '/', exact: true, name: 'Home' }, { path: '/', exact: true, name: 'Home' },
// { path: '/dashboard', name: 'Dashboard', component: Dashboard}, // { path: '/dashboard', name: 'Dashboard', component: Dashboard},
{ path: '/dashboard', name: 'DashboardBOD', component: DashboardBOD }, { 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-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', exact: true, name: 'Dashboard Project', component: DashboardProject },
{ path: '/dashboard-project/:PROJECT_ID/:GANTT_ID/:SCURVE', exact: true, name: 'Dashboard Project', component: DashboardProject }, { path: '/dashboard-project/:PROJECT_ID/:GANTT_ID/:SCURVE', exact: true, name: 'Dashboard Project', component: DashboardProject },

17
src/views/Dashboard/DashboardBOD.js

@ -13,8 +13,21 @@ import toRupiah from '@develoka/angka-rupiah-js';
import Icon from '@iconify/react'; import Icon from '@iconify/react';
import { HealthByBudget, HealthBySchedule } from './Components'; import { HealthByBudget, HealthBySchedule } from './Components';
const DashboardBOD = () => { const DashboardBOD = (props) => {
const token = localStorage.getItem("token") 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 = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",

17
src/views/Dashboard/DashboardCustomer.js

@ -25,8 +25,21 @@ const center = {
lng: 106.816666 lng: 106.816666
} }
const DashboardCustomer = () => { const DashboardCustomer = (props) => {
const token = localStorage.getItem("token") 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 = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",

533
src/views/Master/MasterCompany/DialogForm.js

@ -1,17 +1,18 @@
import React, { useState, useMemo, useEffect } from 'react' import React, { useState, useMemo, useEffect } from 'react'
import { import {
Modal, ModalHeader, ModalBody, ModalFooter, Modal, ModalHeader, ModalBody, ModalFooter,
Button, Form, FormGroup, Label, Input, Col, Row, Card, CardBody, Fade Button, Form, FormGroup, Row, Col, Label, Input,
} from 'reactstrap'; } from 'reactstrap';
import { Pagination, Table, Tooltip, Select, Input as InputAntd } from 'antd'; import { Pagination, Table, Tooltip, Select } from 'antd';
import moment from 'moment'; import SweetAlert from 'react-bootstrap-sweetalert';
import { NotificationContainer, NotificationManager } from 'react-notifications'; import { NotificationContainer, NotificationManager } from 'react-notifications';
import DialogFormUser from './DialogFormUser'; import DialogFormUser from './FormUser';
import DialogFormMenu from './FormMenu';
import 'antd/dist/antd.css'; import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import axios from "../../../const/interceptorApi" import axios from "../../../const/interceptorApi"
import { 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'; } from '../../../const/ApiConst';
const token = window.localStorage.getItem('token'); const token = window.localStorage.getItem('token');
const config = { const config = {
@ -21,8 +22,8 @@ const config = {
"Content-type": `application/json` "Content-type": `application/json`
} }
}; };
const { Option } = Select const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, companyID, companyNameProp }) => {
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, roleList, companyID }) => { const { Option } = Select
const { t } = useTranslation() const { t } = useTranslation()
const [registrationnumber, setRegistrationNumber] = useState('') const [registrationnumber, setRegistrationNumber] = useState('')
const [companyName, setCompanyName] = useState('') const [companyName, setCompanyName] = useState('')
@ -38,8 +39,10 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const [htmlTitle, setHtmlTitle] = useState('') const [htmlTitle, setHtmlTitle] = useState('')
const [appName, setAppName] = useState('') const [appName, setAppName] = useState('')
const [baseUrl, setBaseUrl] = useState([]) const [baseUrl, setBaseUrl] = useState([])
const [statusCompany, setStatusCompany] = useState('active') const [statusCompany, setStatusCompany] = useState(true)
const [template, setTemplate] = useState('') const [template, setTemplate] = useState('')
const [lastIdxURL, setLastIdxURL] = useState(0);
const [dataTable, setDatatable] = useState([]) const [dataTable, setDatatable] = useState([])
const [openDialogUser, setOpenDialogUser] = useState(false) const [openDialogUser, setOpenDialogUser] = useState(false)
@ -48,12 +51,27 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const [rowsPerPage, setRowsPerPage] = useState(10) const [rowsPerPage, setRowsPerPage] = useState(10)
const [totalPage, setTotalPage] = useState(0) const [totalPage, setTotalPage] = useState(0)
const [search, setSearch] = useState('') 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(() => { useEffect(() => {
if (companyID) { if (companyID && typeDialog === 'Set') {
getDataUser() getDataUser()
getRoleList()
} else {
getDataMenu()
} }
}, [companyID, rowsPerPage, currentPage]) }, [typeDialog, companyID, rowsPerPage, currentPage, rowsPerPageMenu, currentPageMenu])
const onShowSizeChange = (current, pageSize) => { const onShowSizeChange = (current, pageSize) => {
setRowsPerPage(pageSize) setRowsPerPage(pageSize)
@ -62,6 +80,30 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const onPagination = (current, pageSize) => { const onPagination = (current, pageSize) => {
setCurrentPage(current) 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 () => { const getDataUser = async () => {
let start = 0; 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 () => { const handleAddUser = async () => {
@ -174,8 +256,51 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setOpenDialogUser(true) 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); 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 = () => { 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 = () => { const handleCancel = () => {
closeDialog('cancel', 'none') closeDialog('cancel', 'none')
setDatatable([])
} }
const isValidEmail = (email) => { const onConfirmDelete = async () => {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; let url = USER_DELETE(idDelete);
return emailRegex.test(email);
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 = () => { const handleChangeBaseURL = (value, index) => {
return ( const newBaseURL = [...baseUrl];
<> newBaseURL[index] = value;
{roleList.map((val, index) => { setBaseUrl(newBaseURL);
return ( }
<Option key={index} value={val.id}>{val.name}</Option>
) 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 (
<Row key={index} style={{ marginBottom: 10 }}>
<Col md={8}>
<Input
type="text"
value={item.url}
name="item"
onChange={(e) => handleChangeBaseURL(e, index)}
/>
</Col>
<Col md={2}>
<Button
color="danger"
size="sm"
onClick={() => deleteBaseURL(item.id)}
>
<i className="fa fa-trash"></i>
</Button>
</Col>
</Row>
);
});
} else if (baseUrl.length < 1) {
return (
<div
style={{
textAlign: "center",
color: "red",
marginTop: 25,
marginBottom: 25,
}}
>
No Base URL found
</div>
);
}
};
const renderFromCompany = () => { const renderFromCompany = () => {
return ( return (
@ -293,14 +505,169 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
<span style={{ color: "red" }}>*</span>required. <span style={{ color: "red" }}>*</span>required.
</Col> </Col>
</Row> </Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Number Registration<span style={{ color: "red" }}>*</span></Label>
<Input type="text" value={registrationnumber} onChange={(e) => setRegistrationNumber(e.target.value)} placeholder='Input Number Registration' />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Company Name<span style={{ color: "red" }}>*</span></Label>
<Input type="text" value={companyName} onChange={(e) => setCompanyName(e.target.value)} placeholder=' Input Company Name' />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Email</Label>
<Input type="email" value={emailCompany} onChange={(e) => setEmailCompany(e.target.value)} placeholder={t('inputEmail')}
onBlur={(e) => {
if (!isValidEmail(e.target.value)) {
alert("Masukkan email yang valid.");
}
}}
/>
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Phone Number</Label>
<Input type="text" value={phoneNumber} onChange={(e) => setPhoneNumber(e.target.value.replace(/[^0-9]/g, ''))} placeholder={t('inputNoPhone')} maxLength="15" />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Address</Label>
<Input type="textarea" value={addressCompany} onChange={(e) => setAddressCompany(e.target.value)} placeholder=' Input Address' />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">About</Label>
<Input type="textarea" value={about} onChange={(e) => setAbout(e.target.value)} placeholder=' Input Company Name' />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">App Name</Label>
<Input type="text" value={appName} onChange={(e) => setAppName(e.target.value)} placeholder=' Input App Name' />
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">HTML Title</Label>
<Input type="text" value={htmlTitle} onChange={(e) => setHtmlTitle(e.target.value)} placeholder=' Input HTML Title' />
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Status Company<span style={{ color: "red" }}>*</span></Label>
<Select style={{ width: "100%" }} defaultValue={statusCompany} onChange={(e) => setStatusCompany(e)} placeholder="Select a template for application">
<Option value={true}>Active</Option>
<Option value={false}>Inactive</Option>
</Select>
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize">Template Application<span style={{ color: "red" }}>*</span></Label>
<Select style={{ width: "100%" }} defaultValue={template} onChange={(e) => setTemplate(e)} placeholder="Select a template for application">
<Option value={'1'}>Construction</Option>
<Option value={'2'}>IT (Information AND Technology)</Option>
</Select>
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<Col md={12}>
<Label className="capitalize">Base URL<span style={{ color: "red" }}>*</span></Label>
<Row>
<Col md={8}>
<p>URL</p>
</Col>
<Col md={2}>
<p>Action</p>
</Col>
<Col md={1}>
<Tooltip title="Add row">
<Button
size="sm"
color="primary"
onClick={() => addBaseUrl()}
>
<i className="fa fa-plus"></i>
</Button>
</Tooltip>
</Col>
</Row>
<div style={{ marginBottom: 50 }}>{RenderBaseURL()}</div>
</Col>
</Col>
<Col md={6}>
<Row>
<FormGroup>
<Label className="capitalize" style={{ fontWeight: "bold" }}>Logo Login</Label>
<Input
type="file"
accept="image/*"
// onChange={(e) => handleLogoHeader(e.target.files[0])}
/>
</FormGroup>
</Row>
<Row>
<FormGroup>
<Label className="capitalize" style={{ fontWeight: "bold" }}>Logo Header</Label>
<Input
type="file"
accept="image/*"
onChange={(e) => handleLogoHeader(e.target.files[0])}
/>
</FormGroup>
</Row>
<Row>
<FormGroup>
<Label className="capitalize" style={{ fontWeight: "bold" }}>Fav Icon Logo</Label>
<Input
type="file"
accept="image/*"
// onChange={(e) => setProjectStructureOrg(e.target.files[0])}
/>
</FormGroup>
</Row>
</Col>
</Row>
</Form> </Form>
) )
} }
const RenderTable = useMemo(() => { const RenderTableUser = useMemo(() => {
const columns = [ const columns = [
{
title: t('action'),
dataIndex: '',
key: 'x',
render: (text, record) => <>
<Tooltip title={t('edit')}>
<Button size={"sm"} color='success' onClick={() => handleEditUser(text)}><i className="fa fa-edit"></i></Button>
</Tooltip>{" "}
<Tooltip title={t('delete')}>
<Button size={"sm"} color='danger' onClick={() => handleDeleteUser(text.id)}><i className="fa fa-trash"></i></Button>
</Tooltip>
</>,
},
{ title: t('nik'), dataIndex: 'ktp_number', key: 'ktp_number' }, { title: t('nik'), dataIndex: 'ktp_number', key: 'ktp_number' },
{ title: t('nameHR'), dataIndex: 'name', key: 'name' }, { 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: 'Phone No.', dataIndex: 'phone_number', key: 'phone_number' },
{ title: 'Email', dataIndex: 'email', key: 'email' }, { title: 'Email', dataIndex: 'email', key: 'email' },
{ title: 'Status', dataIndex: 'status_resource', key: 'status_status' } { title: 'Status', dataIndex: 'status_resource', key: 'status_status' }
// title: t('action'),
// dataIndex: '',
// key: 'x',
// render: (text, record) => <>
// <Tooltip title={t('edit')}>
// <Button size="small" type="link" style={{ color: 'green' }} onClick={() => handleEdit(text)}><i className="fa fa-edit"></i></Button>
// </Tooltip>
// <Tooltip title={t('delete')}>
// <Button size="small" type="link" style={{ color: 'red' }} onClick={() => handleDelete(text.id)}><i className="fa fa-trash"></i></Button>
// </Tooltip>
// <Tooltip title="Set User">
// <Button size="small" type="link" style={{ color: 'primary' }} onClick={() => handleSetWorker(text)}><i className="fa fa-users"></i></Button>
// </Tooltip>
// </>,
// },
// { 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 ( return (
<Table <Table
@ -348,29 +693,92 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
) )
}, [dataTable]) }, [dataTable])
const renderTableMenu = useMemo(() => {
const columns = [
{
title: t('action'),
dataIndex: '',
key: 'x',
render: (text, record) => <>
<Tooltip title={t('delete')}>
<i id="TooltipDelete" className="fa fa-trash" style={{ color: 'red', marginRight: '10px', cursor: "pointer" }} onClick={() => handleDeleteMenu(text.id)}></i>
</Tooltip>
<Tooltip title={t('edit')}>
<i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEditMenu(text)}></i>
</Tooltip>
</>,
},
{ 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 (
<Table
rowKey="id"
size="small"
columns={columns}
dataSource={dataTableMenu}
pagination={false}
/>
)
}, [dataTableMenu])
return ( return (
<> <>
<NotificationContainer />
<SweetAlert
show={alertDelete}
warning
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title={t('deleteConfirm')}
onConfirm={onConfirmDelete}
onCancel={() => cancelDelete()}
focusCancelBtn
>
{t('deleteMsg')}
</SweetAlert>
<DialogFormUser <DialogFormUser
openDialog={openDialogUser} openDialog={openDialogUser}
closeDialog={closeDialogUser} closeDialog={closeDialogUser}
typeDialog={typeDialogUser} typeDialog={typeDialogUser}
roleList={roleList} roleList={roleList}
companyID={companyID}
dataEdit={dataEdit}
/>
<DialogFormMenu
openDialog={openDialogMenu}
closeDialog={closeDialogMenu}
typeDialog={typeDialogMenu}
companyID={companyID}
companyName={companyNameProp}
dataEdit={dataEdit}
/> />
<Modal size="xl" fullscreen="xl" scrollable={true} isOpen={openDialog} toggle={toggleDialog}> <Modal size="xl" fullscreen="xl" scrollable={true} isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize withBtn" toggle={closeDialog} style={{ width: "100%" }}> <ModalHeader className="capitalize withBtn" toggle={closeDialog} style={{ width: "100%" }}>
{typeDialog === "Save" ? `Add` : typeDialog === "Set" ? "Manage Admin" : "Edit"} Company {typeDialog === "Set-Menu" ? `Menu ${companyNameProp}` : typeDialog === "Save" ? `Add Data Company` : typeDialog === "Set" ? `Manage User ${companyNameProp}` : `Edit ${companyNameProp}`}
{typeDialog === "Set" && ( {typeDialog === "Set" ? (
<Tooltip title={t("add")}> <Tooltip title="Add User">
<Button onClick={handleAddUser} size='sm' color="primary"><i className='fa fa-plus'></i></Button> <Button onClick={handleAddUser} size='sm' color="primary"><i className='fa fa-plus'></i></Button>
</Tooltip> </Tooltip>
)} ) :
(
<Tooltip title="Add Menu">
<Button onClick={handleAddMenu} size='sm' color="primary"><i className='fa fa-plus'></i></Button>
</Tooltip>
)}
</ModalHeader> </ModalHeader>
<ModalBody> <ModalBody>
{typeDialog !== "Set" && renderFromCompany()} {typeDialog !== "Set" && typeDialog !== "Set-Menu" && renderFromCompany()}
{typeDialog === "Set" && ( {typeDialog === "Set" && (
<> <>
{RenderTable} {RenderTableUser}
<Pagination <Pagination
style={{ marginTop: "25px" }} style={{ marginTop: "25px" }}
showSizeChanger showSizeChanger
@ -383,10 +791,25 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
/> />
</> </>
)} )}
{typeDialog === "Set-Menu" && (
<>
{renderTableMenu}
<Pagination
style={{ marginTop: "25px" }}
showSizeChanger
onShowSizeChange={onShowSizeChangeMenu}
onChange={onPaginationMenu}
pageSizeOptions={["10", "25", "50"]}
total={totalPageMenu}
pageSize={rowsPerPageMenu}
current={currentPageMenu}
/>
</>
)}
</ModalBody> </ModalBody>
<ModalFooter> <ModalFooter>
{typeDialog !== "Set" && ( {typeDialog !== "Set" && typeDialog !== "Set-Menu" && (
<Button color="primary" onClick={() => handleSave()}>{typeDialog}</Button> <Button color="primary" onClick={() => handleSave()}>{typeDialog}</Button>
)} )}
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>cancel</Button> <Button className="capitalize" color="secondary" onClick={() => handleCancel()}>cancel</Button>

285
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 (
<Option key={index} value={val.id}>{val.name}</Option>
)
})}
</>
)
}
const renderForm = () => {
return (
<Form>
<Row>
<Col md={12}>
<div style={{ justifyContent: 'center' }}>
<Transfer
showSearch
listStyle={{
width: 250,
height: 300,
}}
titles={['Master Menu', `Menu ${companyName}`]}
targetKeys={targetKeys}
dataSource={menuResource}
onChange={handleChange}
render={item => item.name}
/>
</div>
</Col>
</Row>
</Form>
)
}
const renderFormEdit = () => {
return (
<Form>
<Row>
<Col md={12}>
<span style={{ color: "red" }}>*</span> Wajib diisi.
</Col>
</Row>
<Row>
<Col>
{/* <FormGroup>
<Label className="capitalize">{t('name')} Menu<span style={{ color: "red" }}>*</span></Label>
<Input type="hidden" value={name} onChange={(e) => setName(e.target.value)} placeholder={t('inputName')} />
</FormGroup>
<FormGroup>
<Label className="capitalize">URL<span style={{ color: "red" }}>*</span></Label>
<Input type="hidden" value={url} onChange={(e) => setUrl(e.target.value)} placeholder={t('inputUrl')} />
</FormGroup> */}
<FormGroup>
<Label className="capitalize">{t('icon')}<span style={{ color: "red" }}>*</span> </Label>
<Input type="text" value={icon} onChange={(e) => setIcon(e.target.value)} placeholder={t('inputIcon')} />
</FormGroup>
</Col>
<Col>
<FormGroup>
<Label className="capitalize">{t('order')}<span style={{ color: "red" }}>*</span></Label>
<Input type="text" min="0" value={sequence} onChange={(e) => setSequence(e.target.value.replace(/[^0-9]/g, ''))} placeholder={t('inputOrder')} />
</FormGroup>
<FormGroup>
<Label className="capitalize">{t('parentMenu')}</Label>
<Select showSearch defaultValue={parentId} onChange={onChangeParent} placeholder={t('inputParentMenu')} style={{ width: '100%' }}>
{setupSelectParent()}
</Select>
</FormGroup>
{/* <FormGroup>
<Label className="capitalize">Alias Menu</Label>
<Input type="hidden" value={aliasName} onChange={(e) => setAliasName(e.target.value)} placeholder={t('inputAliasMenu')} />
</FormGroup> */}
</Col>
</Row>
</Form>
)
}
return (
<>
<Modal ssize="md" scrollable={true} isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize withBtn" toggle={closeDialog} style={{ width: "100%" }}>
Add Data Menu
</ModalHeader>
<ModalBody>
{typeDialog !== 'Edit' ? renderForm() : renderFormEdit()}
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => handleSave()}>{typeDialog}</Button>{''}
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>cancel</Button>
</ModalFooter>
</Modal>
</>
)
}
export default FormMenu;

199
src/views/Master/MasterCompany/DialogFormUser.js → src/views/Master/MasterCompany/FormUser.js

@ -1,107 +1,122 @@
import React, { useState, useMemo } from 'react' import React, { useState, useEffect } from 'react'
import { import {
Modal, ModalHeader, ModalBody, ModalFooter, Modal, ModalHeader, ModalBody, ModalFooter,
Button, Form, FormGroup, Label, Input, Col, Row, Card, CardBody, Fade Button, Form, FormGroup, Label, Input, Col, Row
} from 'reactstrap'; } from 'reactstrap';
import { DatePicker, Table, Tooltip, Select, Input as InputAntd } from 'antd'; import { Select } from 'antd';
import moment from 'moment'; import { USER_ADD, USER_EDIT } from '../../../const/ApiConst.js';
import 'antd/dist/antd.css'; import 'antd/dist/antd.css';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import axios from 'axios';
const { Option } = Select 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 { t } = useTranslation()
const [id, setId] = useState('')
const [resourceName, setResourceName] = useState('') const [resourceName, setResourceName] = useState('')
const [username, setUsername] = useState('') const [username, setUsername] = useState('')
const [password, setPassword] = useState('') const [password, setPassword] = useState('')
const [retryPassword, setRetryPassword] = useState('')
const [employeeType, setEmployeeType] = useState('') const [employeeType, setEmployeeType] = useState('')
const [phoneNo, setPhoneNo] = useState('') const [phoneNo, setPhoneNo] = useState('')
const [email, setEmail] = useState('') const [email, setEmail] = useState('')
const [gender, setGender] = useState('') const [gender, setGender] = useState('')
const [birthDate, setBirthDate] = useState('')
const [birthPlace, setBirthPlace] = useState('')
const [ktpNumber, setKtpNumber] = useState('') const [ktpNumber, setKtpNumber] = useState('')
const [roleId, setRoleId] = useState('') const [roleId, setRoleId] = useState('')
const [address, setAddress] = useState('')
const [statusResource, setStatusResource] = useState('active') 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 = ''; let data = '';
if (typeDialog === "Save") { if (typeDialog === "Save") {
data = { data = {
// registration_no: registrationnumber, name: resourceName,
// company_name: companyName, employee_type: employeeType,
// address: addressCompany, phone_number: phoneNo,
// phone_no: phoneNumber, email,
// email: emailCompany, gender,
// description: description, ktp_number: ktpNumber,
// logo_login: logoLogin, role_id: roleId,
// logo_header: logoHeader, status_resource: statusResource,
// favicon_image: favIcon, company_id: companyID,
// login_instruction: loginInstruction, username,
// about: about, password,
// html_title: htmlTitle,
// app_name: appName,
// base_url: baseUrl,
// is_active: statusCompany,
// template_id: template
} }
console.log(data) const formData = data
const result = await axios.post(USER_ADD, formData, config)
closeDialog('save', data); .then(res => res)
} else if (typeDialog === "Set") { .catch((error) => error.response);
// 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,
// }
closeDialog('edit', data); if (result && result.data && result.data.code === 200) {
closeDialog('success', `Data resource berhasil ditambah`)
} else {
closeDialog('failed', result.data.message)
}
} else { } else {
// data = { data = {
// id, id,
// name: resourceName, name: resourceName,
// username, username,
// employee_type: employeeType, employee_type: employeeType,
// phone_number: phoneNo, phone_number: phoneNo,
// email, email,
// gender, gender,
// birth_place: birthPlace, ktp_number: ktpNumber,
// blood_type: bloodType, role_id: roleId,
// ktp_number: ktpNumber, status_resource: statusResource,
// biaya_per_jam: biayaPerJam.replace('.', ''), company_id: companyID,
// role_id: roleId, username,
// divisi_id: divisionId, password,
// address, }
// status_resource: statusResource, if (password == '') {
// status_boundary: statusRestriction, data.password = dataEdit.password;
// company_id: company_id }
// } let urlEdit = USER_EDIT(data.id)
const formData = data
// if (birthDate && birthDate != "") { const result = await axios.put(urlEdit, formData, config)
// data['birth_date'] = birthDate; .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
<Row> <Row>
<Col md={6}> <Col md={6}>
<FormGroup> <FormGroup>
<Label className="capitalize">{t('birthPlace')}</Label> <Label className="capitalize">{t('roles')} <span style={{ color: "red" }}>*</span></Label>
<Input type="text" value={birthPlace} onChange={(e) => setBirthPlace(e.target.value)} placeholder={t('inputBrithPlace')} /> <Select showSearch defaultValue={roleId} onChange={(val) => setRoleId(val)} placeholder={t('selectRole')} style={{ width: '100%' }}>
{setupSelectRole()}
</Select>
</FormGroup> </FormGroup>
</Col> </Col>
<Col md={6}> <Col md={6}>
<FormGroup> <FormGroup>
<Label className="capitalize">{t('birthDate')}</Label> <Label className="capitalize">Status</Label>
<DatePicker format={"DD-MM-YYYY"} style={{ width: "100%" }} value={birthDate} placeholder={t('inputBrithDate')} onChange={(date, dateString) => setBirthDate(date)} /> <Select style={{ width: "100%" }} defaultValue={statusResource} onChange={(e) => setStatusResource(e)} >
<Option value={'active'}>Active</Option>
<Option value={'inactive'}>Inactive</Option>
</Select>
</FormGroup> </FormGroup>
</Col> </Col>
</Row> </Row>
<Row> <Row>
<Col md={6}> <Col md={6}>
<FormGroup> <FormGroup>
<Label className="capitalize">{t('roles')} <span style={{ color: "red" }}>*</span></Label> <Label className="capitalize">Username</Label>
<Select showSearch defaultValue={roleId} onChange={(val) => setRoleId(val)} placeholder={t('selectRole')} style={{ width: '100%' }}> <Input type="text" value={username} onChange={(e) => setUsername(e.target.value)} placeholder={`Username...`} />
{setupSelectRole()}
</Select>
</FormGroup> </FormGroup>
</Col> </Col>
</Row> </Row>
<Row> <Row>
<Col md={6}>
<Label className="capitalize">Status</Label>
<Select style={{ width: "100%" }} defaultValue={statusResource} onChange={(e) => setStatusResource(e)}>
<Option value={'active'}>Active</Option>
<Option value={'inactive'}>Inactive</Option>
</Select>
</Col>
<Col md={6}> <Col md={6}>
<FormGroup> <FormGroup>
<Label className="capitalize">{t('address')}</Label> <Label className="capitalize">Password</Label>
<Input type="textarea" value={address} onChange={(e) => setAddress(e.target.value)} placeholder={t('inputAddress')} /> <Input type="password" value={password} onChange={(e) => setPassword(e.target.value)} placeholder={`Password...`} />
</FormGroup> </FormGroup>
</Col> </Col>
</Row> </Row>
</Form> </Form>
) )
@ -255,4 +264,4 @@ const DialogFormUser = ({ openDialog, closeDialog, toggleDialog, typeDialog, dat
) )
} }
export default DialogFormUser; export default FormUser;

196
src/views/Master/MasterCompany/index.js

@ -2,19 +2,14 @@ import * as XLSX from 'xlsx';
import React, { useState, useEffect, useMemo } from 'react'; import React, { useState, useEffect, useMemo } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert'; import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi" import axios from "../../../const/interceptorApi"
import moment from 'moment'
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import DialogForm from './DialogForm' import DialogForm from './DialogForm'
import { NotificationContainer, NotificationManager } from 'react-notifications'; import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Table, Button, Tooltip } from 'antd'; import { Pagination, Table, Button, Tooltip } from 'antd';
import { 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'; } from '../../../const/ApiConst';
import { useTranslation } from 'react-i18next'; 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 token = window.localStorage.getItem('token');
const config = { const config = {
headers: headers:
@ -23,8 +18,7 @@ const config = {
"Content-type": `application/json` "Content-type": `application/json`
} }
}; };
const role_name = window.localStorage.getItem('role_name');
const company_id = window.localStorage.getItem('company_id');
const MasterCompany = ({ params }) => { const MasterCompany = ({ params }) => {
const token = localStorage.getItem("token") const token = localStorage.getItem("token")
const company_id = localStorage.getItem("company_id") const company_id = localStorage.getItem("company_id")
@ -45,17 +39,16 @@ const MasterCompany = ({ params }) => {
const [idDelete, setIdDelete] = useState(0) const [idDelete, setIdDelete] = useState(0)
const [openDialog, setOpenDialog] = useState(false) const [openDialog, setOpenDialog] = useState(false)
const [openDialogShift, setOpenDialogShift] = useState(false) const [openDialogShift, setOpenDialogShift] = useState(false)
const [roleList, setRoleList] = useState([])
const [rowsPerPage, setRowsPerPage] = useState(10) const [rowsPerPage, setRowsPerPage] = useState(10)
const [search, setSearch] = useState('') const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0) const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save') const [typeDialog, setTypeDialog] = useState('Save')
const [typeDialogShift, setTypeDialogShift] = useState('Save') const [typeDialogShift, setTypeDialogShift] = useState('Save')
const [companyID, setCompanyID] = useState('') const [companyID, setCompanyID] = useState('')
const [companyName, setCompanyName] = useState('')
const pageName = params.name; const pageName = params.name;
const { t } = useTranslation(); const { t } = useTranslation();
useEffect(() => { useEffect(() => {
getRoleList()
getDivisiList() getDivisiList()
}, []) }, [])
@ -63,12 +56,7 @@ const MasterCompany = ({ params }) => {
getDataUser() getDataUser()
}, [search, rowsPerPage, currentPage]) }, [search, rowsPerPage, currentPage])
useEffect(() => {
const cekData = dataExport || []
if (cekData.length > 0) {
exportExcel()
}
}, [dataExport])
const onShowSizeChange = (current, pageSize) => { const onShowSizeChange = (current, pageSize) => {
setRowsPerPage(pageSize) setRowsPerPage(pageSize)
@ -78,22 +66,6 @@ const MasterCompany = ({ params }) => {
setCurrentPage(current) 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 getDivisiList = async () => {
const formData = { const formData = {
"paging": { "start": 0, "length": -1 }, "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) => { const handleEdit = (data) => {
setDataEdit(data) setDataEdit(data)
@ -312,15 +169,19 @@ const MasterCompany = ({ params }) => {
const handleSetWorker = async (data) => { const handleSetWorker = async (data) => {
setCompanyID(data.id) setCompanyID(data.id)
setCompanyName(data.company_name)
await setDataEdit(data) await setDataEdit(data)
handleOpenDialog('Set'); handleOpenDialog('Set');
} }
const handleSetUserShift = async (data) => { const handleSetMenu = async (data) => {
setCompanyID(data.id)
setCompanyName(data.company_name)
await setDataEdit(data) await setDataEdit(data)
handleOpenDialogShift('Save'); handleOpenDialog('Set-Menu');
} }
const handleDelete = async (id) => { const handleDelete = async (id) => {
await setAlertDelete(true) await setAlertDelete(true)
await setIdDelete(id) await setIdDelete(id)
@ -336,13 +197,6 @@ const MasterCompany = ({ params }) => {
setOpenDialog(false) setOpenDialog(false)
} }
const handleCloseDialogShift = (type, data) => {
if (type === "save") {
saveUserShift(data);
}
setDataEdit([])
setOpenDialogShift(false)
}
const saveUser = async (data) => { const saveUser = async (data) => {
const formData = 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) => { const editUser = async (data) => {
let urlEdit = USER_EDIT(data.id) let urlEdit = USER_EDIT(data.id)
@ -393,9 +233,7 @@ const MasterCompany = ({ params }) => {
setOpenDialog(!openDialog) setOpenDialog(!openDialog)
} }
const toggleAddDialogShift = () => {
setOpenDialogShift(!openDialogShift)
}
const onConfirmDelete = async () => { const onConfirmDelete = async () => {
let url = USER_DELETE(idDelete); let url = USER_DELETE(idDelete);
@ -431,13 +269,15 @@ const MasterCompany = ({ params }) => {
<Tooltip title={t('edit')}> <Tooltip title={t('edit')}>
<Button size="small" type="link" style={{ color: 'green' }} onClick={() => handleEdit(text)}><i className="fa fa-edit"></i></Button> <Button size="small" type="link" style={{ color: 'green' }} onClick={() => handleEdit(text)}><i className="fa fa-edit"></i></Button>
</Tooltip> </Tooltip>
<Tooltip title={t('delete')}> <Tooltip title={t('delete')}>
<Button size="small" type="link" style={{ color: 'red' }} onClick={() => handleDelete(text.id)}><i className="fa fa-trash"></i></Button> <Button size="small" type="link" style={{ color: 'red' }} onClick={() => handleDelete(text.id)}><i className="fa fa-trash"></i></Button>
</Tooltip> </Tooltip>
<Tooltip title="Set User"> <Tooltip title="Set User">
<Button size="small" type="link" style={{ color: 'primary' }} onClick={() => handleSetWorker(text)}><i className="fa fa-users"></i></Button> <Button size="small" type="link" style={{ color: 'primary' }} onClick={() => handleSetWorker(text)}><i className="fa fa-users"></i></Button>
</Tooltip> </Tooltip>
<Tooltip title="Set Menu">
<Button size="small" type="link" style={{ color: 'orange' }} onClick={() => handleSetMenu(text)}><i className="fa fa-bars"></i></Button>
</Tooltip>
</>, </>,
}, },
@ -481,9 +321,9 @@ const MasterCompany = ({ params }) => {
typeDialog={typeDialog} typeDialog={typeDialog}
dataEdit={dataEdit} dataEdit={dataEdit}
clickOpenModal={clickOpenModal} clickOpenModal={clickOpenModal}
roleList={roleList}
divisiList={divisiList} divisiList={divisiList}
companyID={companyID} companyID={companyID}
companyNameProp={companyName}
/> />
<Card> <Card>
@ -497,12 +337,6 @@ const MasterCompany = ({ params }) => {
<Tooltip title='Add Company'> <Tooltip title='Add Company'>
<Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button> <Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button>
</Tooltip> </Tooltip>
{/* <Tooltip title="HR Sync">
<Button style={{ background: "#007bff ", color: "#fff", marginLeft: "5px" }} onClick={() => handleSync()}><i className="fa fa-spinner"></i></Button>
</Tooltip>
<Tooltip title={t('exportExcel')}>
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip> */}
</Col> </Col>
</Row> </Row>
</CardHeader> </CardHeader>

25
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 = { const config = {
headers: headers:
{ {
@ -157,15 +157,28 @@ class Login extends Component {
this.props.history.push("/dashboard-customer/58/63"); this.props.history.push("/dashboard-customer/58/63");
} }
else { 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) { 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) { } else if (role_id == 28) {
this.props.history.push("/dashboard-customer/58/63"); this.props.history.push("/dashboard-customer/58/63");
} }
else { 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 { } else {
NotificationManager.error('Login Failed', 'Failed'); NotificationManager.error('Login Failed', 'Failed');
@ -209,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) this.getDataMenu(access_token, data_user.role_id, data_user.id)
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);
@ -217,8 +230,8 @@ 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('hierarchy', JSON.stringify(data_user.hierarchy));
} else { } else {
console.log("kode : ", doLogin.data.code);
// NotificationManager.error('Cek username atau password anda!', 'Gagal Login!'); // NotificationManager.error('Cek username atau password anda!', 'Gagal Login!');
NotificationManager.error(doLogin.data.message, 'Login Failed!'); NotificationManager.error(doLogin.data.message, 'Login Failed!');
this.setState({ loader: false }); this.setState({ loader: false });

27
src/views/SimproV2/CreatedProyek/DialogGantt.js

@ -13,8 +13,20 @@ import DialogUserGantt from './DialogUserGantt';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, hierarchyId, hierarchyName, openDialogHierarchy }) => { const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, hierarchyId, hierarchyName, openDialogHierarchy, isLogin, token, role_id, user_id }) => {
const token = localStorage.getItem("token") 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 = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -35,6 +47,7 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName
useEffect(() => { useEffect(() => {
if (openDialog && hierarchyId > 0 || idTask > 0 && !openDialogHierarchy) { if (openDialog && hierarchyId > 0 || idTask > 0 && !openDialogHierarchy) {
setLoading(true);
getdataGantt(); getdataGantt();
} }
if (!openDialog) { if (!openDialog) {
@ -150,7 +163,15 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName
</Tooltip>{" "} </Tooltip>{" "}
</Link> </Link>
<Link to={`/projects/${text.id}/${idTask}/gantt`}> <Link to={{
pathname: `/projects/${text.id}/${idTask}/gantt`,
state: {
isLogin: isLogin,
token: token,
role_id: role_id,
user_id: user_id,
}
}}>
<Tooltip title="Gantt"> <Tooltip title="Gantt">
<Button size={"sm"} color='primary'><i className="fa fa-gears"></i></Button> <Button size={"sm"} color='primary'><i className="fa fa-gears"></i></Button>
</Tooltip></Link>{" "} </Tooltip></Link>{" "}

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

@ -1,7 +1,7 @@
import React, { useEffect, useState, useMemo } from 'react' import React, { useEffect, useState, useMemo } from 'react'
import { Modal, ModalHeader, ModalBody, } from 'reactstrap'; import { Modal, ModalHeader, ModalBody, } from 'reactstrap';
import { Button } 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 'antd/dist/antd.css';
import moment from 'moment'; import moment from 'moment';
import SweetAlert from 'react-bootstrap-sweetalert'; import SweetAlert from 'react-bootstrap-sweetalert';
@ -41,8 +41,10 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
const [idGantt, setIdGantt] = useState(0) const [idGantt, setIdGantt] = useState(0)
const [humanResource, setHumanResource] = useState([]) const [humanResource, setHumanResource] = useState([])
const { t } = useTranslation(); const { t } = useTranslation();
const [loading, setLoading] = useState(true);
useEffect(() => { useEffect(() => {
if (idTask > 0) { if (idTask > 0) {
setLoading(true);
getdataHierarchy(); getdataHierarchy();
} }
}, [saveHierarchy, idTask, openDialog, closeDialog, openDialogFormGantt]) }, [saveHierarchy, idTask, openDialog, closeDialog, openDialogFormGantt])
@ -157,7 +159,9 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
if (result && result.status == 200) { if (result && result.status == 200) {
const sortedData = _.orderBy(result.data.data, ['name'], ['asc']); const sortedData = _.orderBy(result.data.data, ['name'], ['asc']);
setDataHierarchy(sortedData); setDataHierarchy(sortedData);
setLoading(false);
} else { } else {
setLoading(false);
NotificationManager.error(`Data gantt project gagal terload silahkan coba lagi!`, 'Failed!!'); NotificationManager.error(`Data gantt project gagal terload silahkan coba lagi!`, 'Failed!!');
} }
} }
@ -285,9 +289,11 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
</Tooltip> </Tooltip>
</ModalHeader> </ModalHeader>
<ModalBody> <ModalBody>
<div style={{ width: '100%', overflow: "auto" }}> <Spin tip="Loading..." spinning={loading}>
{RenderTable} <div style={{ width: '100%', overflow: "auto" }}>
</div> {RenderTable}
</div>
</Spin>
</ModalBody> </ModalBody>
{/* <ModalFooter> {/* <ModalFooter>
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button> <Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button>

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

@ -89,19 +89,29 @@ import AssignK3Project from "./AssignK3Project";
import ViewProject from "./ViewProject"; import ViewProject from "./ViewProject";
import ReportAnalysis from "./ReportAnalysis"; import ReportAnalysis from "./ReportAnalysis";
import { Icon } from "@iconify/react"; import { Icon } from "@iconify/react";
// import { Link } from 'react-router-dom';
// import SubProyekComp from './SubProyekComp'; // import SubProyekComp from './SubProyekComp';
import { Link, useHistory } from "react-router-dom"; import { Link, useHistory, withRouter } from "react-router-dom";
const url = ""; 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 format = "DD-MM-YYYY";
const CreatedProyek = ({ params, ...props }) => { 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 history = useHistory();
const token = localStorage.getItem("token");
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -200,7 +210,7 @@ const CreatedProyek = ({ params, ...props }) => {
}, [openDialogProyek]); }, [openDialogProyek]);
useEffect(() => { useEffect(() => {
role_id !== "44" ? getDataProyek() : getDataProyekByCustomer(); parseInt(role_id) !== 44 ? getDataProyek() : getDataProyekByCustomer();
}, [search, rowsPerPage, currentPage]); }, [search, rowsPerPage, currentPage]);
useEffect(() => { useEffect(() => {
@ -284,15 +294,17 @@ const CreatedProyek = ({ params, ...props }) => {
); );
return; return;
} else if (result.status == 200 && result.data.data) { } else if (result.status == 200 && result.data.data) {
history.push( history.push({
`/dashboard-customer/${id}/${result.data.gantt}/1` pathname: `/dashboard-customer/${id}/${result.data.gantt}/1`,
); state: { role_id: role_id, user_id: user_id, token: token, isLogin: true }
});
} }
}; };
const getDataProyek = async () => { const getDataProyek = async () => {
let start = 0; let start = 0;
let hierarchy = [];
hierarchy.push(JSON.parse(localStorage.getItem("hierarchy")));
if (currentPage !== 1 && currentPage > 1) { if (currentPage !== 1 && currentPage > 1) {
start = currentPage * rowsPerPage - rowsPerPage; start = currentPage * rowsPerPage - rowsPerPage;
} }
@ -335,6 +347,7 @@ const CreatedProyek = ({ params, ...props }) => {
if (parseInt(role_id) !== 1) { if (parseInt(role_id) !== 1) {
payload["columns"] = [ payload["columns"] = [
{ name: "id", logic_operator: "=", value: proyek_id, operator: "AND" }, { 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" "checklist_k3_id"
], ],
"columns": [ "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`; const URL = `${BASE_OSPRO}/api/project-to-checklist-k3/search`;
@ -584,11 +597,11 @@ const CreatedProyek = ({ params, ...props }) => {
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if(result && result.status==200){ if (result && result.status == 200) {
console.log("cek get project to checklist k3",result.data.data) console.log("cek get project to checklist k3", result.data.data)
let dataRes = result.data.data; let dataRes = result.data.data;
if (dataRes.length > 0) { if (dataRes.length > 0) {
setK3Search(dataRes); setK3Search(dataRes);
} }
} }
} }
@ -616,8 +629,8 @@ const CreatedProyek = ({ params, ...props }) => {
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.data.code == 200) { 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 { 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 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); setProjectCharter(dataToSend);
} else { } else {
NotificationManager.error("Gagal Mengambil Data!!", "Failed"); NotificationManager.error("Gagal Mengambil Data!!", "Failed");
@ -894,7 +907,7 @@ const CreatedProyek = ({ params, ...props }) => {
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.data.code === 200) { if (result && result.data && result.data.code === 200) {
role_id !== "44" ? getDataProyek() : getDataProyekByCustomer(); parseInt(role_id) !== 44 ? getDataProyek() : getDataProyekByCustomer();
getProjectImage(idDelete); getProjectImage(idDelete);
deleteImage(idDelete); deleteImage(idDelete);
setIdDelete(0); setIdDelete(0);
@ -965,7 +978,7 @@ const CreatedProyek = ({ params, ...props }) => {
NotificationManager.success(`${result.data.message}`, "Success!!"); NotificationManager.success(`${result.data.message}`, "Success!!");
} }
role_id !== "44" ? getDataProyek() : getDataProyekByCustomer(); parseInt(role_id) !== 44 ? getDataProyek() : getDataProyekByCustomer();
} else { } else {
NotificationManager.error(`${result.data.message}`, "Failed!!"); NotificationManager.error(`${result.data.message}`, "Failed!!");
} }
@ -1104,7 +1117,7 @@ const CreatedProyek = ({ params, ...props }) => {
.post(IMAGE_UPLOAD, formData, HEADER_MULTIPART) .post(IMAGE_UPLOAD, formData, HEADER_MULTIPART)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
return "berhasil"; return "berhasil";
}; };
const deleteImage = async (id) => { const deleteImage = async (id) => {
@ -1114,7 +1127,7 @@ const CreatedProyek = ({ params, ...props }) => {
.delete(URL, HEADER) .delete(URL, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
return "berhasil"; return "berhasil";
}; };
const editProyek = async (data) => { const editProyek = async (data) => {
@ -1144,7 +1157,7 @@ const CreatedProyek = ({ params, ...props }) => {
); );
} }
if (result && result.status === 200) { if (result && result.status === 200) {
role_id !== "44" ? getDataProyek() : getDataProyekByCustomer(); parseInt(role_id) !== 44 ? getDataProyek() : getDataProyekByCustomer();
NotificationManager.success(`Data proyek berhasil Ubah`, "Success!!"); NotificationManager.success(`Data proyek berhasil Ubah`, "Success!!");
} else { } else {
NotificationManager.error(`${result.data.message}`, "Failed!!"); NotificationManager.error(`${result.data.message}`, "Failed!!");
@ -1509,16 +1522,16 @@ const CreatedProyek = ({ params, ...props }) => {
<span className="menu-text">Request Tools</span> <span className="menu-text">Request Tools</span>
</div> */} </div> */}
{/* <Link to={`/project-charter/${text.id}/gantt`}> */} {/* <Link to={`/project-charter/${text.id}/gantt`}> */}
{ {
/*text.type_proyek_id != 9 ?*/ /*text.type_proyek_id != 9 ?*/
<div className="menu-list" onClick={() => handleOpenDialogGantt(text)}> <div className="menu-list" onClick={() => handleOpenDialogGantt(text)}>
<span className="menu-icon"> <span className="menu-icon">
<i className="fa fa-bars"></i> <i className="fa fa-bars"></i>
</span> </span>
<span className="menu-text">Gantt</span> <span className="menu-text">Gantt</span>
</div> </div>
/*: null*/ /*: null*/
} }
<div className="menu-list" onClick={() => handleSCurve(text)}> <div className="menu-list" onClick={() => handleSCurve(text)}>
<span className="menu-icon"> <span className="menu-icon">
<i className="fa fa-line-chart"></i> <i className="fa fa-line-chart"></i>
@ -1618,7 +1631,7 @@ const CreatedProyek = ({ params, ...props }) => {
dataIndex: "", dataIndex: "",
key: "x", key: "x",
render: (text, record) => render: (text, record) =>
role_id == "44" ? ( parseInt(role_id) == 44 ? (
<> <>
<Tooltip title="Dashboard Project"> <Tooltip title="Dashboard Project">
<Button <Button
@ -1932,6 +1945,10 @@ const CreatedProyek = ({ params, ...props }) => {
closeDialog={closeDialogGantt} closeDialog={closeDialogGantt}
toggleDialog={toggleDialogGantt} toggleDialog={toggleDialogGantt}
idTask={idTask} idTask={idTask}
role_id={role_id}
user_id={user_id}
token={token}
isLogin={isLogin}
proyekName={proyekName} proyekName={proyekName}
/> />
), ),
@ -1997,7 +2014,7 @@ const CreatedProyek = ({ params, ...props }) => {
/> />
</Col> </Col>
<Col> <Col>
{role_id == "44" ? null : ( // role kustomer {parseInt(role_id) == 44 ? null : ( // role kustomer
<Tooltip title="Add Project"> <Tooltip title="Add Project">
<Button <Button
style={{ background: "#4caf50", color: "#fff" }} style={{ background: "#4caf50", color: "#fff" }}
@ -2034,12 +2051,12 @@ const CreatedProyek = ({ params, ...props }) => {
</Button> </Button>
</> </>
} }
// visible={visible} // visible={visible}
// onVisibleChange={handleVisibleChange} // onVisibleChange={handleVisibleChange}
> >
<Button <Button
style={{ marginLeft: "5px" }} style={{ marginLeft: "5px" }}
// onClick={() => handleExportExcel()} // onClick={() => handleExportExcel()}
> >
<i className="fa fa-print"></i> <i className="fa fa-print"></i>
</Button> </Button>
@ -2068,5 +2085,4 @@ const CreatedProyek = ({ params, ...props }) => {
</div> </div>
); );
}; };
export default withRouter(CreatedProyek);
export default CreatedProyek;

24
src/views/SimproV2/Gantt/GanttFrame.js

@ -1,16 +1,28 @@
import React, { useEffect, useState } from 'react'; 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'; import { BASE_SIMPRO_LUMEN } from '../../../const/ApiConst';
const GanttFrame = React.memo((props) => { 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 history = useHistory();
const { versionGanttId, idProject, token, ro, timestamp } = props; const { versionGanttId, idProject, token, ro, timestamp } = props;
const iframeSrc = `https://konstruksi-gantt.ospro.id/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}&timestamp=${timestamp}`; const iframeSrc = `https://konstruksi-gantt.ospro.id/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}&timestamp=${timestamp}`;
const [batchEntityData, setBatchEntityData] = useState(null); const [batchEntityData, setBatchEntityData] = useState(null);
useEffect(() => { useEffect(() => {
const handleMessage = (event) => { const handleMessage = (event) => {
if (event.data && event.data.batchEntity) { if (event.data && event.data.batchEntity) {
@ -46,4 +58,4 @@ const GanttFrame = React.memo((props) => {
); );
}); });
export default GanttFrame; export default withRouter(GanttFrame);

28
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 "react-tiny-fab/dist/styles.css";
import { useHistory } from "react-router-dom"; import { useHistory } from "react-router-dom";
import GanttFrame from "./GanttFrame"; 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; let roCount = 0;
const Gantt = (props) => { 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 versionGanttId = props.match.params ? props.match.params.id : 0;
const idProject = props.match.params.project ? props.match.params.project : 0; const idProject = props.match.params.project ? props.match.params.project : 0;
const timestamp = props.match.params.timestamp const timestamp = props.match.params.timestamp

Loading…
Cancel
Save