Browse Source

add form company_id

pull/1/head
wahyun 11 months ago
parent
commit
c1ed033a7f
  1. 91
      src/views/Master/MasterRoles/DialogForm.js
  2. 61
      src/views/Master/MasterRoles/DialogMenuRoles.js
  3. 23
      src/views/Master/MasterRoles/index.js
  4. 88
      src/views/Master/RoleProject/DialogForm.js
  5. 9
      src/views/Master/RoleProject/index.js
  6. 58
      src/views/SimproV2/CreatedProyek/DialogFormProyek.js
  7. 64
      src/views/SimproV2/CreatedProyek/index.js
  8. 57
      src/views/SimproV2/ResourceWorker/DialogForm.js
  9. 26
      src/views/SimproV2/ResourceWorker/index.js

91
src/views/Master/MasterRoles/DialogForm.js

@ -1,22 +1,13 @@
import React, { Component } from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter, Row, Col } from 'reactstrap';
import { Button, Form, FormGroup, Label, Input } from 'reactstrap';
import { Modal, ModalHeader, ModalBody, ModalFooter, Row, Col, Button, Form, FormGroup, Label, Input } from 'reactstrap';
import 'antd/dist/antd.css';
import { withTranslation } from 'react-i18next';
import axios from 'axios';
import { NotificationManager } from 'react-notifications';
import { Select } from 'antd';
import { MENU_SEARCH } from '../../../const/ApiConst.js';
import { COMPANY_MANAGEMENT_LIST, MENU_SEARCH } from '../../../const/ApiConst.js';
const { Option } = Select
const token = window.localStorage.getItem('token');
const company_id = localStorage.getItem("company_id")
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
class DialogForm extends Component {
constructor(props) {
@ -27,16 +18,26 @@ class DialogForm extends Component {
description: "",
openDialog: false,
isParentClick: false,
companyList: [],
scompany_id:null,
menu: [],
selectedMenu: null,
all_project: false,
company_id
company_id: props.company_id || null,
role_name: props.role_name || '',
token: props.token || '',
config: {
headers: {
Authorization: `Bearer ${props.token || ''}`,
"Content-type": "application/json",
}
}
}
}
async componentDidMount() {
this.props.showDialog(this.showDialog);
this.getDataProyekCompany();
this.getAllMenu();
this.props.showDialog(this.showDialog);
}
async componentDidUpdate() {
if (this.state.isParentClick === true) {
@ -47,7 +48,7 @@ class DialogForm extends Component {
name: dataEdit.name,
description: dataEdit.description,
selectedMenu: dataEdit.default_page,
company_id
scompany_id : dataEdit.company_id
})
} else {
this.setState({
@ -55,13 +56,27 @@ class DialogForm extends Component {
name: "",
description: "",
selectedMenu: null,
company_id
scompany_id : null
})
}
this.setState({ isParentClick: false });
}
}
getDataProyekCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, this.state.config)
.then((res) => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || [];
this.setState({companyList: dataRes})
} else {
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
}
};
getAllMenu = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
@ -72,7 +87,7 @@ class DialogForm extends Component {
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.post(MENU_SEARCH, payload, config)
.post(MENU_SEARCH, payload, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
@ -85,6 +100,10 @@ class DialogForm extends Component {
}
validation = () => {
if (this.state.role_name === 'Super Admin' && !this.state.scompany_id || this.state.scompany_id === "") {
alert("Company data cannot be empty!");
return true;
}
if (!this.state.name || this.state.name === "") {
alert("Role Name cannot be empty!");
return true;
@ -101,7 +120,9 @@ class DialogForm extends Component {
name,
description,
selectedMenu,
role_name,
company_id,
scompany_id,
all_project
} = this.state
@ -114,7 +135,7 @@ class DialogForm extends Component {
name,
description,
selectedMenu,
company_id,
company_id : role_name !== 'Super Admin' ? company_id : scompany_id,
all_project
}
@ -125,21 +146,22 @@ class DialogForm extends Component {
name,
description,
selectedMenu,
company_id,
company_id : role_name !== 'Super Admin' ? company_id : scompany_id,
all_project
}
this.props.closeDialog('edit', data);
}
this.setState({ id: 0 });
}
}
handleCancel = () => {
this.props.closeDialog('cancel', 'none')
}
onChangeCompanyProject = (val) => {
this.setState({scompany_id : val});
};
renderForm = () => {
const { t } = this.props;
return (
@ -150,6 +172,31 @@ class DialogForm extends Component {
</Col>
</Row>
<Row>
{
this.state.role_name === 'Super Admin' && (
<Col md={12}>
<FormGroup>
<Label className="capitalize">Assign Company Project<span style={{ color: "red" }}>*</span></Label>
<Select
showSearch
filterOption={(inputValue, option) =>
option.children.toLowerCase().includes(inputValue.toLowerCase())
}
value={this.state.scompany_id}
defaultValue={this.state.scompany_id}
onChange={this.onChangeCompanyProject}
style={{ width: "100%" }}
>
{this.state.companyList.map((res) => (
<Option key={res.id} value={res.id}>
{res.company_name}
</Option>
))}
</Select>
</FormGroup>
</Col>
)
}
<Col md={12}>
<FormGroup>
<Label>{this.props.t('nameRole')}<span style={{ color: "red" }}>*</span></Label>

61
src/views/Master/MasterRoles/DialogMenuRoles.js

@ -7,17 +7,6 @@ import { MENU_SEARCH } from '../../../const/ApiConst.js';
import { withTranslation, WithTranslation } from 'react-i18next';
const BASE_URL = "http://siopas.co.id/custom-php/api/geohr/";
const token = window.localStorage.getItem('token');
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
class DialogMenuRoles extends Component {
constructor(props) {
super(props)
@ -27,28 +16,24 @@ class DialogMenuRoles extends Component {
description: "",
openDialog: false,
isParentClick: false,
menu: [],
stateMenu: [],
menu:[],
allChecked: true,
company_id: props.company_id || null,
role_name: props.role_name || '',
token: props.token || '',
config: {
headers: {
Authorization: `Bearer ${props.token || ''}`,
"Content-type": "application/json",
}
}
async componentDidMount() {
this.props.showDialog(this.showDialog);
this.getAllMenu();
}
async componentDidUpdate() {
if (this.state.isParentClick === true) {
const { idRoles } = this.props
this.setStateMenu(true);
this.setState({ isParentClick: false, id: idRoles });
}
}
showDialog = () => {
this.setState({ isParentClick: true });
async componentDidMount() {
this.getAllMenu()
this.props.showDialog(this.showDialog);
}
getAllMenu = async () => {
@ -60,22 +45,26 @@ class DialogMenuRoles extends Component {
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.post(MENU_SEARCH, payload, config)
.post(MENU_SEARCH, payload, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
this.setState({ menu: result.data.data }, () => {
this.setStateMenu(false);
});
} else {
this.setState({ menu: result.data.data });
}
}
async componentDidUpdate() {
if (this.state.isParentClick === true) {
const { idRoles } = this.props
this.setStateMenu(true);
this.setState({ isParentClick: false, id: idRoles });
}
}
showDialog = () => {
this.setState({ isParentClick: true });
}
setStateMenu = edit => {

23
src/views/Master/MasterRoles/index.js

@ -194,7 +194,7 @@ class index extends Component {
const { idDelete } = this.state
const url = ROLE_DELETE(idDelete)
const result = await axios.delete(url, this.config)
const result = await axios.delete(url, this.state.config)
.then(res => res)
.catch((error) => error.response);
@ -219,7 +219,7 @@ class index extends Component {
all_project: data.all_project
}
const result = await axios.post(ROLE_ADD, formData, this.config)
const result = await axios.post(ROLE_ADD, formData, this.state.config)
.then(res => res)
.catch((error) => error.response);
@ -241,7 +241,7 @@ class index extends Component {
all_project: data.all_project
}
const url = ROLE_EDIT(data.id)
const result = await axios.put(url, formData, this.config)
const result = await axios.put(url, formData, this.state.config)
.then(res => res)
.catch((error) => error.response);
@ -310,7 +310,7 @@ class index extends Component {
}
const result = await axios
.post(ROLEMENU_SEARCH, formData, this.config)
.post(ROLEMENU_SEARCH, formData, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
@ -334,7 +334,7 @@ class index extends Component {
menu_id: val.menu_id,
role_id: val.roles_id
}
promises.push(axios.post(ROLEMENU_ADD, formData, this.config)
promises.push(axios.post(ROLEMENU_ADD, formData, this.state.config)
.then(res => result.push(res)))
}
})
@ -354,7 +354,7 @@ class index extends Component {
deleteCurrentRoleMenu = async (id) => {
let urlDel = ROLEMENU_DELETE_ROLE(id)
const result = await axios.delete(urlDel, this.config)
const result = await axios.delete(urlDel, this.state.config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
@ -472,9 +472,9 @@ class index extends Component {
dataEdit={this.state.dataEdit}
showDialog={showDialog => this.showChildDialog = showDialog}
dataHs={this.state.dataIdHo}
companyID={this.state.company_id}
roleName={this.state.role_name}
company_id={this.state.company_id}
role_name={this.state.role_name}
token={this.state.token}
/>
<DialogMenuRoles
openDialog={dialogMenuForm}
@ -482,8 +482,9 @@ class index extends Component {
idRoles={this.state.idRoles}
showDialog={showDialog => this.showMenuRolesDialog = showDialog}
menuRoles={this.state.menuRoles}
companyID={this.state.company_id}
roleName={this.state.role_name}
company_id={this.state.company_id}
role_name={this.state.role_name}
token={this.state.token}
/>
<Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}>

88
src/views/Master/RoleProject/DialogForm.js

@ -1,9 +1,12 @@
import React, { Component } from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { Button, Form, FormGroup, Label, Input } from 'reactstrap';
import { Modal, ModalHeader, ModalBody, ModalFooter, Button, Form, FormGroup, Label, Input } from 'reactstrap';
import 'antd/dist/antd.css';
import axios from 'axios';
import { COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst.js';
import { withTranslation } from 'react-i18next';
const company_id = localStorage.getItem("company_id")
import { NotificationManager } from 'react-notifications';
import { Select } from 'antd';
const { Option } = Select
class DialogForm extends Component {
constructor(props) {
super(props)
@ -12,13 +15,24 @@ class DialogForm extends Component {
name: "",
description: "",
openDialog: false,
companyList: [],
scompany_id:null,
isParentClick: false,
company_id
company_id: props.company_id || null,
role_name: props.role_name || '',
token: props.token || '',
config: {
headers: {
Authorization: `Bearer ${props.token || ''}`,
"Content-type": "application/json",
}
}
}
}
async componentDidMount() {
this.props.showDialog(this.showDialog);
this.getDataProyekCompany();
}
async componentDidUpdate() {
@ -29,13 +43,14 @@ class DialogForm extends Component {
id: dataEdit.id,
name: dataEdit.name,
description: dataEdit.description,
company_id
scompany_id : dataEdit.company_id
})
} else {
this.setState({
id: 0,
name: "",
description: ""
description: "",
scompany_id:null
})
}
this.setState({ isParentClick: false });
@ -47,21 +62,46 @@ class DialogForm extends Component {
this.setState({ isParentClick: true });
}
getDataProyekCompany = async () => {
const result = await axios
.get(COMPANY_MANAGEMENT_LIST, this.state.config)
.then((res) => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || [];
this.setState({companyList: dataRes})
} else {
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
}
};
validation = () => {
if (this.state.role_name === 'Super Admin' && !this.state.scompany_id || this.state.scompany_id === "") {
alert("Company data cannot be empty!");
return true;
}
}
handleSave = () => {
const {
id,
name,
description
description,
role_name,
company_id,
scompany_id
} = this.state
let data = '';
const err = this.validation();
if(!err) {
if (this.props.typeDialog === "Save") {
data = {
id,
name,
description,
company_id
company_id : role_name !== 'Super Admin' ? company_id : scompany_id,
}
this.props.closeDialog('save', data);
} else {
@ -69,23 +109,49 @@ class DialogForm extends Component {
id,
name,
description,
company_id
company_id : role_name !== 'Super Admin' ? company_id : scompany_id,
}
this.props.closeDialog('edit', data);
}
}
this.setState({ id: 0 });
}
handleCancel = () => {
this.props.closeDialog('cancel', 'none')
}
onChangeCompanyProject = (val) => {
this.setState({scompany_id : val});
};
renderForm = () => {
const { t } = this.props;
return (
<Form>
{
this.state.role_name === 'Super Admin' && (
<FormGroup>
<Label className="capitalize">Assign Company Project<span style={{ color: "red" }}>*</span></Label>
<Select
showSearch
filterOption={(inputValue, option) =>
option.children.toLowerCase().includes(inputValue.toLowerCase())
}
value={this.state.scompany_id}
defaultValue={this.state.scompany_id}
onChange={this.onChangeCompanyProject}
style={{ width: "100%" }}
>
{this.state.companyList.map((res) => (
<Option key={res.id} value={res.id}>
{res.company_name}
</Option>
))}
</Select>
</FormGroup>
)
}
<FormGroup>
<Label>{this.props.t('name')}</Label>
<Input type="text" value={this.state.name} onChange={(e) => this.setState({ name: e.target.value })} placeholder={this.props.t('inputName')} />

9
src/views/Master/RoleProject/index.js

@ -6,7 +6,7 @@ import axios from 'axios';
import { Button } from 'reactstrap';
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { PROJECT_ROLE_ADD, PROJECT_ROLE_SEARCH, PROJECT_ROLE_EDIT, PROJECT_ROLE_DELETE, ROLEMENU_ADD, ROLEMENU_SEARCH, ROLEMENU_DELETE_ROLE } from '../../../const/ApiConst.js';
import { PROJECT_ROLE_ADD, PROJECT_ROLE_SEARCH, PROJECT_ROLE_EDIT, PROJECT_ROLE_DELETE } from '../../../const/ApiConst.js';
import { Pagination, Tooltip, Table } from 'antd';
import { withTranslation } from 'react-i18next';
const LENGTH_DATA = 10
@ -202,7 +202,7 @@ class index extends Component {
const formData = {
name: data.name,
description: data.description,
company_id: this.state.company_id
company_id: data.company_id
}
const result = await axios.post(PROJECT_ROLE_ADD, formData, this.state.config)
@ -223,7 +223,7 @@ class index extends Component {
const formData = {
name: data.name,
description: data.description,
company_id : this.state.company_id
company_id : data.company_id
}
const url = PROJECT_ROLE_EDIT(data.id)
const result = await axios.put(url, formData, this.state.config)
@ -390,6 +390,9 @@ class index extends Component {
dataEdit={this.state.dataEdit}
showDialog={showDialog => this.showChildDialog = showDialog}
dataHs={this.state.dataIdHo}
company_id={this.state.company_id}
role_name={this.state.role_name}
token={this.state.token}
/>
<Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}>

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

@ -35,7 +35,9 @@ const DialogFormProyek = ({
dataDivisions,
dataPM,
projectImage,
company_id
company_id,
role_name,
companyList
}) => {
const token = localStorage.getItem("token");
const HEADER = {
@ -65,6 +67,7 @@ const DialogFormProyek = ({
const [finance, setFinance] = useState("");
const [investor, setInvestor] = useState("");
const [company, setCompany] = useState("");
const [scompany_id, setCompanyId] = useState(null);
const [step, setStep] = useState(1);
const [currencyList, setCurrencyList] = useState(null);
const [currency, setCurrency] = useState(""); // merge of code | symbol | name
@ -115,6 +118,7 @@ const DialogFormProyek = ({
setProjectDuration(val.durasi_proyek);
setInvestor(val.investor);
setCompany(val.company);
setCompanyId(val.company_id)
setFinance(val.finance);
setObjectives(val.project_objectives ? val.project_objectives : "");
setTestingEnv(val.testing_environment);
@ -206,6 +210,7 @@ const DialogFormProyek = ({
setDivisiProject(null);
setProjectStructureOrg(null);
setCompany("");
setCompanyId(null)
setCurrency("");
setCurrencyCode("");
setCurrencySymbol(null);
@ -276,7 +281,7 @@ const DialogFormProyek = ({
currency_symbol: currencySymbol,
currency_code: currencyCode,
currency_name: currencyName,
company_id: parseInt(company_id)
company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id)
};
data.projectCharter = { checklist, issue, potentialRisks, participants, milestones, approval };
data.imageStructureOrg = organization ? organization : null;
@ -307,7 +312,7 @@ const DialogFormProyek = ({
currency_symbol: currencySymbol,
currency_code: currencyCode,
currency_name: currencyName,
company_id: parseInt(company_id)
company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id)
};
data.projectCharter = { checklist, issue, potentialRisks, participants, milestones, approval };
data.imageStructureOrg = organization ? organization : null;
@ -326,6 +331,10 @@ const DialogFormProyek = ({
setTypeproject(val);
};
const onChangeCompanyProject = (val) => {
setCompanyId(val);
};
const onChangePhaseProject = (val) => {
setPhaseProject(val);
};
@ -404,6 +413,10 @@ const DialogFormProyek = ({
alert("End Date cannot be empty!");
return false;
}
if (role_name === 'Super Admin' && !scompany_id || scompany_id === "") {
alert("Company data cannot be empty!");
return false;
}
if (!biaya || biaya === "") {
alert("Budget cannot be empty!");
return false;
@ -754,16 +767,31 @@ const DialogFormProyek = ({
</Col>
</Row>
<Row>
{
role_name === 'Super Admin' && (
<Col md={6}>
<FormGroup>
<Label className="capitalize" style={{ fontWeight: "bold" }}>Work Area</Label>
<Input
type="text"
value={workArea}
onChange={(e) => setWorkArea(e.target.value)}
/>
<Label className="capitalize" style={{ fontWeight: "bold" }}>Assign Company Project<span style={{ color: "red" }}>*</span></Label>
<Select
showSearch
filterOption={(inputValue, option) =>
option.children.toLowerCase().includes(inputValue.toLowerCase())
}
value={scompany_id}
defaultValue={scompany_id}
onChange={onChangeCompanyProject}
style={{ width: "100%" }}
>
{companyList.map((res) => (
<Option key={res.id} value={res.id}>
{res.company_name}
</Option>
))}
</Select>
</FormGroup>
</Col>
)
}
<Col md={6}>
<FormGroup>
<Label className="capitalize" style={{ fontWeight: "bold" }}>Company</Label>
@ -774,8 +802,6 @@ const DialogFormProyek = ({
/>
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>
<FormGroup>
<Label className="capitalize" style={{ fontWeight: "bold" }}>
@ -804,6 +830,16 @@ const DialogFormProyek = ({
</Row>
</FormGroup>
</Col>
<Col md={6}>
<FormGroup>
<Label className="capitalize" style={{ fontWeight: "bold" }}>Work Area</Label>
<Input
type="text"
value={workArea}
onChange={(e) => setWorkArea(e.target.value)}
/>
</FormGroup>
</Col>
</Row>
<Row>
<Col md={6}>

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

@ -36,6 +36,7 @@ import {
PROJECT_TYPE_SEARCH,
PROYEK_ADD,
PROYEK_SEARCH,
COMPANY_MANAGEMENT_LIST,
PROYEK_EDIT,
ASSIGN_HR_PROJECT_SEARCH,
PROJECT_CHECKLIST_SEARCH,
@ -116,6 +117,7 @@ const CreatedProyek = ({ params, ...props }) => {
const [idTask, setidTask] = useState(0);
const [projectId, setProjectId] = useState(0);
const [dataTable, setDatatable] = useState([]);
const [companyList, setDataCompany] = useState([]);
const [search, setSearch] = useState("");
const [currentPage, setCurrentPage] = useState(1);
const [totalPage, setTotalPage] = useState(0);
@ -193,6 +195,9 @@ const CreatedProyek = ({ params, ...props }) => {
handleGetPhaseProject();
handleGetDivisions();
handleGetDataPm();
if(role_name === 'Super Admin') {
getDataProyekCompany();
}
}
}, [openDialogProyek]);
@ -224,33 +229,36 @@ const CreatedProyek = ({ params, ...props }) => {
const handleGetTipeProject = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
"columns": [
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
],
"columns": [],
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
if(role_name !== 'Super Admin') {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }
)
}
const result = await axios
.post(PROJECT_TYPE_SEARCH, payload, HEADER)
.then((res) => res)
.catch((err) => err.response);
if (result && result.data && result.data.code === 200) {
setDataTypeProyek(result.data.data);
} else {
}
};
const handleGetPhaseProject = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
"columns": [
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
],
"columns": [],
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
if(role_name !== 'Super Admin') {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }
)
}
const result = await axios
.post(PROJECT_PHASE_SEARCH, payload, HEADER)
.then((res) => res)
@ -263,13 +271,15 @@ const CreatedProyek = ({ params, ...props }) => {
const handleGetDivisions = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
"columns": [
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
],
"columns": [],
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
if(role_name !== 'Super Admin') {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }
)
}
const result = await axios
.post(DIVISI_SEARCH, payload, HEADER)
.then((res) => res)
@ -284,13 +294,15 @@ const CreatedProyek = ({ params, ...props }) => {
const handleGetDataPm = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
"columns": [
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
],
"columns": [],
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
if(role_name !== 'Super Admin') {
payload.columns.push(
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }
)
}
const result = await axios
.post(USER_SEARCH, payload, HEADER)
.then((res) => res)
@ -302,6 +314,22 @@ const CreatedProyek = ({ params, ...props }) => {
}
};
const getDataProyekCompany = 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) {
let dataRes = result.data.data || [];
setDataCompany(dataRes);
setLoading(false);
} else {
setLoading(false);
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
}
};
const handleDashboard = async (id) => {
const URL = `${BASE_OSPRO}/api/project/detail/${id}`;
const result = await axios
@ -1846,6 +1874,8 @@ const CreatedProyek = ({ params, ...props }) => {
dataPM={dataPm}
projectImage={image}
company_id={company_id}
role_name={role_name}
companyList={companyList}
/>
),
[

57
src/views/SimproV2/ResourceWorker/DialogForm.js

@ -7,21 +7,10 @@ import { DatePicker, Tooltip, Select, Input as InputAntd } from 'antd';
import moment from 'moment';
import 'antd/dist/antd.css';
import { formatRupiah, formatNumber } from '../../../const/CustomFunc'
import { ROLE_SEARCH } from '../../../const/ApiConst'
import { useTranslation } from 'react-i18next';
const { Option } = Select
const token = window.localStorage.getItem('token');
const company_id = localStorage.getItem("company_id")
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, roleList, divisiList }) => {
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, roleList, divisiList, role_name, companyList, company_id }) => {
const [openDialogMap, setOpenDialogMap] = useState(false)
const [id, setId] = useState(0)
@ -39,6 +28,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const [ktpNumber, setKtpNumber] = useState('')
const [biayaPerJam, setBiayaPerJam] = useState('')
const [roleId, setRoleId] = useState('')
const [scompany_id, setCompanyId] = useState(null);
const [address, setAddress] = useState('')
const [divisionId, setDivisionId] = useState('')
const [statusResource, setStatusResource] = useState('active')
@ -55,6 +45,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setPhoneNo(dataEdit.phone_number)
setEmail(dataEdit.email)
setGender(dataEdit.gender)
setCompanyId(dataEdit.company_id)
setBirthDate(dataEdit.birth_date ? moment(dataEdit.birth_date) : "")
setBirthPlace(dataEdit.birth_place)
setBloodType(dataEdit.blood_type)
@ -82,6 +73,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setRoleId('')
setDivisionId('')
setAddress('')
setCompanyId(null)
setStatusResource('active')
setStatusRestriction(false)
}
@ -117,7 +109,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
address,
status_resource: statusResource,
status_boundary: statusRestriction,
company_id: company_id
company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id)
}
if (birthDate && birthDate != "") {
@ -165,7 +157,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
address,
status_resource: statusResource,
status_boundary: statusRestriction,
company_id: company_id
company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id)
}
if (birthDate && birthDate != "") {
@ -176,6 +168,10 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
}
}
const onChangeCompanyProject = (val) => {
setCompanyId(val);
};
const handleCancel = () => {
closeDialog('cancel', 'none')
}
@ -307,13 +303,31 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
</Row>
<Row>
{
role_name === 'Super Admin' && (
<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>
<FormGroup>
<Label className="capitalize">Assign Company Project<span style={{ color: "red" }}>*</span></Label>
<Select
showSearch
filterOption={(inputValue, option) =>
option.children.toLowerCase().includes(inputValue.toLowerCase())
}
value={scompany_id}
defaultValue={scompany_id}
onChange={onChangeCompanyProject}
style={{ width: "100%" }}
>
{companyList.map((res) => (
<Option key={res.id} value={res.id}>
{res.company_name}
</Option>
))}
</Select>
</FormGroup>
</Col>
)
}
<Col md={6}>
<Label className="capitalize">{t('restrictions')}</Label>
<Select style={{ width: "100%" }} defaultValue={statusRestriction} onChange={(e) => setStatusRestriction(e)}>
@ -321,6 +335,13 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
<Option value={false}>Tidak</Option>
</Select>
</Col>
<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}>
<FormGroup>
<Label className="capitalize">{t('address')}</Label>

26
src/views/SimproV2/ResourceWorker/index.js

@ -10,7 +10,7 @@ import { DownloadOutlined } from '@ant-design/icons';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Table, Button, Tooltip, Spin } from 'antd';
import {
PROYEK_SEARCH, USER_ADD, USER_SEARCH, USER_EDIT, USER_DELETE, ROLE_SEARCH, DIVISI_SEARCH, USER_SHIFT_ADD, USER_SYNC
USER_ADD, USER_SEARCH, USER_EDIT, USER_DELETE, ROLE_SEARCH, DIVISI_SEARCH, USER_SHIFT_ADD, COMPANY_MANAGEMENT_LIST
} from '../../../const/ApiConst';
import { useTranslation } from 'react-i18next';
@ -43,6 +43,7 @@ const ResourceWorker = ({ params, ...props }) => {
const [dataExport, setDataExport] = useState([])
const [dataTable, setDatatable] = useState([])
const [divisiList, setDivisiList] = useState([])
const [companyList, setDataCompany] = useState([]);
const [idDelete, setIdDelete] = useState(0)
const [openDialog, setOpenDialog] = useState(false)
const [openDialogShift, setOpenDialogShift] = useState(false)
@ -59,6 +60,9 @@ const ResourceWorker = ({ params, ...props }) => {
useEffect(() => {
getRoleList()
getDivisiList()
if(role_name === 'Super Admin') {
getDataProyekCompany();
}
}, [])
useEffect(() => {
@ -96,7 +100,6 @@ const ResourceWorker = ({ params, ...props }) => {
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
)
}
const result = await axios
.post(ROLE_SEARCH, formData, HEADER)
.then(res => res)
@ -251,6 +254,22 @@ const ResourceWorker = ({ params, ...props }) => {
}
}
const getDataProyekCompany = 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) {
let dataRes = result.data.data || [];
setDataCompany(dataRes);
setLoading(false);
} else {
setLoading(false);
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
}
};
const handleSearch = e => {
const value = e.target.value
setSearch(value);
@ -599,6 +618,9 @@ const ResourceWorker = ({ params, ...props }) => {
clickOpenModal={clickOpenModal}
roleList={roleList}
divisiList={divisiList}
role_name={role_name}
companyList={companyList}
company_id={company_id}
/>
<DialogFormUserShift
openDialog={openDialogShift}

Loading…
Cancel
Save