|
|
@ -3,7 +3,7 @@ import { |
|
|
|
Modal, ModalHeader, ModalBody, ModalFooter, |
|
|
|
Modal, ModalHeader, ModalBody, ModalFooter, |
|
|
|
Button, Form, FormGroup, Row, Col, Label, Input, |
|
|
|
Button, Form, FormGroup, Row, Col, Label, Input, |
|
|
|
} from 'reactstrap'; |
|
|
|
} from 'reactstrap'; |
|
|
|
import { Pagination, Table, Tooltip, Select } from 'antd'; |
|
|
|
import { Pagination, Table, Tooltip, Select, Spin } from 'antd'; |
|
|
|
import SweetAlert from 'react-bootstrap-sweetalert'; |
|
|
|
import SweetAlert from 'react-bootstrap-sweetalert'; |
|
|
|
import { NotificationContainer, NotificationManager } from 'react-notifications'; |
|
|
|
import { NotificationContainer, NotificationManager } from 'react-notifications'; |
|
|
|
import DialogFormUser from './FormUser'; |
|
|
|
import DialogFormUser from './FormUser'; |
|
|
@ -12,7 +12,7 @@ import 'antd/dist/antd.css'; |
|
|
|
import { useTranslation } from 'react-i18next'; |
|
|
|
import { useTranslation } from 'react-i18next'; |
|
|
|
import axios from "../../../const/interceptorApi" |
|
|
|
import axios from "../../../const/interceptorApi" |
|
|
|
import { |
|
|
|
import { |
|
|
|
USER_SEARCH, USER_EDIT, USER_DELETE, ROLE_SEARCH, DIVISI_SEARCH, MENU_COMPANY_SEARCH |
|
|
|
USER_SEARCH, MENU_COMPANY_DELETE, USER_DELETE, ROLE_SEARCH, COMPANY_MANAGEMENT_GET_ID, MENU_COMPANY_SEARCH |
|
|
|
} from '../../../const/ApiConst'; |
|
|
|
} from '../../../const/ApiConst'; |
|
|
|
const token = window.localStorage.getItem('token'); |
|
|
|
const token = window.localStorage.getItem('token'); |
|
|
|
const config = { |
|
|
|
const config = { |
|
|
@ -22,7 +22,7 @@ const config = { |
|
|
|
"Content-type": `application/json` |
|
|
|
"Content-type": `application/json` |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, companyID, companyNameProp }) => { |
|
|
|
const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, companyID, companyNameProp, dataEditCompany, imageHeader, imageFavIcon, imageLogin, lastIdCompany }) => { |
|
|
|
const { Option } = Select |
|
|
|
const { Option } = Select |
|
|
|
const { t } = useTranslation() |
|
|
|
const { t } = useTranslation() |
|
|
|
const [registrationnumber, setRegistrationNumber] = useState('') |
|
|
|
const [registrationnumber, setRegistrationNumber] = useState('') |
|
|
@ -31,9 +31,9 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
const [phoneNumber, setPhoneNumber] = useState('') |
|
|
|
const [phoneNumber, setPhoneNumber] = useState('') |
|
|
|
const [emailCompany, setEmailCompany] = useState('') |
|
|
|
const [emailCompany, setEmailCompany] = useState('') |
|
|
|
const [description, setDescription] = useState('') |
|
|
|
const [description, setDescription] = useState('') |
|
|
|
const [logoLogin, setLogoLogin] = useState([]) |
|
|
|
const [logoLogin, setLogoLogin] = useState(null) |
|
|
|
const [logoHeader, setLogoHeader] = useState([]) |
|
|
|
const [logoHeader, setLogoHeader] = useState(null) |
|
|
|
const [favIcon, setFavIcon] = useState([]) |
|
|
|
const [favIcon, setFavIcon] = useState(null) |
|
|
|
const [loginInstruction, setLoginInstruction] = useState('') |
|
|
|
const [loginInstruction, setLoginInstruction] = useState('') |
|
|
|
const [about, setAbout] = useState('') |
|
|
|
const [about, setAbout] = useState('') |
|
|
|
const [htmlTitle, setHtmlTitle] = useState('') |
|
|
|
const [htmlTitle, setHtmlTitle] = useState('') |
|
|
@ -42,7 +42,8 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
const [statusCompany, setStatusCompany] = useState(true) |
|
|
|
const [statusCompany, setStatusCompany] = useState(true) |
|
|
|
const [template, setTemplate] = useState('') |
|
|
|
const [template, setTemplate] = useState('') |
|
|
|
const [lastIdxURL, setLastIdxURL] = useState(0); |
|
|
|
const [lastIdxURL, setLastIdxURL] = useState(0); |
|
|
|
|
|
|
|
const [availableUrl, setAvailableBaseUrl] = useState(false); |
|
|
|
|
|
|
|
const [id, setId] = useState(0) |
|
|
|
|
|
|
|
|
|
|
|
const [dataTable, setDatatable] = useState([]) |
|
|
|
const [dataTable, setDatatable] = useState([]) |
|
|
|
const [openDialogUser, setOpenDialogUser] = useState(false) |
|
|
|
const [openDialogUser, setOpenDialogUser] = useState(false) |
|
|
@ -63,15 +64,57 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
const [totalPageMenu, setTotalPageMenu] = useState(0) |
|
|
|
const [totalPageMenu, setTotalPageMenu] = useState(0) |
|
|
|
const [openDialogMenu, setOpenDialogMenu] = useState(false) |
|
|
|
const [openDialogMenu, setOpenDialogMenu] = useState(false) |
|
|
|
const [typeDialogMenu, setTypeDialogMenu] = useState("add") |
|
|
|
const [typeDialogMenu, setTypeDialogMenu] = useState("add") |
|
|
|
|
|
|
|
const [loading, setLoading] = useState(true); |
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
if (companyID && typeDialog === 'Set') { |
|
|
|
if (companyID && typeDialog === 'Set') { |
|
|
|
|
|
|
|
setLoading(true) |
|
|
|
getDataUser() |
|
|
|
getDataUser() |
|
|
|
getRoleList() |
|
|
|
getRoleList() |
|
|
|
} else { |
|
|
|
} else if(typeDialog === 'Set-Menu') { |
|
|
|
|
|
|
|
setLoading(true) |
|
|
|
getDataMenu() |
|
|
|
getDataMenu() |
|
|
|
|
|
|
|
} else if(lastIdCompany && typeDialog === 'Save'){ |
|
|
|
|
|
|
|
getLastCompany() |
|
|
|
} |
|
|
|
} |
|
|
|
}, [typeDialog, companyID, rowsPerPage, currentPage, rowsPerPageMenu, currentPageMenu]) |
|
|
|
},[typeDialog, companyID, lastIdCompany, rowsPerPage, currentPage, rowsPerPageMenu, currentPageMenu]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(()=> { |
|
|
|
|
|
|
|
if(typeDialog==="Edit"){ |
|
|
|
|
|
|
|
setId(dataEditCompany.id) |
|
|
|
|
|
|
|
setRegistrationNumber(dataEditCompany.registration_no) |
|
|
|
|
|
|
|
setCompanyName(dataEditCompany.company_name) |
|
|
|
|
|
|
|
setEmailCompany(dataEditCompany.email) |
|
|
|
|
|
|
|
setPhoneNumber(dataEditCompany.phone_no) |
|
|
|
|
|
|
|
setAddressCompany(dataEditCompany.address) |
|
|
|
|
|
|
|
setAbout(dataEditCompany.about) |
|
|
|
|
|
|
|
setAppName(dataEditCompany.app_name) |
|
|
|
|
|
|
|
setHtmlTitle(dataEditCompany.html_title) |
|
|
|
|
|
|
|
setStatusCompany(dataEditCompany.is_active) |
|
|
|
|
|
|
|
setTemplate(dataEditCompany.template_id) |
|
|
|
|
|
|
|
setBaseUrl(dataEditCompany.base_url ? dataEditCompany.base_url : []) |
|
|
|
|
|
|
|
if(dataEditCompany.base_url) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
setAvailableBaseUrl(true) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
setAvailableBaseUrl(false) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
setId(0) |
|
|
|
|
|
|
|
setCompanyName('') |
|
|
|
|
|
|
|
setEmailCompany('') |
|
|
|
|
|
|
|
setPhoneNumber('') |
|
|
|
|
|
|
|
setAddressCompany('') |
|
|
|
|
|
|
|
setAbout('') |
|
|
|
|
|
|
|
setAppName('') |
|
|
|
|
|
|
|
setHtmlTitle('') |
|
|
|
|
|
|
|
setStatusCompany('') |
|
|
|
|
|
|
|
setTemplate('') |
|
|
|
|
|
|
|
setLogoLogin(null) |
|
|
|
|
|
|
|
setLogoHeader(null) |
|
|
|
|
|
|
|
setFavIcon(null) |
|
|
|
|
|
|
|
setBaseUrl([]) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
},[dataEditCompany,openDialog]) |
|
|
|
|
|
|
|
|
|
|
|
const onShowSizeChange = (current, pageSize) => { |
|
|
|
const onShowSizeChange = (current, pageSize) => { |
|
|
|
setRowsPerPage(pageSize) |
|
|
|
setRowsPerPage(pageSize) |
|
|
@ -94,13 +137,12 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
|
|
|
|
|
|
|
|
"orders": { "columns": ["id"], "ascending": false } |
|
|
|
"orders": { "columns": ["id"], "ascending": false } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const result = await axios |
|
|
|
const result = await axios |
|
|
|
.post(ROLE_SEARCH, formData, config) |
|
|
|
.post(ROLE_SEARCH, formData, 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) { |
|
|
|
|
|
|
|
setLoading(false) |
|
|
|
setRoleList(result.data.data); |
|
|
|
setRoleList(result.data.data); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -204,7 +246,9 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
setDatatable(result.data.data); |
|
|
|
setDatatable(result.data.data); |
|
|
|
setTotalPage(result.data.totalRecord); |
|
|
|
setTotalPage(result.data.totalRecord); |
|
|
|
|
|
|
|
setLoading(false) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
setLoading(false) |
|
|
|
NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); |
|
|
|
NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -212,14 +256,14 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
const getDataMenu = async () => { |
|
|
|
const getDataMenu = async () => { |
|
|
|
let start = 0; |
|
|
|
let start = 0; |
|
|
|
|
|
|
|
|
|
|
|
if (currentPage !== 1 && currentPage > 1) { |
|
|
|
if (currentPageMenu !== 1 && currentPageMenu > 1) { |
|
|
|
start = (currentPage * rowsPerPage) - rowsPerPage |
|
|
|
start = (currentPageMenu * rowsPerPageMenu) - rowsPerPageMenu |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const payload = { |
|
|
|
const payload = { |
|
|
|
"paging": { |
|
|
|
"paging": { |
|
|
|
"start": start, |
|
|
|
"start": start, |
|
|
|
"length": rowsPerPage |
|
|
|
"length": rowsPerPageMenu |
|
|
|
}, |
|
|
|
}, |
|
|
|
"columns": [{ |
|
|
|
"columns": [{ |
|
|
|
"name": "company_id", |
|
|
|
"name": "company_id", |
|
|
@ -245,11 +289,24 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
setDatatableMenu(result.data.data); |
|
|
|
setDatatableMenu(result.data.data); |
|
|
|
setTotalPageMenu(result.data.totalRecord); |
|
|
|
setTotalPageMenu(result.data.totalRecord); |
|
|
|
|
|
|
|
setLoading(false) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
setLoading(false) |
|
|
|
NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); |
|
|
|
NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getLastCompany = async () => { |
|
|
|
|
|
|
|
const result = await axios |
|
|
|
|
|
|
|
.get(`${COMPANY_MANAGEMENT_GET_ID(lastIdCompany)}`, config) |
|
|
|
|
|
|
|
.then((res) => res) |
|
|
|
|
|
|
|
.catch((err) => err.response); |
|
|
|
|
|
|
|
const lastRegistrationNumber = result.data.data.registration_no; |
|
|
|
|
|
|
|
const lastNumber = parseInt(lastRegistrationNumber.match(/\d+$/)[0]); |
|
|
|
|
|
|
|
const newNumber = lastNumber + 1; |
|
|
|
|
|
|
|
const newRegistrationNumber = `RG-${newNumber}`; |
|
|
|
|
|
|
|
setRegistrationNumber(newRegistrationNumber); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const handleAddUser = async () => { |
|
|
|
const handleAddUser = async () => { |
|
|
|
await setTypeDialogUser("Save") |
|
|
|
await setTypeDialogUser("Save") |
|
|
@ -271,7 +328,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
if (type == 'success') { |
|
|
|
if (type == 'success') { |
|
|
|
NotificationManager.success(`${message}`, "Success!!"); |
|
|
|
NotificationManager.success(`${message}`, "Success!!"); |
|
|
|
getDataUser() |
|
|
|
getDataUser() |
|
|
|
} else if (type == 'Failed') { |
|
|
|
} else if (type == 'failed') { |
|
|
|
NotificationManager.error(`${message}`, "Failed!!"); |
|
|
|
NotificationManager.error(`${message}`, "Failed!!"); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
@ -297,7 +354,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
if (type == 'success') { |
|
|
|
if (type == 'success') { |
|
|
|
NotificationManager.success(`${message}`, "Success!!"); |
|
|
|
NotificationManager.success(`${message}`, "Success!!"); |
|
|
|
getDataMenu() |
|
|
|
getDataMenu() |
|
|
|
} else if (type == 'Failed') { |
|
|
|
} else if (type == 'failed') { |
|
|
|
NotificationManager.error(`${message}`, "Failed!!"); |
|
|
|
NotificationManager.error(`${message}`, "Failed!!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -323,68 +380,41 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
phone_no: phoneNumber, |
|
|
|
phone_no: phoneNumber, |
|
|
|
email: emailCompany, |
|
|
|
email: emailCompany, |
|
|
|
description: description, |
|
|
|
description: description, |
|
|
|
logo_login: logoLogin, |
|
|
|
|
|
|
|
logo_header: logoHeader, |
|
|
|
|
|
|
|
favicon_image: favIcon, |
|
|
|
|
|
|
|
login_instruction: loginInstruction, |
|
|
|
login_instruction: loginInstruction, |
|
|
|
about: about, |
|
|
|
about: about, |
|
|
|
html_title: htmlTitle, |
|
|
|
html_title: htmlTitle, |
|
|
|
app_name: appName, |
|
|
|
app_name: appName, |
|
|
|
base_url: baseUrl, |
|
|
|
base_url: baseUrl.length == 0 ? null : baseUrl, |
|
|
|
is_active: statusCompany, |
|
|
|
is_active: statusCompany, |
|
|
|
template_id: template |
|
|
|
template_id: parseInt(template) |
|
|
|
} |
|
|
|
} |
|
|
|
console.log(data) |
|
|
|
data.imageLogin = logoLogin ? logoLogin : null; |
|
|
|
|
|
|
|
data.imageHeader = logoHeader ? logoHeader : null; |
|
|
|
|
|
|
|
data.imageFavicon = favIcon ? favIcon : null; |
|
|
|
closeDialog('save', data); |
|
|
|
closeDialog('save', data); |
|
|
|
} else if (typeDialog === "Set") { |
|
|
|
setLoading(false); |
|
|
|
// if (!password && password === "") {
|
|
|
|
} else if (typeDialog === "Edit") { |
|
|
|
// alert("Please fill password");
|
|
|
|
data = { |
|
|
|
// return;
|
|
|
|
id, |
|
|
|
// }
|
|
|
|
registration_no: registrationnumber, |
|
|
|
// if (password !== retryPassword) {
|
|
|
|
company_name: companyName, |
|
|
|
// alert("Password doesn't match");
|
|
|
|
address: addressCompany, |
|
|
|
// return;
|
|
|
|
phone_no: phoneNumber, |
|
|
|
// }
|
|
|
|
email: emailCompany, |
|
|
|
// if (password.length < 8) {
|
|
|
|
description: description, |
|
|
|
// alert("Password minimum 8 character");
|
|
|
|
login_instruction: loginInstruction, |
|
|
|
// return;
|
|
|
|
about: about, |
|
|
|
// }
|
|
|
|
html_title: htmlTitle, |
|
|
|
// data = {
|
|
|
|
app_name: appName, |
|
|
|
// id,
|
|
|
|
base_url: baseUrl.length == 0 ? null : baseUrl, |
|
|
|
// username,
|
|
|
|
is_active: statusCompany, |
|
|
|
// password,
|
|
|
|
template_id: parseInt(template), |
|
|
|
// email,
|
|
|
|
} |
|
|
|
// }
|
|
|
|
data.imageLogin = logoLogin ? logoLogin : null; |
|
|
|
|
|
|
|
data.imageHeader = logoHeader ? logoHeader : null; |
|
|
|
closeDialog('edit', data); |
|
|
|
data.imageFavicon = favIcon ? favIcon : null; |
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// data = {
|
|
|
|
|
|
|
|
// id,
|
|
|
|
|
|
|
|
// name: resourceName,
|
|
|
|
|
|
|
|
// username,
|
|
|
|
|
|
|
|
// employee_type: employeeType,
|
|
|
|
|
|
|
|
// phone_number: phoneNo,
|
|
|
|
|
|
|
|
// email,
|
|
|
|
|
|
|
|
// gender,
|
|
|
|
|
|
|
|
// birth_place: birthPlace,
|
|
|
|
|
|
|
|
// blood_type: bloodType,
|
|
|
|
|
|
|
|
// ktp_number: ktpNumber,
|
|
|
|
|
|
|
|
// biaya_per_jam: biayaPerJam.replace('.', ''),
|
|
|
|
|
|
|
|
// role_id: roleId,
|
|
|
|
|
|
|
|
// divisi_id: divisionId,
|
|
|
|
|
|
|
|
// address,
|
|
|
|
|
|
|
|
// status_resource: statusResource,
|
|
|
|
|
|
|
|
// status_boundary: statusRestriction,
|
|
|
|
|
|
|
|
// company_id: company_id
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (birthDate && birthDate != "") {
|
|
|
|
|
|
|
|
// data['birth_date'] = birthDate;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
closeDialog('edit', data); |
|
|
|
closeDialog('edit', data); |
|
|
|
|
|
|
|
setLoading(false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -395,27 +425,45 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
|
|
|
|
|
|
|
|
const handleCancel = () => { |
|
|
|
const handleCancel = () => { |
|
|
|
closeDialog('cancel', 'none') |
|
|
|
closeDialog('cancel', 'none') |
|
|
|
setDatatable([]) |
|
|
|
setDatatable([]); |
|
|
|
|
|
|
|
setBaseUrl([]); |
|
|
|
|
|
|
|
setAvailableBaseUrl(false); |
|
|
|
|
|
|
|
setLoading(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const onConfirmDelete = async () => { |
|
|
|
const onConfirmDelete = async () => { |
|
|
|
let url = USER_DELETE(idDelete); |
|
|
|
let url; |
|
|
|
|
|
|
|
if(typeDialog === "Set-Menu") { |
|
|
|
|
|
|
|
url = MENU_COMPANY_DELETE(idDelete); |
|
|
|
|
|
|
|
} else if(typeDialog === "Set") { |
|
|
|
|
|
|
|
url = USER_DELETE(idDelete); |
|
|
|
|
|
|
|
} |
|
|
|
const result = await axios.delete(url, config) |
|
|
|
const result = await axios.delete(url, 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) { |
|
|
|
getDataUser() |
|
|
|
setIdDelete(0); |
|
|
|
setIdDelete(0) |
|
|
|
setAlertDelete(false); |
|
|
|
setAlertDelete(false) |
|
|
|
setLoading(false); |
|
|
|
|
|
|
|
if (typeDialog === "Set-Menu") { |
|
|
|
|
|
|
|
getDataMenu(); |
|
|
|
|
|
|
|
NotificationManager.success(`Data menu berhasil dihapus!`, 'Success!!'); |
|
|
|
|
|
|
|
} else if (typeDialog === "Set") { |
|
|
|
|
|
|
|
getDataUser(); |
|
|
|
NotificationManager.success(`Data user berhasil dihapus!`, 'Success!!'); |
|
|
|
NotificationManager.success(`Data user berhasil dihapus!`, 'Success!!'); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
setIdDelete(0) |
|
|
|
setIdDelete(0) |
|
|
|
setAlertDelete(false) |
|
|
|
setAlertDelete(false) |
|
|
|
|
|
|
|
setLoading(false); |
|
|
|
|
|
|
|
if (typeDialog === "Set-Menu") { |
|
|
|
|
|
|
|
NotificationManager.success(`Data menu gagal dihapus!`, 'Success!!'); |
|
|
|
|
|
|
|
} else if (typeDialog === "Set") { |
|
|
|
NotificationManager.error(`Data user gagal dihapus!`, 'Failed!!'); |
|
|
|
NotificationManager.error(`Data user gagal dihapus!`, 'Failed!!'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const cancelDelete = () => { |
|
|
|
const cancelDelete = () => { |
|
|
|
setAlertDelete(false) |
|
|
|
setAlertDelete(false) |
|
|
@ -423,22 +471,48 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const addBaseUrl = () => { |
|
|
|
const addBaseUrl = () => { |
|
|
|
|
|
|
|
if (availableUrl === true) { |
|
|
|
|
|
|
|
const baseUrlArray = JSON.parse(baseUrl); |
|
|
|
|
|
|
|
baseUrlArray.push({ |
|
|
|
|
|
|
|
id: lastIdxURL + 1, |
|
|
|
|
|
|
|
base_url: "", |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
setBaseUrl(JSON.stringify(baseUrlArray)); |
|
|
|
|
|
|
|
setLastIdxURL(lastIdxURL + 1); |
|
|
|
|
|
|
|
} else { |
|
|
|
baseUrl.push({ |
|
|
|
baseUrl.push({ |
|
|
|
id: lastIdxURL + 1, |
|
|
|
id: lastIdxURL + 1, |
|
|
|
url: "", |
|
|
|
base_url: "", |
|
|
|
}); |
|
|
|
}); |
|
|
|
setBaseUrl(baseUrl); |
|
|
|
setBaseUrl(baseUrl); |
|
|
|
setLastIdxURL(lastIdxURL + 1); |
|
|
|
setLastIdxURL(lastIdxURL + 1); |
|
|
|
|
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const handleChangeBaseURL = (value, index) => { |
|
|
|
const handleChangeBaseURL = (e, index) => { |
|
|
|
|
|
|
|
if (availableUrl === true) { |
|
|
|
|
|
|
|
const { name, value } = e.target; |
|
|
|
|
|
|
|
const newBaseURL = [...JSON.parse(baseUrl)]; |
|
|
|
|
|
|
|
newBaseURL[index][name] = value; |
|
|
|
|
|
|
|
setBaseUrl(JSON.stringify(newBaseURL)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
const { name, value } = e.target; |
|
|
|
const newBaseURL = [...baseUrl]; |
|
|
|
const newBaseURL = [...baseUrl]; |
|
|
|
newBaseURL[index] = value; |
|
|
|
newBaseURL[index][name] = value; |
|
|
|
setBaseUrl(newBaseURL); |
|
|
|
setBaseUrl(newBaseURL); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const deleteBaseURL = (id) => { |
|
|
|
const deleteBaseURL = (id) => { |
|
|
|
if (baseUrl && baseUrl.length > 0) { |
|
|
|
if (availableUrl === true) { |
|
|
|
|
|
|
|
const baseUrlArray = JSON.parse(baseUrl); |
|
|
|
|
|
|
|
let checkIdx = baseUrlArray.findIndex((o) => o.id === id); |
|
|
|
|
|
|
|
if (checkIdx > -1) { |
|
|
|
|
|
|
|
baseUrlArray.splice(checkIdx, 1); |
|
|
|
|
|
|
|
const baseFilter = baseUrlArray.filter((i2) => i2 !== id); |
|
|
|
|
|
|
|
setBaseUrl(JSON.stringify(baseFilter)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
let checkIdx = baseUrl.findIndex((o) => o.id === id); |
|
|
|
let checkIdx = baseUrl.findIndex((o) => o.id === id); |
|
|
|
if (checkIdx > -1) { |
|
|
|
if (checkIdx > -1) { |
|
|
|
baseUrl.splice(checkIdx, 1); |
|
|
|
baseUrl.splice(checkIdx, 1); |
|
|
@ -447,24 +521,22 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const handleLogoHeader = (content) => { |
|
|
|
|
|
|
|
const newLogoHeader = [...logoHeader, { |
|
|
|
|
|
|
|
type: "image", |
|
|
|
|
|
|
|
content: content, |
|
|
|
|
|
|
|
}]; |
|
|
|
|
|
|
|
setLogoHeader(newLogoHeader); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const RenderBaseURL = () => { |
|
|
|
const RenderBaseURL = () => { |
|
|
|
if (baseUrl.length > 0) { |
|
|
|
if (baseUrl.length > 0) { |
|
|
|
return baseUrl.map((item, index) => { |
|
|
|
let baseUrlArray; |
|
|
|
|
|
|
|
if(availableUrl === true) { |
|
|
|
|
|
|
|
baseUrlArray = JSON.parse(baseUrl); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
baseUrlArray = baseUrl; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return baseUrlArray.map((item, index) => { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<Row key={index} style={{ marginBottom: 10 }}> |
|
|
|
<Row key={index} style={{ marginBottom: 10 }}> |
|
|
|
<Col md={8}> |
|
|
|
<Col md={8}> |
|
|
|
<Input |
|
|
|
<Input |
|
|
|
type="text" |
|
|
|
type="text" |
|
|
|
value={item.url} |
|
|
|
value={availableUrl === true ? item.base_url ? item.base_url : "" : item.base_url ? item.base_url : "" } |
|
|
|
name="item" |
|
|
|
name="base_url" |
|
|
|
onChange={(e) => handleChangeBaseURL(e, index)} |
|
|
|
onChange={(e) => handleChangeBaseURL(e, index)} |
|
|
|
/> |
|
|
|
/> |
|
|
|
</Col> |
|
|
|
</Col> |
|
|
@ -472,7 +544,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
<Button |
|
|
|
<Button |
|
|
|
color="danger" |
|
|
|
color="danger" |
|
|
|
size="sm" |
|
|
|
size="sm" |
|
|
|
onClick={() => deleteBaseURL(item.id)} |
|
|
|
onClick={() => deleteBaseURL(availableUrl === true ? item.id ? item.id : "" : item.id ? item.id : "")} |
|
|
|
> |
|
|
|
> |
|
|
|
<i className="fa fa-trash"></i> |
|
|
|
<i className="fa fa-trash"></i> |
|
|
|
</Button> |
|
|
|
</Button> |
|
|
@ -502,14 +574,14 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
<Form> |
|
|
|
<Form> |
|
|
|
<Row> |
|
|
|
<Row> |
|
|
|
<Col md={12}> |
|
|
|
<Col md={12}> |
|
|
|
<span style={{ color: "red" }}>*</span>required. |
|
|
|
<span style={{ color: "red" }}>*</span>Is Required |
|
|
|
</Col> |
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
</Row> |
|
|
|
<Row> |
|
|
|
<Row> |
|
|
|
<Col md={6}> |
|
|
|
<Col md={6}> |
|
|
|
<FormGroup> |
|
|
|
<FormGroup> |
|
|
|
<Label className="capitalize">Number Registration<span style={{ color: "red" }}>*</span></Label> |
|
|
|
<Label className="capitalize">Number Registration<span style={{ color: "red" }}>*</span></Label> |
|
|
|
<Input type="text" value={registrationnumber} onChange={(e) => setRegistrationNumber(e.target.value)} placeholder='Input Number Registration' /> |
|
|
|
<Input type="text" value={registrationnumber} readOnly disabled /> |
|
|
|
</FormGroup> |
|
|
|
</FormGroup> |
|
|
|
</Col> |
|
|
|
</Col> |
|
|
|
<Col md={6}> |
|
|
|
<Col md={6}> |
|
|
@ -581,8 +653,8 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
<FormGroup> |
|
|
|
<FormGroup> |
|
|
|
<Label className="capitalize">Template Application<span style={{ color: "red" }}>*</span></Label> |
|
|
|
<Label className="capitalize">Template Application<span style={{ color: "red" }}>*</span></Label> |
|
|
|
<Select style={{ width: "100%" }} defaultValue={template} onChange={(e) => setTemplate(e)} placeholder="Select a template for application"> |
|
|
|
<Select style={{ width: "100%" }} defaultValue={template} onChange={(e) => setTemplate(e)} placeholder="Select a template for application"> |
|
|
|
<Option value={'1'}>Construction</Option> |
|
|
|
<Option value={1}>Construction</Option> |
|
|
|
<Option value={'2'}>IT (Information AND Technology)</Option> |
|
|
|
{/* <Option value={2}>IT (Information AND Technology)</Option> */} |
|
|
|
</Select> |
|
|
|
</Select> |
|
|
|
</FormGroup> |
|
|
|
</FormGroup> |
|
|
|
</Col> |
|
|
|
</Col> |
|
|
@ -620,8 +692,9 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
<Input |
|
|
|
<Input |
|
|
|
type="file" |
|
|
|
type="file" |
|
|
|
accept="image/*" |
|
|
|
accept="image/*" |
|
|
|
// onChange={(e) => handleLogoHeader(e.target.files[0])}
|
|
|
|
onChange={(e) => setLogoLogin(e.target.files[0])} |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
<small>{imageLogin ? imageLogin.image : <p style={{ color: "red" }}>Not found image</p> }</small> |
|
|
|
</FormGroup> |
|
|
|
</FormGroup> |
|
|
|
</Row> |
|
|
|
</Row> |
|
|
|
<Row> |
|
|
|
<Row> |
|
|
@ -630,18 +703,20 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
<Input |
|
|
|
<Input |
|
|
|
type="file" |
|
|
|
type="file" |
|
|
|
accept="image/*" |
|
|
|
accept="image/*" |
|
|
|
onChange={(e) => handleLogoHeader(e.target.files[0])} |
|
|
|
onChange={(e) => setLogoHeader(e.target.files[0])} |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
<small>{imageHeader ? imageHeader.image : <p style={{ color: "red" }}>Not found image</p> }</small> |
|
|
|
</FormGroup> |
|
|
|
</FormGroup> |
|
|
|
</Row> |
|
|
|
</Row> |
|
|
|
<Row> |
|
|
|
<Row> |
|
|
|
<FormGroup> |
|
|
|
<FormGroup> |
|
|
|
<Label className="capitalize" style={{ fontWeight: "bold" }}>Fav Icon Logo</Label> |
|
|
|
<Label className="capitalize" style={{ fontWeight: "bold" }}>Favicon Logo</Label> |
|
|
|
<Input |
|
|
|
<Input |
|
|
|
type="file" |
|
|
|
type="file" |
|
|
|
accept="image/*" |
|
|
|
accept=".ico" |
|
|
|
// onChange={(e) => setProjectStructureOrg(e.target.files[0])}
|
|
|
|
onChange={(e) => setFavIcon(e.target.files[0])} |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
<small>{imageFavIcon ? imageFavIcon.image : <p style={{ color: "red" }}>Not found image</p> }</small> |
|
|
|
</FormGroup> |
|
|
|
</FormGroup> |
|
|
|
</Row> |
|
|
|
</Row> |
|
|
|
</Col> |
|
|
|
</Col> |
|
|
@ -714,7 +789,6 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
{ title: t('icon'), dataIndex: 'icon', key: 'icon' }, |
|
|
|
{ title: t('icon'), dataIndex: 'icon', key: 'icon' }, |
|
|
|
{ title: 'Alias', dataIndex: 'alias_name', key: 'alias_name' }, |
|
|
|
{ title: 'Alias', dataIndex: 'alias_name', key: 'alias_name' }, |
|
|
|
{ title: t('order'), dataIndex: 'sequence', key: 'sequence' }, |
|
|
|
{ title: t('order'), dataIndex: 'sequence', key: 'sequence' }, |
|
|
|
{ title: t('parentMenu'), dataIndex: 'join_first_name', key: 'join_first_name', render: (text, record) => (text ? text : "-") } |
|
|
|
|
|
|
|
]; |
|
|
|
]; |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<Table |
|
|
|
<Table |
|
|
@ -767,6 +841,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
<Button onClick={handleAddUser} size='sm' color="primary"><i className='fa fa-plus'></i></Button> |
|
|
|
<Button onClick={handleAddUser} size='sm' color="primary"><i className='fa fa-plus'></i></Button> |
|
|
|
</Tooltip> |
|
|
|
</Tooltip> |
|
|
|
) : |
|
|
|
) : |
|
|
|
|
|
|
|
typeDialog != "Save" && typeDialog != "Edit" && |
|
|
|
( |
|
|
|
( |
|
|
|
<Tooltip title="Add Menu"> |
|
|
|
<Tooltip title="Add Menu"> |
|
|
|
<Button onClick={handleAddMenu} size='sm' color="primary"><i className='fa fa-plus'></i></Button> |
|
|
|
<Button onClick={handleAddMenu} size='sm' color="primary"><i className='fa fa-plus'></i></Button> |
|
|
@ -778,6 +853,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
{typeDialog !== "Set" && typeDialog !== "Set-Menu" && renderFromCompany()} |
|
|
|
{typeDialog !== "Set" && typeDialog !== "Set-Menu" && renderFromCompany()} |
|
|
|
{typeDialog === "Set" && ( |
|
|
|
{typeDialog === "Set" && ( |
|
|
|
<> |
|
|
|
<> |
|
|
|
|
|
|
|
<Spin tip="Loading..." spinning={loading}> |
|
|
|
{RenderTableUser} |
|
|
|
{RenderTableUser} |
|
|
|
<Pagination |
|
|
|
<Pagination |
|
|
|
style={{ marginTop: "25px" }} |
|
|
|
style={{ marginTop: "25px" }} |
|
|
@ -789,10 +865,12 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
pageSize={rowsPerPage} |
|
|
|
pageSize={rowsPerPage} |
|
|
|
current={currentPage} |
|
|
|
current={currentPage} |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
</Spin> |
|
|
|
</> |
|
|
|
</> |
|
|
|
)} |
|
|
|
)} |
|
|
|
{typeDialog === "Set-Menu" && ( |
|
|
|
{typeDialog === "Set-Menu" && ( |
|
|
|
<> |
|
|
|
<> |
|
|
|
|
|
|
|
<Spin tip="Loading..." spinning={loading}> |
|
|
|
{renderTableMenu} |
|
|
|
{renderTableMenu} |
|
|
|
<Pagination |
|
|
|
<Pagination |
|
|
|
style={{ marginTop: "25px" }} |
|
|
|
style={{ marginTop: "25px" }} |
|
|
@ -804,6 +882,7 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, company |
|
|
|
pageSize={rowsPerPageMenu} |
|
|
|
pageSize={rowsPerPageMenu} |
|
|
|
current={currentPageMenu} |
|
|
|
current={currentPageMenu} |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
</Spin> |
|
|
|
</> |
|
|
|
</> |
|
|
|
)} |
|
|
|
)} |
|
|
|
|
|
|
|
|
|
|
|