diff --git a/src/views/SimproV2/Satuan/DialogForm.js b/src/views/SimproV2/Satuan/DialogForm.js index 3ebbc50..b2acb99 100644 --- a/src/views/SimproV2/Satuan/DialogForm.js +++ b/src/views/SimproV2/Satuan/DialogForm.js @@ -1,139 +1,139 @@ -import React, { useEffect, useState } from 'react' -import { - Modal, ModalHeader, ModalBody, ModalFooter, - Button, Form, FormGroup, Label, Input, Col, Row -} from 'reactstrap'; -import { Select } from 'antd'; -import 'antd/dist/antd.css'; -import { useTranslation } from 'react-i18next'; -const { Option } = Select; - -const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, company_id, listCompany, role_name }) => { - const [id, setId] = useState(0) - const [name, setName] = useState('') - const [description, setDescription] = useState('') - const [selectedCompany, setSelectedCompany] = useState(null) - const { t } = useTranslation() - - - useEffect(() => { - if (typeDialog === "Edit") { - setId(dataEdit.id) - setDescription(dataEdit.description) - setName(dataEdit.name) - setSelectedCompany(dataEdit.company_id); - } else { - setId(0) - } - }, [dataEdit, openDialog]) - - const handleSave = () => { - let data = ''; - if (typeDialog === "Save") { - if (role_name === 'Super Admin') { - company_id = selectedCompany - } - data = { - name: name, - description: description, - company_id: company_id - } - - closeDialog('save', data); - } else { - - if (role_name === 'Super Admin') { - company_id = selectedCompany - } - data = { - id, - name: name, - description: description, - company_id: company_id - } - closeDialog('edit', data); - } - setId(0) - setDescription('') - setSelectedCompany(null) - - } - - const handleCancel = () => { - closeDialog('cancel', 'none') - setId(0) - setDescription('') - setSelectedCompany(null) - } - - const onChangeCompany = (val) => { - setSelectedCompany(val); - }; - - const renderForm = () => { - return ( -
- - - - - setName(e.target.value)} placeholder={t('inputName')} /> - - - - - - setDescription(e.target.value)} placeholder={t('inputDescription')} /> - - - - {role_name === 'Super Admin' && - - - - - - - - - } -
- ) - } - - - return ( - <> - - {typeDialog == "Save" ? `Add` : "Edit"} {'uom'} - - {renderForm()} - - - {' '} - - - - - ) - -} - -export default DialogForm; \ No newline at end of file +import React, { useEffect, useState } from 'react' +import { + Modal, ModalHeader, ModalBody, ModalFooter, + Button, Form, FormGroup, Label, Input, Col, Row +} from 'reactstrap'; +import { Select } from 'antd'; +import 'antd/dist/antd.css'; +import { useTranslation } from 'react-i18next'; +const { Option } = Select; + +const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, company_id, listCompany, role_name }) => { + const [id, setId] = useState(0) + const [name, setName] = useState('') + const [description, setDescription] = useState('') + const [selectedCompany, setSelectedCompany] = useState(null) + const { t } = useTranslation() + + + useEffect(() => { + if (typeDialog === "Edit") { + setId(dataEdit.id) + setDescription(dataEdit.description) + setName(dataEdit.name) + setSelectedCompany(dataEdit.company_id); + } else { + setId(0) + } + }, [dataEdit, openDialog]) + + const handleSave = () => { + let data = ''; + if (typeDialog === "Save") { + if (role_name === 'Super Admin') { + company_id = parseInt(selectedCompany) + } + data = { + name: name, + description: description, + company_id: parseInt(company_id) + } + + closeDialog('save', data); + } else { + + if (role_name === 'Super Admin') { + company_id = parseInt(selectedCompany) + } + data = { + id, + name: name, + description: description, + company_id: parseInt(company_id) + } + closeDialog('edit', data); + } + setId(0) + setDescription('') + setSelectedCompany(null) + + } + + const handleCancel = () => { + closeDialog('cancel', 'none') + setId(0) + setDescription('') + setSelectedCompany(null) + } + + const onChangeCompany = (val) => { + setSelectedCompany(val); + }; + + const renderForm = () => { + return ( +
+ + + + + setName(e.target.value)} placeholder={t('inputName')} /> + + + + + + setDescription(e.target.value)} placeholder={t('inputDescription')} /> + + + + {role_name === 'Super Admin' && + + + + + + + + + } +
+ ) + } + + + return ( + <> + + {typeDialog == "Save" ? `Add` : "Edit"} {'uom'} + + {renderForm()} + + + {' '} + + + + + ) + +} + +export default DialogForm; diff --git a/src/views/SimproV2/Satuan/index.js b/src/views/SimproV2/Satuan/index.js index fae6018..ab81794 100644 --- a/src/views/SimproV2/Satuan/index.js +++ b/src/views/SimproV2/Satuan/index.js @@ -116,7 +116,7 @@ const Satuan = ({ params, ...props }) => { if (role_name !== "Super Admin") { payload.columns.push( - { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, + { "name": "company_id", "logic_operator": "=", "value": parseInt(company_id), "operator": "AND" }, ) } else { payload.columns.push(