diff --git a/src/views/Master/MasterMenu/DialogForm.js b/src/views/Master/MenuCompany/DialogForm.js similarity index 77% rename from src/views/Master/MasterMenu/DialogForm.js rename to src/views/Master/MenuCompany/DialogForm.js index be33f53..e9cbc50 100644 --- a/src/views/Master/MasterMenu/DialogForm.js +++ b/src/views/Master/MenuCompany/DialogForm.js @@ -7,7 +7,7 @@ import 'antd/dist/antd.css'; import { useTranslation } from 'react-i18next'; const { Option } = Select -const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, dataMenu }) => { +const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, dataMenu, listCompany, role_name, company_id }) => { const [id, setId] = useState(0) const [name, setName] = useState('') const [url, setUrl] = useState('') @@ -15,17 +15,19 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi const [icon, setIcon] = useState('') const [sequence, setSequence] = useState(0) const [parentId, setParentId] = useState(null) + const [selectedCompany, setSelectedCompany] = useState(null) const { t } = useTranslation() useEffect(() => { if (typeDialog === "Edit") { setId(dataEdit.id) - setName(dataEdit.name) + setName(dataEdit.join_first_name) setUrl(dataEdit.url) setIcon(dataEdit.icon) - setParentId(dataEdit.parent_id) + setParentId(dataEdit.parent_menu_id) setSequence(dataEdit.sequence) setAliasName(dataEdit.alias_name) + setSelectedCompany(dataEdit.company_id) } else { setId(0) setName('') @@ -61,12 +63,16 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi const err = validation(); if (!err) { if (typeDialog === "Save") { + if (role_name === 'Super Admin') { + company_id = selectedCompany + } data = { name, url, sequence: parseInt(sequence), icon, alias_name: aliasName, + company_id: company_id } if (parentId && parentId > 0) { @@ -75,6 +81,9 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi closeDialog('save', data); } else { + if (role_name === 'Super Admin') { + company_id = selectedCompany + } data = { id, name, @@ -82,12 +91,12 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi sequence: parseInt(sequence), icon, alias_name: aliasName, + company_id: company_id } if (parentId && parentId > 0) { data['parent_id'] = parentId } - closeDialog('edit', data); } setId(0) @@ -127,6 +136,10 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi ) } + const onChangeCompany = (val) => { + setSelectedCompany(val); + }; + const renderForm = () => { return (