From 9c92502dbc823b7cb751f4342e68b929f6e83129 Mon Sep 17 00:00:00 2001 From: wahyuun Date: Fri, 23 Feb 2024 13:47:10 +0700 Subject: [PATCH] ignore super admin --- src/views/Master/MasterCompany/index.js | 31 +++++++++++++------ .../SimproV2/CreatedProyek/DialogDocument.js | 8 +++-- .../SimproV2/CreatedProyek/FormDocument.js | 12 ++++--- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/views/Master/MasterCompany/index.js b/src/views/Master/MasterCompany/index.js index 9a06900..a7bab4f 100644 --- a/src/views/Master/MasterCompany/index.js +++ b/src/views/Master/MasterCompany/index.js @@ -20,7 +20,11 @@ const config = { const MasterCompany = ({ params }) => { const token = localStorage.getItem("token") - const company_id = localStorage.getItem("company_id") + let company_id = ''; + const role = window.localStorage.getItem('role_name'); + if(role != 'Super Admin') { + company_id = localStorage.getItem("company_id"); + } const HEADER = { headers: { "Content-Type": "application/json", @@ -53,7 +57,10 @@ const MasterCompany = ({ params }) => { const [loading, setLoading] = useState(true); const pageName = params.name; const { t } = useTranslation(); - const configApp = JSON.parse(window.localStorage.getItem('configApp')); + let configApp = ''; + if (role !== 'Super Admin') { + configApp = JSON.parse(window.localStorage.getItem('configApp')); + } useEffect(() => { setLoading(true) getDataCompany() @@ -354,7 +361,9 @@ const MasterCompany = ({ params }) => { formData.append('ref_id', id); formData.append('category', 'company_logo_header'); formData.append('files', data); - formData.append('company_name',configApp.company_name); + if(role != 'Super Admin') { + formData.append('company_name',configApp.company_name); + } await axios .post(IMAGE_UPLOAD, formData, HEADER_MULTIPART) @@ -368,7 +377,9 @@ const MasterCompany = ({ params }) => { formData.append('ref_id', id); formData.append('category', 'company_logo_login'); formData.append('files', data); - formData.append('company_name',configApp.company_name); + if(role != 'Super Admin') { + formData.append('company_name',configApp.company_name); + } await axios .post(IMAGE_UPLOAD, formData, HEADER_MULTIPART) @@ -382,7 +393,9 @@ const MasterCompany = ({ params }) => { formData.append('ref_id', id); formData.append('category', 'company_favicon'); formData.append('files', data); - formData.append('company_name',configApp.company_name); + if(role != 'Super Admin') { + formData.append('company_name',configApp.company_name); + } await axios .post(IMAGE_UPLOAD, formData, HEADER_MULTIPART) @@ -402,7 +415,7 @@ const MasterCompany = ({ params }) => { // Delete Image Function const deleteImageHeader = async (id) => { - const URL = IMAGE_DELETE(id, 'company_logo_header', company_id); + const URL = IMAGE_DELETE(id, 'company_logo_header', company_id != '' ? company_id : 'undifined'); await axios .delete(URL, HEADER) .then(res => res) @@ -411,7 +424,7 @@ const MasterCompany = ({ params }) => { }; const deleteImageLogin = async (id) => { - const URL = IMAGE_DELETE(id, 'company_logo_login', company_id); + const URL = IMAGE_DELETE(id, 'company_logo_login', company_id != '' ? company_id : 'undifined'); await axios .delete(URL, HEADER) .then(res => res) @@ -420,7 +433,7 @@ const MasterCompany = ({ params }) => { }; const deleteImageFavicon = async (id) => { - const URL = IMAGE_DELETE(id, 'company_favicon', company_id); + const URL = IMAGE_DELETE(id, 'company_favicon', company_id != '' ? company_id : 'undifined'); await axios .delete(URL, HEADER) .then(res => res) @@ -429,7 +442,7 @@ const MasterCompany = ({ params }) => { }; const deleteImageSlider = async (id) => { - const URL = IMAGE_MULTIPLE_DELETE(id, 'company_slider_login', company_id); + const URL = IMAGE_MULTIPLE_DELETE(id, 'company_slider_login', company_id != '' ? company_id : 'undifined'); await axios .delete(URL, HEADER) .then(res => res) diff --git a/src/views/SimproV2/CreatedProyek/DialogDocument.js b/src/views/SimproV2/CreatedProyek/DialogDocument.js index 69830d0..8dded7e 100644 --- a/src/views/SimproV2/CreatedProyek/DialogDocument.js +++ b/src/views/SimproV2/CreatedProyek/DialogDocument.js @@ -12,6 +12,7 @@ import DialogRequest from './FormDocument'; import DialogRequestFolder from './FormFolderDocument'; const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName }) => { const token = localStorage.getItem("token") + const role = window.localStorage.getItem('role_name'); const HEADER = { headers: { "Content-Type": "application/json", @@ -99,8 +100,11 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN } const handleShow = (file) => { - const configApp = JSON.parse(window.localStorage.getItem('configApp')); - const urlShow = `${BASE_SIMPRO_LUMEN_FILE_COMPANY(file, configApp.company_name)}` + let configApp = ''; + if (role !== 'Super Admin') { + configApp = JSON.parse(window.localStorage.getItem('configApp')); + } + const urlShow = `${BASE_SIMPRO_LUMEN_FILE_COMPANY(file, configApp != '' ? configApp.company_name : 'undifined')}` window.open(urlShow); } diff --git a/src/views/SimproV2/CreatedProyek/FormDocument.js b/src/views/SimproV2/CreatedProyek/FormDocument.js index 71edd49..f333717 100644 --- a/src/views/SimproV2/CreatedProyek/FormDocument.js +++ b/src/views/SimproV2/CreatedProyek/FormDocument.js @@ -7,7 +7,8 @@ import 'antd/dist/antd.css'; import { NotificationManager } from 'react-notifications'; const DialogRequest = ({ openDialog, closeDialog, toggleDialog, idTask, parentIdNewFolder }) => { - const token = localStorage.getItem("token") + const token = localStorage.getItem("token"); + const role = window.localStorage.getItem('role_name'); const HEADER = { headers: { "Content-Type": "application/json", @@ -33,12 +34,13 @@ const DialogRequest = ({ openDialog, closeDialog, toggleDialog, idTask, parentId } const uploadDokumen = async () => { - const configApp = JSON.parse(window.localStorage.getItem('configApp')); - + let configApp = ''; const formData = new FormData; + if (role !== 'Super Admin') { + configApp = JSON.parse(window.localStorage.getItem('configApp')); + formData.append('company_name',configApp.company_name); + } formData.append('dokumen', file, file.name); - formData.append('company_name',configApp.company_name); - if (parentIdNewFolder > 0) { formData.append('ref_id', parentIdNewFolder); // folder_id formData.append('type_dokumen', 'project-document-in-folder');