From 5545a4d368f26521e68468cb1b89ac58a5cc6379 Mon Sep 17 00:00:00 2001 From: wahyun Date: Wed, 17 Jul 2024 13:14:10 +0700 Subject: [PATCH 1/3] fix: deleted company_id & company_name --- src/const/ApiConst.js | 40 +- src/containers/DefaultLayout/DefaultLayout.js | 9 +- src/views/Dashboard/DashboardBOD.js | 31 +- src/views/Dashboard/DashboardCustomer.js | 3 +- src/views/Dashboard/DashboardProject.js | 7 +- .../Dashboard/DashboardProjectCarousell.js | 5 +- src/views/MapMonitoring/index.js | 5 +- src/views/Master/MasterAbsensi/index.js | 1189 ++++++++--------- .../Master/MasterBroadcast/DialogForm.js | 821 ++++++------ src/views/Master/MasterBroadcast/index.js | 51 +- src/views/Master/MasterRoles/DialogForm.js | 62 +- .../Master/MasterRoles/DialogMenuRoles.js | 7 +- src/views/Master/MasterRoles/index.js | 49 +- .../Master/ProjectExpenditure/DialogForm.js | 7 +- src/views/Master/ProjectExpenditure/index.js | 13 +- .../ProjectFinancialHealth/DialogForm.js | 7 +- .../Master/ProjectFinancialHealth/index.js | 13 +- src/views/Master/ProjectInvoice/DialogForm.js | 7 +- src/views/Master/ProjectInvoice/index.js | 13 +- src/views/Master/ProjectPhase/DialogForm.js | 223 ++-- src/views/Master/ProjectPhase/index.js | 71 +- .../ProjectScheduleHealth/DialogForm.js | 7 +- .../Master/ProjectScheduleHealth/index.js | 13 +- src/views/Master/Proyek/index.js | 3 +- src/views/Master/RoleProject/DialogForm.js | 73 +- src/views/Master/RoleProject/index.js | 73 +- src/views/Pages/Login/Login.js | 8 +- src/views/Report/k3/index.js | 26 +- src/views/SimproV2/ChecklistK3/DialogForm.js | 237 ++-- src/views/SimproV2/ChecklistK3/index.js | 75 +- src/views/SimproV2/Closing/index.js | 3 +- .../CreatedProyek/AsignCustProject.js | 5 +- .../SimproV2/CreatedProyek/AsignHrProject.js | 8 +- .../CreatedProyek/DialogAssignCust.js | 5 +- .../SimproV2/CreatedProyek/DialogDocument.js | 16 +- .../CreatedProyek/DialogFormProyek.js | 57 +- .../SimproV2/CreatedProyek/DialogGantt.js | 4 +- .../SimproV2/CreatedProyek/FormDocument.js | 10 +- src/views/SimproV2/CreatedProyek/index.js | 152 +-- src/views/SimproV2/DemoRequest/index.js | 5 +- src/views/SimproV2/Divisi/DialogForm.js | 71 +- src/views/SimproV2/Divisi/index.js | 79 +- src/views/SimproV2/Gantt/GanttFrame.js | 6 +- src/views/SimproV2/Gantt/index.js | 4 +- src/views/SimproV2/LimitasiUser/index.js | 27 +- src/views/SimproV2/PanicButton/index.js | 13 - src/views/SimproV2/PlanningHarian/index.js | 712 +++++----- src/views/SimproV2/Presence/index.js | 26 +- src/views/SimproV2/Profile/index.js | 8 +- src/views/SimproV2/ProjectType/DialogForm.js | 41 +- src/views/SimproV2/ProjectType/index.js | 70 +- src/views/SimproV2/ResourceMaterial/index.js | 10 +- .../SimproV2/ResourceWorker/DialogForm.js | 43 +- src/views/SimproV2/ResourceWorker/index.js | 80 +- src/views/SimproV2/Satuan/DialogForm.js | 54 +- src/views/SimproV2/Satuan/index.js | 69 +- .../Settings/components/MyProfile/Index.js | 12 +- .../Settings/components/Plan/Container1.js | 21 +- src/views/testgantt/index.js | 486 +++---- 59 files changed, 1952 insertions(+), 3293 deletions(-) diff --git a/src/const/ApiConst.js b/src/const/ApiConst.js index 4e82340..cc1a72b 100644 --- a/src/const/ApiConst.js +++ b/src/const/ApiConst.js @@ -126,11 +126,11 @@ export let BASE_OSPRO = "https://si-api.ospro.id"; export let BASE_SIMPRO_LUMEN = `${BASE_OSPRO}/api`; export let BASE_SIMPRO_LUMEN_IMAGE = `${BASE_OSPRO}/assets/image`; export let BASE_SIMPRO_LUMEN_FILE = `${BASE_OSPRO}/assets/file/project`; -export let BASE_SIMPRO_LUMEN_FILE_COMPANY = (file, company_name, dateFile) => { - return `${BASE_OSPRO}/assets/${company_name}/${dateFile}/file/project/${file}`; +export let BASE_SIMPRO_LUMEN_FILE_COMPANY = (file) => { + return `${BASE_OSPRO}/assets/file/project/${file}`; } -export let BASE_SIMPRO_LUMEN_IMAGE_COMPANY = (file, company_name, dateFile) => { - return `${BASE_OSPRO}/assets/${company_name}/${dateFile}/image/${file}`; +export let BASE_SIMPRO_LUMEN_IMAGE_COMPANY = (file) => { + return `${BASE_OSPRO}/assets/image/${file}`; } export const USERROLE_ADD = `${BASE_SIMPRO}/user-role/add`; @@ -289,9 +289,7 @@ export const TRANSACTION_DELETE = (id) => { }; export const TRANSACTION_LIST = `${BASE_SIMPRO_LUMEN}/product-transaction/list`; -export const STORAGE_LIMIT_INFORMATION = (company_name) => { - return `${BASE_SIMPRO_LUMEN}/information-storage/${company_name}`; -}; +export const STORAGE_LIMIT_INFORMATION = `${BASE_SIMPRO_LUMEN}/information-storage`; export const STORAGE_LIMIT_INFORMATION_ALL_COMPANY = `${BASE_SIMPRO_LUMEN}/information-storage-all-company` export const ABSENSI_ADD = `${BASE_SIMPRO_LUMEN}/permit/add`; @@ -320,11 +318,11 @@ export const DOCUMENT_SEARCH = `${BASE_SIMPRO_LUMEN}/document-project/search`; export const DOCUMENT_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/document-project/update/${id}`; }; -export const DOCUMENT_DELETE = (id, company_id) => { - return `${BASE_SIMPRO_LUMEN}/document-project/delete/${id}/${company_id}`; +export const DOCUMENT_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/document-project/delete/${id}`; }; -export const DOCUMENT_DOWNLOAD = (id, company_id) => { - return `${BASE_SIMPRO_LUMEN}/document-project/download/${id}/${company_id}`; +export const DOCUMENT_DOWNLOAD = (id) => { + return `${BASE_SIMPRO_LUMEN}/document-project/download/${id}`; }; export const ROLE_ADD = `${BASE_SIMPRO_LUMEN}/role/add`; @@ -436,8 +434,8 @@ export const PROYEK_GET_ID = (id) => { export const PROYEK_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/project/update/${id}`; }; -export const PROYEK_DELETE = (id, company_id) => { - return `${BASE_SIMPRO_LUMEN}/project/delete/${id}/${company_id}`; +export const PROYEK_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/project/delete/${id}`; }; export const PROJECT_ROLE_ADD = `${BASE_SIMPRO_LUMEN}/project-role/add`; @@ -722,8 +720,8 @@ export const ASSIGN_HR_PROJECT_SEARCH = `${BASE_SIMPRO_LUMEN}/user-to-proyek/sea export const ASSIGN_HR_PROJECT_EDIT = (id) => { return `${BASE_SIMPRO_LUMEN}/user-to-proyek/update/${id}`; }; -export const ASSIGN_HR_PROJECT_DELETE = (id, company_id) => { - return `${BASE_SIMPRO_LUMEN}/user-to-proyek/delete/${id}/${company_id}`; +export const ASSIGN_HR_PROJECT_DELETE = (id) => { + return `${BASE_SIMPRO_LUMEN}/user-to-proyek/delete/${id}`; }; export const ASSIGN_HR_PROJECT_LIST = `${BASE_SIMPRO_LUMEN}/user-to-proyek/list`; @@ -741,8 +739,8 @@ export const FOLDER_DOCUMENT_PROYEK_ADD = `${BASE_SIMPRO_LUMEN}/folder-document- export const FOLDER_DOCUMENT_PROYEK_SEARCH = `${BASE_SIMPRO_LUMEN}/folder-document-proyek/search`; export const FOLDER_DOCUMENT_PROYEK_UPDATE = (id) => `${BASE_SIMPRO_LUMEN}/folder-document-proyek/update/${id}`; -export const FOLDER_DOCUMENT_PROYEK_DELETE = (id, company_id) => - `${BASE_SIMPRO_LUMEN}/folder-document-proyek/delete/${id}/${company_id}`; +export const FOLDER_DOCUMENT_PROYEK_DELETE = (id) => + `${BASE_SIMPRO_LUMEN}/folder-document-proyek/delete/${id}`; export const FOLDER_DOCUMENT_PROYEK_GET_TREE = (proyek_id) => `${BASE_SIMPRO_LUMEN}/folder-document-proyek/get-tree/${proyek_id}`; @@ -793,11 +791,11 @@ export const IMAGE_SEARCH = `${BASE_SIMPRO_LUMEN}/image/search`; export const OSPRO_BASE_IMAGE = `${BASE_OSPRO}/api/assets/image`; export const IMAGE_UPLOAD = `${BASE_SIMPRO_LUMEN}/image/upload`; export const IMAGE_MULTIPLE_UPLOAD = `${BASE_SIMPRO_LUMEN}/image/multiple-upload`; -export const IMAGE_MULTIPLE_DELETE = (id, category, company_id) => { - return `${BASE_SIMPRO_LUMEN}/image/multiple-delete/${id}/${category}/${company_id}`; +export const IMAGE_MULTIPLE_DELETE = (id, category) => { + return `${BASE_SIMPRO_LUMEN}/image/multiple-delete/${id}/${category}`; } -export const IMAGE_DELETE = (id, category, company_id) => { - return `${BASE_SIMPRO_LUMEN}/image/delete/${id}/${category}/${company_id}`; +export const IMAGE_DELETE = (id, category) => { + return `${BASE_SIMPRO_LUMEN}/image/delete/${id}/${category}`; } diff --git a/src/containers/DefaultLayout/DefaultLayout.js b/src/containers/DefaultLayout/DefaultLayout.js index ef4d6af..a737e45 100644 --- a/src/containers/DefaultLayout/DefaultLayout.js +++ b/src/containers/DefaultLayout/DefaultLayout.js @@ -39,16 +39,14 @@ class DefaultLayout extends Component { constructor(props) { super(props); - let role_id = '', token = '', company_id = 0, menu = '' + let role_id = '', token = '', menu = '' if (props.location.state && props.location.state.role_id) { role_id = props.location.state.role_id; token = props.location.state.token; - company_id = props.location.state.company_id; menu = props.location.state.menu_login; } else { role_id = localStorage.getItem("role_id"); token = localStorage.getItem("token"); - company_id = localStorage.getItem('company_id'); menu = localStorage.getItem("menu_login"); } @@ -59,8 +57,7 @@ class DefaultLayout extends Component { routes2: routes, finalRoutes: [], breadrCrumbReady: false, - minimized: true, - company_id: company_id + minimized: true }; } async componentDidMount() { @@ -161,7 +158,6 @@ class DefaultLayout extends Component { e.preventDefault() } await localStorage.removeItem("role_id"); - await localStorage.removeItem("company_id"); document.getElementById('title').innerText = 'OSPRO'; this.setFavicon(`${process.env.PUBLIC_URL}/OSPRO.ico`); await window.localStorage.clear(); @@ -364,7 +360,6 @@ class DefaultLayout extends Component { user_id={props.location.state ? props.location.state.user_id : localStorage.getItem("user_id")} role_id={props.location.state ? props.location.state.role_id : localStorage.getItem("role_id")} isLogin={props.location.state ? props.location.state.isLogin : localStorage.getItem("isLogin")} - company_id={props.location.state ? props.location.state.company_id : localStorage.getItem("company_id")} role_name={props.location.state ? props.location.state.role_name : localStorage.getItem("role_name")} all_project={props.location.state ? props.location.state.all_project : localStorage.getItem("all_project")} token={props.location.state ? props.location.state.token : localStorage.getItem("token")} diff --git a/src/views/Dashboard/DashboardBOD.js b/src/views/Dashboard/DashboardBOD.js index 822de60..b662d7c 100644 --- a/src/views/Dashboard/DashboardBOD.js +++ b/src/views/Dashboard/DashboardBOD.js @@ -15,13 +15,12 @@ import { HealthByBudget, HealthBySchedule } from './Components'; import { Link } from 'react-router-dom'; import { Card, CardBody, CardHeader, Input } from "reactstrap"; const DashboardBOD = (props) => { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = ''; + let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name = '', hierarchy = [], user_name = ''; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; token = props.token; isLogin = props.isLogin; - company_id = props.company_id; all_project = props.all_project; role_name = props.role_name; isLogin = props.isLogin; @@ -81,7 +80,7 @@ const DashboardBOD = (props) => { // project expenditure const getCompanyCashFlow = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-company-cashflow/${company_id}/${all_project}/${hierarchy}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-company-cashflow/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project Expenditure."; @@ -107,31 +106,31 @@ const DashboardBOD = (props) => { // Project Expenditure Color const getCompanyExpenditureColor = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-detail-expenditure-color/${company_id}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-detail-expenditure-color/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) SET_PROJECT_EXPENDITURE_COLOR(result.data.data) } const getCompanyFinancialHealthColor = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-detail-financial-health-color/${company_id}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-detail-financial-health-color/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) SET_PROJECT_FINANCIAL_HEALTH_COLOR(result.data.data) } const getCompanyScheduleHealthColor = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-detail-schedule-health-color/${company_id}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-detail-schedule-health-color/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) SET_PROJECT_SCHEDULE_HEALTH_COLOR(result.data.data) } const getCompanyInvoiceColor = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-detail-invoice-color/${company_id}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-detail-invoice-color/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) SET_PROJECT_INVOICE_COLOR(result.data.data) } const getInvoiceOutstanding = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-invoice-outstanding/${company_id}/${all_project}/${hierarchy}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-invoice-outstanding/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project Invoice vs Cash In."; @@ -154,7 +153,7 @@ const DashboardBOD = (props) => { } const getProjectPerScheduleHealth = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-schedule-health/${company_id}/${all_project}/${hierarchy}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-schedule-health/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project by Schedule Health."; @@ -178,7 +177,7 @@ const DashboardBOD = (props) => { } const getProjectPerBudgetHealth = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-budget-health/${company_id}/${all_project}/${hierarchy}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-budget-health/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project by Budget Health."; @@ -201,7 +200,7 @@ const DashboardBOD = (props) => { } const getProjectBudgetHealthPerDivision = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-budget-health-per-division/${company_id}/${all_project}/${hierarchy}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-budget-health-per-division/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project by Schedule Health per Division."; @@ -225,7 +224,7 @@ const DashboardBOD = (props) => { } const getProjectScheduleHealthPerDivision = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-schedule-health-per-division/${company_id}/${all_project}/${hierarchy}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-schedule-health-per-division/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project by Schedule Health."; @@ -248,7 +247,7 @@ const DashboardBOD = (props) => { } const getProjectPerPhase = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-phase/${company_id}/${all_project}/${hierarchy}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-phase/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project by Phase."; @@ -273,7 +272,7 @@ const DashboardBOD = (props) => { } const getTotalProjectPerDivision = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-division/${company_id}/${all_project}/${hierarchy}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-per-division/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project by Division."; @@ -298,7 +297,7 @@ const DashboardBOD = (props) => { } const getTotalProjectValuePerDivision = async () => { - const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-value-per-division/${company_id}/${all_project}/${hierarchy}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-total-project-value-per-division/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Project Value by Division"; @@ -327,7 +326,7 @@ const DashboardBOD = (props) => { return; } setOpenDetailedView(true); - const URL = `${BASE_OSPRO}/api/dashboard/get-detail-expenditure/${company_id}/${all_project}/${hierarchy}/${role_name}` + const URL = `${BASE_OSPRO}/api/dashboard/get-detail-expenditure/${all_project}/${hierarchy}/${role_name}` const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response) const content = "Get Detail Expenditure"; diff --git a/src/views/Dashboard/DashboardCustomer.js b/src/views/Dashboard/DashboardCustomer.js index 8f0f5f6..5f70574 100644 --- a/src/views/Dashboard/DashboardCustomer.js +++ b/src/views/Dashboard/DashboardCustomer.js @@ -26,13 +26,12 @@ const center = { } const DashboardCustomer = (props) => { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name='', hierarchy=[], user_name=''; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; token = props.token; isLogin = props.isLogin; - company_id = props.company_id; all_project = props.all_project; role_name = props.role_name; isLogin = props.isLogin; diff --git a/src/views/Dashboard/DashboardProject.js b/src/views/Dashboard/DashboardProject.js index a843992..cc6fe8b 100644 --- a/src/views/Dashboard/DashboardProject.js +++ b/src/views/Dashboard/DashboardProject.js @@ -60,13 +60,12 @@ const center = { lng: 106.816666, }; const DashboardProject = (props) => { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = ''; + let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name = '', hierarchy = [], user_name = ''; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; token = props.token; isLogin = props.isLogin; - company_id = props.company_id; all_project = props.all_project; role_name = props.role_name; isLogin = props.isLogin; @@ -80,8 +79,8 @@ const DashboardProject = (props) => { }, }; const { PROJECT_ID, GANTT_ID, SCURVE } = useParams(); - const URL_GANTT = `https://project-gantt.ospro.id/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1&role_name=${role_name}&company_id=${company_id}`; - // const URL_GANTT = `http://localhost:8444/generic-ospro-gantt/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1&role_name=${role_name}&company_id=${company_id}`; + const URL_GANTT = `https://project-gantt.ospro.id/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1&role_name=${role_name}`; + // const URL_GANTT = `http://localhost:8444/generic-ospro-gantt/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1&role_name=${role_name}`; const mapRef = useRef(); const [projectName, setProjectName] = useState(""); diff --git a/src/views/Dashboard/DashboardProjectCarousell.js b/src/views/Dashboard/DashboardProjectCarousell.js index b0555f0..04247e6 100644 --- a/src/views/Dashboard/DashboardProjectCarousell.js +++ b/src/views/Dashboard/DashboardProjectCarousell.js @@ -70,13 +70,12 @@ const center = { }; const DashboardProject = ({args,...props}) => { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name='', hierarchy=[], user_name=''; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; token = props.token; isLogin = props.isLogin; - company_id = props.company_id; all_project = props.all_project; role_name = props.role_name; isLogin = props.isLogin; @@ -129,7 +128,7 @@ const DashboardProject = ({args,...props}) => { setIsReadyProjectDetail(false); setIsReadySCurve(false) setIsReadySCurve(false); - const URL = `${BASE_OSPRO}/api/project-carausell/${company_id}/${all_project}/${hierarchy}`; + const URL = `${BASE_OSPRO}/api/project-carausell/${all_project}/${hierarchy}`; const result = await axios .get(URL, HEADER) .then((res) => res) diff --git a/src/views/MapMonitoring/index.js b/src/views/MapMonitoring/index.js index 9b558dd..13d805e 100644 --- a/src/views/MapMonitoring/index.js +++ b/src/views/MapMonitoring/index.js @@ -29,13 +29,12 @@ import moment from 'moment'; import axios from "../../const/interceptorApi"; const MapMonitoring = ({ ...props }) => { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name='', configApp={}; + let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name='', hierarchy=[], user_name='', configApp={}; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; token = props.token; isLogin = props.isLogin; - company_id = props.company_id; all_project = props.all_project; role_name = props.role_name; isLogin = props.isLogin; @@ -225,7 +224,7 @@ const MapMonitoring = ({ ...props }) => { const pointToLayerUserPoints = (feature, latlng) => { let imgSrc = DEFAULT_USER_ICON; if (feature && feature.properties && feature.properties.image && feature.properties.image !== '') { - imgSrc = `${BASE_SIMPRO_LUMEN_IMAGE_COMPANY(feature.properties.image, JSON.parse(configApp).company_name, moment(feature.properties.created_at).format('YYYY-MM'))}` + imgSrc = `${BASE_SIMPRO_LUMEN_IMAGE_COMPANY(feature.properties.image)}` } let img = `` let logoMarker = L.divIcon({ diff --git a/src/views/Master/MasterAbsensi/index.js b/src/views/Master/MasterAbsensi/index.js index b8e26f5..0d490f6 100644 --- a/src/views/Master/MasterAbsensi/index.js +++ b/src/views/Master/MasterAbsensi/index.js @@ -1,601 +1,588 @@ -import React, { Component } from 'react'; -import { Card, CardBody, CardHeader, Col, Row, Table, Input, InputGroup } from 'reactstrap'; -import { Button } from 'reactstrap'; -import axios from 'axios'; -import moment from 'moment'; -import SweetAlert from 'react-bootstrap-sweetalert'; -import DialogForm from './DialogForm'; -import { NotificationContainer, NotificationManager } from 'react-notifications'; -import { Pagination, Tooltip } from 'antd'; -import { DatePicker, Select } from 'antd'; -import * as XLSX from 'xlsx'; -import { ABSENSI_SEARCH, ABSENSI_ADD, ABSENSI_DELETE, ABSENSI_EDIT, PROYEK_SEARCH, USERPROYEK_SEARCH } from '../../../const/ApiConst.js'; -import MapConfig from '../../MapConfig/MapConfig'; -import { withTranslation } from 'react-i18next'; -const { RangePicker } = DatePicker; -const { Option } = Select -const token = window.localStorage.getItem('token'); -const config = { - headers: - { - Authorization: `Bearer ${token}`, - "Content-type": `application/json` - } -}; - - -const BASE_URL = ""; -const LENGTH_DATA = 10 - -class index extends Component { - constructor(props) { - super(props) - this.state = { - dataTable: [], - dataExport: [], - openDialog: false, - typeDialog: 'Save', - dataEdit: null, - alertDelete: false, - idDelete: 0, - dataGs: [], - dataIdHo: [], - search: "", - page: 0, - rowsPerPage: LENGTH_DATA, - currentPage: 1, - totalPage: 0, - tooltipEdit: false, - tooltipDelete: false, - startDate: moment(moment().format("YYYY-M-D")), - endDate: moment(moment().format("YYYY-M-D")), - currentDay: 'today', - tooltipTambah: false, - tooltipExport: false, - currentProyek: parseInt(localStorage.getItem('role_id')) === 2 ? parseInt(localStorage.getItem('proyek_id')) : null, - allUserToProyek: [], - allDataProyek: [], - finishSetupOption: false, - role_name: props.role_name || '', - role_id: props.role_id || 0, - user_id: props.user_id || 0, - isLogin: props.isLogin || false, - token: props.token || '', - all_project: props.all_project || null, - hierarchy: props.hierarchy || [], - user_name: props.user_name || '', - } - } - - async componentDidMount() { - this.getDataAbsensi(); - this.getAllProyek(); - this.setUpFirstProyek(); - } - - async componentDidUpdate(prevProps, prevState) { - const { search, startDate, dataExport, currentProyek, allUserToProyek } = this.state - if (search !== prevState.search) this.getDataAbsensi() - if (startDate !== prevState.startDate) this.getDataAbsensi() - if (dataExport !== prevState.dataExport) { - if (dataExport.length > 0) { - this.exportExcel() - } - } - if (currentProyek !== prevState.currentProyek) { - if (localStorage.getItem('role_id') !== 2) { - this.getUserProyek(); - } - } - if (allUserToProyek !== prevState.allUserToProyek) { - this.getDataAbsensi(); - } - } - - setUpFirstProyek = () => { - if (parseInt(localStorage.getItem('role_id')) === 2) { - this.setState({ disableProyek: true }); - } else { - this.setState({ currentProyek: null }) - } - } - - handleSearch = e => { - const value = e.target.value - this.setState({ search: value, currentPage: 1 }) - }; - - getAllProyek = async () => { - const payload = { - "paging": { "start": 0, "length": -1 }, - "columns": [ - { "name": "nama", "logic_operator": "ilike", "value": "", "operator": "AND" } - ], - "joins": [], - "orders": { "columns": ["id"], "ascending": false } - } - - const result = await axios - .post(PROYEK_SEARCH, payload, config) - .then(res => res) - .catch((error) => error.response); - - - if (result && result.data && result.data.code == 200) { - this.setState({ allDataProyek: result.data.data }) - } else { - } - } - - - getUserProyek = async () => { - const payload = { - "paging": { "start": 0, "length": -1 }, - "joins": [], - "orders": { "columns": ["id"], "ascending": false } - } - - if (parseInt(localStorage.getItem('role_id')) === 1) { - if (this.state.currentProyek && this.state.currentProyek > 0) { - payload['columns'] = [ - { "name": "proyek_id", "logic_operator": "=", "value": `${this.state.currentProyek}`, "operator": "AND" } - ] - } - } else { - payload['columns'] = [ - { "name": "proyek_id", "logic_operator": "=", "value": `${localStorage.getItem('proyek_id')}`, "operator": "AND" } - ] - } - - - const result = await axios - .post(USERPROYEK_SEARCH, payload, config) - .then(res => res) - .catch((error) => error.response); - - - if (result && result.data && result.data.code == 200) { - this.setState({ allUserToProyek: result.data.data }) - } else { - } - } - - getDataAbsensi = async () => { - let url = ""; - - let start = 0; - if (this.state.currentPage !== 1 && this.state.currentPage > 1) { - start = (this.state.currentPage * this.state.rowsPerPage) - this.state.rowsPerPage - } - - let dateStart = moment(this.state.startDate).format("YYYY-MM-DD 00:00:00"); - let dateEnd = moment(this.state.endDate).format("YYYY-MM-DD 23:59:59"); - - const payload = { - "paging": { - "start": start, - "length": this.state.rowsPerPage - }, - "filter_columns": [ - { - "name": "name", - "value": "", - "table_name": "m_users" - } - ], - "columns": [ - { "name": "created_at", "logic_operator": "range", "value": dateStart, "value1": dateEnd, "operator": "AND" }, - { "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND", "table_name": "m_users" } - ], - "joins": [ - { - "name": "m_users", - "column_join": "user_id", - "column_results": [ - "name", - ] - } - ], - "orders": { - "columns": [ - "id" - ], - "ascending": false - } - } - if (this.state.role_name === 'Super Admin') { - payload.joins.push( - { name: "m_company", column_join: "company_id", column_results: ["company_name"] } - ) - payload.columns.push( - { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } - ) - } - - - const result = await axios - .post(ABSENSI_SEARCH, payload, config) - .then(res => res) - .catch((error) => error.response); - - - if (result && result.data && result.data.code == 200) { - let totalRecord = result.data.totalRecord - let resData = result.data.data || [] - - this.setState({ dataTable: resData, totalPage: totalRecord }); - } else { - NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); - } - } - - handleOpenDialog = (type) => { - this.setState({ openDialog: true, typeDialog: type }) - this.showChildDialog(); - } - - handleCloseDialog = (type, data) => { - if (type === "save") { - this.saveAbsensi(data); - } else if (type === "edit") { - this.editDataAbsensi(data); - } - - this.setState({ openDialog: false }) - } - - toggleAddDialog = () => { - this.setState({ openDialog: !this.state.openDialog }) - } - - onConfirmDelete = async () => { - const { idDelete } = this.state - let url = ABSENSI_DELETE(idDelete) - const result = await axios.delete(url, MapConfig) - .then(res => res) - .catch((error) => error.response); - - if (result && result.data && result.data.code == 200) { - this.getDataAbsensi() - this.setState({ idDelete: 0, alertDelete: false }) - NotificationManager.success('Data absensi berhasil dihapus!!', 'Success!!'); - } else { - this.getDataAbsensi() - this.setState({ idDelete: 0, alertDelete: false }) - NotificationManager.error('Data absensi gagal dihapus!!', 'Failed!!'); - } - } - - saveAbsensi = async (data) => { - - const formData = { - user_id: data.idEmployee, - description: data.description, - created_at: data.dateAbsent - } - const result = await axios.post(ABSENSI_ADD, formData, config) - .then(res => res) - .catch((error) => error.response); - - if (result && result.data && result.data.code == 200) { - this.getDataAbsensi(); - NotificationManager.success('Data absensi berhasil ditambahkan!!', 'Success!!'); - } else { - NotificationManager.error(`${result.data.message}`, 'Failed!!'); - } - - } - - editDataAbsensi = async (data) => { - let url = ABSENSI_EDIT(data.id) - - const formData = { - user_id: data.idEmployee, - description: data.description, - created_at: data.dateAbsent - } - - const result = await axios.put(url, formData, config) - .then(res => res) - .catch((error) => error.response); - if (result && result.data && result.data.code == 200) { - this.getDataAbsensi(); - NotificationManager.success('Data absensi berhasil diedit!!', 'Success!!'); - } else { - NotificationManager.error('Data absensi gagal diedit!!', 'Failed!!'); - } - - } - - - handleEdit = (data) => { - this.setState({ dataEdit: data }); - this.handleOpenDialog('Edit'); - } - - handleDelete = (id) => { - this.setState({ alertDelete: true, idDelete: id }); - } - - onShowSizeChange = (current, pageSize) => { - this.setState({ rowsPerPage: pageSize }, () => { - this.getDataAbsensi(); - }) - } - - onPagination = (current, pageSize) => { - this.setState({ currentPage: current, page: (current - 1) * pageSize }, () => { - this.getDataAbsensi(); - }) - } - - toggle = (param) => { - if (param === "edit") { - this.setState(prevState => ({ tooltipEdit: !prevState.tooltipEdit })) - } else if (param === "delete") { - this.setState(prevState => ({ tooltipDelete: !prevState.tooltipDelete })) - } else if (param === "tambah") { - this.setState(prevState => ({ tooltipTambah: !prevState.tooltipTambah })) - } else if (param === "export") { - this.setState(prevState => ({ tooltipExport: !prevState.tooltipExport })) - } - } - - handleDatePicker = (date, dateString) => { - this.setState({ startDate: date[0], endDate: date[1] }, () => { - this.getDataAbsensi(); - }) - } - - handleTipe = (e) => { - this.setState({ typeClock: e.target.value }, () => { - this.getDataAbsensi(); - }); - } - - handleExportExcel = async () => { - let dateStart = moment(this.state.startDate).format("YYYY-MM-DD 00:00:00"); - let dateEnd = moment(this.state.endDate).format("YYYY-MM-DD 23:59:59"); - const payload = { - "paging": { - "start": 0, - "length": -1 - }, - "filter_columns": [ - { - "name": "name", - "value": "", - "table_name": "m_users" - } - ], - "columns": [ - { "name": "created_at", "logic_operator": "range", "value": dateStart, "value1": dateEnd, "operator": "AND" }, - { "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND", "table_name": "m_users" } - ], - "joins": [ - { - "name": "m_users", - "column_join": "user_id", - "column_results": [ - "name", - ] - } - ], - "orders": { - "columns": [ - "id" - ], - "ascending": false - } - } - - - - const result = await axios - .post(ABSENSI_SEARCH, payload, config) - .then(res => res) - .catch((error) => error.response); - - - if (result && result.data && result.data.code == 200) { - let resData = result.data.data || [] - const excelData = []; - - resData.map((n, index) => { - let dataRow = { - "Nama Human Resource": n.join_first_name ? n.join_first_name : "", - "Deskripsi": n.description ? n.description : "", - "Tanggal Absensi": n.created_at !== null ? moment(n.created_at).format("DD-MM-YYYY") : "-", - } - excelData.push(dataRow) - }) - this.setState({ dataExport: excelData }) - } else { - NotificationManager.error('Gagal Export Data!!', 'Failed'); - } - } - - exportExcel = () => { - const dataExcel = this.state.dataExport || []; - const fileName = `Data Absensi.xlsx`; - const ws = XLSX.utils.json_to_sheet(dataExcel); - const wb = XLSX.utils.book_new(); - XLSX.utils.book_append_sheet(wb, ws, `Data Absensi`); - - XLSX.writeFile(wb, fileName); - this.setState({ dataExport: [] }) - } - - setupSelectProyek = () => { - let allDataProyek = this.state.allDataProyek - return ( - <> - {allDataProyek.map((val, index) => { - return ( - - ) - }) - } - - ) - } - - onChangeProyek = (val) => { - this.setState({ currentProyek: val }); - } - - renderTable = () => { - const t = this.props; - const dataTable2 = this.state.dataTable || []; - return ( - - {dataTable2.length !== 0 ? dataTable2.map((n) => { - return ( - - {/* - this.handleDelete(n.id)}> - this.toggle("delete")}> - Delete - - - this.handleEdit(n)}> - this.toggle("edit")}> - Edit - - */} - {this.state.role_name === 'Super Admin' && - {n.join_second_company_name ? n.join_second_company_name : ""} - } - {n.join_first_name ? n.join_first_name : ""} - {n.description ? n.description : "-"} - {n.created_at ? moment(n.created_at).format("YYYY-MM-DD") : "-"} - - ) - }) : - {this.props.t('noData')} - - } - - ) - } - - handleChangeDay = (e) => { - const val = e.target.value; - this.setState({ currentDay: val }); - if (val === "today") { - this.setState({ - startDate: moment(moment().format("YYYY-M-D")), - endDate: moment(moment().format("YYYY-M-D")), - currentPage: 1 - }) - } else if (val === "3 day") { - this.setState({ - startDate: moment(moment().subtract(3, "days").format("YYYY-M-D")), - endDate: moment(moment().format("YYYY-M-D")), - currentPage: 1 - }) - } else if (val === "7 day") { - this.setState({ - startDate: moment(moment().subtract(7, "days").format("YYYY-M-D")), - endDate: moment(moment().format("YYYY-M-D")), - currentPage: 1 - }) - } else { - this.setState({ - startDate: moment(moment().format("YYYY-M-D")), - endDate: moment(moment().format("YYYY-M-D")), - currentPage: 1 - }) - } - } - - render() { - const t = this.props; - const column = [ - this.state.role_name === 'Super Admin' ? { name: this.props.t('company') } : null, - { name: this.props.t('nameHR') }, - { name: this.props.t('description') }, - { name: this.props.t('dateAbsent') }, - ].filter(column => column && column.name); - - const { tooltipTambah, tooltipExport, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete } = this.state - return ( -
- - this.setState({ alertDelete: false, idDelete: 0 })} - focusCancelBtn - > - {this.props.t('deleteMsg')} - - this.toggleAddDialog} - typeDialog={this.state.typeDialog} - dataEdit={this.state.dataEdit} - showDialog={showDialog => this.showChildDialog = showDialog} - dataHs={this.state.dataIdHo} - /> - - -

{this.props.params.name}

-
- - - -
-
- -
-
-
- this.handleChangeDay(e)} defaultValue={this.state.currentDay}> - - - - -
-
- {' '} - -
-
- -
- - - - {/* */} - {column.map((i, index) => { - return ( - - ) - })} - - - {this.renderTable()} -
Actions{i.name}
- -
-
-
- ) - } -} -export default withTranslation()(index); +import React, { Component } from 'react'; +import { Card, CardBody, CardHeader, Col, Row, Table, Input, InputGroup } from 'reactstrap'; +import { Button } from 'reactstrap'; +import axios from 'axios'; +import moment from 'moment'; +import SweetAlert from 'react-bootstrap-sweetalert'; +import DialogForm from './DialogForm'; +import { NotificationContainer, NotificationManager } from 'react-notifications'; +import { Pagination, Tooltip } from 'antd'; +import { DatePicker, Select } from 'antd'; +import * as XLSX from 'xlsx'; +import { ABSENSI_SEARCH, ABSENSI_ADD, ABSENSI_DELETE, ABSENSI_EDIT, PROYEK_SEARCH, USERPROYEK_SEARCH } from '../../../const/ApiConst.js'; +import MapConfig from '../../MapConfig/MapConfig'; +import { withTranslation } from 'react-i18next'; +const { RangePicker } = DatePicker; +const { Option } = Select +const token = window.localStorage.getItem('token'); +const config = { + headers: + { + Authorization: `Bearer ${token}`, + "Content-type": `application/json` + } +}; + + +const BASE_URL = ""; +const LENGTH_DATA = 10 + +class index extends Component { + constructor(props) { + super(props) + this.state = { + dataTable: [], + dataExport: [], + openDialog: false, + typeDialog: 'Save', + dataEdit: null, + alertDelete: false, + idDelete: 0, + dataGs: [], + dataIdHo: [], + search: "", + page: 0, + rowsPerPage: LENGTH_DATA, + currentPage: 1, + totalPage: 0, + tooltipEdit: false, + tooltipDelete: false, + startDate: moment(moment().format("YYYY-M-D")), + endDate: moment(moment().format("YYYY-M-D")), + currentDay: 'today', + tooltipTambah: false, + tooltipExport: false, + currentProyek: parseInt(localStorage.getItem('role_id')) === 2 ? parseInt(localStorage.getItem('proyek_id')) : null, + allUserToProyek: [], + allDataProyek: [], + finishSetupOption: false, + role_name: props.role_name || '', + role_id: props.role_id || 0, + user_id: props.user_id || 0, + isLogin: props.isLogin || false, + token: props.token || '', + all_project: props.all_project || null, + hierarchy: props.hierarchy || [], + user_name: props.user_name || '', + } + } + + async componentDidMount() { + this.getDataAbsensi(); + this.getAllProyek(); + this.setUpFirstProyek(); + } + + async componentDidUpdate(prevProps, prevState) { + const { search, startDate, dataExport, currentProyek, allUserToProyek } = this.state + if (search !== prevState.search) this.getDataAbsensi() + if (startDate !== prevState.startDate) this.getDataAbsensi() + if (dataExport !== prevState.dataExport) { + if (dataExport.length > 0) { + this.exportExcel() + } + } + if (currentProyek !== prevState.currentProyek) { + if (localStorage.getItem('role_id') !== 2) { + this.getUserProyek(); + } + } + if (allUserToProyek !== prevState.allUserToProyek) { + this.getDataAbsensi(); + } + } + + setUpFirstProyek = () => { + if (parseInt(localStorage.getItem('role_id')) === 2) { + this.setState({ disableProyek: true }); + } else { + this.setState({ currentProyek: null }) + } + } + + handleSearch = e => { + const value = e.target.value + this.setState({ search: value, currentPage: 1 }) + }; + + getAllProyek = async () => { + const payload = { + "paging": { "start": 0, "length": -1 }, + "columns": [ + { "name": "nama", "logic_operator": "ilike", "value": "", "operator": "AND" } + ], + "joins": [], + "orders": { "columns": ["id"], "ascending": false } + } + + const result = await axios + .post(PROYEK_SEARCH, payload, config) + .then(res => res) + .catch((error) => error.response); + + + if (result && result.data && result.data.code == 200) { + this.setState({ allDataProyek: result.data.data }) + } else { + } + } + + + getUserProyek = async () => { + const payload = { + "paging": { "start": 0, "length": -1 }, + "joins": [], + "orders": { "columns": ["id"], "ascending": false } + } + + if (parseInt(localStorage.getItem('role_id')) === 1) { + if (this.state.currentProyek && this.state.currentProyek > 0) { + payload['columns'] = [ + { "name": "proyek_id", "logic_operator": "=", "value": `${this.state.currentProyek}`, "operator": "AND" } + ] + } + } else { + payload['columns'] = [ + { "name": "proyek_id", "logic_operator": "=", "value": `${localStorage.getItem('proyek_id')}`, "operator": "AND" } + ] + } + + + const result = await axios + .post(USERPROYEK_SEARCH, payload, config) + .then(res => res) + .catch((error) => error.response); + + + if (result && result.data && result.data.code == 200) { + this.setState({ allUserToProyek: result.data.data }) + } else { + } + } + + getDataAbsensi = async () => { + let url = ""; + + let start = 0; + if (this.state.currentPage !== 1 && this.state.currentPage > 1) { + start = (this.state.currentPage * this.state.rowsPerPage) - this.state.rowsPerPage + } + + let dateStart = moment(this.state.startDate).format("YYYY-MM-DD 00:00:00"); + let dateEnd = moment(this.state.endDate).format("YYYY-MM-DD 23:59:59"); + + const payload = { + "paging": { + "start": start, + "length": this.state.rowsPerPage + }, + "filter_columns": [ + { + "name": "name", + "value": "", + "table_name": "m_users" + } + ], + "columns": [ + { "name": "created_at", "logic_operator": "range", "value": dateStart, "value1": dateEnd, "operator": "AND" }, + { "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND", "table_name": "m_users" } + ], + "joins": [ + { + "name": "m_users", + "column_join": "user_id", + "column_results": [ + "name", + ] + } + ], + "orders": { + "columns": [ + "id" + ], + "ascending": false + } + } + + const result = await axios + .post(ABSENSI_SEARCH, payload, config) + .then(res => res) + .catch((error) => error.response); + + + if (result && result.data && result.data.code == 200) { + let totalRecord = result.data.totalRecord + let resData = result.data.data || [] + + this.setState({ dataTable: resData, totalPage: totalRecord }); + } else { + NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); + } + } + + handleOpenDialog = (type) => { + this.setState({ openDialog: true, typeDialog: type }) + this.showChildDialog(); + } + + handleCloseDialog = (type, data) => { + if (type === "save") { + this.saveAbsensi(data); + } else if (type === "edit") { + this.editDataAbsensi(data); + } + + this.setState({ openDialog: false }) + } + + toggleAddDialog = () => { + this.setState({ openDialog: !this.state.openDialog }) + } + + onConfirmDelete = async () => { + const { idDelete } = this.state + let url = ABSENSI_DELETE(idDelete) + const result = await axios.delete(url, MapConfig) + .then(res => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code == 200) { + this.getDataAbsensi() + this.setState({ idDelete: 0, alertDelete: false }) + NotificationManager.success('Data absensi berhasil dihapus!!', 'Success!!'); + } else { + this.getDataAbsensi() + this.setState({ idDelete: 0, alertDelete: false }) + NotificationManager.error('Data absensi gagal dihapus!!', 'Failed!!'); + } + } + + saveAbsensi = async (data) => { + + const formData = { + user_id: data.idEmployee, + description: data.description, + created_at: data.dateAbsent + } + const result = await axios.post(ABSENSI_ADD, formData, config) + .then(res => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code == 200) { + this.getDataAbsensi(); + NotificationManager.success('Data absensi berhasil ditambahkan!!', 'Success!!'); + } else { + NotificationManager.error(`${result.data.message}`, 'Failed!!'); + } + + } + + editDataAbsensi = async (data) => { + let url = ABSENSI_EDIT(data.id) + + const formData = { + user_id: data.idEmployee, + description: data.description, + created_at: data.dateAbsent + } + + const result = await axios.put(url, formData, config) + .then(res => res) + .catch((error) => error.response); + if (result && result.data && result.data.code == 200) { + this.getDataAbsensi(); + NotificationManager.success('Data absensi berhasil diedit!!', 'Success!!'); + } else { + NotificationManager.error('Data absensi gagal diedit!!', 'Failed!!'); + } + + } + + + handleEdit = (data) => { + this.setState({ dataEdit: data }); + this.handleOpenDialog('Edit'); + } + + handleDelete = (id) => { + this.setState({ alertDelete: true, idDelete: id }); + } + + onShowSizeChange = (current, pageSize) => { + this.setState({ rowsPerPage: pageSize }, () => { + this.getDataAbsensi(); + }) + } + + onPagination = (current, pageSize) => { + this.setState({ currentPage: current, page: (current - 1) * pageSize }, () => { + this.getDataAbsensi(); + }) + } + + toggle = (param) => { + if (param === "edit") { + this.setState(prevState => ({ tooltipEdit: !prevState.tooltipEdit })) + } else if (param === "delete") { + this.setState(prevState => ({ tooltipDelete: !prevState.tooltipDelete })) + } else if (param === "tambah") { + this.setState(prevState => ({ tooltipTambah: !prevState.tooltipTambah })) + } else if (param === "export") { + this.setState(prevState => ({ tooltipExport: !prevState.tooltipExport })) + } + } + + handleDatePicker = (date, dateString) => { + this.setState({ startDate: date[0], endDate: date[1] }, () => { + this.getDataAbsensi(); + }) + } + + handleTipe = (e) => { + this.setState({ typeClock: e.target.value }, () => { + this.getDataAbsensi(); + }); + } + + handleExportExcel = async () => { + let dateStart = moment(this.state.startDate).format("YYYY-MM-DD 00:00:00"); + let dateEnd = moment(this.state.endDate).format("YYYY-MM-DD 23:59:59"); + const payload = { + "paging": { + "start": 0, + "length": -1 + }, + "filter_columns": [ + { + "name": "name", + "value": "", + "table_name": "m_users" + } + ], + "columns": [ + { "name": "created_at", "logic_operator": "range", "value": dateStart, "value1": dateEnd, "operator": "AND" }, + { "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND", "table_name": "m_users" } + ], + "joins": [ + { + "name": "m_users", + "column_join": "user_id", + "column_results": [ + "name", + ] + } + ], + "orders": { + "columns": [ + "id" + ], + "ascending": false + } + } + + + + const result = await axios + .post(ABSENSI_SEARCH, payload, config) + .then(res => res) + .catch((error) => error.response); + + + if (result && result.data && result.data.code == 200) { + let resData = result.data.data || [] + const excelData = []; + + resData.map((n, index) => { + let dataRow = { + "Nama Human Resource": n.join_first_name ? n.join_first_name : "", + "Deskripsi": n.description ? n.description : "", + "Tanggal Absensi": n.created_at !== null ? moment(n.created_at).format("DD-MM-YYYY") : "-", + } + excelData.push(dataRow) + }) + this.setState({ dataExport: excelData }) + } else { + NotificationManager.error('Gagal Export Data!!', 'Failed'); + } + } + + exportExcel = () => { + const dataExcel = this.state.dataExport || []; + const fileName = `Data Absensi.xlsx`; + const ws = XLSX.utils.json_to_sheet(dataExcel); + const wb = XLSX.utils.book_new(); + XLSX.utils.book_append_sheet(wb, ws, `Data Absensi`); + + XLSX.writeFile(wb, fileName); + this.setState({ dataExport: [] }) + } + + setupSelectProyek = () => { + let allDataProyek = this.state.allDataProyek + return ( + <> + {allDataProyek.map((val, index) => { + return ( + + ) + }) + } + + ) + } + + onChangeProyek = (val) => { + this.setState({ currentProyek: val }); + } + + renderTable = () => { + const t = this.props; + const dataTable2 = this.state.dataTable || []; + return ( + + {dataTable2.length !== 0 ? dataTable2.map((n) => { + return ( + + {/* + this.handleDelete(n.id)}> + this.toggle("delete")}> + Delete + + + this.handleEdit(n)}> + this.toggle("edit")}> + Edit + + */} + {n.join_first_name ? n.join_first_name : ""} + {n.description ? n.description : "-"} + {n.created_at ? moment(n.created_at).format("YYYY-MM-DD") : "-"} + + ) + }) : + {this.props.t('noData')} + + } + + ) + } + + handleChangeDay = (e) => { + const val = e.target.value; + this.setState({ currentDay: val }); + if (val === "today") { + this.setState({ + startDate: moment(moment().format("YYYY-M-D")), + endDate: moment(moment().format("YYYY-M-D")), + currentPage: 1 + }) + } else if (val === "3 day") { + this.setState({ + startDate: moment(moment().subtract(3, "days").format("YYYY-M-D")), + endDate: moment(moment().format("YYYY-M-D")), + currentPage: 1 + }) + } else if (val === "7 day") { + this.setState({ + startDate: moment(moment().subtract(7, "days").format("YYYY-M-D")), + endDate: moment(moment().format("YYYY-M-D")), + currentPage: 1 + }) + } else { + this.setState({ + startDate: moment(moment().format("YYYY-M-D")), + endDate: moment(moment().format("YYYY-M-D")), + currentPage: 1 + }) + } + } + + render() { + const t = this.props; + const column = [ + { name: this.props.t('nameHR') }, + { name: this.props.t('description') }, + { name: this.props.t('dateAbsent') }, + ].filter(column => column && column.name); + + const { tooltipTambah, tooltipExport, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete } = this.state + return ( +
+ + this.setState({ alertDelete: false, idDelete: 0 })} + focusCancelBtn + > + {this.props.t('deleteMsg')} + + this.toggleAddDialog} + typeDialog={this.state.typeDialog} + dataEdit={this.state.dataEdit} + showDialog={showDialog => this.showChildDialog = showDialog} + dataHs={this.state.dataIdHo} + /> + + +

{this.props.params.name}

+
+ + + +
+
+ +
+
+
+ this.handleChangeDay(e)} defaultValue={this.state.currentDay}> + + + + +
+
+ {' '} + +
+
+ +
+ + + + {/* */} + {column.map((i, index) => { + return ( + + ) + })} + + + {this.renderTable()} +
Actions{i.name}
+ +
+
+
+ ) + } +} +export default withTranslation()(index); diff --git a/src/views/Master/MasterBroadcast/DialogForm.js b/src/views/Master/MasterBroadcast/DialogForm.js index 6f264dd..6d7801b 100644 --- a/src/views/Master/MasterBroadcast/DialogForm.js +++ b/src/views/Master/MasterBroadcast/DialogForm.js @@ -1,434 +1,387 @@ -import 'antd/dist/antd.css'; -import React, { Component } from 'react'; -import { Button, Form, FormFeedback, FormGroup, Input, Label, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap'; -import Select from 'react-select'; -import axios from 'axios'; -import { BASE_URL_GEOHR_API2, ROLE_SEARCH, USER_WASPANG, USER_LIST, USER_SEARCH } from '../../../const/ApiConst'; -import { Transfer } from 'antd'; -import { withTranslation } from 'react-i18next'; - - -const token = window.localStorage.getItem('token'); - -const config = { - headers: - { - Authorization: `Bearer ${token}`, - "Content-type": `application/json` - } -}; - - -const ERROR_TITLE = "judul is required!" -const ERROR_MESSAGE = "message is required!" -const BASE_URL = "https://oslog.id/geohr-api/"; -const roleName = window.localStorage.getItem('role_name'); -let countError = 0; -class DialogForm extends Component { - constructor(props) { - super(props) - this.state = { - id: 0, - title: "", - description: "", - message: "", - openDialog: false, - isParentClick: false, - errorTitle: "", - errorMessage: "", - errorDivision: "", - errorEmployee: "", - penerima: "all", - displayKaryawan: "none", - displayDivisi: "none", - listOrganizationSelect: [], - currentSelectDiv: null, - dataEmployee: [], - dataSourceEmployee: [], - idOrganization: 0, - targetKeys: [], - selectedKeys: [], - allEmployeeId: [], - idEmployeeDivision: [], - idOrganization: [], - disableTransfer: true, - listCompany: [], - company_id: this.props.company_id, - role_name: '' - } - } - - async componentDidMount() { - if (this.props.company_id !== null) { - this.getDataRole(); - this.getDataUsers(); - } - this.props.showDialog(this.showDialog); - } - - async componentDidUpdate() { - if (this.state.isParentClick === true) { - if (this.props.typeDialog === "Edit") { - const { dataEdit } = this.props - this.setState({ - id: dataEdit.id, - title: dataEdit.title_notif, - description: dataEdit.description, - message: dataEdit.message_notif, - company_id: dataEdit.company_id - }) - } else { - this.setState({ - id: 0, - title: "", - description: "", - message: "", - company_id: 0 - }) - } - this.setState({ isParentClick: false }); - } - } - - - showDialog = () => { - this.setState({ isParentClick: true }); - } - - - - validate = () => { - let isError = false - const { title, message, penerima } = this.state - if (title === "") { - isError = true - this.setState({ errorTitle: ERROR_TITLE }) - } else if (title.length < 3 || title.length > 100) { - isError = true - this.setState({ errorTitle: "Title minimum 3-100 karakter!" }) - } - - if (message === "") { - isError = true - this.setState({ errorMessage: ERROR_MESSAGE }) - } else if (message.length < 3 || message.length > 200) { - isError = true - this.setState({ errorMessage: "message minimum 3-200 karakter!" }) - } - - if (penerima === "division") { - if (this.state.idOrganization === 0) { - this.setState({ errorDivision: "Silahkan pilih divisi penerima!" }) - } - } else if (penerima === "karyawan") { - if (this.state.selectedKeys.length === 0) { - this.setState({ errorEmployee: "Silahkan pilih karyawan penerima!" }) - } - } - return isError - } - handleSave = (param) => { - let err = this.validate() - if (!err) { - const { - id, - title, - description, - message, - penerima, - - } = this.state - let { - company_id - } = this.state - let idSend = []; - let send_to_type = "all"; - if (penerima === "all") { - idSend = this.state.allEmployeeId; - send_to_type = "all"; - } else if (penerima === "organization") { - idSend = this.state.idOrganization; - send_to_type = "roles"; - } else if (penerima === "karyawan") { - idSend = this.state.targetKeys; - send_to_type = "users"; - } - - if (Array.isArray(idSend)) { - idSend = idSend.map(function (e) { - return e.toString() - }); - } else { - idSend = idSend; - } - if (this.props.role_name !== 'Super Admin') { - company_id = parseInt(this.props.company_id) - } - const data = { - title, - description, - message, - send_to_type, - id: idSend, - company_id: company_id - } - if (param === 'registered' || param === 'send') { - this.props.handleSaveBroadcast(param, data) - } - this.setState({ id: 0, idOrganization: 0, currentSelectDiv: null, targetKeys: [], penerima: "all", displayKaryawan: "none", displayDivisi: "none", disableTransfer: true }); - } - } - - handleCancel = () => { - this.props.handleSaveBroadcast('cancel', 'none') - } - - handleChangePenerima = type => { - if (type === "organization") { - this.setState({ displayDivisi: "block", displayKaryawan: "none", disableTransfer: true, errorDivision: "", targetKeys: [] }) - } else if (type === "karyawan") { - this.setState({ displayKaryawan: "block", displayDivisi: "none", disableTransfer: false, errorEmployee: "", idEmployeeDivision: [], currentSelectDiv: null }) - } else { - this.setState({ displayKaryawan: "none", displayDivisi: "none", disableTransfer: true, errorDivision: "", errorEmployee: "", targetKeys: [], idEmployeeDivision: [], currentSelectDiv: null }) - } - this.setState({ penerima: type }); - } - - handleSelectOrganization = (inputValue, actionMeta) => { - this.setState({ idOrganization: inputValue.value, currentSelectDiv: { value: inputValue.value, label: inputValue.label }, errorDivision: "" }, () => { - this.setEmployeeOrganization(); - }); - } - - setEmployeeOrganization = () => { - let arrEd = this.state.dataEmployee.data; - let cek = arrEd.filter(this.filterId) - - this.setState({ idEmployeeDivision: cek }) - } - - filterId = (val) => { - return val.organization_id == this.state.idOrganization - } - - getDataRole = async () => { - const payload = { - "paging": { - "start": 0, - "length": -1 - }, - "columns": [ - { - "name": "company_id", - "logic_operator": "=", - "value": this.state.company_id, - "operator": "AND" - } - ], - "orders": { "columns": ["id"], "ascending": false } - } - - const result = await axios - .post(ROLE_SEARCH, payload, config) - .then(res => res) - .catch((error) => error.response); - - if (result && result.data && result.data.code === 200) { - this.setState({ dataDivision: result.data.data }, () => { - this.setDataOrganization(); - }) - } else { - } - } - - setDataOrganization = () => { - const { dataDivision } = this.state - const listOrganization = [] - dataDivision.map((val, index) => { - listOrganization.push({ - value: val.id, - label: val.name - }) - }) - this.setState({ listOrganizationSelect: listOrganization }) - } - - getDataUsers = async () => { - const payload = { - "paging": { - "start": 0, - "length": -1 - }, - "columns": [ - { - "name": "name", - "logic_operator": "like", - "value": "", - "operator": "AND", - "table_name": "m_users" - }, - { - "name": "company_id", - "logic_operator": "=", - "value": this.state.company_id, - "operator": "AND" - } - ], - "orders": { - "columns": [ - "id" - ], - "ascending": false - } - } - //TODO should use search instead - const result = await axios - .post(USER_SEARCH, payload, config) - .then(res => res) - .catch((error) => error.response); - - if (result && result.data && result.status == 200) { - this.setState({ dataEmployee: result.data }, () => { - this.setDataEmployee(); - }); - } else { - } - } - - setDataEmployee = () => { - const listEmployee = []; - const allIdEmployee = []; - this.state.dataEmployee.data.map((val, index) => { - allIdEmployee.push(val.id); - listEmployee.push({ - key: val.id, - id: val.id, - title: val.name - }); - }) - - this.setState({ dataSourceEmployee: listEmployee, allEmployeeId: allIdEmployee }) - } - - handleChangeTransfer = (nextTargetKeys, direction, moveKeys) => { - this.setState({ targetKeys: nextTargetKeys, errorEmployee: "" }); - - }; - - handleSelectChangeTransfer = (sourceSelectedKeys, targetSelectedKeys) => { - this.setState({ selectedKeys: [...sourceSelectedKeys, ...targetSelectedKeys], errorEmployee: "" }); - - }; - - handleSelectCompany = (selectedOption) => { - const selectedCompanyId = selectedOption.value; - this.setState({ company_id: selectedCompanyId }, () => { - this.getDataRole(); - this.getDataUsers(); - }); - } - - renderForm = () => { - const t = this.props - const { errorTitle, errorMessage } = this.state - return ( -
- {this.props.role_name === 'Super Admin' && ( - - - this.handleChangePenerima(e.target.value)}> - - - - - - - - - this.setState( - { - errorTitle: e.target.value !== "" ? "" : ERROR_TITLE, - title: e.target.value - })} - placeholder={this.props.t('inputTitle')} /> - {errorTitle && ( - {errorTitle} - )} - - - - this.setState({ errorMessage: e.target.value !== "" ? "" : ERROR_MESSAGE, message: e.target.value })} placeholder={this.props.t('inputMsg')} /> - {errorMessage && ( - {errorMessage} - )} - - - - this.setState({ description: e.target.value })} placeholder={this.props.t('inputDescription')} /> - -
- ) - } - handleCloseDialog = () => { - this.props.closeDialog() - this.setState({ - errorTitle: "", - errorMessage: "", - errorDivision: "", - errorEmployee: "" - }) - } - render() { - return ( - - {this.props.t('broadcastDetail')} - - {this.renderForm()} - - - {' '} - {' '} - - - - ) - } -} -export default withTranslation()(DialogForm); \ No newline at end of file +import 'antd/dist/antd.css'; +import React, { Component } from 'react'; +import { Button, Form, FormFeedback, FormGroup, Input, Label, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap'; +import Select from 'react-select'; +import axios from 'axios'; +import { BASE_URL_GEOHR_API2, ROLE_SEARCH, USER_WASPANG, USER_LIST, USER_SEARCH } from '../../../const/ApiConst'; +import { Transfer } from 'antd'; +import { withTranslation } from 'react-i18next'; + + +const token = window.localStorage.getItem('token'); + +const config = { + headers: + { + Authorization: `Bearer ${token}`, + "Content-type": `application/json` + } +}; + + +const ERROR_TITLE = "judul is required!" +const ERROR_MESSAGE = "message is required!" +const BASE_URL = "https://oslog.id/geohr-api/"; +const roleName = window.localStorage.getItem('role_name'); +let countError = 0; +class DialogForm extends Component { + constructor(props) { + super(props) + this.state = { + id: 0, + title: "", + description: "", + message: "", + openDialog: false, + isParentClick: false, + errorTitle: "", + errorMessage: "", + errorDivision: "", + errorEmployee: "", + penerima: "all", + displayKaryawan: "none", + displayDivisi: "none", + listOrganizationSelect: [], + currentSelectDiv: null, + dataEmployee: [], + dataSourceEmployee: [], + idOrganization: 0, + targetKeys: [], + selectedKeys: [], + allEmployeeId: [], + idEmployeeDivision: [], + idOrganization: [], + disableTransfer: true, + role_name: '' + } + } + + async componentDidMount() { + this.props.showDialog(this.showDialog); + } + + async componentDidUpdate() { + if (this.state.isParentClick === true) { + if (this.props.typeDialog === "Edit") { + const { dataEdit } = this.props + this.setState({ + id: dataEdit.id, + title: dataEdit.title_notif, + description: dataEdit.description, + message: dataEdit.message_notif + }) + } else { + this.setState({ + id: 0, + title: "", + description: "", + message: "" + }) + } + this.setState({ isParentClick: false }); + } + } + + + showDialog = () => { + this.setState({ isParentClick: true }); + } + + + + validate = () => { + let isError = false + const { title, message, penerima } = this.state + if (title === "") { + isError = true + this.setState({ errorTitle: ERROR_TITLE }) + } else if (title.length < 3 || title.length > 100) { + isError = true + this.setState({ errorTitle: "Title minimum 3-100 karakter!" }) + } + + if (message === "") { + isError = true + this.setState({ errorMessage: ERROR_MESSAGE }) + } else if (message.length < 3 || message.length > 200) { + isError = true + this.setState({ errorMessage: "message minimum 3-200 karakter!" }) + } + + if (penerima === "division") { + if (this.state.idOrganization === 0) { + this.setState({ errorDivision: "Silahkan pilih divisi penerima!" }) + } + } else if (penerima === "karyawan") { + if (this.state.selectedKeys.length === 0) { + this.setState({ errorEmployee: "Silahkan pilih karyawan penerima!" }) + } + } + return isError + } + handleSave = (param) => { + let err = this.validate() + if (!err) { + const { + id, + title, + description, + message, + penerima, + + } = this.state + let idSend = []; + let send_to_type = "all"; + if (penerima === "all") { + idSend = this.state.allEmployeeId; + send_to_type = "all"; + } else if (penerima === "organization") { + idSend = this.state.idOrganization; + send_to_type = "roles"; + } else if (penerima === "karyawan") { + idSend = this.state.targetKeys; + send_to_type = "users"; + } + + if (Array.isArray(idSend)) { + idSend = idSend.map(function (e) { + return e.toString() + }); + } else { + idSend = idSend; + } + const data = { + title, + description, + message, + send_to_type, + id: idSend + } + if (param === 'registered' || param === 'send') { + this.props.handleSaveBroadcast(param, data) + } + this.setState({ id: 0, idOrganization: 0, currentSelectDiv: null, targetKeys: [], penerima: "all", displayKaryawan: "none", displayDivisi: "none", disableTransfer: true }); + } + } + + handleCancel = () => { + this.props.handleSaveBroadcast('cancel', 'none') + } + + handleChangePenerima = type => { + if (type === "organization") { + this.setState({ displayDivisi: "block", displayKaryawan: "none", disableTransfer: true, errorDivision: "", targetKeys: [] }) + } else if (type === "karyawan") { + this.setState({ displayKaryawan: "block", displayDivisi: "none", disableTransfer: false, errorEmployee: "", idEmployeeDivision: [], currentSelectDiv: null }) + } else { + this.setState({ displayKaryawan: "none", displayDivisi: "none", disableTransfer: true, errorDivision: "", errorEmployee: "", targetKeys: [], idEmployeeDivision: [], currentSelectDiv: null }) + } + this.setState({ penerima: type }); + } + + handleSelectOrganization = (inputValue, actionMeta) => { + this.setState({ idOrganization: inputValue.value, currentSelectDiv: { value: inputValue.value, label: inputValue.label }, errorDivision: "" }, () => { + this.setEmployeeOrganization(); + }); + } + + setEmployeeOrganization = () => { + let arrEd = this.state.dataEmployee.data; + let cek = arrEd.filter(this.filterId) + + this.setState({ idEmployeeDivision: cek }) + } + + filterId = (val) => { + return val.organization_id == this.state.idOrganization + } + + getDataRole = async () => { + const payload = { + "paging": { + "start": 0, + "length": -1 + }, + "orders": { "columns": ["id"], "ascending": false } + } + + const result = await axios + .post(ROLE_SEARCH, payload, config) + .then(res => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code === 200) { + this.setState({ dataDivision: result.data.data }, () => { + this.setDataOrganization(); + }) + } else { + } + } + + setDataOrganization = () => { + const { dataDivision } = this.state + const listOrganization = [] + dataDivision.map((val, index) => { + listOrganization.push({ + value: val.id, + label: val.name + }) + }) + this.setState({ listOrganizationSelect: listOrganization }) + } + + getDataUsers = async () => { + const payload = { + "paging": { + "start": 0, + "length": -1 + }, + "columns": [ + { + "name": "name", + "logic_operator": "like", + "value": "", + "operator": "AND", + "table_name": "m_users" + } + ], + "orders": { + "columns": [ + "id" + ], + "ascending": false + } + } + //TODO should use search instead + const result = await axios + .post(USER_SEARCH, payload, config) + .then(res => res) + .catch((error) => error.response); + + if (result && result.data && result.status == 200) { + this.setState({ dataEmployee: result.data }, () => { + this.setDataEmployee(); + }); + } else { + } + } + + setDataEmployee = () => { + const listEmployee = []; + const allIdEmployee = []; + this.state.dataEmployee.data.map((val, index) => { + allIdEmployee.push(val.id); + listEmployee.push({ + key: val.id, + id: val.id, + title: val.name + }); + }) + + this.setState({ dataSourceEmployee: listEmployee, allEmployeeId: allIdEmployee }) + } + + handleChangeTransfer = (nextTargetKeys, direction, moveKeys) => { + this.setState({ targetKeys: nextTargetKeys, errorEmployee: "" }); + + }; + + handleSelectChangeTransfer = (sourceSelectedKeys, targetSelectedKeys) => { + this.setState({ selectedKeys: [...sourceSelectedKeys, ...targetSelectedKeys], errorEmployee: "" }); + + }; + + renderForm = () => { + const t = this.props + const { errorTitle, errorMessage } = this.state + return ( +
+ + + this.handleChangePenerima(e.target.value)}> + + + + + + + + + this.setState( + { + errorTitle: e.target.value !== "" ? "" : ERROR_TITLE, + title: e.target.value + })} + placeholder={this.props.t('inputTitle')} /> + {errorTitle && ( + {errorTitle} + )} + + + + this.setState({ errorMessage: e.target.value !== "" ? "" : ERROR_MESSAGE, message: e.target.value })} placeholder={this.props.t('inputMsg')} /> + {errorMessage && ( + {errorMessage} + )} + + + + this.setState({ description: e.target.value })} placeholder={this.props.t('inputDescription')} /> + +
+ ) + } + handleCloseDialog = () => { + this.props.closeDialog() + this.setState({ + errorTitle: "", + errorMessage: "", + errorDivision: "", + errorEmployee: "" + }) + } + render() { + return ( + + {this.props.t('broadcastDetail')} + + {this.renderForm()} + + + {' '} + {' '} + + + + ) + } +} +export default withTranslation()(DialogForm); diff --git a/src/views/Master/MasterBroadcast/index.js b/src/views/Master/MasterBroadcast/index.js index 2622210..c32abb3 100644 --- a/src/views/Master/MasterBroadcast/index.js +++ b/src/views/Master/MasterBroadcast/index.js @@ -5,7 +5,7 @@ import React, { Component } from 'react'; import SweetAlert from 'react-bootstrap-sweetalert'; import axios from 'axios'; import moment from 'moment'; -import { USER_LIST, BASE_SIMPRO_LUMEN, ROLE_LIST, COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst'; +import { BASE_SIMPRO_LUMEN } from '../../../const/ApiConst'; import { Button, Card, CardBody, CardHeader, DropdownItem, DropdownMenu, DropdownToggle, Input, InputGroup, InputGroupButtonDropdown, Table, Row, Col } from 'reactstrap'; import { DatePicker, Pagination } from 'antd'; import { NotificationContainer, NotificationManager } from 'react-notifications'; @@ -66,9 +66,7 @@ class index extends Component { totalPage: 0, typeClock: "All", typeDialog: 'Save', - role_name: props.role_name || '', - company_id: props.company_id, - listCompany: [] + role_name: props.role_name || '' } } @@ -82,17 +80,6 @@ class index extends Component { if (startDate !== prevState.startDate) this.getDataBroadcast() } - - getDataCompany = async () => { - const result = await axios - .get(COMPANY_MANAGEMENT_LIST, config) - .then(res => res) - .catch((error) => error.response); - - if (result && result.data && result.data.code == 200) { - this.setState({ listCompany: result.data.data }) - } - } handleSearch = e => { const value = e.target.value this.setState({ search: value, currentPage: 1 }) @@ -139,24 +126,6 @@ class index extends Component { } } - if (this.state.role_name === 'Super Admin') { - payload.joins.push( - { name: "m_company", column_join: "company_id", column_results: ["company_name"] } - ) - payload.columns.push( - { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } - ) - } else { - payload.columns.push( - { - "name": "company_id", - "logic_operator": "=", - "value": this.state.company_id, - "operator": "AND" - } - ) - } - const result = await axios .post(url, payload, config) .then(res => res) @@ -164,7 +133,6 @@ class index extends Component { if (result && result.data) { if (result.data.code === 200) { this.setState({ dataTable: result.data.data, totalPage: result.data.totalRecord }); - this.getDataCompany() } else { NotificationManager.error('Failed retreiving data!!', 'Failed'); } @@ -217,8 +185,7 @@ class index extends Component { "status_send": type, "send_to_type": "all", "message_notif": data.message, - "description": data.description, - "company_id": data.company_id + "description": data.description } const paramRoles = { @@ -227,8 +194,7 @@ class index extends Component { "send_to_type": "roles", "message_notif": data.message, "description": data.description, - "send_to_id": data.id, - "company_id": data.company_id + "send_to_id": data.id } const paramUsers = { @@ -237,8 +203,7 @@ class index extends Component { "send_to_type": "users", "message_notif": data.message, "description": data.description, - "send_to_id": data.send_to_type == "users" ? data.id.map((id, index) => id) : null, - "company_id": data.company_id + "send_to_id": data.send_to_type == "users" ? data.id.map((id, index) => id) : null } if (data.send_to_type === "all") { @@ -491,9 +456,6 @@ class index extends Component { - {this.state.role_name === 'Super Admin' && - {n.join_first_company_name ? n.join_first_company_name : "-"} - } {n.title_notif} {n.message_notif !== "" ? n.message_notif : "-"} {n.description !== "" ? n.description : "-"} @@ -560,7 +522,6 @@ class index extends Component { render() { const column = [ { name: this.props.t('action') }, - this.state.role_name === 'Super Admin' ? { name: this.props.t('company') } : null, { name: this.props.t('title') }, { name: this.props.t('message') }, { name: this.props.t('description') }, @@ -595,9 +556,7 @@ class index extends Component { dataEdit={this.state.dataEdit} showDialog={showDialog => this.showChildDialog = showDialog} dataHs={this.state.dataIdHo} - company_id={this.state.company_id} role_name={this.state.role_name} - listCompany={this.state.listCompany} /> { - const result = await axios - .get(COMPANY_MANAGEMENT_LIST, this.state.config) - .then((res) => res) - .catch((error) => error.response); - - if (result && result.data && result.data.code == 200) { - let dataRes = result.data.data || []; - this.setState({companyList: dataRes}) - } else { - NotificationManager.error("Gagal Mengambil Data!!", "Failed"); - } - }; - getAllMenu = async () => { const payload = { "paging": { "start": 0, "length": -1 }, @@ -100,10 +80,6 @@ class DialogForm extends Component { } validation = () => { - if (this.state.role_name === 'Super Admin' && !this.state.scompany_id || this.state.scompany_id === "") { - alert("Company data cannot be empty!"); - return true; - } if (!this.state.name || this.state.name === "") { alert("Role Name cannot be empty!"); return true; @@ -125,8 +101,6 @@ class DialogForm extends Component { description, selectedMenu, role_name, - company_id, - scompany_id, all_project } = this.state @@ -139,7 +113,6 @@ class DialogForm extends Component { name, description, selectedMenu, - company_id : role_name !== 'Super Admin' ? company_id : scompany_id, all_project } @@ -150,7 +123,6 @@ class DialogForm extends Component { name, description, selectedMenu, - company_id : role_name !== 'Super Admin' ? company_id : scompany_id, all_project } this.props.closeDialog('edit', data); @@ -163,9 +135,6 @@ class DialogForm extends Component { this.props.closeDialog('cancel', 'none') } - onChangeCompanyProject = (val) => { - this.setState({scompany_id : val}); - }; renderForm = () => { const { t } = this.props; return ( @@ -176,31 +145,6 @@ class DialogForm extends Component { - { - this.state.role_name === 'Super Admin' && ( - - - - - - - ) - } diff --git a/src/views/Master/MasterRoles/DialogMenuRoles.js b/src/views/Master/MasterRoles/DialogMenuRoles.js index ab8c026..86f4a40 100644 --- a/src/views/Master/MasterRoles/DialogMenuRoles.js +++ b/src/views/Master/MasterRoles/DialogMenuRoles.js @@ -3,7 +3,7 @@ import { Modal, ModalHeader, ModalBody, ModalFooter, Table } from 'reactstrap'; import { Button, Form } from 'reactstrap'; import 'antd/dist/antd.css'; import axios from 'axios'; -import { MENU_COMPANY_SEARCH } from '../../../const/ApiConst.js'; +import { MENU_SEARCH } from '../../../const/ApiConst'; const token = window.localStorage.getItem('token'); const config = { headers: @@ -68,11 +68,8 @@ export default class DialogMenuRoles extends Component { ], "orders": { "columns": ["id"], "ascending": false } } - payload.columns.push( - { "name": "company_id", "logic_operator": "=", "value": this.props.company_id, "operator": "AND" } - ) const result = await axios - .post(MENU_COMPANY_SEARCH, payload, config) + .post(MENU_SEARCH, payload, config) .then(res => res) .catch((error) => error.response); if (result && result.data && result.data.code == 200) { diff --git a/src/views/Master/MasterRoles/index.js b/src/views/Master/MasterRoles/index.js index 123d531..47e91cd 100644 --- a/src/views/Master/MasterRoles/index.js +++ b/src/views/Master/MasterRoles/index.js @@ -51,7 +51,6 @@ class index extends Component { all_project: props.all_project || null, hierarchy: props.hierarchy || [], user_name: props.user_name || '', - company_id: props.company_id || 0, config: { headers: { Authorization: `Bearer ${props.token || ''}`, @@ -92,18 +91,6 @@ class index extends Component { , }, - ...(this.state.role_name === 'Super Admin' - ? [ - { - title: this.props.t('company'), - dataIndex: "join_first_company_name", - key: "join_first_company_name", - render: (text, record) => ( - {record.join_first_company_name} - ), - } - ] - : []), { title: this.props.t('nameRole'), dataIndex: 'name', key: 'name', className: "nowrap" }, { title: this.props.t('description'), dataIndex: 'description', key: 'description' }, ] @@ -148,18 +135,6 @@ class index extends Component { "joins": [], "orders": { "columns": ["id"], "ascending": false } } - if (this.state.role_name !== "Super Admin") { - formData.columns.push( - { "name": "company_id", "logic_operator": "=", "value": this.props.company_id, "operator": "AND" }, - ) - } else { - formData.joins.push( - { "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] } - ) - formData.group_column.where.push( - { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } - ) - } const result = await axios .post(ROLE_SEARCH, formData, this.state.config) .then(res => res) @@ -226,7 +201,6 @@ class index extends Component { name: data.name, description: data.description, default_page: data.selectedMenu, - company_id: data.company_id, all_project: data.all_project } @@ -247,7 +221,6 @@ class index extends Component { name: data.name, description: data.description, default_page: data.selectedMenu, - company_id: data.company_id, all_project: data.all_project } const url = ROLE_EDIT(data.id) @@ -264,7 +237,7 @@ class index extends Component { } handleEdit = (data) => { - this.setState({ dataEdit: data, company_id: data.company_id }); + this.setState({ dataEdit: data }); this.handleOpenDialog('Edit'); } @@ -324,7 +297,7 @@ class index extends Component { .then(res => res) .catch((error) => error.response); if (result && result.data && result.data.code == 200) { - this.setState({ menuRoles: result.data.data, idRoles: data.id, company_id: data.company_id }, () => { + this.setState({ menuRoles: result.data.data, idRoles: data.id }, () => { this.handleOpenDialogMr(); }); } @@ -395,19 +368,6 @@ class index extends Component { "orders": { "columns": ["id"], "ascending": false } } - if (this.state.role_name !== "Super Admin") { - formData.columns.push( - { "name": "company_id", "logic_operator": "=", "value": this.props.company_id, "operator": "AND" }, - ) - } else { - formData.joins.push( - { "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] } - ) - formData.group_column.where.push( - { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } - ) - } - const result = await axios .post(ROLE_SEARCH, formData, this.state.config) .then(res => res) @@ -418,9 +378,6 @@ class index extends Component { const dataExport = []; dataRes.map((val, index) => { let row = {}; - if (this.state.role_name === 'Super Admin') { - row.Company = val.join_first_company_name; - } row.Nama = val.name; row.Deskripsi = val.description; dataExport.push(row); @@ -478,7 +435,6 @@ class index extends Component { dataEdit={this.state.dataEdit} showDialog={showDialog => this.showChildDialog = showDialog} dataHs={this.state.dataIdHo} - company_id={this.state.company_id} role_name={this.state.role_name} token={this.state.token} /> @@ -488,7 +444,6 @@ class index extends Component { idRoles={this.state.idRoles} showDialog={showDialog => this.showMenuRolesDialog = showDialog} menuRoles={this.state.menuRoles} - company_id={this.state.company_id} role_name={this.state.role_name} role_id={this.state.role_id} token={this.state.token} diff --git a/src/views/Master/ProjectExpenditure/DialogForm.js b/src/views/Master/ProjectExpenditure/DialogForm.js index 1bf2886..6373c3a 100644 --- a/src/views/Master/ProjectExpenditure/DialogForm.js +++ b/src/views/Master/ProjectExpenditure/DialogForm.js @@ -9,7 +9,6 @@ import InputColor from "./InputColor"; import "./styles.css"; import "rc-color-picker/assets/index.css"; import { useTranslation } from 'react-i18next'; -const company_id = localStorage.getItem("company_id") const { Option } = Select; const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit }) => { const [id, setId] = useState(0) @@ -33,16 +32,14 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi if (typeDialog === "Save") { data = { name: projectExpenditure, - color, - company_id + color } closeDialog('save', data); } else { data = { id, name: projectExpenditure, - color, - company_id + color } closeDialog('edit', data); } diff --git a/src/views/Master/ProjectExpenditure/index.js b/src/views/Master/ProjectExpenditure/index.js index c9b227d..e7653a8 100644 --- a/src/views/Master/ProjectExpenditure/index.js +++ b/src/views/Master/ProjectExpenditure/index.js @@ -12,13 +12,12 @@ import { useTranslation } from 'react-i18next'; const ProjectExpenditure = ({ params, ...props }) => { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name='', hierarchy=[], user_name=''; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; token = props.token; isLogin = props.isLogin; - company_id = props.company_id; all_project = props.all_project; role_name = props.role_name; isLogin = props.isLogin; @@ -85,15 +84,7 @@ const ProjectExpenditure = ({ params, ...props }) => { "start": start } } - if (role_name !== "Super Admin") { - payload.columns.push( - { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, - ) - } else { - payload.columns.push( - { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, - ) - } + const result = await axios .post(PROJECT_EXPENDITURE_SEARCH, payload, HEADER) .then((res) => res) diff --git a/src/views/Master/ProjectFinancialHealth/DialogForm.js b/src/views/Master/ProjectFinancialHealth/DialogForm.js index aed6397..d00dd8f 100644 --- a/src/views/Master/ProjectFinancialHealth/DialogForm.js +++ b/src/views/Master/ProjectFinancialHealth/DialogForm.js @@ -9,7 +9,6 @@ import InputColor from "./InputColor"; import "./styles.css"; import "rc-color-picker/assets/index.css"; import { useTranslation } from 'react-i18next'; -const company_id = localStorage.getItem("company_id") const { Option } = Select; const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit }) => { const [id, setId] = useState(0) @@ -33,16 +32,14 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi if (typeDialog === "Save") { data = { name: projectFinancialHealth, - color, - company_id + color } closeDialog('save', data); } else { data = { id, name: projectFinancialHealth, - color, - company_id + color } closeDialog('edit', data); } diff --git a/src/views/Master/ProjectFinancialHealth/index.js b/src/views/Master/ProjectFinancialHealth/index.js index 28f9fcd..59576e2 100644 --- a/src/views/Master/ProjectFinancialHealth/index.js +++ b/src/views/Master/ProjectFinancialHealth/index.js @@ -12,13 +12,12 @@ import { useTranslation } from 'react-i18next'; const ProjectFinancialHealth = ({ params, ...props }) => { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name='', hierarchy=[], user_name=''; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; token = props.token; isLogin = props.isLogin; - company_id = props.company_id; all_project = props.all_project; role_name = props.role_name; isLogin = props.isLogin; @@ -85,15 +84,7 @@ const ProjectFinancialHealth = ({ params, ...props }) => { "start": start } } - if (role_name !== "Super Admin") { - payload.columns.push( - { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, - ) - } else { - payload.columns.push( - { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, - ) - } + const result = await axios .post(PROJECT_FINANCIAL_HEALTH_SEARCH, payload, HEADER) .then((res) => res) diff --git a/src/views/Master/ProjectInvoice/DialogForm.js b/src/views/Master/ProjectInvoice/DialogForm.js index 2a42dc1..cd02234 100644 --- a/src/views/Master/ProjectInvoice/DialogForm.js +++ b/src/views/Master/ProjectInvoice/DialogForm.js @@ -9,7 +9,6 @@ import InputColor from "./InputColor"; import "./styles.css"; import "rc-color-picker/assets/index.css"; import { useTranslation } from 'react-i18next'; -const company_id = localStorage.getItem("company_id") const { Option } = Select; const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit }) => { const [id, setId] = useState(0) @@ -33,16 +32,14 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi if (typeDialog === "Save") { data = { name: projectInvoice, - color, - company_id + color } closeDialog('save', data); } else { data = { id, name: projectInvoice, - color, - company_id + color } closeDialog('edit', data); } diff --git a/src/views/Master/ProjectInvoice/index.js b/src/views/Master/ProjectInvoice/index.js index c030d1d..ca652ee 100644 --- a/src/views/Master/ProjectInvoice/index.js +++ b/src/views/Master/ProjectInvoice/index.js @@ -12,13 +12,12 @@ import { useTranslation } from 'react-i18next'; const ProjectInvoice = ({ params, ...props }) => { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name='', hierarchy=[], user_name=''; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; token = props.token; isLogin = props.isLogin; - company_id = props.company_id; all_project = props.all_project; role_name = props.role_name; isLogin = props.isLogin; @@ -85,15 +84,7 @@ const ProjectInvoice = ({ params, ...props }) => { "start": start } } - if (role_name !== "Super Admin") { - payload.columns.push( - { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, - ) - } else { - payload.columns.push( - { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, - ) - } + const result = await axios .post(PROJECT_INVOICE_SEARCH, payload, HEADER) .then((res) => res) diff --git a/src/views/Master/ProjectPhase/DialogForm.js b/src/views/Master/ProjectPhase/DialogForm.js index 05d02be..9318254 100644 --- a/src/views/Master/ProjectPhase/DialogForm.js +++ b/src/views/Master/ProjectPhase/DialogForm.js @@ -1,132 +1,91 @@ -import React, { useEffect, useState } from 'react' -import { - Modal, ModalHeader, ModalBody, ModalFooter, - Button, Form, FormGroup, Label, Input, Col, Row -} from 'reactstrap'; -import 'antd/dist/antd.css'; -import InputColor from "./InputColor"; -import "./styles.css"; -import "rc-color-picker/assets/index.css"; -import { useTranslation } from 'react-i18next'; -import { Select } from 'antd'; -const { Option } = Select -const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, company_id, listCompany, role_name }) => { - const [id, setId] = useState(0) - const [projectType, setProjectType] = useState('') - const [color, setColor] = useState('') - const [selectedCompany, setSelectedCompany] = useState(null) - const { t } = useTranslation(); - useEffect(() => { - if (typeDialog === "Edit") { - setId(dataEdit.id) - setProjectType(dataEdit.name) - setColor(dataEdit.color) - setSelectedCompany(dataEdit.company_id) - } else { - setId(0) - setColor('') - setProjectType('') - } - }, [dataEdit, openDialog]) - - const handleSave = () => { - let data = ''; - if (typeDialog === "Save") { - if (role_name === 'Super Admin') { - company_id = selectedCompany - } - data = { - name: projectType, - color, - company_id: company_id - } - closeDialog('save', data); - } else { - if (role_name === 'Super Admin') { - company_id = selectedCompany - } - data = { - id, - name: projectType, - color, - company_id: company_id - } - closeDialog('edit', data); - } - setId(0) - } - - const handleCancel = () => { - closeDialog('cancel', 'none') - setId(0) - } - - const onChangeCompany = (val) => { - setSelectedCompany(val); - }; - - const renderForm = () => { - return ( -
- - - - - setProjectType(e.target.value)} /> - - - - - - setColor(e.color)} /> - - - - {role_name === 'Super Admin' && - - - - - - - - - } -
- ) - } - - return ( - <> - - {typeDialog == "Save" ? `Add` : "Edit"} data - - {renderForm()} - - - {' '} - - - - - ) -} - -export default DialogForm; +import React, { useEffect, useState } from 'react' +import { + Modal, ModalHeader, ModalBody, ModalFooter, + Button, Form, FormGroup, Label, Input, Col, Row +} from 'reactstrap'; +import 'antd/dist/antd.css'; +import InputColor from "./InputColor"; +import "./styles.css"; +import "rc-color-picker/assets/index.css"; +import { useTranslation } from 'react-i18next'; +import { Select } from 'antd'; +const { Option } = Select +const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, role_name }) => { + const [id, setId] = useState(0) + const [projectType, setProjectType] = useState('') + const [color, setColor] = useState('') + const { t } = useTranslation(); + useEffect(() => { + if (typeDialog === "Edit") { + setId(dataEdit.id) + setProjectType(dataEdit.name) + setColor(dataEdit.color) + } else { + setId(0) + setColor('') + setProjectType('') + } + }, [dataEdit, openDialog]) + + const handleSave = () => { + let data = ''; + if (typeDialog === "Save") { + data = { + name: projectType, + color + } + closeDialog('save', data); + } else { + data = { + id, + name: projectType, + color + } + closeDialog('edit', data); + } + setId(0) + } + + const handleCancel = () => { + closeDialog('cancel', 'none') + setId(0) + } + + const renderForm = () => { + return ( +
+ + + + + setProjectType(e.target.value)} /> + + + + + + setColor(e.color)} /> + + + +
+ ) + } + + return ( + <> + + {typeDialog == "Save" ? `Add` : "Edit"} data + + {renderForm()} + + + {' '} + + + + + ) +} + +export default DialogForm; diff --git a/src/views/Master/ProjectPhase/index.js b/src/views/Master/ProjectPhase/index.js index 708e91a..204ce2a 100644 --- a/src/views/Master/ProjectPhase/index.js +++ b/src/views/Master/ProjectPhase/index.js @@ -6,27 +6,22 @@ import axios from "../../../const/interceptorApi" import moment from 'moment' import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; import { NotificationContainer, NotificationManager } from 'react-notifications'; -import { PROJECT_PHASE_ADD, PROJECT_PHASE_EDIT, PROJECT_PHASE_DELETE, PROJECT_PHASE_SEARCH, COMPANY_MANAGEMENT_LIST, BASE_OSPRO } from '../../../const/ApiConst'; +import { PROJECT_PHASE_ADD, PROJECT_PHASE_EDIT, PROJECT_PHASE_DELETE, PROJECT_PHASE_SEARCH, BASE_OSPRO } from '../../../const/ApiConst'; import { Pagination, Button, Tooltip, Table } from 'antd'; import { useTranslation } from 'react-i18next'; import { - formatNumber, - formatRupiah, - formatThousand, - renderFormatRupiah, checkActMenup, } from "../../../const/CustomFunc"; import { useLocation } from "react-router-dom"; const ProjectPhase = ({ params, ...props }) => { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = ''; + let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name = '', hierarchy = [], user_name = ''; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; token = props.token; isLogin = props.isLogin; - company_id = props.company_id; all_project = props.all_project; role_name = props.role_name; isLogin = props.isLogin; @@ -58,7 +53,6 @@ const ProjectPhase = ({ params, ...props }) => { const [search, setSearch] = useState('') const [totalPage, setTotalPage] = useState(0) const [typeDialog, setTypeDialog] = useState('Save') - const [listCompany, setListCompany] = useState([]) const { t } = useTranslation() useEffect(() => { getDataProjectPhase() @@ -71,21 +65,6 @@ const ProjectPhase = ({ params, ...props }) => { } }, [dataExport]) - useEffect(() => { - getDataCompany() - }, []) - - const getDataCompany = async () => { - const result = await axios - .get(COMPANY_MANAGEMENT_LIST, HEADER) - .then(res => res) - .catch((error) => error.response); - - if (result && result.data && result.data.code == 200) { - setListCompany(result.data.data); - } - } - const getDataProjectPhase = async () => { let start = 0; if (currentPage !== 1 && currentPage > 1) { @@ -116,21 +95,7 @@ const ProjectPhase = ({ params, ...props }) => { }, 'joins': [] } - if (role_name !== "Super Admin") { - payload.columns.push( - { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, - ) - } else { - payload.columns.push( - { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, - ) - payload.joins.push( - { name: "m_company", column_join: "company_id", column_results: ["company_name"] } - ) - payload.group_column.where.push( - { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } - ) - } + const result = await axios .post(PROJECT_PHASE_SEARCH, payload, HEADER) .then((res) => res) @@ -189,21 +154,6 @@ const ProjectPhase = ({ params, ...props }) => { }, 'joins': [] } - if (role_name !== "Super Admin") { - payload.columns.push( - { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, - ) - } else { - payload.columns.push( - { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, - ) - payload.joins.push( - { name: "m_company", column_join: "company_id", column_results: ["company_name"] } - ) - payload.group_column.where.push( - { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } - ) - } const result = await axios .post(PROJECT_PHASE_SEARCH, payload, HEADER) @@ -214,9 +164,6 @@ const ProjectPhase = ({ params, ...props }) => { const excelData = []; resData.map((val, index) => { let dataRow = {}; - if (role_name === 'Super Admin') { - dataRow.Company = val.join_first_company_name; - } dataRow.Nama = val.name; dataRow.Color = val.color; excelData.push(dataRow) @@ -376,16 +323,6 @@ const ProjectPhase = ({ params, ...props }) => { {" "} , }, - ...(role_name === 'Super Admin' ? - [{ - title: t('companyName'), - dataIndex: "join_first_company_name", - key: "join_first_company_name", - render: (text, record) => ( - {record.join_first_company_name} - ) - }] - : []), { title: t('phase'), dataIndex: 'name', key: 'name', className: "nowrap" }, @@ -435,9 +372,7 @@ const ProjectPhase = ({ params, ...props }) => { dataEdit={dataEdit} clickOpenModal={clickOpenModal} dataParent={allDataMenu} - listCompany={listCompany} role_name={role_name} - company_id={company_id} /> diff --git a/src/views/Master/ProjectScheduleHealth/DialogForm.js b/src/views/Master/ProjectScheduleHealth/DialogForm.js index 7b77ead..2e2f646 100644 --- a/src/views/Master/ProjectScheduleHealth/DialogForm.js +++ b/src/views/Master/ProjectScheduleHealth/DialogForm.js @@ -9,7 +9,6 @@ import InputColor from "./InputColor"; import "./styles.css"; import "rc-color-picker/assets/index.css"; import { useTranslation } from 'react-i18next'; -const company_id = localStorage.getItem("company_id") const { Option } = Select; const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit }) => { const [id, setId] = useState(0) @@ -33,16 +32,14 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi if (typeDialog === "Save") { data = { name: projectScheduleHealth, - color, - company_id + color } closeDialog('save', data); } else { data = { id, name: projectScheduleHealth, - color, - company_id + color } closeDialog('edit', data); } diff --git a/src/views/Master/ProjectScheduleHealth/index.js b/src/views/Master/ProjectScheduleHealth/index.js index 36bc06f..3ce800f 100644 --- a/src/views/Master/ProjectScheduleHealth/index.js +++ b/src/views/Master/ProjectScheduleHealth/index.js @@ -12,13 +12,12 @@ import { useTranslation } from 'react-i18next'; const ProjectScheduleHealth = ({ params, ...props }) => { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; + let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name='', hierarchy=[], user_name=''; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; token = props.token; isLogin = props.isLogin; - company_id = props.company_id; all_project = props.all_project; role_name = props.role_name; isLogin = props.isLogin; @@ -85,15 +84,7 @@ const ProjectScheduleHealth = ({ params, ...props }) => { "start": start } } - if (role_name !== "Super Admin") { - payload.columns.push( - { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, - ) - } else { - payload.columns.push( - { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, - ) - } + const result = await axios .post(PROJECT_SCHEDULE_HEALTH_SEARCH, payload, HEADER) .then((res) => res) diff --git a/src/views/Master/Proyek/index.js b/src/views/Master/Proyek/index.js index 3a63728..503db44 100644 --- a/src/views/Master/Proyek/index.js +++ b/src/views/Master/Proyek/index.js @@ -48,7 +48,6 @@ const data = [ const url = ""; const proyek_id = localStorage.getItem('proyek_id'); const role_id = localStorage.getItem('role_id'); -const company_id = window.localStorage.getItem('company_id'); const IndexRole = ({ params }) => { const token = localStorage.getItem("token") @@ -215,7 +214,7 @@ const IndexRole = ({ params }) => { } const onConfirmDelete = async () => { - let urlDel = PROYEK_DELETE(idDelete, company_id); + let urlDel = PROYEK_DELETE(idDelete); const result = await axios.delete(urlDel, HEADER) .then(res => res) .catch((error) => error.response); diff --git a/src/views/Master/RoleProject/DialogForm.js b/src/views/Master/RoleProject/DialogForm.js index d52f788..3e80e2a 100644 --- a/src/views/Master/RoleProject/DialogForm.js +++ b/src/views/Master/RoleProject/DialogForm.js @@ -2,7 +2,6 @@ import React, { Component } from 'react' import { Modal, ModalHeader, ModalBody, ModalFooter, Button, Form, FormGroup, Label, Input } from 'reactstrap'; import 'antd/dist/antd.css'; import axios from 'axios'; -import { COMPANY_MANAGEMENT_LIST } from '../../../const/ApiConst.js'; import { withTranslation } from 'react-i18next'; import { NotificationManager } from 'react-notifications'; import { Select } from 'antd'; @@ -15,10 +14,7 @@ class DialogForm extends Component { name: "", description: "", openDialog: false, - companyList: [], - scompany_id:null, isParentClick: false, - company_id: props.company_id || null, role_name: props.role_name || '', token: props.token || '', config: { @@ -32,7 +28,6 @@ class DialogForm extends Component { async componentDidMount() { this.props.showDialog(this.showDialog); - this.getDataProyekCompany(); } async componentDidUpdate() { @@ -42,15 +37,13 @@ class DialogForm extends Component { this.setState({ id: dataEdit.id, name: dataEdit.name, - description: dataEdit.description, - scompany_id : dataEdit.company_id + description: dataEdit.description }) } else { this.setState({ id: 0, name: "", - description: "", - scompany_id:null + description: "" }) } this.setState({ isParentClick: false }); @@ -62,58 +55,29 @@ class DialogForm extends Component { this.setState({ isParentClick: true }); } - getDataProyekCompany = async () => { - const result = await axios - .get(COMPANY_MANAGEMENT_LIST, this.state.config) - .then((res) => res) - .catch((error) => error.response); - - if (result && result.data && result.data.code == 200) { - let dataRes = result.data.data || []; - this.setState({companyList: dataRes}) - } else { - NotificationManager.error("Gagal Mengambil Data!!", "Failed"); - } - }; - - validation = () => { - if (this.state.role_name === 'Super Admin' && !this.state.scompany_id || this.state.scompany_id === "") { - alert("Company data cannot be empty!"); - return true; - } - } - handleSave = () => { const { id, name, - description, - role_name, - company_id, - scompany_id + description } = this.state let data = ''; - const err = this.validation(); - if(!err) { if (this.props.typeDialog === "Save") { data = { id, name, - description, - company_id : role_name !== 'Super Admin' ? company_id : scompany_id, + description } this.props.closeDialog('save', data); } else { data = { id, name, - description, - company_id : role_name !== 'Super Admin' ? company_id : scompany_id, + description } this.props.closeDialog('edit', data); } - } this.setState({ id: 0 }); } @@ -121,37 +85,10 @@ class DialogForm extends Component { this.props.closeDialog('cancel', 'none') } - onChangeCompanyProject = (val) => { - this.setState({scompany_id : val}); - }; - renderForm = () => { const { t } = this.props; return (
- { - this.state.role_name === 'Super Admin' && ( - - - - - ) - } this.setState({ name: e.target.value })} placeholder={this.props.t('inputName')} /> diff --git a/src/views/Master/RoleProject/index.js b/src/views/Master/RoleProject/index.js index 4d7bbc5..58750dd 100644 --- a/src/views/Master/RoleProject/index.js +++ b/src/views/Master/RoleProject/index.js @@ -39,7 +39,6 @@ class index extends Component { tooltipTambah: false, totalPage: 0, typeDialog: 'Save', - company_id: props.company_id || 0, role_name: props.role_name || '', role_id: props.role_id || 0, user_id: props.user_id || 0, @@ -65,32 +64,22 @@ class index extends Component { render: (text, record) => <> { - checkActMenup('/project-role', 'delete') ? - this.handleDelete(text.id)}> - : - null - } + checkActMenup('/project-role', 'delete') ? + this.handleDelete(text.id)}> + : + null + } { - checkActMenup('/project-role', 'update') ? - this.handleEdit(text)}> - : - null - } + checkActMenup('/project-role', 'update') ? + this.handleEdit(text)}> + : + null + } , }, - { - title: this.state.role_name === 'Super Admin' ? "Company Name" : null, - dataIndex: "join_first_company_name", - key: "join_first_company_name", - render: (text, record) => { - return this.state.role_name === 'Super Admin' ? ( - {record.join_first_company_name} - ) : null; - } - }, { title: this.props.t('name'), dataIndex: 'name', key: 'name', className: "nowrap" }, { title: this.props.t('description'), dataIndex: 'description', key: 'description' }, ]; @@ -133,21 +122,7 @@ class index extends Component { "joins": [], "orders": { "columns": ["id"], "ascending": false } } - if (this.state.role_name !== "Super Admin") { - formData.columns.push( - { "name": "company_id", "logic_operator": "=", "value": parseInt(this.state.company_id), "operator": "AND" }, - ) - } else { - formData.columns.push( - { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, - ) - formData.joins.push( - { "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] } - ) - formData.group_column.where.push( - { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } - ) - } + const result = await axios .post(PROJECT_ROLE_SEARCH, formData, this.state.config) .then(res => res) @@ -212,8 +187,7 @@ class index extends Component { const formData = { name: data.name, - description: data.description, - company_id: data.company_id + description: data.description } const result = await axios.post(PROJECT_ROLE_ADD, formData, this.state.config) @@ -233,8 +207,7 @@ class index extends Component { const formData = { name: data.name, - description: data.description, - company_id : data.company_id + description: data.description } const url = PROJECT_ROLE_EDIT(data.id) const result = await axios.put(url, formData, this.state.config) @@ -315,21 +288,7 @@ class index extends Component { "joins": [], "orders": { "columns": ["id"], "ascending": false } } - if (this.state.role_name !== "Super Admin") { - payload.columns.push( - { "name": "company_id", "logic_operator": "=", "value": this.state.company_id, "operator": "AND" }, - ) - } else { - payload.columns.push( - { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, - ) - payload.joins.push( - { "name": "m_company", "column_join": "company_id", "column_results": ["company_name"] } - ) - payload.group_column.where.push( - { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } - ) - } + const result = await axios .post(PROJECT_ROLE_SEARCH, payload, this.state.config) .then(res => res) @@ -339,9 +298,6 @@ class index extends Component { const dataExport = []; dataRes.map((val, index) => { let row = {}; - if (this.state.role_name === 'Super Admin') { - row.Company = val.join_first_company_name; - } row.Nama = val.name; row.Deskripsi = val.description; dataExport.push(row); @@ -401,7 +357,6 @@ class index extends Component { dataEdit={this.state.dataEdit} showDialog={showDialog => this.showChildDialog = showDialog} dataHs={this.state.dataIdHo} - company_id={this.state.company_id} role_name={this.state.role_name} token={this.state.token} /> diff --git a/src/views/Pages/Login/Login.js b/src/views/Pages/Login/Login.js index df23776..e6ee1f9 100644 --- a/src/views/Pages/Login/Login.js +++ b/src/views/Pages/Login/Login.js @@ -134,7 +134,7 @@ class Login extends Component { } } - getDataMenu = async (token, role_id, hierarchy, user_id, company_id, role_name, all_project, user_name, configApp) => { + getDataMenu = async (token, role_id, hierarchy, user_id, role_name, all_project, user_name, configApp) => { const config = { headers: { @@ -167,7 +167,6 @@ class Login extends Component { user_id, token, isLogin: true, - company_id, role_name, all_project, user_name, @@ -186,7 +185,6 @@ class Login extends Component { user_id, token, isLogin: true, - company_id, role_name, all_project, user_name, @@ -209,7 +207,6 @@ class Login extends Component { user_id, token, isLogin: true, - company_id, role_name, all_project, user_name, @@ -259,13 +256,12 @@ class Login extends Component { if (doLogin && doLogin.data && doLogin.data.code === 200) { const { access_token, data_user } = doLogin.data.data this.getDataRole(access_token, data_user.role_id) - this.getDataMenu(access_token, data_user.role_id, data_user.hierarchy, data_user.id, data_user.company_id, data_user.role.name, data_user.role.all_project, data_user.user_name, data_user.configApp) + this.getDataMenu(access_token, data_user.role_id, data_user.hierarchy, data_user.id, data_user.role.name, data_user.role.all_project, data_user.user_name, data_user.configApp) window.localStorage.setItem('isLogin', true); window.localStorage.setItem('token', access_token); window.localStorage.setItem('user_id', data_user.id); window.localStorage.setItem('user_name', data_user.name); window.localStorage.setItem('role_id', data_user.role_id); - window.localStorage.setItem('company_id', data_user.company_id); window.localStorage.setItem('role_name', data_user.role.name); window.localStorage.setItem('all_project', data_user.role.all_project); window.localStorage.setItem('hierarchy', JSON.stringify(data_user.hierarchy)); diff --git a/src/views/Report/k3/index.js b/src/views/Report/k3/index.js index a9821de..e611ece 100644 --- a/src/views/Report/k3/index.js +++ b/src/views/Report/k3/index.js @@ -26,13 +26,12 @@ const LENGTH_DATA = 10 class index extends Component { constructor(props) { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = '', configApp={}; + let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name = '', hierarchy = [], user_name = '', configApp={}; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; token = props.token; isLogin = props.isLogin; - company_id = props.company_id; all_project = props.all_project; role_name = props.role_name; isLogin = props.isLogin; @@ -76,9 +75,7 @@ class index extends Component { proyekIds: [], allDataProyek: [], finishSetupOption: false, - company_id: company_id, role_name: role_name, - companyName: JSON.parse(configApp).company_name, role_id: role_id, hierarchy: hierarchy } @@ -210,24 +207,8 @@ class index extends Component { if (currentProyek) { payload.columns.push({ "name": "proyek_id", "logic_operator": "=", "value": this.state.currentProyek }) - if (this.state.role_name === "Super Admin") { - payload.joins.push( - { name: "m_company", column_join: "company_id", column_results: ["company_name"] } - ) - payload.columns.push( - { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } - ) - } } else { payload.columns.push({ "name": "proyek_id", "logic_operator": "in", "value": this.state.proyekIds }) - if (this.state.role_name === "Super Admin") { - payload.joins.push( - { name: "m_company", column_join: "company_id", column_results: ["company_name"] } - ) - payload.columns.push( - { name: "company_name", logic_operator: "~*", value: this.state.search, table_name: "m_company" } - ) - } } const result = await axios @@ -481,9 +462,6 @@ class index extends Component { {dataTable2.length !== 0 ? dataTable2.map((n) => { return ( - {this.state.role_name === 'Super Admin' && - {n.join_third_company_name ? n.join_third_company_name : "-"} - } {n.join_first_name ? n.join_first_name : "-"} {n.join_second_nama ? n.join_second_nama : "-"} {n.report_date ? moment(n.report_date).format("DD-MM-YYYY") : "-"} @@ -553,7 +531,6 @@ class index extends Component { render() { const column = [ - this.state.role_name === 'Super Admin' ? { name: this.props.t('company') } : null, { name: this.props.t('nameHR') }, { name: this.props.t('projectName') }, { name: this.props.t('dateReport') }, @@ -585,7 +562,6 @@ class index extends Component { closeDialog={this.handleCloseDialog} toggleDialog={() => this.toggleAddDialog} dataImage={this.state.dataImage} - companyName={this.state.companyName} showDialog={showDialog => this.showChildDialog = showDialog} /> diff --git a/src/views/SimproV2/ChecklistK3/DialogForm.js b/src/views/SimproV2/ChecklistK3/DialogForm.js index 07a4ab2..4e475f5 100644 --- a/src/views/SimproV2/ChecklistK3/DialogForm.js +++ b/src/views/SimproV2/ChecklistK3/DialogForm.js @@ -1,140 +1,97 @@ -import React, { useEffect, useState } from 'react' -import { - Modal, ModalHeader, ModalBody, ModalFooter, - Button, Form, FormGroup, Label, Input, Col, Row -} from 'reactstrap'; -import 'antd/dist/antd.css'; -import { useTranslation } from 'react-i18next'; -import { Select } from 'antd'; -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 { - handleClearData() - } - }, [dataEdit, openDialog]) - - const handleSave = () => { - let data = ''; - if (role_name === 'Super Admin') { - company_id = selectedCompany - } - - if (typeDialog === "Save") { - data = { - name: name, - description: description, - company_id: parseInt(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); - } - handleClearData() - } - - const handleCancel = () => { - closeDialog('cancel', 'none') - handleClearData() - } - - const handleClearData = () => { - setId(0) - setName('') - 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"} Checlist K3 - - {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 'antd/dist/antd.css'; +import { useTranslation } from 'react-i18next'; +import { Select } from 'antd'; +const { Option } = Select; + +const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdit, role_name }) => { + const [id, setId] = useState(0) + const [name, setName] = useState('') + const [description, setDescription] = useState('') + const { t } = useTranslation() + + useEffect(() => { + if (typeDialog === "Edit") { + setId(dataEdit.id) + setDescription(dataEdit.description) + setName(dataEdit.name) + + } else { + handleClearData() + } + }, [dataEdit, openDialog]) + + const handleSave = () => { + let data = ''; + if (typeDialog === "Save") { + data = { + name: name, + description: description + } + closeDialog('save', data); + } else { + data = { + id, + name: name, + description: description + } + closeDialog('edit', data); + } + handleClearData() + } + + const handleCancel = () => { + closeDialog('cancel', 'none') + handleClearData() + } + + const handleClearData = () => { + setId(0) + setName('') + setDescription('') + } + + const renderForm = () => { + return ( +
+ + + + + setName(e.target.value)} placeholder={t('inputName')} /> + + + + + + setDescription(e.target.value)} placeholder={t('inputDescription')} /> + + + +
+ ) + } + + + return ( + <> + + {typeDialog == "Save" ? `Add` : "Edit"} Checlist K3 + + {renderForm()} + + + {' '} + + + + + ) + +} + +export default DialogForm; diff --git a/src/views/SimproV2/ChecklistK3/index.js b/src/views/SimproV2/ChecklistK3/index.js index 758f833..8f91cbd 100644 --- a/src/views/SimproV2/ChecklistK3/index.js +++ b/src/views/SimproV2/ChecklistK3/index.js @@ -7,17 +7,11 @@ import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap'; import { NotificationContainer, NotificationManager } from 'react-notifications'; import { Pagination, Button, Tooltip, } from 'antd'; import { - CHECKLIST_K3_ADD, CHECKLIST_K3_EDIT, CHECKLIST_K3_DELETE, CHECKLIST_K3_SEARCH, COMPANY_MANAGEMENT_LIST + CHECKLIST_K3_ADD, CHECKLIST_K3_EDIT, CHECKLIST_K3_DELETE, CHECKLIST_K3_SEARCH } from '../../../const/ApiConst'; import { useTranslation } from 'react-i18next'; import { useLocation } from "react-router-dom"; -import { - formatNumber, - formatRupiah, - formatThousand, - renderFormatRupiah, - checkActMenup, -} from "../../../const/CustomFunc"; +import { checkActMenup } from "../../../const/CustomFunc"; const token = window.localStorage.getItem('token'); const config = { @@ -29,13 +23,12 @@ const config = { }; const ChecklistK3 = ({ params, ...props }) => { - let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name = '', hierarchy = [], user_name = ''; + let role_id = 0, user_id = 0, isLogin = false, token = '', all_project = null, role_name = '', hierarchy = [], user_name = ''; if (props && props.role_id && props.user_id) { role_id = props.role_id; user_id = props.user_id; token = props.token; isLogin = props.isLogin; - company_id = props.company_id; all_project = props.all_project; role_name = props.role_name; isLogin = props.isLogin; @@ -64,10 +57,8 @@ const ChecklistK3 = ({ params, ...props }) => { const [search, setSearch] = useState('') const [totalPage, setTotalPage] = useState(0) const [typeDialog, setTypeDialog] = useState('Save') - const [listCompany, setListCompany] = useState([]) const { t } = useTranslation() const column = [ - role_name === 'Super Admin' ? { name: t('company') } : null, { name: t('name') }, { name: t('description') }, ].filter(column => column && column.name) @@ -82,30 +73,11 @@ const ChecklistK3 = ({ params, ...props }) => { } }, [dataExport]) - useEffect(() => { - getDataCompany() - }, []) - - - const getDataCompany = async () => { - const result = await axios - .get(COMPANY_MANAGEMENT_LIST, config) - .then(res => res) - .catch((error) => error.response); - - if (result && result.data && result.data.code == 200) { - setListCompany(result.data.data); - } - } - const getDataChecklistK3 = async () => { - let start = 0; - if (currentPage !== 1 && currentPage > 1) { start = (currentPage * rowsPerPage) - rowsPerPage } - const payload = { group_column: { "operator": "AND", @@ -132,22 +104,6 @@ const ChecklistK3 = ({ params, ...props }) => { 'joins': [] } - if (role_name !== "Super Admin") { - payload.columns.push( - { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, - ) - } else { - payload.columns.push( - { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, - ) - payload.joins.push( - { name: "m_company", column_join: "company_id", column_results: ["company_name"] } - ) - payload.group_column.where.push( - { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } - ) - } - const result = await axios .post(CHECKLIST_K3_SEARCH, payload, config) .then(res => res) @@ -190,21 +146,6 @@ const ChecklistK3 = ({ params, ...props }) => { "joins": [], "orders": { "columns": ["id"], "ascending": false } } - if (role_name !== "Super Admin") { - payload.columns.push( - { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, - ) - } else { - payload.columns.push( - { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, - ) - payload.joins.push( - { name: "m_company", column_join: "company_id", column_results: ["company_name"] } - ) - payload.group_column.where.push( - { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } - ) - } const result = await axios .post(CHECKLIST_K3_SEARCH, payload, config) @@ -216,9 +157,6 @@ const ChecklistK3 = ({ params, ...props }) => { const excelData = []; resData.map((val, index) => { let dataRow = {}; - if (role_name === 'Super Admin') { - dataRow.Company = val.join_first_company_name; - } dataRow.Nama = val.name; dataRow.Deskripsi = val.description; excelData.push(dataRow) @@ -359,8 +297,6 @@ const ChecklistK3 = ({ params, ...props }) => { dataEdit={dataEdit} clickOpenModal={clickOpenModal} dataParent={allDataMenu} - company_id={company_id} - listCompany={listCompany} role_name={role_name} /> @@ -420,11 +356,6 @@ const ChecklistK3 = ({ params, ...props }) => { } - {role_name === 'Super Admin' && - ( - {n.join_first_company_name} - ) - } {n.name} {n.description} diff --git a/src/views/SimproV2/Closing/index.js b/src/views/SimproV2/Closing/index.js index 23f6b50..8710c3f 100644 --- a/src/views/SimproV2/Closing/index.js +++ b/src/views/SimproV2/Closing/index.js @@ -14,7 +14,6 @@ import { formatRupiah } from '../../../const/CustomFunc' const url = ""; const proyek_id = localStorage.getItem('proyek_id'); const role_id = localStorage.getItem('role_id'); -const company_id = window.localStorage.getItem('company_id'); const format = "DD-MM-YYYY"; const Closing = ({ params, ...props }) => { @@ -145,7 +144,7 @@ const Closing = ({ params, ...props }) => { const toggleAddDialogView = () => setOpenDialogViewDetail(!openDialogViewDetail) const onConfirmDelete = async () => { - let urlDel = PROYEK_DELETE(idDelete, company_id) + let urlDel = PROYEK_DELETE(idDelete) const result = await axios.delete(urlDel, HEADER) .then(res => res) .catch((error) => error.response); diff --git a/src/views/SimproV2/CreatedProyek/AsignCustProject.js b/src/views/SimproV2/CreatedProyek/AsignCustProject.js index 9742738..0769092 100644 --- a/src/views/SimproV2/CreatedProyek/AsignCustProject.js +++ b/src/views/SimproV2/CreatedProyek/AsignCustProject.js @@ -13,7 +13,7 @@ import { NotificationContainer, NotificationManager } from 'react-notifications' import SweetAlert from 'react-bootstrap-sweetalert'; import FormAsignCust from './DialogAssignCust'; -const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, company_id, token }) => { +const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, token }) => { const HEADER = { headers: { "Content-Type": "application/json", @@ -83,7 +83,7 @@ const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proy } const onConfirmDelete = async () => { - let urlDel = ASSIGN_HR_PROJECT_DELETE(idDelete, parseInt(company_id)) + let urlDel = ASSIGN_HR_PROJECT_DELETE(idDelete) const result = await axios.delete(urlDel, HEADER) .then(res => res) .catch((error) => error.response); @@ -198,7 +198,6 @@ const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proy closeDialog={handleCloseDialogFormTools} toggleDialog={toogleDialogFormTools} idTask={idTask} - company_id={company_id} token={token} /> diff --git a/src/views/SimproV2/CreatedProyek/AsignHrProject.js b/src/views/SimproV2/CreatedProyek/AsignHrProject.js index f38eea7..8c123b3 100644 --- a/src/views/SimproV2/CreatedProyek/AsignHrProject.js +++ b/src/views/SimproV2/CreatedProyek/AsignHrProject.js @@ -11,7 +11,7 @@ import SweetAlert from 'react-bootstrap-sweetalert'; import FormAsignHr from './FormAsignHr'; import { formatThousand } from '../../../const/CustomFunc'; -const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, company_id, proyekName, token }) => { +const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, token }) => { const HEADER = { headers: { "Content-Type": "application/json", @@ -91,9 +91,6 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, compan "start": 0, "length": -1 }, - "columns": [ - { "name": "company_id", "logic_operator": "=", "value": parseInt(company_id) }, - ], "orders": { "columns": [ "id" @@ -117,9 +114,6 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, compan "start": 0, "length": -1 }, - "columns": [ - { "name": "company_id", "logic_operator": "=", "value": parseInt(company_id) }, - ], "joins": [], "orders": { "columns": [ diff --git a/src/views/SimproV2/CreatedProyek/DialogAssignCust.js b/src/views/SimproV2/CreatedProyek/DialogAssignCust.js index be052e9..a9e0d08 100644 --- a/src/views/SimproV2/CreatedProyek/DialogAssignCust.js +++ b/src/views/SimproV2/CreatedProyek/DialogAssignCust.js @@ -12,7 +12,7 @@ import 'antd/dist/antd.css'; import { NotificationManager } from 'react-notifications'; const role_id = localStorage.getItem('role_id'); -const DialogAssignCust = ({ openDialog, closeDialog, toggleDialog, idTask, company_id, token }) => { +const DialogAssignCust = ({ openDialog, closeDialog, toggleDialog, idTask, token }) => { const HEADER = { headers: { "Content-Type": "application/json", @@ -50,8 +50,7 @@ const DialogAssignCust = ({ openDialog, closeDialog, toggleDialog, idTask, compa "length": -1 }, "columns": [ - { "name": "is_customer", "logic_operator": "=", "value": true }, - { "name": "company_id", "logic_operator": "=", "value": company_id }, + { "name": "is_customer", "logic_operator": "=", "value": true } ], "orders": { "columns": [ diff --git a/src/views/SimproV2/CreatedProyek/DialogDocument.js b/src/views/SimproV2/CreatedProyek/DialogDocument.js index 0826206..ccf596a 100644 --- a/src/views/SimproV2/CreatedProyek/DialogDocument.js +++ b/src/views/SimproV2/CreatedProyek/DialogDocument.js @@ -10,7 +10,7 @@ import axios from "../../../const/interceptorApi" import { NotificationContainer, NotificationManager } from 'react-notifications'; import DialogRequest from './FormDocument'; import DialogRequestFolder from './FormFolderDocument'; -const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, companyId, token, role_name, companyName }) => { +const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, token, role_name }) => { const HEADER = { headers: { "Content-Type": "application/json", @@ -73,7 +73,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN } const handleDownload = (id, file) => { - fetch(DOCUMENT_DOWNLOAD(id, parseInt(companyId)), { + fetch(DOCUMENT_DOWNLOAD(id), { headers: new Headers({ 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` @@ -91,8 +91,8 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN }); } - const handleShow = (file, dateFile) => { - const urlShow = `${BASE_SIMPRO_LUMEN_FILE_COMPANY(file, companyName, dateFile)}` + const handleShow = (file) => { + const urlShow = `${BASE_SIMPRO_LUMEN_FILE_COMPANY(file)}` window.open(urlShow); } @@ -118,14 +118,13 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN const renderShowDokumen = (data) => { let arrayFile = data.file.split(".") - const dateFile = moment(data.created_at).format('YYYY-MM'); let length = arrayFile.length length = length - 1 const fileExt = arrayFile[length]; if (["pdf", "png", "jpg", "jpeg", "gif"].includes(fileExt)) { return ( - + ) } @@ -200,7 +199,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN } const onConfirmDelete = async () => { - let urlDel = DOCUMENT_DELETE(idDelete, parseInt(companyId)) + let urlDel = DOCUMENT_DELETE(idDelete) const result = await axios.delete(urlDel, HEADER) .then(res => res) .catch((error) => error.response); @@ -218,7 +217,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN } const onConfirmDeleteFolder = async () => { - let urlDel = FOLDER_DOCUMENT_PROYEK_DELETE(idDelete, parseInt(companyId)) + let urlDel = FOLDER_DOCUMENT_PROYEK_DELETE(idDelete) const result = await axios.delete(urlDel, HEADER) .then(res => res) .catch((error) => error.response); @@ -314,7 +313,6 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN idTask={parseInt(idTask)} parentIdNewFolder={parentIdNewFolder} dataEdit={dataEdit} - companyId={companyId} token={token} role_name={role_name} /> diff --git a/src/views/SimproV2/CreatedProyek/DialogFormProyek.js b/src/views/SimproV2/CreatedProyek/DialogFormProyek.js index f475c47..e1f99d6 100644 --- a/src/views/SimproV2/CreatedProyek/DialogFormProyek.js +++ b/src/views/SimproV2/CreatedProyek/DialogFormProyek.js @@ -32,10 +32,8 @@ const DialogFormProyek = ({ dataDivisions, dataPM, projectImage, - company_id, role_name, - token, - companyList + token }) => { const HEADER = { headers: { @@ -65,8 +63,6 @@ const DialogFormProyek = ({ const [organization, setProjectStructureOrg] = useState(null); const [finance, setFinance] = useState(""); const [investor, setInvestor] = useState(""); - const [company, setCompany] = useState(""); - const [scompany_id, setCompanyId] = useState(null); const [step, setStep] = useState(1); const [currencyList, setCurrencyList] = useState(null); const [currencyCode, setCurrencyCode] = useState("IDR"); @@ -117,8 +113,6 @@ const DialogFormProyek = ({ setWorkArea(val.area_kerja); setProjectDuration(val.durasi_proyek); setInvestor(val.investor); - setCompany(val.company); - setCompanyId(val.company_id) setFinance(val.finance); setObjectives(val.project_objectives ? val.project_objectives : ""); setTestingEnv(val.testing_environment); @@ -209,8 +203,6 @@ const DialogFormProyek = ({ setProjectDuration(""); setDivisiProject(null); setProjectStructureOrg(null); - setCompany(""); - setCompanyId(null) setCurrencyCode("IDR"); setCurrencySymbol("Rp"); setCurrencyName("Indonesian rupiah"); @@ -268,7 +260,6 @@ const DialogFormProyek = ({ pm_id: pic, investor, finance, - company, area_kerja: workArea, durasi_proyek: parseInt(duration), late_consequence: late, @@ -280,7 +271,6 @@ const DialogFormProyek = ({ currency_symbol: currencySymbol, currency_code: currencyCode, currency_name: currencyName, - company_id: role_name !== "Super Admin" ? parseInt(company_id) : parseInt(scompany_id), value_proyek: valueProyek, income_year: incomeYearly }; @@ -301,7 +291,6 @@ const DialogFormProyek = ({ pm_id: pic, investor, finance, - company, area_kerja: workArea, durasi_proyek: parseInt(duration), late_consequence: late, @@ -313,7 +302,6 @@ const DialogFormProyek = ({ currency_symbol: currencySymbol, currency_code: currencyCode, currency_name: currencyName, - company_id: role_name !== "Super Admin" ? parseInt(company_id) : parseInt(scompany_id), value_proyek: valueProyek, income_year: incomeYearly }; @@ -334,10 +322,6 @@ const DialogFormProyek = ({ setTypeproject(val); }; - const onChangeCompanyProject = (val) => { - setCompanyId(val); - }; - const onChangePhaseProject = (val) => { setPhaseProject(val); }; @@ -424,10 +408,6 @@ const DialogFormProyek = ({ alert("End Date cannot be empty!"); return false; } - if (role_name === 'Super Admin' && !scompany_id || scompany_id === "") { - alert("Company data cannot be empty!"); - return false; - } if (!biaya || biaya === "") { alert("Budget cannot be empty!"); return false; @@ -782,41 +762,6 @@ const DialogFormProyek = ({
- { - role_name === 'Super Admin' && ( - - - - - - - ) - } - - - - setCompany(e.target.value)} - /> - -