Browse Source

add form company_id

pull/1/head
wahyun 10 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 React, { Component } from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter, Row, Col } from 'reactstrap'; import { Modal, ModalHeader, ModalBody, ModalFooter, Row, Col, Button, Form, FormGroup, Label, Input } from 'reactstrap';
import { Button, Form, FormGroup, Label, Input } from 'reactstrap';
import 'antd/dist/antd.css'; import 'antd/dist/antd.css';
import { withTranslation } from 'react-i18next'; import { withTranslation } from 'react-i18next';
import axios from 'axios'; import axios from 'axios';
import { NotificationManager } from 'react-notifications';
import { Select } from 'antd'; 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 { 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 { class DialogForm extends Component {
constructor(props) { constructor(props) {
@ -27,16 +18,26 @@ class DialogForm extends Component {
description: "", description: "",
openDialog: false, openDialog: false,
isParentClick: false, isParentClick: false,
companyList: [],
scompany_id:null,
menu: [], menu: [],
selectedMenu: null, selectedMenu: null,
all_project: false, 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() { async componentDidMount() {
this.props.showDialog(this.showDialog); this.getDataProyekCompany();
this.getAllMenu(); this.getAllMenu();
this.props.showDialog(this.showDialog);
} }
async componentDidUpdate() { async componentDidUpdate() {
if (this.state.isParentClick === true) { if (this.state.isParentClick === true) {
@ -47,7 +48,7 @@ class DialogForm extends Component {
name: dataEdit.name, name: dataEdit.name,
description: dataEdit.description, description: dataEdit.description,
selectedMenu: dataEdit.default_page, selectedMenu: dataEdit.default_page,
company_id scompany_id : dataEdit.company_id
}) })
} else { } else {
this.setState({ this.setState({
@ -55,13 +56,27 @@ class DialogForm extends Component {
name: "", name: "",
description: "", description: "",
selectedMenu: null, selectedMenu: null,
company_id scompany_id : null
}) })
} }
this.setState({ isParentClick: false }); 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 () => { getAllMenu = async () => {
const payload = { const payload = {
"paging": { "start": 0, "length": -1 }, "paging": { "start": 0, "length": -1 },
@ -72,7 +87,7 @@ class DialogForm extends Component {
"orders": { "columns": ["id"], "ascending": false } "orders": { "columns": ["id"], "ascending": false }
} }
const result = await axios const result = await axios
.post(MENU_SEARCH, payload, config) .post(MENU_SEARCH, payload, this.state.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
@ -85,6 +100,10 @@ class DialogForm extends Component {
} }
validation = () => { 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 === "") { if (!this.state.name || this.state.name === "") {
alert("Role Name cannot be empty!"); alert("Role Name cannot be empty!");
return true; return true;
@ -101,7 +120,9 @@ class DialogForm extends Component {
name, name,
description, description,
selectedMenu, selectedMenu,
role_name,
company_id, company_id,
scompany_id,
all_project all_project
} = this.state } = this.state
@ -114,7 +135,7 @@ class DialogForm extends Component {
name, name,
description, description,
selectedMenu, selectedMenu,
company_id, company_id : role_name !== 'Super Admin' ? company_id : scompany_id,
all_project all_project
} }
@ -125,21 +146,22 @@ class DialogForm extends Component {
name, name,
description, description,
selectedMenu, selectedMenu,
company_id, company_id : role_name !== 'Super Admin' ? company_id : scompany_id,
all_project all_project
} }
this.props.closeDialog('edit', data); this.props.closeDialog('edit', data);
} }
this.setState({ id: 0 }); this.setState({ id: 0 });
} }
} }
handleCancel = () => { handleCancel = () => {
this.props.closeDialog('cancel', 'none') this.props.closeDialog('cancel', 'none')
} }
onChangeCompanyProject = (val) => {
this.setState({scompany_id : val});
};
renderForm = () => { renderForm = () => {
const { t } = this.props; const { t } = this.props;
return ( return (
@ -150,6 +172,31 @@ class DialogForm extends Component {
</Col> </Col>
</Row> </Row>
<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}> <Col md={12}>
<FormGroup> <FormGroup>
<Label>{this.props.t('nameRole')}<span style={{ color: "red" }}>*</span></Label> <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'; import { withTranslation, WithTranslation } from 'react-i18next';
const BASE_URL = "http://siopas.co.id/custom-php/api/geohr/"; 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 { class DialogMenuRoles extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
@ -27,28 +16,24 @@ class DialogMenuRoles extends Component {
description: "", description: "",
openDialog: false, openDialog: false,
isParentClick: false, isParentClick: false,
menu: [],
stateMenu: [], stateMenu: [],
menu:[],
allChecked: true, 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 });
} }
} }
async componentDidMount() {
showDialog = () => { this.getAllMenu()
this.setState({ isParentClick: true }); this.props.showDialog(this.showDialog);
} }
getAllMenu = async () => { getAllMenu = async () => {
@ -60,22 +45,26 @@ class DialogMenuRoles extends Component {
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "orders": { "columns": ["id"], "ascending": false }
} }
const result = await axios const result = await axios
.post(MENU_SEARCH, payload, config) .post(MENU_SEARCH, payload, this.state.config)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
this.setState({ menu: result.data.data }, () => { this.setState({ menu: result.data.data });
this.setStateMenu(false); }
});
} else {
} }
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 => { setStateMenu = edit => {

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

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

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

@ -1,9 +1,12 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; import { Modal, ModalHeader, ModalBody, ModalFooter, Button, Form, FormGroup, Label, Input } from 'reactstrap';
import { Button, Form, FormGroup, Label, Input } from 'reactstrap';
import 'antd/dist/antd.css'; import 'antd/dist/antd.css';
import axios from 'axios';
import { COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst.js';
import { withTranslation } from 'react-i18next'; 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 { class DialogForm extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
@ -12,13 +15,24 @@ class DialogForm extends Component {
name: "", name: "",
description: "", description: "",
openDialog: false, openDialog: false,
companyList: [],
scompany_id:null,
isParentClick: false, 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() { async componentDidMount() {
this.props.showDialog(this.showDialog); this.props.showDialog(this.showDialog);
this.getDataProyekCompany();
} }
async componentDidUpdate() { async componentDidUpdate() {
@ -29,13 +43,14 @@ class DialogForm extends Component {
id: dataEdit.id, id: dataEdit.id,
name: dataEdit.name, name: dataEdit.name,
description: dataEdit.description, description: dataEdit.description,
company_id scompany_id : dataEdit.company_id
}) })
} else { } else {
this.setState({ this.setState({
id: 0, id: 0,
name: "", name: "",
description: "" description: "",
scompany_id:null
}) })
} }
this.setState({ isParentClick: false }); this.setState({ isParentClick: false });
@ -47,21 +62,46 @@ class DialogForm extends Component {
this.setState({ isParentClick: true }); 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 = () => { handleSave = () => {
const { const {
id, id,
name, name,
description description,
role_name,
company_id,
scompany_id
} = this.state } = this.state
let data = ''; let data = '';
const err = this.validation();
if(!err) {
if (this.props.typeDialog === "Save") { if (this.props.typeDialog === "Save") {
data = { data = {
id, id,
name, name,
description, description,
company_id company_id : role_name !== 'Super Admin' ? company_id : scompany_id,
} }
this.props.closeDialog('save', data); this.props.closeDialog('save', data);
} else { } else {
@ -69,23 +109,49 @@ class DialogForm extends Component {
id, id,
name, name,
description, description,
company_id company_id : role_name !== 'Super Admin' ? company_id : scompany_id,
} }
this.props.closeDialog('edit', data); this.props.closeDialog('edit', data);
} }
}
this.setState({ id: 0 }); this.setState({ id: 0 });
} }
handleCancel = () => { handleCancel = () => {
this.props.closeDialog('cancel', 'none') this.props.closeDialog('cancel', 'none')
} }
onChangeCompanyProject = (val) => {
this.setState({scompany_id : val});
};
renderForm = () => { renderForm = () => {
const { t } = this.props; const { t } = this.props;
return ( return (
<Form> <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> <FormGroup>
<Label>{this.props.t('name')}</Label> <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')} /> <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 { Button } from 'reactstrap';
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications'; 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 { Pagination, Tooltip, Table } from 'antd';
import { withTranslation } from 'react-i18next'; import { withTranslation } from 'react-i18next';
const LENGTH_DATA = 10 const LENGTH_DATA = 10
@ -202,7 +202,7 @@ class index extends Component {
const formData = { const formData = {
name: data.name, name: data.name,
description: data.description, 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) const result = await axios.post(PROJECT_ROLE_ADD, formData, this.state.config)
@ -223,7 +223,7 @@ class index extends Component {
const formData = { const formData = {
name: data.name, name: data.name,
description: data.description, description: data.description,
company_id : this.state.company_id company_id : data.company_id
} }
const url = PROJECT_ROLE_EDIT(data.id) const url = PROJECT_ROLE_EDIT(data.id)
const result = await axios.put(url, formData, this.state.config) const result = await axios.put(url, formData, this.state.config)
@ -390,6 +390,9 @@ class index extends Component {
dataEdit={this.state.dataEdit} dataEdit={this.state.dataEdit}
showDialog={showDialog => this.showChildDialog = showDialog} showDialog={showDialog => this.showChildDialog = showDialog}
dataHs={this.state.dataIdHo} dataHs={this.state.dataIdHo}
company_id={this.state.company_id}
role_name={this.state.role_name}
token={this.state.token}
/> />
<Card> <Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}> <CardHeader style={{ display: "flex", justifyContent: "space-between" }}>

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

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

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

@ -36,6 +36,7 @@ import {
PROJECT_TYPE_SEARCH, PROJECT_TYPE_SEARCH,
PROYEK_ADD, PROYEK_ADD,
PROYEK_SEARCH, PROYEK_SEARCH,
COMPANY_MANAGEMENT_LIST,
PROYEK_EDIT, PROYEK_EDIT,
ASSIGN_HR_PROJECT_SEARCH, ASSIGN_HR_PROJECT_SEARCH,
PROJECT_CHECKLIST_SEARCH, PROJECT_CHECKLIST_SEARCH,
@ -116,6 +117,7 @@ const CreatedProyek = ({ params, ...props }) => {
const [idTask, setidTask] = useState(0); const [idTask, setidTask] = useState(0);
const [projectId, setProjectId] = useState(0); const [projectId, setProjectId] = useState(0);
const [dataTable, setDatatable] = useState([]); const [dataTable, setDatatable] = useState([]);
const [companyList, setDataCompany] = useState([]);
const [search, setSearch] = useState(""); const [search, setSearch] = useState("");
const [currentPage, setCurrentPage] = useState(1); const [currentPage, setCurrentPage] = useState(1);
const [totalPage, setTotalPage] = useState(0); const [totalPage, setTotalPage] = useState(0);
@ -193,6 +195,9 @@ const CreatedProyek = ({ params, ...props }) => {
handleGetPhaseProject(); handleGetPhaseProject();
handleGetDivisions(); handleGetDivisions();
handleGetDataPm(); handleGetDataPm();
if(role_name === 'Super Admin') {
getDataProyekCompany();
}
} }
}, [openDialogProyek]); }, [openDialogProyek]);
@ -224,33 +229,36 @@ const CreatedProyek = ({ params, ...props }) => {
const handleGetTipeProject = async () => { const handleGetTipeProject = async () => {
const payload = { const payload = {
"paging": { "start": 0, "length": -1 }, "paging": { "start": 0, "length": -1 },
"columns": [ "columns": [],
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
],
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "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 const result = await axios
.post(PROJECT_TYPE_SEARCH, payload, HEADER) .post(PROJECT_TYPE_SEARCH, payload, HEADER)
.then((res) => res) .then((res) => res)
.catch((err) => err.response); .catch((err) => err.response);
if (result && result.data && result.data.code === 200) { if (result && result.data && result.data.code === 200) {
setDataTypeProyek(result.data.data); setDataTypeProyek(result.data.data);
} else {
} }
}; };
const handleGetPhaseProject = async () => { const handleGetPhaseProject = async () => {
const payload = { const payload = {
"paging": { "start": 0, "length": -1 }, "paging": { "start": 0, "length": -1 },
"columns": [ "columns": [],
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
],
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "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 const result = await axios
.post(PROJECT_PHASE_SEARCH, payload, HEADER) .post(PROJECT_PHASE_SEARCH, payload, HEADER)
.then((res) => res) .then((res) => res)
@ -263,13 +271,15 @@ const CreatedProyek = ({ params, ...props }) => {
const handleGetDivisions = async () => { const handleGetDivisions = async () => {
const payload = { const payload = {
"paging": { "start": 0, "length": -1 }, "paging": { "start": 0, "length": -1 },
"columns": [ "columns": [],
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
],
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "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 const result = await axios
.post(DIVISI_SEARCH, payload, HEADER) .post(DIVISI_SEARCH, payload, HEADER)
.then((res) => res) .then((res) => res)
@ -284,13 +294,15 @@ const CreatedProyek = ({ params, ...props }) => {
const handleGetDataPm = async () => { const handleGetDataPm = async () => {
const payload = { const payload = {
"paging": { "start": 0, "length": -1 }, "paging": { "start": 0, "length": -1 },
"columns": [ "columns": [],
{ "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" },
],
"joins": [], "joins": [],
"orders": { "columns": ["id"], "ascending": false } "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 const result = await axios
.post(USER_SEARCH, payload, HEADER) .post(USER_SEARCH, payload, HEADER)
.then((res) => res) .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 handleDashboard = async (id) => {
const URL = `${BASE_OSPRO}/api/project/detail/${id}`; const URL = `${BASE_OSPRO}/api/project/detail/${id}`;
const result = await axios const result = await axios
@ -1846,6 +1874,8 @@ const CreatedProyek = ({ params, ...props }) => {
dataPM={dataPm} dataPM={dataPm}
projectImage={image} projectImage={image}
company_id={company_id} 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 moment from 'moment';
import 'antd/dist/antd.css'; import 'antd/dist/antd.css';
import { formatRupiah, formatNumber } from '../../../const/CustomFunc' import { formatRupiah, formatNumber } from '../../../const/CustomFunc'
import { ROLE_SEARCH } from '../../../const/ApiConst'
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const { Option } = Select const { Option } = Select
const token = window.localStorage.getItem('token'); const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, roleList, divisiList, role_name, companyList, company_id }) => {
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 [openDialogMap, setOpenDialogMap] = useState(false) const [openDialogMap, setOpenDialogMap] = useState(false)
const [id, setId] = useState(0) const [id, setId] = useState(0)
@ -39,6 +28,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
const [ktpNumber, setKtpNumber] = useState('') const [ktpNumber, setKtpNumber] = useState('')
const [biayaPerJam, setBiayaPerJam] = useState('') const [biayaPerJam, setBiayaPerJam] = useState('')
const [roleId, setRoleId] = useState('') const [roleId, setRoleId] = useState('')
const [scompany_id, setCompanyId] = useState(null);
const [address, setAddress] = useState('') const [address, setAddress] = useState('')
const [divisionId, setDivisionId] = useState('') const [divisionId, setDivisionId] = useState('')
const [statusResource, setStatusResource] = useState('active') const [statusResource, setStatusResource] = useState('active')
@ -55,6 +45,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setPhoneNo(dataEdit.phone_number) setPhoneNo(dataEdit.phone_number)
setEmail(dataEdit.email) setEmail(dataEdit.email)
setGender(dataEdit.gender) setGender(dataEdit.gender)
setCompanyId(dataEdit.company_id)
setBirthDate(dataEdit.birth_date ? moment(dataEdit.birth_date) : "") setBirthDate(dataEdit.birth_date ? moment(dataEdit.birth_date) : "")
setBirthPlace(dataEdit.birth_place) setBirthPlace(dataEdit.birth_place)
setBloodType(dataEdit.blood_type) setBloodType(dataEdit.blood_type)
@ -82,6 +73,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
setRoleId('') setRoleId('')
setDivisionId('') setDivisionId('')
setAddress('') setAddress('')
setCompanyId(null)
setStatusResource('active') setStatusResource('active')
setStatusRestriction(false) setStatusRestriction(false)
} }
@ -117,7 +109,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
address, address,
status_resource: statusResource, status_resource: statusResource,
status_boundary: statusRestriction, status_boundary: statusRestriction,
company_id: company_id company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id)
} }
if (birthDate && birthDate != "") { if (birthDate && birthDate != "") {
@ -165,7 +157,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
address, address,
status_resource: statusResource, status_resource: statusResource,
status_boundary: statusRestriction, status_boundary: statusRestriction,
company_id: company_id company_id: role_name != "Super Admin" ? parseInt(company_id) : parseInt(scompany_id)
} }
if (birthDate && birthDate != "") { if (birthDate && birthDate != "") {
@ -176,6 +168,10 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
} }
} }
const onChangeCompanyProject = (val) => {
setCompanyId(val);
};
const handleCancel = () => { const handleCancel = () => {
closeDialog('cancel', 'none') closeDialog('cancel', 'none')
} }
@ -307,13 +303,31 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
</Row> </Row>
<Row> <Row>
{
role_name === 'Super Admin' && (
<Col md={6}> <Col md={6}>
<Label className="capitalize">Status</Label> <FormGroup>
<Select style={{ width: "100%" }} defaultValue={statusResource} onChange={(e) => setStatusResource(e)}> <Label className="capitalize">Assign Company Project<span style={{ color: "red" }}>*</span></Label>
<Option value={'active'}>Active</Option> <Select
<Option value={'inactive'}>Inactive</Option> 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> </Select>
</FormGroup>
</Col> </Col>
)
}
<Col md={6}> <Col md={6}>
<Label className="capitalize">{t('restrictions')}</Label> <Label className="capitalize">{t('restrictions')}</Label>
<Select style={{ width: "100%" }} defaultValue={statusRestriction} onChange={(e) => setStatusRestriction(e)}> <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> <Option value={false}>Tidak</Option>
</Select> </Select>
</Col> </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}> <Col md={6}>
<FormGroup> <FormGroup>
<Label className="capitalize">{t('address')}</Label> <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 { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Table, Button, Tooltip, Spin } from 'antd'; import { Pagination, Table, Button, Tooltip, Spin } from 'antd';
import { 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'; } from '../../../const/ApiConst';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
@ -43,6 +43,7 @@ const ResourceWorker = ({ params, ...props }) => {
const [dataExport, setDataExport] = useState([]) const [dataExport, setDataExport] = useState([])
const [dataTable, setDatatable] = useState([]) const [dataTable, setDatatable] = useState([])
const [divisiList, setDivisiList] = useState([]) const [divisiList, setDivisiList] = useState([])
const [companyList, setDataCompany] = useState([]);
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)
@ -59,6 +60,9 @@ const ResourceWorker = ({ params, ...props }) => {
useEffect(() => { useEffect(() => {
getRoleList() getRoleList()
getDivisiList() getDivisiList()
if(role_name === 'Super Admin') {
getDataProyekCompany();
}
}, []) }, [])
useEffect(() => { useEffect(() => {
@ -96,7 +100,6 @@ const ResourceWorker = ({ params, ...props }) => {
{ "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" },
) )
} }
const result = await axios const result = await axios
.post(ROLE_SEARCH, formData, HEADER) .post(ROLE_SEARCH, formData, HEADER)
.then(res => res) .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 handleSearch = e => {
const value = e.target.value const value = e.target.value
setSearch(value); setSearch(value);
@ -599,6 +618,9 @@ const ResourceWorker = ({ params, ...props }) => {
clickOpenModal={clickOpenModal} clickOpenModal={clickOpenModal}
roleList={roleList} roleList={roleList}
divisiList={divisiList} divisiList={divisiList}
role_name={role_name}
companyList={companyList}
company_id={company_id}
/> />
<DialogFormUserShift <DialogFormUserShift
openDialog={openDialogShift} openDialog={openDialogShift}

Loading…
Cancel
Save