|
|
|
@ -4,33 +4,27 @@ import React, { useState, useEffect } from 'react';
|
|
|
|
|
import SweetAlert from 'react-bootstrap-sweetalert'; |
|
|
|
|
import axios from "../../../const/interceptorApi" |
|
|
|
|
import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap'; |
|
|
|
|
import { DIVISI_LIST, DIVISI_ADD, DIVISI_EDIT, DIVISI_DELETE, DIVISI_SEARCH } from '../../../const/ApiConst'; |
|
|
|
|
import { DIVISI_LIST, DIVISI_ADD, DIVISI_EDIT, DIVISI_DELETE, DIVISI_SEARCH, COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst'; |
|
|
|
|
import { NotificationContainer, NotificationManager } from 'react-notifications'; |
|
|
|
|
import { Pagination, Button, Tooltip } from 'antd'; |
|
|
|
|
import { useTranslation } from 'react-i18next'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const column = [ |
|
|
|
|
{ name: "Company Name" }, |
|
|
|
|
{ name: "Nama Divisi" }, |
|
|
|
|
{ name: "Deskripsi" }, |
|
|
|
|
{ name: "Color" }, |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
const ProjectType = ({ params, ...props }) => { |
|
|
|
|
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; |
|
|
|
|
if (props && props.role_id && props.user_id) { |
|
|
|
|
role_id = props.role_id; |
|
|
|
|
user_id = props.user_id; |
|
|
|
|
token = props.token; |
|
|
|
|
isLogin = props.isLogin; |
|
|
|
|
company_id = props.company_id; |
|
|
|
|
all_project = props.all_project; |
|
|
|
|
role_name = props.role_name; |
|
|
|
|
isLogin = props.isLogin; |
|
|
|
|
hierarchy = props.hierarchy; |
|
|
|
|
user_name = props.user_name; |
|
|
|
|
} |
|
|
|
|
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = ''; |
|
|
|
|
if (props && props.role_id && props.user_id) { |
|
|
|
|
role_id = props.role_id; |
|
|
|
|
user_id = props.user_id; |
|
|
|
|
token = props.token; |
|
|
|
|
isLogin = props.isLogin; |
|
|
|
|
company_id = props.company_id; |
|
|
|
|
all_project = props.all_project; |
|
|
|
|
role_name = props.role_name; |
|
|
|
|
isLogin = props.isLogin; |
|
|
|
|
hierarchy = props.hierarchy; |
|
|
|
|
user_name = props.user_name; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const HEADER = { |
|
|
|
|
headers: { |
|
|
|
|
"Content-Type": "application/json", |
|
|
|
@ -53,8 +47,14 @@ const ProjectType = ({ params, ...props }) => {
|
|
|
|
|
const [totalPage, setTotalPage] = useState(0) |
|
|
|
|
const [typeDialog, setTypeDialog] = useState('Save') |
|
|
|
|
const [dataDivisions, setDataDivisions] = useState([]) |
|
|
|
|
const [listCompany, setListCompany] = useState([]) |
|
|
|
|
const { t } = useTranslation() |
|
|
|
|
|
|
|
|
|
const column = [ |
|
|
|
|
role_name === 'Super Admin' ? { name: t('company') } : null, |
|
|
|
|
{ name: t('nameDivision') }, |
|
|
|
|
{ name: t('description') }, |
|
|
|
|
{ name: t('color') }, |
|
|
|
|
].filter(column => column && column.name); |
|
|
|
|
useEffect(() => { |
|
|
|
|
getDataProjectType(); |
|
|
|
|
}, [currentPage, rowsPerPage, search]) |
|
|
|
@ -65,6 +65,20 @@ const ProjectType = ({ params, ...props }) => {
|
|
|
|
|
exportExcel() |
|
|
|
|
} |
|
|
|
|
}, [dataExport]) |
|
|
|
|
useEffect(() => { |
|
|
|
|
getDataCompany() |
|
|
|
|
}, []) |
|
|
|
|
|
|
|
|
|
const getDataCompany = async () => { |
|
|
|
|
const result = await axios |
|
|
|
|
.get(COMPANY_MANAGEMENT_LIST, HEADER) |
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
|
setListCompany(result.data.data); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const getListDivision = async () => { |
|
|
|
|
const payload = { |
|
|
|
@ -72,13 +86,13 @@ const ProjectType = ({ params, ...props }) => {
|
|
|
|
|
"operator": "AND", |
|
|
|
|
"group_operator": "OR", |
|
|
|
|
"where": [ |
|
|
|
|
{ |
|
|
|
|
"name": "name", |
|
|
|
|
"logic_operator": "~*", |
|
|
|
|
"value": search, |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
"name": "name", |
|
|
|
|
"logic_operator": "~*", |
|
|
|
|
"value": search, |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
columns: [], |
|
|
|
|
"orders": { |
|
|
|
|
"ascending": true, |
|
|
|
@ -102,10 +116,10 @@ const ProjectType = ({ params, ...props }) => {
|
|
|
|
|
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, |
|
|
|
|
) |
|
|
|
|
payload.joins.push( |
|
|
|
|
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] } |
|
|
|
|
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] } |
|
|
|
|
) |
|
|
|
|
payload.group_column.where.push( |
|
|
|
|
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } |
|
|
|
|
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
const listDivions = await axios |
|
|
|
@ -135,13 +149,13 @@ const ProjectType = ({ params, ...props }) => {
|
|
|
|
|
"operator": "AND", |
|
|
|
|
"group_operator": "OR", |
|
|
|
|
"where": [ |
|
|
|
|
{ |
|
|
|
|
"name": "name", |
|
|
|
|
"logic_operator": "~*", |
|
|
|
|
"value": search, |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
"name": "name", |
|
|
|
|
"logic_operator": "~*", |
|
|
|
|
"value": search, |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
columns: [], |
|
|
|
|
"orders": { |
|
|
|
|
"ascending": true, |
|
|
|
@ -196,13 +210,13 @@ const ProjectType = ({ params, ...props }) => {
|
|
|
|
|
"operator": "AND", |
|
|
|
|
"group_operator": "OR", |
|
|
|
|
"where": [ |
|
|
|
|
{ |
|
|
|
|
"name": "name", |
|
|
|
|
"logic_operator": "~*", |
|
|
|
|
"value": search, |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
"name": "name", |
|
|
|
|
"logic_operator": "~*", |
|
|
|
|
"value": search, |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
"columns": [], |
|
|
|
|
"orders": { |
|
|
|
|
"ascending": true, |
|
|
|
@ -218,17 +232,17 @@ const ProjectType = ({ params, ...props }) => {
|
|
|
|
|
} |
|
|
|
|
if (role_name !== "Super Admin") { |
|
|
|
|
payload.columns.push( |
|
|
|
|
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, |
|
|
|
|
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, |
|
|
|
|
) |
|
|
|
|
} else { |
|
|
|
|
} else { |
|
|
|
|
payload.columns.push( |
|
|
|
|
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, |
|
|
|
|
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, |
|
|
|
|
) |
|
|
|
|
payload.joins.push( |
|
|
|
|
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] } |
|
|
|
|
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] } |
|
|
|
|
) |
|
|
|
|
payload.group_column.where.push( |
|
|
|
|
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } |
|
|
|
|
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
const result = await axios |
|
|
|
@ -241,10 +255,10 @@ const ProjectType = ({ params, ...props }) => {
|
|
|
|
|
resData.map((val, index) => { |
|
|
|
|
let dataRow = {}; |
|
|
|
|
if (role_name === 'Super Admin') { |
|
|
|
|
dataRow.Company = val.join_first_company_name; |
|
|
|
|
dataRow.Company = val.join_first_company_name; |
|
|
|
|
} |
|
|
|
|
dataRow["Nama Divisi"]=val.name; |
|
|
|
|
dataRow.Deskripsi=val.description; |
|
|
|
|
dataRow["Nama Divisi"] = val.name; |
|
|
|
|
dataRow.Deskripsi = val.description; |
|
|
|
|
excelData.push(dataRow) |
|
|
|
|
}) |
|
|
|
|
await setDataExport(excelData) |
|
|
|
@ -393,6 +407,8 @@ const ProjectType = ({ params, ...props }) => {
|
|
|
|
|
dataParent={allDataMenu} |
|
|
|
|
dataDivisions={dataDivisions} |
|
|
|
|
company_id={company_id} |
|
|
|
|
listCompany={listCompany} |
|
|
|
|
role_name={role_name} |
|
|
|
|
/> |
|
|
|
|
<Card> |
|
|
|
|
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}> |
|
|
|
@ -436,10 +452,10 @@ const ProjectType = ({ params, ...props }) => {
|
|
|
|
|
<i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i> |
|
|
|
|
</Tooltip> |
|
|
|
|
</td> |
|
|
|
|
{role_name === 'Super Admin'&& |
|
|
|
|
( |
|
|
|
|
<td>{n.join_first_company_name}</td> |
|
|
|
|
) |
|
|
|
|
{role_name === 'Super Admin' && |
|
|
|
|
( |
|
|
|
|
<td>{n.join_first_company_name}</td> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
<td>{n.name}</td> |
|
|
|
|
<td>{n.description ?? '-'}</td> |
|
|
|
|