ibnu
5 months ago
61 changed files with 2065 additions and 3360 deletions
File diff suppressed because it is too large
Load Diff
@ -1,434 +1,387 @@ |
|||||||
import 'antd/dist/antd.css'; |
import 'antd/dist/antd.css'; |
||||||
import React, { Component } from 'react'; |
import React, { Component } from 'react'; |
||||||
import { Button, Form, FormFeedback, FormGroup, Input, Label, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap'; |
import { Button, Form, FormFeedback, FormGroup, Input, Label, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap'; |
||||||
import Select from 'react-select'; |
import Select from 'react-select'; |
||||||
import axios from 'axios'; |
import axios from 'axios'; |
||||||
import { BASE_URL_GEOHR_API2, ROLE_SEARCH, USER_WASPANG, USER_LIST, USER_SEARCH } from '../../../const/ApiConst'; |
import { BASE_URL_GEOHR_API2, ROLE_SEARCH, USER_WASPANG, USER_LIST, USER_SEARCH } from '../../../const/ApiConst'; |
||||||
import { Transfer } from 'antd'; |
import { Transfer } from 'antd'; |
||||||
import { withTranslation } from 'react-i18next'; |
import { withTranslation } from 'react-i18next'; |
||||||
|
|
||||||
|
|
||||||
const token = window.localStorage.getItem('token'); |
const token = window.localStorage.getItem('token'); |
||||||
|
|
||||||
const config = { |
const config = { |
||||||
headers: |
headers: |
||||||
{ |
{ |
||||||
Authorization: `Bearer ${token}`, |
Authorization: `Bearer ${token}`, |
||||||
"Content-type": `application/json` |
"Content-type": `application/json` |
||||||
} |
} |
||||||
}; |
}; |
||||||
|
|
||||||
|
|
||||||
const ERROR_TITLE = "judul is required!" |
const ERROR_TITLE = "judul is required!" |
||||||
const ERROR_MESSAGE = "message is required!" |
const ERROR_MESSAGE = "message is required!" |
||||||
const BASE_URL = "https://oslog.id/geohr-api/"; |
const BASE_URL = "https://oslog.id/geohr-api/"; |
||||||
const roleName = window.localStorage.getItem('role_name'); |
const roleName = window.localStorage.getItem('role_name'); |
||||||
let countError = 0; |
let countError = 0; |
||||||
class DialogForm extends Component { |
class DialogForm extends Component { |
||||||
constructor(props) { |
constructor(props) { |
||||||
super(props) |
super(props) |
||||||
this.state = { |
this.state = { |
||||||
id: 0, |
id: 0, |
||||||
title: "", |
title: "", |
||||||
description: "", |
description: "", |
||||||
message: "", |
message: "", |
||||||
openDialog: false, |
openDialog: false, |
||||||
isParentClick: false, |
isParentClick: false, |
||||||
errorTitle: "", |
errorTitle: "", |
||||||
errorMessage: "", |
errorMessage: "", |
||||||
errorDivision: "", |
errorDivision: "", |
||||||
errorEmployee: "", |
errorEmployee: "", |
||||||
penerima: "all", |
penerima: "all", |
||||||
displayKaryawan: "none", |
displayKaryawan: "none", |
||||||
displayDivisi: "none", |
displayDivisi: "none", |
||||||
listOrganizationSelect: [], |
listOrganizationSelect: [], |
||||||
currentSelectDiv: null, |
currentSelectDiv: null, |
||||||
dataEmployee: [], |
dataEmployee: [], |
||||||
dataSourceEmployee: [], |
dataSourceEmployee: [], |
||||||
idOrganization: 0, |
idOrganization: 0, |
||||||
targetKeys: [], |
targetKeys: [], |
||||||
selectedKeys: [], |
selectedKeys: [], |
||||||
allEmployeeId: [], |
allEmployeeId: [], |
||||||
idEmployeeDivision: [], |
idEmployeeDivision: [], |
||||||
idOrganization: [], |
idOrganization: [], |
||||||
disableTransfer: true, |
disableTransfer: true, |
||||||
listCompany: [], |
role_name: '' |
||||||
company_id: this.props.company_id, |
} |
||||||
role_name: '' |
} |
||||||
} |
|
||||||
} |
async componentDidMount() { |
||||||
|
this.props.showDialog(this.showDialog); |
||||||
async componentDidMount() { |
} |
||||||
if (this.props.company_id !== null) { |
|
||||||
this.getDataRole(); |
async componentDidUpdate() { |
||||||
this.getDataUsers(); |
if (this.state.isParentClick === true) { |
||||||
} |
if (this.props.typeDialog === "Edit") { |
||||||
this.props.showDialog(this.showDialog); |
const { dataEdit } = this.props |
||||||
} |
this.setState({ |
||||||
|
id: dataEdit.id, |
||||||
async componentDidUpdate() { |
title: dataEdit.title_notif, |
||||||
if (this.state.isParentClick === true) { |
description: dataEdit.description, |
||||||
if (this.props.typeDialog === "Edit") { |
message: dataEdit.message_notif |
||||||
const { dataEdit } = this.props |
}) |
||||||
this.setState({ |
} else { |
||||||
id: dataEdit.id, |
this.setState({ |
||||||
title: dataEdit.title_notif, |
id: 0, |
||||||
description: dataEdit.description, |
title: "", |
||||||
message: dataEdit.message_notif, |
description: "", |
||||||
company_id: dataEdit.company_id |
message: "" |
||||||
}) |
}) |
||||||
} else { |
} |
||||||
this.setState({ |
this.setState({ isParentClick: false }); |
||||||
id: 0, |
} |
||||||
title: "", |
} |
||||||
description: "", |
|
||||||
message: "", |
|
||||||
company_id: 0 |
showDialog = () => { |
||||||
}) |
this.setState({ isParentClick: true }); |
||||||
} |
} |
||||||
this.setState({ isParentClick: false }); |
|
||||||
} |
|
||||||
} |
|
||||||
|
validate = () => { |
||||||
|
let isError = false |
||||||
showDialog = () => { |
const { title, message, penerima } = this.state |
||||||
this.setState({ isParentClick: true }); |
if (title === "") { |
||||||
} |
isError = true |
||||||
|
this.setState({ errorTitle: ERROR_TITLE }) |
||||||
|
} else if (title.length < 3 || title.length > 100) { |
||||||
|
isError = true |
||||||
validate = () => { |
this.setState({ errorTitle: "Title minimum 3-100 karakter!" }) |
||||||
let isError = false |
} |
||||||
const { title, message, penerima } = this.state |
|
||||||
if (title === "") { |
if (message === "") { |
||||||
isError = true |
isError = true |
||||||
this.setState({ errorTitle: ERROR_TITLE }) |
this.setState({ errorMessage: ERROR_MESSAGE }) |
||||||
} else if (title.length < 3 || title.length > 100) { |
} else if (message.length < 3 || message.length > 200) { |
||||||
isError = true |
isError = true |
||||||
this.setState({ errorTitle: "Title minimum 3-100 karakter!" }) |
this.setState({ errorMessage: "message minimum 3-200 karakter!" }) |
||||||
} |
} |
||||||
|
|
||||||
if (message === "") { |
if (penerima === "division") { |
||||||
isError = true |
if (this.state.idOrganization === 0) { |
||||||
this.setState({ errorMessage: ERROR_MESSAGE }) |
this.setState({ errorDivision: "Silahkan pilih divisi penerima!" }) |
||||||
} else if (message.length < 3 || message.length > 200) { |
} |
||||||
isError = true |
} else if (penerima === "karyawan") { |
||||||
this.setState({ errorMessage: "message minimum 3-200 karakter!" }) |
if (this.state.selectedKeys.length === 0) { |
||||||
} |
this.setState({ errorEmployee: "Silahkan pilih karyawan penerima!" }) |
||||||
|
} |
||||||
if (penerima === "division") { |
} |
||||||
if (this.state.idOrganization === 0) { |
return isError |
||||||
this.setState({ errorDivision: "Silahkan pilih divisi penerima!" }) |
} |
||||||
} |
handleSave = (param) => { |
||||||
} else if (penerima === "karyawan") { |
let err = this.validate() |
||||||
if (this.state.selectedKeys.length === 0) { |
if (!err) { |
||||||
this.setState({ errorEmployee: "Silahkan pilih karyawan penerima!" }) |
const { |
||||||
} |
id, |
||||||
} |
title, |
||||||
return isError |
description, |
||||||
} |
message, |
||||||
handleSave = (param) => { |
penerima, |
||||||
let err = this.validate() |
|
||||||
if (!err) { |
} = this.state |
||||||
const { |
let idSend = []; |
||||||
id, |
let send_to_type = "all"; |
||||||
title, |
if (penerima === "all") { |
||||||
description, |
idSend = this.state.allEmployeeId; |
||||||
message, |
send_to_type = "all"; |
||||||
penerima, |
} else if (penerima === "organization") { |
||||||
|
idSend = this.state.idOrganization; |
||||||
} = this.state |
send_to_type = "roles"; |
||||||
let { |
} else if (penerima === "karyawan") { |
||||||
company_id |
idSend = this.state.targetKeys; |
||||||
} = this.state |
send_to_type = "users"; |
||||||
let idSend = []; |
} |
||||||
let send_to_type = "all"; |
|
||||||
if (penerima === "all") { |
if (Array.isArray(idSend)) { |
||||||
idSend = this.state.allEmployeeId; |
idSend = idSend.map(function (e) { |
||||||
send_to_type = "all"; |
return e.toString() |
||||||
} else if (penerima === "organization") { |
}); |
||||||
idSend = this.state.idOrganization; |
} else { |
||||||
send_to_type = "roles"; |
idSend = idSend; |
||||||
} else if (penerima === "karyawan") { |
} |
||||||
idSend = this.state.targetKeys; |
const data = { |
||||||
send_to_type = "users"; |
title, |
||||||
} |
description, |
||||||
|
message, |
||||||
if (Array.isArray(idSend)) { |
send_to_type, |
||||||
idSend = idSend.map(function (e) { |
id: idSend |
||||||
return e.toString() |
} |
||||||
}); |
if (param === 'registered' || param === 'send') { |
||||||
} else { |
this.props.handleSaveBroadcast(param, data) |
||||||
idSend = idSend; |
} |
||||||
} |
this.setState({ id: 0, idOrganization: 0, currentSelectDiv: null, targetKeys: [], penerima: "all", displayKaryawan: "none", displayDivisi: "none", disableTransfer: true }); |
||||||
if (this.props.role_name !== 'Super Admin') { |
} |
||||||
company_id = parseInt(this.props.company_id) |
} |
||||||
} |
|
||||||
const data = { |
handleCancel = () => { |
||||||
title, |
this.props.handleSaveBroadcast('cancel', 'none') |
||||||
description, |
} |
||||||
message, |
|
||||||
send_to_type, |
handleChangePenerima = type => { |
||||||
id: idSend, |
if (type === "organization") { |
||||||
company_id: company_id |
this.setState({ displayDivisi: "block", displayKaryawan: "none", disableTransfer: true, errorDivision: "", targetKeys: [] }) |
||||||
} |
} else if (type === "karyawan") { |
||||||
if (param === 'registered' || param === 'send') { |
this.setState({ displayKaryawan: "block", displayDivisi: "none", disableTransfer: false, errorEmployee: "", idEmployeeDivision: [], currentSelectDiv: null }) |
||||||
this.props.handleSaveBroadcast(param, data) |
} else { |
||||||
} |
this.setState({ displayKaryawan: "none", displayDivisi: "none", disableTransfer: true, errorDivision: "", errorEmployee: "", targetKeys: [], idEmployeeDivision: [], currentSelectDiv: null }) |
||||||
this.setState({ id: 0, idOrganization: 0, currentSelectDiv: null, targetKeys: [], penerima: "all", displayKaryawan: "none", displayDivisi: "none", disableTransfer: true }); |
} |
||||||
} |
this.setState({ penerima: type }); |
||||||
} |
} |
||||||
|
|
||||||
handleCancel = () => { |
handleSelectOrganization = (inputValue, actionMeta) => { |
||||||
this.props.handleSaveBroadcast('cancel', 'none') |
this.setState({ idOrganization: inputValue.value, currentSelectDiv: { value: inputValue.value, label: inputValue.label }, errorDivision: "" }, () => { |
||||||
} |
this.setEmployeeOrganization(); |
||||||
|
}); |
||||||
handleChangePenerima = type => { |
} |
||||||
if (type === "organization") { |
|
||||||
this.setState({ displayDivisi: "block", displayKaryawan: "none", disableTransfer: true, errorDivision: "", targetKeys: [] }) |
setEmployeeOrganization = () => { |
||||||
} else if (type === "karyawan") { |
let arrEd = this.state.dataEmployee.data; |
||||||
this.setState({ displayKaryawan: "block", displayDivisi: "none", disableTransfer: false, errorEmployee: "", idEmployeeDivision: [], currentSelectDiv: null }) |
let cek = arrEd.filter(this.filterId) |
||||||
} else { |
|
||||||
this.setState({ displayKaryawan: "none", displayDivisi: "none", disableTransfer: true, errorDivision: "", errorEmployee: "", targetKeys: [], idEmployeeDivision: [], currentSelectDiv: null }) |
this.setState({ idEmployeeDivision: cek }) |
||||||
} |
} |
||||||
this.setState({ penerima: type }); |
|
||||||
} |
filterId = (val) => { |
||||||
|
return val.organization_id == this.state.idOrganization |
||||||
handleSelectOrganization = (inputValue, actionMeta) => { |
} |
||||||
this.setState({ idOrganization: inputValue.value, currentSelectDiv: { value: inputValue.value, label: inputValue.label }, errorDivision: "" }, () => { |
|
||||||
this.setEmployeeOrganization(); |
getDataRole = async () => { |
||||||
}); |
const payload = { |
||||||
} |
"paging": { |
||||||
|
"start": 0, |
||||||
setEmployeeOrganization = () => { |
"length": -1 |
||||||
let arrEd = this.state.dataEmployee.data; |
}, |
||||||
let cek = arrEd.filter(this.filterId) |
"orders": { "columns": ["id"], "ascending": false } |
||||||
|
} |
||||||
this.setState({ idEmployeeDivision: cek }) |
|
||||||
} |
const result = await axios |
||||||
|
.post(ROLE_SEARCH, payload, config) |
||||||
filterId = (val) => { |
.then(res => res) |
||||||
return val.organization_id == this.state.idOrganization |
.catch((error) => error.response); |
||||||
} |
|
||||||
|
if (result && result.data && result.data.code === 200) { |
||||||
getDataRole = async () => { |
this.setState({ dataDivision: result.data.data }, () => { |
||||||
const payload = { |
this.setDataOrganization(); |
||||||
"paging": { |
}) |
||||||
"start": 0, |
} else { |
||||||
"length": -1 |
} |
||||||
}, |
} |
||||||
"columns": [ |
|
||||||
{ |
setDataOrganization = () => { |
||||||
"name": "company_id", |
const { dataDivision } = this.state |
||||||
"logic_operator": "=", |
const listOrganization = [] |
||||||
"value": this.state.company_id, |
dataDivision.map((val, index) => { |
||||||
"operator": "AND" |
listOrganization.push({ |
||||||
} |
value: val.id, |
||||||
], |
label: val.name |
||||||
"orders": { "columns": ["id"], "ascending": false } |
}) |
||||||
} |
}) |
||||||
|
this.setState({ listOrganizationSelect: listOrganization }) |
||||||
const result = await axios |
} |
||||||
.post(ROLE_SEARCH, payload, config) |
|
||||||
.then(res => res) |
getDataUsers = async () => { |
||||||
.catch((error) => error.response); |
const payload = { |
||||||
|
"paging": { |
||||||
if (result && result.data && result.data.code === 200) { |
"start": 0, |
||||||
this.setState({ dataDivision: result.data.data }, () => { |
"length": -1 |
||||||
this.setDataOrganization(); |
}, |
||||||
}) |
"columns": [ |
||||||
} else { |
{ |
||||||
} |
"name": "name", |
||||||
} |
"logic_operator": "like", |
||||||
|
"value": "", |
||||||
setDataOrganization = () => { |
"operator": "AND", |
||||||
const { dataDivision } = this.state |
"table_name": "m_users" |
||||||
const listOrganization = [] |
} |
||||||
dataDivision.map((val, index) => { |
], |
||||||
listOrganization.push({ |
"orders": { |
||||||
value: val.id, |
"columns": [ |
||||||
label: val.name |
"id" |
||||||
}) |
], |
||||||
}) |
"ascending": false |
||||||
this.setState({ listOrganizationSelect: listOrganization }) |
} |
||||||
} |
} |
||||||
|
//TODO should use search instead
|
||||||
getDataUsers = async () => { |
const result = await axios |
||||||
const payload = { |
.post(USER_SEARCH, payload, config) |
||||||
"paging": { |
.then(res => res) |
||||||
"start": 0, |
.catch((error) => error.response); |
||||||
"length": -1 |
|
||||||
}, |
if (result && result.data && result.status == 200) { |
||||||
"columns": [ |
this.setState({ dataEmployee: result.data }, () => { |
||||||
{ |
this.setDataEmployee(); |
||||||
"name": "name", |
}); |
||||||
"logic_operator": "like", |
} else { |
||||||
"value": "", |
} |
||||||
"operator": "AND", |
} |
||||||
"table_name": "m_users" |
|
||||||
}, |
setDataEmployee = () => { |
||||||
{ |
const listEmployee = []; |
||||||
"name": "company_id", |
const allIdEmployee = []; |
||||||
"logic_operator": "=", |
this.state.dataEmployee.data.map((val, index) => { |
||||||
"value": this.state.company_id, |
allIdEmployee.push(val.id); |
||||||
"operator": "AND" |
listEmployee.push({ |
||||||
} |
key: val.id, |
||||||
], |
id: val.id, |
||||||
"orders": { |
title: val.name |
||||||
"columns": [ |
}); |
||||||
"id" |
}) |
||||||
], |
|
||||||
"ascending": false |
this.setState({ dataSourceEmployee: listEmployee, allEmployeeId: allIdEmployee }) |
||||||
} |
} |
||||||
} |
|
||||||
//TODO should use search instead
|
handleChangeTransfer = (nextTargetKeys, direction, moveKeys) => { |
||||||
const result = await axios |
this.setState({ targetKeys: nextTargetKeys, errorEmployee: "" }); |
||||||
.post(USER_SEARCH, payload, config) |
|
||||||
.then(res => res) |
}; |
||||||
.catch((error) => error.response); |
|
||||||
|
handleSelectChangeTransfer = (sourceSelectedKeys, targetSelectedKeys) => { |
||||||
if (result && result.data && result.status == 200) { |
this.setState({ selectedKeys: [...sourceSelectedKeys, ...targetSelectedKeys], errorEmployee: "" }); |
||||||
this.setState({ dataEmployee: result.data }, () => { |
|
||||||
this.setDataEmployee(); |
}; |
||||||
}); |
|
||||||
} else { |
renderForm = () => { |
||||||
} |
const t = this.props |
||||||
} |
const { errorTitle, errorMessage } = this.state |
||||||
|
return ( |
||||||
setDataEmployee = () => { |
<Form> |
||||||
const listEmployee = []; |
<FormGroup> |
||||||
const allIdEmployee = []; |
<Label>{this.props.t('receiver')}</Label> |
||||||
this.state.dataEmployee.data.map((val, index) => { |
<Input type="select" value={this.state.penerima} onChange={(e) => this.handleChangePenerima(e.target.value)}> |
||||||
allIdEmployee.push(val.id); |
<option value="all">{this.props.t('all')}</option> |
||||||
listEmployee.push({ |
<option value="organization">{this.props.t('roles')}</option> |
||||||
key: val.id, |
<option value="karyawan">{this.props.t('user')}</option> |
||||||
id: val.id, |
</Input> |
||||||
title: val.name |
</FormGroup> |
||||||
}); |
<FormGroup style={{ display: this.state.displayDivisi }}> |
||||||
}) |
<Label>{this.props.t('roles')}</Label> |
||||||
|
<Select options={this.state.listOrganizationSelect} onChange={this.handleSelectOrganization} value={this.state.currentSelectDiv} /> |
||||||
this.setState({ dataSourceEmployee: listEmployee, allEmployeeId: allIdEmployee }) |
{this.state.errorDivision && <FormFeedback>{this.state.errorDivision}</FormFeedback>} |
||||||
} |
</FormGroup> |
||||||
|
<FormGroup style={{ display: this.state.displayKaryawan }}> |
||||||
handleChangeTransfer = (nextTargetKeys, direction, moveKeys) => { |
<Label>{this.props.t('user')}</Label> |
||||||
this.setState({ targetKeys: nextTargetKeys, errorEmployee: "" }); |
{!this.state.disableTransfer && |
||||||
|
<Transfer |
||||||
}; |
dataSource={this.state.dataSourceEmployee} |
||||||
|
showSearch |
||||||
handleSelectChangeTransfer = (sourceSelectedKeys, targetSelectedKeys) => { |
titles={['', 'Terpilih']} |
||||||
this.setState({ selectedKeys: [...sourceSelectedKeys, ...targetSelectedKeys], errorEmployee: "" }); |
targetKeys={this.state.targetKeys} |
||||||
|
selectedKeys={this.state.selectedKeys} |
||||||
}; |
onChange={this.handleChangeTransfer} |
||||||
|
onSelectChange={this.handleSelectChangeTransfer} |
||||||
handleSelectCompany = (selectedOption) => { |
render={item => item.title} |
||||||
const selectedCompanyId = selectedOption.value; |
disabled={this.state.disableTransfer} |
||||||
this.setState({ company_id: selectedCompanyId }, () => { |
/> |
||||||
this.getDataRole(); |
} |
||||||
this.getDataUsers(); |
{this.state.errorEmployee && <FormFeedback>{this.state.errorEmployee}</FormFeedback>} |
||||||
}); |
</FormGroup> |
||||||
} |
<FormGroup> |
||||||
|
<Label>{this.props.t('title')}</Label> |
||||||
renderForm = () => { |
<Input invalid={errorTitle} type="text" value={this.state.title} |
||||||
const t = this.props |
onChange={(e) => |
||||||
const { errorTitle, errorMessage } = this.state |
this.setState( |
||||||
return ( |
{ |
||||||
<Form> |
errorTitle: e.target.value !== "" ? "" : ERROR_TITLE, |
||||||
{this.props.role_name === 'Super Admin' && ( |
title: e.target.value |
||||||
<FormGroup> |
})} |
||||||
<Label>{this.props.t('company')}</Label> |
placeholder={this.props.t('inputTitle')} /> |
||||||
<Select |
{errorTitle && ( |
||||||
options={this.props.listCompany.map(company => ({ value: company.id, label: company.company_name }))} |
<FormFeedback>{errorTitle}</FormFeedback> |
||||||
onChange={this.handleSelectCompany} |
)} |
||||||
value={this.state.company_id} |
</FormGroup> |
||||||
/> |
<FormGroup> |
||||||
</FormGroup> |
<Label>{this.props.t('messageBroadcast')}</Label> |
||||||
)} |
<Input |
||||||
<FormGroup> |
invalid={errorMessage} |
||||||
<Label>{this.props.t('receiver')}</Label> |
style={{ minHeight: "100px" }} |
||||||
<Input type="select" value={this.state.penerima} onChange={(e) => this.handleChangePenerima(e.target.value)}> |
type="textarea" |
||||||
<option value="all">{this.props.t('all')}</option> |
value={this.state.message} |
||||||
<option value="organization">{this.props.t('roles')}</option> |
onChange={(e) => this.setState({ errorMessage: e.target.value !== "" ? "" : ERROR_MESSAGE, message: e.target.value })} placeholder={this.props.t('inputMsg')} /> |
||||||
<option value="karyawan">{this.props.t('user')}</option> |
{errorMessage && ( |
||||||
</Input> |
<FormFeedback>{errorMessage}</FormFeedback> |
||||||
</FormGroup> |
)} |
||||||
<FormGroup style={{ display: this.state.displayDivisi }}> |
</FormGroup> |
||||||
<Label>{this.props.t('roles')}</Label> |
<FormGroup> |
||||||
<Select options={this.state.listOrganizationSelect} onChange={this.handleSelectOrganization} value={this.state.currentSelectDiv} /> |
<Label>{this.props.t('broadcastDescription')}</Label> |
||||||
{this.state.errorDivision && <FormFeedback>{this.state.errorDivision}</FormFeedback>} |
<Input style={{ minHeight: "100px" }} type="textarea" value={this.state.description} onChange={(e) => this.setState({ description: e.target.value })} placeholder={this.props.t('inputDescription')} /> |
||||||
</FormGroup> |
</FormGroup> |
||||||
<FormGroup style={{ display: this.state.displayKaryawan }}> |
</Form > |
||||||
<Label>{this.props.t('user')}</Label> |
) |
||||||
{!this.state.disableTransfer && |
} |
||||||
<Transfer |
handleCloseDialog = () => { |
||||||
dataSource={this.state.dataSourceEmployee} |
this.props.closeDialog() |
||||||
showSearch |
this.setState({ |
||||||
titles={['', 'Terpilih']} |
errorTitle: "", |
||||||
targetKeys={this.state.targetKeys} |
errorMessage: "", |
||||||
selectedKeys={this.state.selectedKeys} |
errorDivision: "", |
||||||
onChange={this.handleChangeTransfer} |
errorEmployee: "" |
||||||
onSelectChange={this.handleSelectChangeTransfer} |
}) |
||||||
render={item => item.title} |
} |
||||||
disabled={this.state.disableTransfer} |
render() { |
||||||
/> |
return ( |
||||||
} |
<Modal isOpen={this.props.openDialog} toggle={this.props.toggleDialog}> |
||||||
{this.state.errorEmployee && <FormFeedback>{this.state.errorEmployee}</FormFeedback>} |
<ModalHeader toggle={this.handleCloseDialog}>{this.props.t('broadcastDetail')}</ModalHeader> |
||||||
</FormGroup> |
<ModalBody> |
||||||
<FormGroup> |
{this.renderForm()} |
||||||
<Label>{this.props.t('title')}</Label> |
</ModalBody> |
||||||
<Input invalid={errorTitle} type="text" value={this.state.title} |
<ModalFooter> |
||||||
onChange={(e) => |
<Button color="primary" onClick={() => this.handleSave("send")}>{this.props.t('saveSend')}</Button>{' '} |
||||||
this.setState( |
<Button color="primary" onClick={() => this.handleSave("registered")}>{this.props.t('save')}</Button>{' '} |
||||||
{ |
<Button color="secondary" onClick={this.handleCloseDialog}>{this.props.t('cancel')}</Button> |
||||||
errorTitle: e.target.value !== "" ? "" : ERROR_TITLE, |
</ModalFooter> |
||||||
title: e.target.value |
</Modal> |
||||||
})} |
) |
||||||
placeholder={this.props.t('inputTitle')} /> |
} |
||||||
{errorTitle && ( |
} |
||||||
<FormFeedback>{errorTitle}</FormFeedback> |
export default withTranslation()(DialogForm); |
||||||
)} |
|
||||||
</FormGroup> |
|
||||||
<FormGroup> |
|
||||||
<Label>{this.props.t('messageBroadcast')}</Label> |
|
||||||
<Input |
|
||||||
invalid={errorMessage} |
|
||||||
style={{ minHeight: "100px" }} |
|
||||||
type="textarea" |
|
||||||
value={this.state.message} |
|
||||||
onChange={(e) => this.setState({ errorMessage: e.target.value !== "" ? "" : ERROR_MESSAGE, message: e.target.value })} placeholder={this.props.t('inputMsg')} /> |
|
||||||
{errorMessage && ( |
|
||||||
<FormFeedback>{errorMessage}</FormFeedback> |
|
||||||
)} |
|
||||||
</FormGroup> |
|
||||||
<FormGroup> |
|
||||||
<Label>{this.props.t('broadcastDescription')}</Label> |
|
||||||
<Input style={{ minHeight: "100px" }} type="textarea" value={this.state.description} onChange={(e) => this.setState({ description: e.target.value })} placeholder={this.props.t('inputDescription')} /> |
|
||||||
</FormGroup> |
|
||||||
</Form > |
|
||||||
) |
|
||||||
} |
|
||||||
handleCloseDialog = () => { |
|
||||||
this.props.closeDialog() |
|
||||||
this.setState({ |
|
||||||
errorTitle: "", |
|
||||||
errorMessage: "", |
|
||||||
errorDivision: "", |
|
||||||
errorEmployee: "" |
|
||||||
}) |
|
||||||
} |
|
||||||
render() { |
|
||||||
return ( |
|
||||||
<Modal isOpen={this.props.openDialog} toggle={this.props.toggleDialog}> |
|
||||||
<ModalHeader toggle={this.handleCloseDialog}>{this.props.t('broadcastDetail')}</ModalHeader> |
|
||||||
<ModalBody> |
|
||||||
{this.renderForm()} |
|
||||||
</ModalBody> |
|
||||||
<ModalFooter> |
|
||||||
<Button color="primary" onClick={() => this.handleSave("send")}>{this.props.t('saveSend')}</Button>{' '} |
|
||||||
<Button color="primary" onClick={() => this.handleSave("registered")}>{this.props.t('save')}</Button>{' '} |
|
||||||
<Button color="secondary" onClick={this.handleCloseDialog}>{this.props.t('cancel')}</Button> |
|
||||||
</ModalFooter> |
|
||||||
</Modal> |
|
||||||
) |
|
||||||
} |
|
||||||
} |
|
||||||
export default withTranslation()(DialogForm); |
|
||||||
|
@ -1,132 +1,91 @@ |
|||||||
import React, { useEffect, useState } from 'react' |
import React, { useEffect, useState } from 'react' |
||||||
import { |
import { |
||||||
Modal, ModalHeader, ModalBody, ModalFooter, |
Modal, ModalHeader, ModalBody, ModalFooter, |
||||||
Button, Form, FormGroup, Label, Input, Col, Row |
Button, Form, FormGroup, Label, Input, Col, Row |
||||||
} from 'reactstrap'; |
} from 'reactstrap'; |
||||||
import 'antd/dist/antd.css'; |
import 'antd/dist/antd.css'; |
||||||
import InputColor from "./InputColor"; |
import InputColor from "./InputColor"; |
||||||
import "./styles.css"; |
import "./styles.css"; |
||||||
import "rc-color-picker/assets/index.css"; |
import "rc-color-picker/assets/index.css"; |
||||||
import { useTranslation } from 'react-i18next'; |
import { useTranslation } from 'react-i18next'; |
||||||
import { Select } from 'antd'; |
import { Select } from 'antd'; |
||||||
const { Option } = Select |
const { Option } = Select |
||||||
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, company_id, listCompany, role_name }) => { |
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, role_name }) => { |
||||||
const [id, setId] = useState(0) |
const [id, setId] = useState(0) |
||||||
const [projectType, setProjectType] = useState('') |
const [projectType, setProjectType] = useState('') |
||||||
const [color, setColor] = useState('') |
const [color, setColor] = useState('') |
||||||
const [selectedCompany, setSelectedCompany] = useState(null) |
const { t } = useTranslation(); |
||||||
const { t } = useTranslation(); |
useEffect(() => { |
||||||
useEffect(() => { |
if (typeDialog === "Edit") { |
||||||
if (typeDialog === "Edit") { |
setId(dataEdit.id) |
||||||
setId(dataEdit.id) |
setProjectType(dataEdit.name) |
||||||
setProjectType(dataEdit.name) |
setColor(dataEdit.color) |
||||||
setColor(dataEdit.color) |
} else { |
||||||
setSelectedCompany(dataEdit.company_id) |
setId(0) |
||||||
} else { |
setColor('') |
||||||
setId(0) |
setProjectType('') |
||||||
setColor('') |
} |
||||||
setProjectType('') |
}, [dataEdit, openDialog]) |
||||||
} |
|
||||||
}, [dataEdit, openDialog]) |
const handleSave = () => { |
||||||
|
let data = ''; |
||||||
const handleSave = () => { |
if (typeDialog === "Save") { |
||||||
let data = ''; |
data = { |
||||||
if (typeDialog === "Save") { |
name: projectType, |
||||||
if (role_name === 'Super Admin') { |
color |
||||||
company_id = selectedCompany |
} |
||||||
} |
closeDialog('save', data); |
||||||
data = { |
} else { |
||||||
name: projectType, |
data = { |
||||||
color, |
id, |
||||||
company_id: company_id |
name: projectType, |
||||||
} |
color |
||||||
closeDialog('save', data); |
} |
||||||
} else { |
closeDialog('edit', data); |
||||||
if (role_name === 'Super Admin') { |
} |
||||||
company_id = selectedCompany |
setId(0) |
||||||
} |
} |
||||||
data = { |
|
||||||
id, |
const handleCancel = () => { |
||||||
name: projectType, |
closeDialog('cancel', 'none') |
||||||
color, |
setId(0) |
||||||
company_id: company_id |
} |
||||||
} |
|
||||||
closeDialog('edit', data); |
const renderForm = () => { |
||||||
} |
return ( |
||||||
setId(0) |
<Form> |
||||||
} |
<Row> |
||||||
|
<Col md={6}> |
||||||
const handleCancel = () => { |
<FormGroup> |
||||||
closeDialog('cancel', 'none') |
<Label className="capitalize">{t('phase')}</Label> |
||||||
setId(0) |
<Input type="text" value={projectType} onChange={(e) => setProjectType(e.target.value)} /> |
||||||
} |
</FormGroup> |
||||||
|
</Col> |
||||||
const onChangeCompany = (val) => { |
<Col md={6}> |
||||||
setSelectedCompany(val); |
<FormGroup> |
||||||
}; |
<Label className="capitalize">{t('color')}</Label> |
||||||
|
<InputColor value={color} color={color} onChange={(e) => setColor(e.color)} /> |
||||||
const renderForm = () => { |
</FormGroup> |
||||||
return ( |
</Col> |
||||||
<Form> |
</Row> |
||||||
<Row> |
</Form> |
||||||
<Col md={6}> |
) |
||||||
<FormGroup> |
} |
||||||
<Label className="capitalize">{t('phase')}</Label> |
|
||||||
<Input type="text" value={projectType} onChange={(e) => setProjectType(e.target.value)} /> |
return ( |
||||||
</FormGroup> |
<> |
||||||
</Col> |
<Modal size="lg" isOpen={openDialog} toggle={toggleDialog}> |
||||||
<Col md={6}> |
<ModalHeader className="capitalize" toggle={closeDialog}>{typeDialog == "Save" ? `Add` : "Edit"} data</ModalHeader> |
||||||
<FormGroup> |
<ModalBody> |
||||||
<Label className="capitalize">{t('color')}</Label> |
{renderForm()} |
||||||
<InputColor value={color} color={color} onChange={(e) => setColor(e.color)} /> |
</ModalBody> |
||||||
</FormGroup> |
<ModalFooter> |
||||||
</Col> |
<Button color="primary" onClick={() => handleSave()}>{typeDialog}</Button>{' '} |
||||||
</Row> |
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>{t('cancel')}</Button> |
||||||
{role_name === 'Super Admin' && |
</ModalFooter> |
||||||
<Row> |
</Modal> |
||||||
<Col md={6}> |
</> |
||||||
<FormGroup> |
) |
||||||
<Label className="capitalize"> |
} |
||||||
{t('company')}<span style={{ color: "red" }}>*</span> |
|
||||||
</Label> |
export default DialogForm; |
||||||
<Select |
|
||||||
showSearch |
|
||||||
filterOption={(inputValue, option) => |
|
||||||
option.children.toLowerCase().includes(inputValue.toLowerCase()) |
|
||||||
} |
|
||||||
value={selectedCompany} |
|
||||||
defaultValue={selectedCompany} |
|
||||||
onChange={onChangeCompany} |
|
||||||
style={{ width: "100%" }} |
|
||||||
> |
|
||||||
{listCompany.map((res) => ( |
|
||||||
<Option key={res.id} value={res.id}> |
|
||||||
{res.company_name} |
|
||||||
</Option> |
|
||||||
))} |
|
||||||
</Select> |
|
||||||
</FormGroup> |
|
||||||
</Col> |
|
||||||
</Row> |
|
||||||
} |
|
||||||
</Form> |
|
||||||
) |
|
||||||
} |
|
||||||
|
|
||||||
return ( |
|
||||||
<> |
|
||||||
<Modal size="lg" isOpen={openDialog} toggle={toggleDialog}> |
|
||||||
<ModalHeader className="capitalize" toggle={closeDialog}>{typeDialog == "Save" ? `Add` : "Edit"} data</ModalHeader> |
|
||||||
<ModalBody> |
|
||||||
{renderForm()} |
|
||||||
</ModalBody> |
|
||||||
<ModalFooter> |
|
||||||
<Button color="primary" onClick={() => handleSave()}>{typeDialog}</Button>{' '} |
|
||||||
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>{t('cancel')}</Button> |
|
||||||
</ModalFooter> |
|
||||||
</Modal> |
|
||||||
</> |
|
||||||
) |
|
||||||
} |
|
||||||
|
|
||||||
export default DialogForm; |
|
||||||
|
@ -1,140 +1,97 @@ |
|||||||
import React, { useEffect, useState } from 'react' |
import React, { useEffect, useState } from 'react' |
||||||
import { |
import { |
||||||
Modal, ModalHeader, ModalBody, ModalFooter, |
Modal, ModalHeader, ModalBody, ModalFooter, |
||||||
Button, Form, FormGroup, Label, Input, Col, Row |
Button, Form, FormGroup, Label, Input, Col, Row |
||||||
} from 'reactstrap'; |
} from 'reactstrap'; |
||||||
import 'antd/dist/antd.css'; |
import 'antd/dist/antd.css'; |
||||||
import { useTranslation } from 'react-i18next'; |
import { useTranslation } from 'react-i18next'; |
||||||
import { Select } from 'antd'; |
import { Select } from 'antd'; |
||||||
const { Option } = Select; |
const { Option } = Select; |
||||||
|
|
||||||
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, company_id, listCompany, role_name }) => { |
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, role_name }) => { |
||||||
const [id, setId] = useState(0) |
const [id, setId] = useState(0) |
||||||
const [name, setName] = useState('') |
const [name, setName] = useState('') |
||||||
const [description, setDescription] = useState('') |
const [description, setDescription] = useState('') |
||||||
const [selectedCompany, setSelectedCompany] = useState(null) |
const { t } = useTranslation() |
||||||
const { t } = useTranslation() |
|
||||||
|
useEffect(() => { |
||||||
useEffect(() => { |
if (typeDialog === "Edit") { |
||||||
if (typeDialog === "Edit") { |
setId(dataEdit.id) |
||||||
setId(dataEdit.id) |
setDescription(dataEdit.description) |
||||||
setDescription(dataEdit.description) |
setName(dataEdit.name) |
||||||
setName(dataEdit.name) |
|
||||||
setSelectedCompany(dataEdit.company_id); |
} else { |
||||||
|
handleClearData() |
||||||
} else { |
} |
||||||
handleClearData() |
}, [dataEdit, openDialog]) |
||||||
} |
|
||||||
}, [dataEdit, openDialog]) |
const handleSave = () => { |
||||||
|
let data = ''; |
||||||
const handleSave = () => { |
if (typeDialog === "Save") { |
||||||
let data = ''; |
data = { |
||||||
if (role_name === 'Super Admin') { |
name: name, |
||||||
company_id = selectedCompany |
description: description |
||||||
} |
} |
||||||
|
closeDialog('save', data); |
||||||
if (typeDialog === "Save") { |
} else { |
||||||
data = { |
data = { |
||||||
name: name, |
id, |
||||||
description: description, |
name: name, |
||||||
company_id: parseInt(company_id), |
description: description |
||||||
} |
} |
||||||
closeDialog('save', data); |
closeDialog('edit', data); |
||||||
} else { |
} |
||||||
if (role_name === 'Super Admin') { |
handleClearData() |
||||||
company_id = selectedCompany |
} |
||||||
} |
|
||||||
data = { |
const handleCancel = () => { |
||||||
id, |
closeDialog('cancel', 'none') |
||||||
name: name, |
handleClearData() |
||||||
description: description, |
} |
||||||
company_id: company_id, |
|
||||||
} |
const handleClearData = () => { |
||||||
closeDialog('edit', data); |
setId(0) |
||||||
} |
setName('') |
||||||
handleClearData() |
setDescription('') |
||||||
} |
} |
||||||
|
|
||||||
const handleCancel = () => { |
const renderForm = () => { |
||||||
closeDialog('cancel', 'none') |
return ( |
||||||
handleClearData() |
<Form> |
||||||
} |
<Row> |
||||||
|
<Col md={6}> |
||||||
const handleClearData = () => { |
<FormGroup> |
||||||
setId(0) |
<Label className="capitalize">{t('name')}</Label> |
||||||
setName('') |
<Input type="text" value={name} onChange={(e) => setName(e.target.value)} placeholder={t('inputName')} /> |
||||||
setDescription('') |
</FormGroup> |
||||||
setSelectedCompany(null) |
</Col> |
||||||
} |
<Col md={6}> |
||||||
|
<FormGroup> |
||||||
const onChangeCompany = (val) => { |
<Label className="capitalize">{t('description')}</Label> |
||||||
setSelectedCompany(val); |
<Input row="4" type="textarea" value={description} onChange={(e) => setDescription(e.target.value)} placeholder={t('inputDescription')} /> |
||||||
}; |
</FormGroup> |
||||||
|
</Col> |
||||||
const renderForm = () => { |
</Row> |
||||||
return ( |
</Form> |
||||||
<Form> |
) |
||||||
<Row> |
} |
||||||
<Col md={6}> |
|
||||||
<FormGroup> |
|
||||||
<Label className="capitalize">{t('name')}</Label> |
return ( |
||||||
<Input type="text" value={name} onChange={(e) => setName(e.target.value)} placeholder={t('inputName')} /> |
<> |
||||||
</FormGroup> |
<Modal size="lg" isOpen={openDialog} toggle={toggleDialog}> |
||||||
</Col> |
<ModalHeader className="capitalize" toggle={closeDialog}>{typeDialog == "Save" ? `Add` : "Edit"} Checlist K3</ModalHeader> |
||||||
<Col md={6}> |
<ModalBody> |
||||||
<FormGroup> |
{renderForm()} |
||||||
<Label className="capitalize">{t('description')}</Label> |
</ModalBody> |
||||||
<Input row="4" type="textarea" value={description} onChange={(e) => setDescription(e.target.value)} placeholder={t('inputDescription')} /> |
<ModalFooter> |
||||||
</FormGroup> |
<Button color="primary" onClick={() => handleSave()}>{typeDialog}</Button>{' '} |
||||||
</Col> |
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>{t('cancel')}</Button> |
||||||
</Row> |
</ModalFooter> |
||||||
{role_name === 'Super Admin' && |
</Modal> |
||||||
<Row> |
</> |
||||||
<Col md={6}> |
) |
||||||
<FormGroup> |
|
||||||
<Label className="capitalize"> |
} |
||||||
{t('company')}<span style={{ color: "red" }}>*</span> |
|
||||||
</Label> |
export default DialogForm; |
||||||
<Select |
|
||||||
showSearch |
|
||||||
filterOption={(inputValue, option) => |
|
||||||
option.children.toLowerCase().includes(inputValue.toLowerCase()) |
|
||||||
} |
|
||||||
value={selectedCompany} |
|
||||||
defaultValue={selectedCompany} |
|
||||||
onChange={onChangeCompany} |
|
||||||
style={{ width: "100%" }} |
|
||||||
> |
|
||||||
{listCompany.map((res) => ( |
|
||||||
<Option key={res.id} value={res.id}> |
|
||||||
{res.company_name} |
|
||||||
</Option> |
|
||||||
))} |
|
||||||
</Select> |
|
||||||
</FormGroup> |
|
||||||
</Col> |
|
||||||
</Row> |
|
||||||
} |
|
||||||
</Form> |
|
||||||
) |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
return ( |
|
||||||
<> |
|
||||||
<Modal size="lg" isOpen={openDialog} toggle={toggleDialog}> |
|
||||||
<ModalHeader className="capitalize" toggle={closeDialog}>{typeDialog == "Save" ? `Add` : "Edit"} Checlist K3</ModalHeader> |
|
||||||
<ModalBody> |
|
||||||
{renderForm()} |
|
||||||
</ModalBody> |
|
||||||
<ModalFooter> |
|
||||||
<Button color="primary" onClick={() => handleSave()}>{typeDialog}</Button>{' '} |
|
||||||
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>{t('cancel')}</Button> |
|
||||||
</ModalFooter> |
|
||||||
</Modal> |
|
||||||
</> |
|
||||||
) |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
export default DialogForm; |
|
||||||
|
@ -1,357 +1,355 @@ |
|||||||
import React, { useState, useEffect, useMemo } from 'react'; |
import React, { useState, useEffect, useMemo } from 'react'; |
||||||
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; |
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; |
||||||
import { DownloadOutlined } from '@ant-design/icons'; |
import { DownloadOutlined } from '@ant-design/icons'; |
||||||
import axios from "../../../const/interceptorApi" |
import axios from "../../../const/interceptorApi" |
||||||
import * as XLSX from 'xlsx'; |
import * as XLSX from 'xlsx'; |
||||||
import SweetAlert from 'react-bootstrap-sweetalert'; |
import SweetAlert from 'react-bootstrap-sweetalert'; |
||||||
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 { |
||||||
BASE_SIMPRO, PROYEK_ADD, PROYEK_SEARCH, PROYEK_EDIT, PROYEK_DELETE, |
PROYEK_SEARCH,USER_ADD, USER_SEARCH, USER_EDIT, USER_DELETE,ROLE_SEARCH |
||||||
USER_ADD, USER_SEARCH, USER_EDIT, USER_DELETE, |
} from '../../../const/ApiConst'; |
||||||
USERROLE_SEARCH, ROLE_SEARCH |
import moment from 'moment' |
||||||
} from '../../../const/ApiConst'; |
|
||||||
import moment from 'moment' |
const url = ""; |
||||||
|
const proyek_id = localStorage.getItem('proyek_id'); |
||||||
const url = ""; |
const role_id = localStorage.getItem('role_id'); |
||||||
const proyek_id = localStorage.getItem('proyek_id'); |
const format = "DD-MM-YYYY"; |
||||||
const role_id = localStorage.getItem('role_id'); |
const token = window.localStorage.getItem('token'); |
||||||
const format = "DD-MM-YYYY"; |
const config = { |
||||||
const token = window.localStorage.getItem('token'); |
headers: |
||||||
const config = { |
{ |
||||||
headers: |
Authorization: `Bearer ${token}`, |
||||||
{ |
"Content-type": `application/json` |
||||||
Authorization: `Bearer ${token}`, |
} |
||||||
"Content-type": `application/json` |
}; |
||||||
} |
|
||||||
}; |
const PlanningHarian = ({ params }) => { |
||||||
|
const token = localStorage.getItem("token") |
||||||
const PlanningHarian = ({ params }) => { |
const HEADER = { |
||||||
const token = localStorage.getItem("token") |
headers: { |
||||||
const HEADER = { |
"Content-Type": "application/json", |
||||||
headers: { |
"Authorization": `Bearer ${token}` |
||||||
"Content-Type": "application/json", |
} |
||||||
"Authorization": `Bearer ${token}` |
} |
||||||
} |
const pageName = params.name; |
||||||
} |
const [search, setSearch] = useState('') |
||||||
const pageName = params.name; |
const [currentPage, setCurrentPage] = useState(1) |
||||||
const [search, setSearch] = useState('') |
const [openDialog, setOpenDialog] = useState(false) |
||||||
const [currentPage, setCurrentPage] = useState(1) |
const [typeDialog, setTypeDialog] = useState('Save') |
||||||
const [openDialog, setOpenDialog] = useState(false) |
const [dataExport, setDataExport] = useState([]) |
||||||
const [typeDialog, setTypeDialog] = useState('Save') |
const [rowsPerPage, setRowsPerPage] = useState(10) |
||||||
const [dataExport, setDataExport] = useState([]) |
const [dataEdit, setDataEdit] = useState([]) |
||||||
const [rowsPerPage, setRowsPerPage] = useState(10) |
const [alertDelete, setAlertDelete] = useState(false) |
||||||
const [dataEdit, setDataEdit] = useState([]) |
const [idDelete, setIdDelete] = useState(0) |
||||||
const [alertDelete, setAlertDelete] = useState(false) |
const [dataTable, setDatatable] = useState([]) |
||||||
const [idDelete, setIdDelete] = useState(0) |
const [clickOpenModal, setClickOpenModal] = useState(false) |
||||||
const [dataTable, setDatatable] = useState([]) |
const [totalPage, setTotalPage] = useState(0) |
||||||
const [clickOpenModal, setClickOpenModal] = useState(false) |
const [roleList, setRoleList] = useState([]) |
||||||
const [totalPage, setTotalPage] = useState(0) |
|
||||||
const [roleList, setRoleList] = useState([]) |
useEffect(() => { |
||||||
|
getDataUser() |
||||||
useEffect(() => { |
getRoleList() |
||||||
getDataUser() |
}, []) |
||||||
getRoleList() |
|
||||||
}, []) |
const getRoleList = async () => { |
||||||
|
const formData = { |
||||||
const getRoleList = async () => { |
"paging": { "start": 0, "length": -1 }, |
||||||
const formData = { |
"orders": { "columns": ["id"], "ascending": false } |
||||||
"paging": { "start": 0, "length": -1 }, |
} |
||||||
"orders": { "columns": ["id"], "ascending": false } |
|
||||||
} |
const result = await axios |
||||||
|
.post(ROLE_SEARCH, formData, config) |
||||||
const result = await axios |
.then(res => res) |
||||||
.post(ROLE_SEARCH, formData, config) |
.catch((error) => error.response); |
||||||
.then(res => res) |
|
||||||
.catch((error) => error.response); |
if (result && result.data && result.data.code == 200) { |
||||||
|
setRoleList(result.data.data); |
||||||
if (result && result.data && result.data.code == 200) { |
} else { |
||||||
setRoleList(result.data.data); |
NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); |
||||||
} else { |
} |
||||||
NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); |
} |
||||||
} |
|
||||||
} |
const getDataUser = async () => { |
||||||
|
|
||||||
const getDataUser = async () => { |
let start = 0; |
||||||
|
|
||||||
let start = 0; |
if (currentPage !== 1 && currentPage > 1) { |
||||||
|
start = (currentPage * rowsPerPage) - rowsPerPage |
||||||
if (currentPage !== 1 && currentPage > 1) { |
} |
||||||
start = (currentPage * rowsPerPage) - rowsPerPage |
|
||||||
} |
const payload = { |
||||||
|
"paging": { |
||||||
const payload = { |
"start": start, |
||||||
"paging": { |
"length": rowsPerPage |
||||||
"start": start, |
}, |
||||||
"length": rowsPerPage |
"columns": [ |
||||||
}, |
{ |
||||||
"columns": [ |
"name": "name", |
||||||
{ |
"logic_operator": "ilike", |
||||||
"name": "name", |
"value": search, |
||||||
"logic_operator": "ilike", |
"operator": "AND" |
||||||
"value": search, |
} |
||||||
"operator": "AND" |
], |
||||||
} |
"joins": [ |
||||||
], |
{ |
||||||
"joins": [ |
"name": "m_roles", |
||||||
{ |
"column_join": "role_id", |
||||||
"name": "m_roles", |
"column_results": [ |
||||||
"column_join": "role_id", |
"name", |
||||||
"column_results": [ |
"description" |
||||||
"name", |
] |
||||||
"description" |
} |
||||||
] |
], |
||||||
} |
"orders": { |
||||||
], |
"columns": [ |
||||||
"orders": { |
"id" |
||||||
"columns": [ |
], |
||||||
"id" |
"ascending": false |
||||||
], |
} |
||||||
"ascending": false |
} |
||||||
} |
|
||||||
} |
const result = await axios |
||||||
|
.post(USER_SEARCH, payload, config) |
||||||
const result = await axios |
.then(res => res) |
||||||
.post(USER_SEARCH, payload, config) |
.catch((error) => error.response); |
||||||
.then(res => res) |
|
||||||
.catch((error) => error.response); |
if (result && result.data && result.data.code == 200) { |
||||||
|
setDatatable(result.data.data); |
||||||
if (result && result.data && result.data.code == 200) { |
setTotalPage(result.data.totalRecord); |
||||||
setDatatable(result.data.data); |
} else { |
||||||
setTotalPage(result.data.totalRecord); |
NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); |
||||||
} else { |
} |
||||||
NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); |
} |
||||||
} |
|
||||||
} |
const handleSearch = e => { |
||||||
|
const value = e.target.value |
||||||
const handleSearch = e => { |
setSearch(value); |
||||||
const value = e.target.value |
setCurrentPage(1) |
||||||
setSearch(value); |
}; |
||||||
setCurrentPage(1) |
|
||||||
}; |
const handleOpenDialog = (type) => { |
||||||
|
setOpenDialog(true) |
||||||
const handleOpenDialog = (type) => { |
setTypeDialog(type) |
||||||
setOpenDialog(true) |
} |
||||||
setTypeDialog(type) |
|
||||||
} |
const handleExportExcel = async () => { |
||||||
|
|
||||||
const handleExportExcel = async () => { |
const payload = { |
||||||
|
"paging": { "start": 0, "length": -1 }, |
||||||
const payload = { |
"joins": [], |
||||||
"paging": { "start": 0, "length": -1 }, |
"orders": { "columns": ["id"], "ascending": false } |
||||||
"joins": [], |
} |
||||||
"orders": { "columns": ["id"], "ascending": false } |
|
||||||
} |
if (parseInt(role_id) !== 1) { |
||||||
|
payload["columns"] = [ |
||||||
if (parseInt(role_id) !== 1) { |
{ "name": "id", "logic_operator": "=", "value": proyek_id, "operator": "AND" } |
||||||
payload["columns"] = [ |
] |
||||||
{ "name": "id", "logic_operator": "=", "value": proyek_id, "operator": "AND" } |
} |
||||||
] |
|
||||||
} |
const result = await axios |
||||||
|
.post(PROYEK_SEARCH, payload, HEADER) |
||||||
const result = await axios |
.then(res => res) |
||||||
.post(PROYEK_SEARCH, payload, HEADER) |
.catch((error) => error.response); |
||||||
.then(res => res) |
|
||||||
.catch((error) => error.response); |
|
||||||
|
if (result && result.data && result.data.code == 200) { |
||||||
|
let resData = result.data.data; |
||||||
if (result && result.data && result.data.code == 200) { |
const excelData = []; |
||||||
let resData = result.data.data; |
resData.map((n, index) => { |
||||||
const excelData = []; |
let dataRow = { |
||||||
resData.map((n, index) => { |
"Nama Proyek": n.nama, |
||||||
let dataRow = { |
"Biaya": n.biaya, |
||||||
"Nama Proyek": n.nama, |
"Color Progress": n.color_progress, |
||||||
"Biaya": n.biaya, |
"Jumlah Pekerja": n.jumlah_pekerja, |
||||||
"Color Progress": n.color_progress, |
"Tanggal Mulai": n.mulai_proyek ? moment(n.mulai_proyek).format(format) : "-", |
||||||
"Jumlah Pekerja": n.jumlah_pekerja, |
"Tanggal Selesai": n.akhir_proyek ? moment(n.akhir_proyek).format(format) : "-", |
||||||
"Tanggal Mulai": n.mulai_proyek ? moment(n.mulai_proyek).format(format) : "-", |
} |
||||||
"Tanggal Selesai": n.akhir_proyek ? moment(n.akhir_proyek).format(format) : "-", |
excelData.push(dataRow) |
||||||
} |
}) |
||||||
excelData.push(dataRow) |
await setDataExport(excelData); |
||||||
}) |
} else { |
||||||
await setDataExport(excelData); |
NotificationManager.error('Gagal Export Data!!', 'Failed'); |
||||||
} else { |
} |
||||||
NotificationManager.error('Gagal Export Data!!', 'Failed'); |
} |
||||||
} |
|
||||||
} |
const handleEdit = (data) => { |
||||||
|
setDataEdit(data) |
||||||
const handleEdit = (data) => { |
handleOpenDialog('Edit'); |
||||||
setDataEdit(data) |
} |
||||||
handleOpenDialog('Edit'); |
|
||||||
} |
const handleDelete = async (id) => { |
||||||
|
await setAlertDelete(true) |
||||||
const handleDelete = async (id) => { |
await setIdDelete(id) |
||||||
await setAlertDelete(true) |
} |
||||||
await setIdDelete(id) |
|
||||||
} |
const handleCloseDialog = (type, data) => { |
||||||
|
if (type === "save") { |
||||||
const handleCloseDialog = (type, data) => { |
saveUser(data); |
||||||
if (type === "save") { |
} else if (type === "edit") { |
||||||
saveUser(data); |
editUser(data); |
||||||
} else if (type === "edit") { |
} |
||||||
editUser(data); |
setDataEdit([]) |
||||||
} |
setOpenDialog(false) |
||||||
setDataEdit([]) |
} |
||||||
setOpenDialog(false) |
|
||||||
} |
const saveUser = async (data) => { |
||||||
|
const formData = data |
||||||
const saveUser = async (data) => { |
const result = await axios.post(USER_ADD, formData, HEADER) |
||||||
const formData = data |
.then(res => res) |
||||||
const result = await axios.post(USER_ADD, formData, HEADER) |
.catch((error) => error.response); |
||||||
.then(res => res) |
|
||||||
.catch((error) => error.response); |
if (result && result.data && result.data.code === 200) { |
||||||
|
getDataUser(); |
||||||
if (result && result.data && result.data.code === 200) { |
NotificationManager.success(`Data resource berhasil ditambah`, 'Success!!'); |
||||||
getDataUser(); |
} else { |
||||||
NotificationManager.success(`Data resource berhasil ditambah`, 'Success!!'); |
NotificationManager.error(`${result.data.message}`, 'Failed!!'); |
||||||
} else { |
} |
||||||
NotificationManager.error(`${result.data.message}`, 'Failed!!'); |
} |
||||||
} |
|
||||||
} |
const editUser = async (data) => { |
||||||
|
|
||||||
const editUser = async (data) => { |
let urlEdit = USER_EDIT(data.id) |
||||||
|
const formData = data |
||||||
let urlEdit = USER_EDIT(data.id) |
|
||||||
const formData = data |
const result = await axios.put(urlEdit, formData, HEADER) |
||||||
|
.then(res => res) |
||||||
const result = await axios.put(urlEdit, formData, HEADER) |
.catch((error) => error.response); |
||||||
.then(res => res) |
|
||||||
.catch((error) => error.response); |
if (result && result.data && result.data.code === 200) { |
||||||
|
getDataUser(); |
||||||
if (result && result.data && result.data.code === 200) { |
NotificationManager.success(`Data resource berhasil diedit`, 'Success!!'); |
||||||
getDataUser(); |
} else { |
||||||
NotificationManager.success(`Data resource berhasil diedit`, 'Success!!'); |
NotificationManager.error(`Data resource gagal di edit`, `Failed!!`); |
||||||
} else { |
} |
||||||
NotificationManager.error(`Data resource gagal di edit`, `Failed!!`); |
} |
||||||
} |
|
||||||
} |
const toggleAddDialog = () => { |
||||||
|
setOpenDialog(!openDialog) |
||||||
const toggleAddDialog = () => { |
} |
||||||
setOpenDialog(!openDialog) |
|
||||||
} |
const onConfirmDelete = async () => { |
||||||
|
let url = USER_DELETE(idDelete); |
||||||
const onConfirmDelete = async () => { |
|
||||||
let url = USER_DELETE(idDelete); |
const result = await axios.delete(url, config) |
||||||
|
.then(res => res) |
||||||
const result = await axios.delete(url, config) |
.catch((error) => error.response); |
||||||
.then(res => res) |
|
||||||
.catch((error) => error.response); |
if (result && result.data && result.data.code === 200) { |
||||||
|
getDataUser() |
||||||
if (result && result.data && result.data.code === 200) { |
setIdDelete(0) |
||||||
getDataUser() |
setAlertDelete(false) |
||||||
setIdDelete(0) |
NotificationManager.success(`Data user berhasil dihapus!`, 'Success!!'); |
||||||
setAlertDelete(false) |
} else { |
||||||
NotificationManager.success(`Data user berhasil dihapus!`, 'Success!!'); |
setIdDelete(0) |
||||||
} else { |
setAlertDelete(false) |
||||||
setIdDelete(0) |
NotificationManager.error(`Data user gagal dihapus!}`, 'Failed!!'); |
||||||
setAlertDelete(false) |
} |
||||||
NotificationManager.error(`Data user gagal dihapus!}`, 'Failed!!'); |
} |
||||||
} |
|
||||||
} |
const cancelDelete = () => { |
||||||
|
setAlertDelete(false) |
||||||
const cancelDelete = () => { |
setIdDelete(0) |
||||||
setAlertDelete(false) |
} |
||||||
setIdDelete(0) |
|
||||||
} |
const RenderTable = useMemo(() => { |
||||||
|
const columns = [ |
||||||
const RenderTable = useMemo(() => { |
|
||||||
const columns = [ |
{ title: 'Subproject Name', dataIndex: 'name', key: 'name' }, |
||||||
|
{ title: 'Activity', dataIndex: 'name', key: 'name' }, |
||||||
{ title: 'Subproject Name', dataIndex: 'name', key: 'name' }, |
{ title: 'Target', dataIndex: 'name', key: 'name' }, |
||||||
{ title: 'Activity', dataIndex: 'name', key: 'name' }, |
{ title: 'Unit', dataIndex: 'name', key: 'name' }, |
||||||
{ title: 'Target', dataIndex: 'name', key: 'name' }, |
{ title: 'Resource Name', dataIndex: 'name', key: 'name' }, |
||||||
{ title: 'Unit', dataIndex: 'name', key: 'name' }, |
{ |
||||||
{ title: 'Resource Name', dataIndex: 'name', key: 'name' }, |
title: 'Planning Start Date', |
||||||
{ |
dataIndex: 'name', |
||||||
title: 'Planning Start Date', |
key: 'name', |
||||||
dataIndex: 'name', |
render: (text, record) => <>{text}</>, |
||||||
key: 'name', |
}, |
||||||
render: (text, record) => <>{text}</>, |
{ |
||||||
}, |
title: 'Planning End Date', |
||||||
{ |
dataIndex: 'name', |
||||||
title: 'Planning End Date', |
key: 'name', |
||||||
dataIndex: 'name', |
render: (text, record) => <>{text}</>, |
||||||
key: 'name', |
}, |
||||||
render: (text, record) => <>{text}</>, |
{ title: 'Address', dataIndex: 'name', key: 'name' }, |
||||||
}, |
{ |
||||||
{ title: 'Address', dataIndex: 'name', key: 'name' }, |
title: 'Action', |
||||||
{ |
dataIndex: '', |
||||||
title: 'Action', |
key: 'x', |
||||||
dataIndex: '', |
render: (text, record) => <> |
||||||
key: 'x', |
{/* <Tooltip title="Tambah Sub"> |
||||||
render: (text, record) => <> |
<Button size="small" type="link" style={{color:'green'}} onClick={() => handleOpenDialogSub('Save', text)}><i className="fa fa-plus"></i></Button> |
||||||
{/* <Tooltip title="Tambah Sub"> |
</Tooltip> */} |
||||||
<Button size="small" type="link" style={{color:'green'}} onClick={() => handleOpenDialogSub('Save', text)}><i className="fa fa-plus"></i></Button> |
<Tooltip title="Edit"> |
||||||
</Tooltip> */} |
<Button size="small" type="link" style={{ color: 'orange' }} onClick={() => handleEdit(text)}><i className="fa fa-edit"></i></Button> |
||||||
<Tooltip title="Edit"> |
</Tooltip> |
||||||
<Button size="small" type="link" style={{ color: 'orange' }} onClick={() => handleEdit(text)}><i className="fa fa-edit"></i></Button> |
<Tooltip title="Hapus"> |
||||||
</Tooltip> |
<Button size="small" type="link" style={{ color: 'red' }} onClick={() => handleDelete(text.id)}><i className="fa fa-trash"></i></Button> |
||||||
<Tooltip title="Hapus"> |
</Tooltip> |
||||||
<Button size="small" type="link" style={{ color: 'red' }} onClick={() => handleDelete(text.id)}><i className="fa fa-trash"></i></Button> |
</>, |
||||||
</Tooltip> |
}, |
||||||
</>, |
]; |
||||||
}, |
|
||||||
]; |
return ( |
||||||
|
<Table |
||||||
return ( |
size="small" |
||||||
<Table |
columns={columns} |
||||||
size="small" |
dataSource={dataTable} |
||||||
columns={columns} |
/> |
||||||
dataSource={dataTable} |
) |
||||||
/> |
}, [dataTable]) |
||||||
) |
|
||||||
}, [dataTable]) |
return ( |
||||||
|
<div> |
||||||
return ( |
<NotificationContainer /> |
||||||
<div> |
<SweetAlert |
||||||
<NotificationContainer /> |
show={alertDelete} |
||||||
<SweetAlert |
warning |
||||||
show={alertDelete} |
showCancel |
||||||
warning |
confirmBtnText="Delete" |
||||||
showCancel |
confirmBtnBsStyle="danger" |
||||||
confirmBtnText="Delete" |
title={`Are you sure?`} |
||||||
confirmBtnBsStyle="danger" |
onConfirm={onConfirmDelete} |
||||||
title={`Are you sure?`} |
onCancel={() => cancelDelete()} |
||||||
onConfirm={onConfirmDelete} |
focusCancelBtn |
||||||
onCancel={() => cancelDelete()} |
> |
||||||
focusCancelBtn |
Delete this data |
||||||
> |
</SweetAlert> |
||||||
Delete this data |
<DialogForm |
||||||
</SweetAlert> |
openDialog={openDialog} |
||||||
<DialogForm |
closeDialog={handleCloseDialog} |
||||||
openDialog={openDialog} |
toggleDialog={() => toggleAddDialog} |
||||||
closeDialog={handleCloseDialog} |
typeDialog={typeDialog} |
||||||
toggleDialog={() => toggleAddDialog} |
dataEdit={dataEdit} |
||||||
typeDialog={typeDialog} |
clickOpenModal={clickOpenModal} |
||||||
dataEdit={dataEdit} |
roleList={roleList} |
||||||
clickOpenModal={clickOpenModal} |
/> |
||||||
roleList={roleList} |
<Card> |
||||||
/> |
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}> |
||||||
<Card> |
<h4 className="capitalize">{pageName}</h4> |
||||||
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}> |
<Row> |
||||||
<h4 className="capitalize">{pageName}</h4> |
<Col> |
||||||
<Row> |
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={`Search...`} /> |
||||||
<Col> |
</Col> |
||||||
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={`Search...`} /> |
<Col> |
||||||
</Col> |
<Tooltip title="Add Resource"> |
||||||
<Col> |
<Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button> |
||||||
<Tooltip title="Add Resource"> |
</Tooltip> |
||||||
<Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button> |
<Tooltip title="Export Excel"> |
||||||
</Tooltip> |
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button> |
||||||
<Tooltip title="Export Excel"> |
</Tooltip> |
||||||
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button> |
</Col> |
||||||
</Tooltip> |
</Row> |
||||||
</Col> |
</CardHeader> |
||||||
</Row> |
<CardBody> |
||||||
</CardHeader> |
|
||||||
<CardBody> |
{RenderTable} |
||||||
|
</CardBody> |
||||||
{RenderTable} |
</Card> |
||||||
</CardBody> |
</div> |
||||||
</Card> |
) |
||||||
</div> |
} |
||||||
) |
|
||||||
} |
export default PlanningHarian; |
||||||
|
|
||||||
export default PlanningHarian; |
|
||||||
|
@ -1,243 +1,243 @@ |
|||||||
import React, { useEffect, useMemo, useState } from 'react'; |
import React, { useEffect, useMemo, useState } from 'react'; |
||||||
import Timeline from 'react-calendar-timeline' |
import Timeline from 'react-calendar-timeline' |
||||||
import 'react-calendar-timeline/lib/Timeline.css' |
import 'react-calendar-timeline/lib/Timeline.css' |
||||||
import moment from 'moment'; |
import moment from 'moment'; |
||||||
import { BASE_SIMPRO, PROYEK_ADD, PROYEK_SEARCH_DETAIL, PROYEK_EDIT, PROYEK_DELETE } from '../../const/ApiConst'; |
import { BASE_SIMPRO, PROYEK_ADD, PROYEK_SEARCH_DETAIL } from '../../const/ApiConst'; |
||||||
import axios from 'axios'; |
import axios from 'axios'; |
||||||
import { NotificationContainer, NotificationManager } from 'react-notifications'; |
import { NotificationContainer, NotificationManager } from 'react-notifications'; |
||||||
import { Button } from 'antd'; |
import { Button } from 'antd'; |
||||||
import { |
import { |
||||||
Container, Col, Row, UncontrolledTooltip, |
Container, Col, Row, UncontrolledTooltip, |
||||||
Card, |
Card, |
||||||
CardBody, |
CardBody, |
||||||
CardHeader, |
CardHeader, |
||||||
Table, |
Table, |
||||||
Modal, ModalHeader, ModalBody, ModalFooter |
Modal, ModalHeader, ModalBody, ModalFooter |
||||||
} from 'reactstrap'; |
} from 'reactstrap'; |
||||||
import GanttFull from './GanttDhtmlx2'; |
import GanttFull from './GanttDhtmlx2'; |
||||||
import DialogForm from '../Master/Proyek/DialogForm'; |
import DialogForm from '../Master/Proyek/DialogForm'; |
||||||
import DialogFormSub from '../Master/Proyek/DialogFormSub'; |
import DialogFormSub from '../Master/Proyek/DialogFormSub'; |
||||||
import Iframe from "@nicholasadamou/react-iframe"; |
import Iframe from "@nicholasadamou/react-iframe"; |
||||||
|
|
||||||
const GanttTimeLine = () => { |
const GanttTimeLine = () => { |
||||||
const token = localStorage.getItem("token") |
const token = localStorage.getItem("token") |
||||||
const HEADER = { |
const HEADER = { |
||||||
headers: { |
headers: { |
||||||
"Content-Type": "application/json", |
"Content-Type": "application/json", |
||||||
"Authorization": `Bearer ${token}` |
"Authorization": `Bearer ${token}` |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
const [dataGantt, setDataGantt] = useState([]); |
const [dataGantt, setDataGantt] = useState([]); |
||||||
const [prevProyekId, setPrevProyekId] = useState(0); |
const [prevProyekId, setPrevProyekId] = useState(0); |
||||||
const [dataGroupGantt, setDataGroupGantt] = useState([]); |
const [dataGroupGantt, setDataGroupGantt] = useState([]); |
||||||
const [maxDateGantt, setMaxDateGantt] = useState(null); |
const [maxDateGantt, setMaxDateGantt] = useState(null); |
||||||
const [minDateGantt, setMinDateGantt] = useState(null); |
const [minDateGantt, setMinDateGantt] = useState(null); |
||||||
const [dataAllTimeLine, setDataAllTimeLine] = useState([]); |
const [dataAllTimeLine, setDataAllTimeLine] = useState([]); |
||||||
const [prevDataAllTimeLine, setPrevDataAllTimeLine] = useState(null); |
const [prevDataAllTimeLine, setPrevDataAllTimeLine] = useState(null); |
||||||
|
|
||||||
const [idTask, setidTask] = useState(0); |
const [idTask, setidTask] = useState(0); |
||||||
const [dataTable, setDatatable] = useState([]) |
const [dataTable, setDatatable] = 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) |
||||||
const [openDialog, setOpenDialog] = useState(false) |
const [openDialog, setOpenDialog] = useState(false) |
||||||
const [openDialogSub, setOpenDialogSub] = useState(false) |
const [openDialogSub, setOpenDialogSub] = useState(false) |
||||||
const [typeDialog, setTypeDialog] = useState('Save'); |
const [typeDialog, setTypeDialog] = useState('Save'); |
||||||
const [typeDialogSub, setTypeDialogSub] = useState('Save') |
const [typeDialogSub, setTypeDialogSub] = useState('Save') |
||||||
const [idDelete, setIdDelete] = useState(0) |
const [idDelete, setIdDelete] = useState(0) |
||||||
const [alertDelete, setAlertDelete] = useState(false) |
const [alertDelete, setAlertDelete] = useState(false) |
||||||
const [dataEdit, setDataEdit] = useState([]) |
const [dataEdit, setDataEdit] = useState([]) |
||||||
const [dataEditSub, setDataEditSub] = useState([]) |
const [dataEditSub, setDataEditSub] = useState([]) |
||||||
const [rowsPerPage, setRowsPerPage] = useState(10) |
const [rowsPerPage, setRowsPerPage] = useState(10) |
||||||
const [clickOpenModal, setClickOpenModal] = useState(false) |
const [clickOpenModal, setClickOpenModal] = useState(false) |
||||||
const [dataExport, setDataExport] = useState([]) |
const [dataExport, setDataExport] = useState([]) |
||||||
const [allDataMenu, setAllDataMenu] = useState([]) |
const [allDataMenu, setAllDataMenu] = useState([]) |
||||||
const [idSubtask, setIdSubtask] = useState(0); |
const [idSubtask, setIdSubtask] = useState(0); |
||||||
|
|
||||||
const handleMappingDataGantt = (data) => { |
const handleMappingDataGantt = (data) => { |
||||||
const minDates = data.map(res => moment(res.mulai_proyek)), |
const minDates = data.map(res => moment(res.mulai_proyek)), |
||||||
minDate = moment.min(minDates) |
minDate = moment.min(minDates) |
||||||
const maxDates = data.map(res => moment(res.akhir_proyek)), |
const maxDates = data.map(res => moment(res.akhir_proyek)), |
||||||
maxDate = moment.max(maxDates) |
maxDate = moment.max(maxDates) |
||||||
|
|
||||||
let groups = [] |
let groups = [] |
||||||
let items = [] |
let items = [] |
||||||
data.map((res, idx) => { |
data.map((res, idx) => { |
||||||
let group = { |
let group = { |
||||||
id: res.id, |
id: res.id, |
||||||
title: res.nama, |
title: res.nama, |
||||||
stackItems: true, |
stackItems: true, |
||||||
height: 50 |
height: 50 |
||||||
} |
} |
||||||
let item = { |
let item = { |
||||||
id: res.id, |
id: res.id, |
||||||
group: res.id, |
group: res.id, |
||||||
title: res.pic, |
title: res.pic, |
||||||
start_time: moment(res.mulai_proyek), |
start_time: moment(res.mulai_proyek), |
||||||
end_time: moment(res.akhir_proyek), |
end_time: moment(res.akhir_proyek), |
||||||
} |
} |
||||||
groups.push(group) |
groups.push(group) |
||||||
items.push(item) |
items.push(item) |
||||||
}) |
}) |
||||||
setDataGantt(items) |
setDataGantt(items) |
||||||
setDataGroupGantt(groups) |
setDataGroupGantt(groups) |
||||||
setMaxDateGantt(maxDate) |
setMaxDateGantt(maxDate) |
||||||
setMinDateGantt(minDate) |
setMinDateGantt(minDate) |
||||||
} |
} |
||||||
|
|
||||||
const handleGetDataProyek = async () => { |
const handleGetDataProyek = async () => { |
||||||
|
|
||||||
const payload = { |
const payload = { |
||||||
"paging": { "start": 0, "length": -1 }, |
"paging": { "start": 0, "length": -1 }, |
||||||
"joins": [ |
"joins": [ |
||||||
{ "name": "subproyeks.m_proyek", "column_join": "proyek_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual", "lat", "lon", "buffer_radius", "geom"] }, |
{ "name": "subproyeks.m_proyek", "column_join": "proyek_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual", "lat", "lon", "buffer_radius", "geom"] }, |
||||||
{ "name": "subproyeks.m_subproyek", "column_join": "parent_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual", "lat", "lon", "buffer_radius", "geom"] } |
{ "name": "subproyeks.m_subproyek", "column_join": "parent_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual", "lat", "lon", "buffer_radius", "geom"] } |
||||||
], |
], |
||||||
"orders": { "columns": ["id"], "ascending": false } |
"orders": { "columns": ["id"], "ascending": false } |
||||||
} |
} |
||||||
|
|
||||||
const result = await axios |
const result = await axios |
||||||
.post(PROYEK_SEARCH_DETAIL, payload, HEADER) |
.post(PROYEK_SEARCH_DETAIL, payload, HEADER) |
||||||
.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) { |
||||||
const { data } = result.data |
const { data } = result.data |
||||||
setDataAllTimeLine(data) |
setDataAllTimeLine(data) |
||||||
setPrevDataAllTimeLine(data) |
setPrevDataAllTimeLine(data) |
||||||
handleMappingDataGantt(data) |
handleMappingDataGantt(data) |
||||||
|
|
||||||
} else { |
} else { |
||||||
NotificationManager.error('Gagal Export Data!!', 'Failed'); |
NotificationManager.error('Gagal Export Data!!', 'Failed'); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
useEffect(() => { |
useEffect(() => { |
||||||
|
|
||||||
handleGetDataProyek() |
handleGetDataProyek() |
||||||
}, []); |
}, []); |
||||||
|
|
||||||
const handleClickGroupGantt = param => { |
const handleClickGroupGantt = param => { |
||||||
const row = prevDataAllTimeLine.filter(res => res.id === param) |
const row = prevDataAllTimeLine.filter(res => res.id === param) |
||||||
if (row.length > 0) { |
if (row.length > 0) { |
||||||
const { subproyeks, proyek_id, parent_id } = row[0] |
const { subproyeks, proyek_id, parent_id } = row[0] |
||||||
setPrevProyekId(parent_id || proyek_id) |
setPrevProyekId(parent_id || proyek_id) |
||||||
handleMappingDataGantt(subproyeks) |
handleMappingDataGantt(subproyeks) |
||||||
setDataAllTimeLine(subproyeks) |
setDataAllTimeLine(subproyeks) |
||||||
} |
} |
||||||
|
|
||||||
} |
} |
||||||
|
|
||||||
const handleOpenDialog = (type) => { |
const handleOpenDialog = (type) => { |
||||||
setOpenDialog(true) |
setOpenDialog(true) |
||||||
setTypeDialog(type) |
setTypeDialog(type) |
||||||
} |
} |
||||||
|
|
||||||
const handleOpenDialogSub = (type, param) => { |
const handleOpenDialogSub = (type, param) => { |
||||||
const { id, parent_id, proyek_id, parent } = param |
const { id, parent_id, proyek_id, parent } = param |
||||||
const idParent = parent == 0 ? 0 : parent == proyek_id ? id : parent_id |
const idParent = parent == 0 ? 0 : parent == proyek_id ? id : parent_id |
||||||
setidTask(proyek_id) |
setidTask(proyek_id) |
||||||
setIdSubtask(idParent) |
setIdSubtask(idParent) |
||||||
setOpenDialogSub(true) |
setOpenDialogSub(true) |
||||||
setTypeDialogSub(type) |
setTypeDialogSub(type) |
||||||
} |
} |
||||||
|
|
||||||
const handleCloseDialog = (type, data) => { |
const handleCloseDialog = (type, data) => { |
||||||
if (type === "save") { |
if (type === "save") { |
||||||
saveProyek(data); |
saveProyek(data); |
||||||
} |
} |
||||||
|
|
||||||
setDataEdit([]) |
setDataEdit([]) |
||||||
setOpenDialog(false) |
setOpenDialog(false) |
||||||
} |
} |
||||||
|
|
||||||
const handleCloseDialogSub = (type, data) => { |
const handleCloseDialogSub = (type, data) => { |
||||||
setDataEditSub([]) |
setDataEditSub([]) |
||||||
setOpenDialogSub(false) |
setOpenDialogSub(false) |
||||||
if (type !== "cancel") { |
if (type !== "cancel") { |
||||||
handleGetDataProyek() |
handleGetDataProyek() |
||||||
} |
} |
||||||
|
|
||||||
} |
} |
||||||
|
|
||||||
const toggleAddDialog = () => { |
const toggleAddDialog = () => { |
||||||
setOpenDialog(!openDialog) |
setOpenDialog(!openDialog) |
||||||
} |
} |
||||||
|
|
||||||
const toggleAddDialogSub = () => { |
const toggleAddDialogSub = () => { |
||||||
setOpenDialogSub(!openDialogSub) |
setOpenDialogSub(!openDialogSub) |
||||||
} |
} |
||||||
|
|
||||||
const saveProyek = async (data) => { |
const saveProyek = async (data) => { |
||||||
const formData = data |
const formData = data |
||||||
|
|
||||||
const result = await axios.post(PROYEK_ADD, formData, HEADER) |
const result = await axios.post(PROYEK_ADD, formData, HEADER) |
||||||
.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) { |
||||||
handleGetDataProyek() |
handleGetDataProyek() |
||||||
NotificationManager.success(`Data proyek berhasil ditambah`, 'Success!!'); |
NotificationManager.success(`Data proyek berhasil ditambah`, 'Success!!'); |
||||||
} else { |
} else { |
||||||
NotificationManager.error(`${result.data.message}`, 'Failed!!'); |
NotificationManager.error(`${result.data.message}`, 'Failed!!'); |
||||||
} |
} |
||||||
|
|
||||||
} |
} |
||||||
|
|
||||||
const RenderGantt = useMemo(() => ( |
const RenderGantt = useMemo(() => ( |
||||||
<GanttFull |
<GanttFull |
||||||
handleOpenDialogSub={handleOpenDialogSub} |
handleOpenDialogSub={handleOpenDialogSub} |
||||||
data={dataAllTimeLine} |
data={dataAllTimeLine} |
||||||
startDate={minDateGantt ? minDateGantt.format("YYYY-MM-DD HH:mm:ss") : moment().add(-40, 'days').format("YYYY-MM-DD HH:mm:ss")} |
startDate={minDateGantt ? minDateGantt.format("YYYY-MM-DD HH:mm:ss") : moment().add(-40, 'days').format("YYYY-MM-DD HH:mm:ss")} |
||||||
endDate={maxDateGantt ? maxDateGantt.format("YYYY-MM-DD HH:mm:ss") : moment().add(40, 'days').format("YYYY-MM-DD HH:mm:ss")} |
endDate={maxDateGantt ? maxDateGantt.format("YYYY-MM-DD HH:mm:ss") : moment().add(40, 'days').format("YYYY-MM-DD HH:mm:ss")} |
||||||
/> |
/> |
||||||
), [dataAllTimeLine, maxDateGantt, minDateGantt]) |
), [dataAllTimeLine, maxDateGantt, minDateGantt]) |
||||||
|
|
||||||
return ( |
return ( |
||||||
<div> |
<div> |
||||||
<NotificationContainer /> |
<NotificationContainer /> |
||||||
{/* time line gantt */} |
{/* time line gantt */} |
||||||
<DialogForm |
<DialogForm |
||||||
openDialog={openDialog} |
openDialog={openDialog} |
||||||
closeDialog={handleCloseDialog} |
closeDialog={handleCloseDialog} |
||||||
toggleDialog={() => toggleAddDialog} |
toggleDialog={() => toggleAddDialog} |
||||||
typeDialog={typeDialog} |
typeDialog={typeDialog} |
||||||
dataEdit={dataEdit} |
dataEdit={dataEdit} |
||||||
clickOpenModal={clickOpenModal} |
clickOpenModal={clickOpenModal} |
||||||
dataParent={allDataMenu} |
dataParent={allDataMenu} |
||||||
/> |
/> |
||||||
<DialogFormSub |
<DialogFormSub |
||||||
openDialog={openDialogSub} |
openDialog={openDialogSub} |
||||||
closeDialog={handleCloseDialogSub} |
closeDialog={handleCloseDialogSub} |
||||||
toggleDialog={() => toggleAddDialogSub} |
toggleDialog={() => toggleAddDialogSub} |
||||||
typeDialog={typeDialogSub} |
typeDialog={typeDialogSub} |
||||||
dataEdit={dataEditSub} |
dataEdit={dataEditSub} |
||||||
idTask={idTask} |
idTask={idTask} |
||||||
idSubtask={idSubtask} |
idSubtask={idSubtask} |
||||||
/> |
/> |
||||||
{/* <Row> |
{/* <Row> |
||||||
<Col md={6} /> |
<Col md={6} /> |
||||||
<Col md={6}> |
<Col md={6}> |
||||||
<Button style={{ float: 'right' }} onClick={() => handleOpenDialog('Save')} type="primary">Add Proyek</Button> |
<Button style={{ float: 'right' }} onClick={() => handleOpenDialog('Save')} type="primary">Add Proyek</Button> |
||||||
</Col> |
</Col> |
||||||
</Row> */} |
</Row> */} |
||||||
{/* {RenderGantt} */} |
{/* {RenderGantt} */} |
||||||
<Iframe |
<Iframe |
||||||
src="http://siopas.co.id/simpro-gantt/gantt.html" |
src="http://siopas.co.id/simpro-gantt/gantt.html" |
||||||
headers={{ |
headers={{ |
||||||
}} |
}} |
||||||
style={{ |
style={{ |
||||||
width: '100%', |
width: '100%', |
||||||
height: '75vh', |
height: '75vh', |
||||||
}} |
}} |
||||||
scrolling="no" |
scrolling="no" |
||||||
frameBorder="0" |
frameBorder="0" |
||||||
/> |
/> |
||||||
|
|
||||||
</div> |
</div> |
||||||
); |
); |
||||||
} |
} |
||||||
|
|
||||||
export default GanttTimeLine; |
export default GanttTimeLine; |
||||||
|
Loading…
Reference in new issue