diff --git a/src/views/SimproV2/CreatedProyek/AsignCustProject.js b/src/views/SimproV2/CreatedProyek/AsignCustProject.js index 9bc6cb2..60d2020 100644 --- a/src/views/SimproV2/CreatedProyek/AsignCustProject.js +++ b/src/views/SimproV2/CreatedProyek/AsignCustProject.js @@ -13,8 +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 }) => { - const token = localStorage.getItem("token") +const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, company_id, token }) => { const HEADER = { headers: { "Content-Type": "application/json", @@ -42,7 +41,7 @@ const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proy }, "columns": [ { "name": "name", "logic_operator": "ilike", "value": "", "table_name": "m_users" }, - { "name": "proyek_id", "logic_operator": "=", "value": idTask }, + { "name": "proyek_id", "logic_operator": "=", "value": parseInt(idTask) }, { "name": "is_customer", "logic_operator": "=", "value": "true" } ], "joins": [ @@ -84,7 +83,7 @@ const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proy } const onConfirmDelete = async () => { - let urlDel = ASSIGN_HR_PROJECT_DELETE(idDelete, company_id) + let urlDel = ASSIGN_HR_PROJECT_DELETE(idDelete, parseInt(company_id)) const result = await axios.delete(urlDel, HEADER) .then(res => res) .catch((error) => error.response); diff --git a/src/views/SimproV2/CreatedProyek/AsignHrProject.js b/src/views/SimproV2/CreatedProyek/AsignHrProject.js index 315ef1b..f38eea7 100644 --- a/src/views/SimproV2/CreatedProyek/AsignHrProject.js +++ b/src/views/SimproV2/CreatedProyek/AsignHrProject.js @@ -11,8 +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 }) => { - const token = localStorage.getItem("token") +const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, company_id, proyekName, token }) => { const HEADER = { headers: { "Content-Type": "application/json", @@ -93,7 +92,7 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, compan "length": -1 }, "columns": [ - { "name": "company_id", "logic_operator": "=", "value": company_id }, + { "name": "company_id", "logic_operator": "=", "value": parseInt(company_id) }, ], "orders": { "columns": [ @@ -119,8 +118,7 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, compan "length": -1 }, "columns": [ - { "name": "created_by", "logic_operator": "ilike", "value": "" }, - { "name": "company_id", "logic_operator": "=", "value": company_id }, + { "name": "company_id", "logic_operator": "=", "value": parseInt(company_id) }, ], "joins": [], "orders": { diff --git a/src/views/SimproV2/CreatedProyek/DialogDocument.js b/src/views/SimproV2/CreatedProyek/DialogDocument.js index 1314dca..0826206 100644 --- a/src/views/SimproV2/CreatedProyek/DialogDocument.js +++ b/src/views/SimproV2/CreatedProyek/DialogDocument.js @@ -10,9 +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 }) => { - const token = localStorage.getItem("token") - const role = window.localStorage.getItem('role_name'); +const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, companyId, token, role_name, companyName }) => { const HEADER = { headers: { "Content-Type": "application/json", @@ -34,7 +32,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN setLoading(true); getDataDocument(); } - }, [parseInt(idTask), openDialog]) + }, [openDialog]) useEffect(() => { if (!openDialog) { @@ -75,7 +73,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN } const handleDownload = (id, file) => { - fetch(DOCUMENT_DOWNLOAD(id, parseInt(idTask)), { + fetch(DOCUMENT_DOWNLOAD(id, parseInt(companyId)), { headers: new Headers({ 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` @@ -93,12 +91,8 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN }); } - const handleShow = (file) => { - let configApp = ''; - if (role !== 'Super Admin') { - configApp = JSON.parse(window.localStorage.getItem('configApp')); - } - const urlShow = `${BASE_SIMPRO_LUMEN_FILE_COMPANY(file, configApp != '' ? configApp.company_name : 'undifined')}` + const handleShow = (file, dateFile) => { + const urlShow = `${BASE_SIMPRO_LUMEN_FILE_COMPANY(file, companyName, dateFile)}` window.open(urlShow); } @@ -122,15 +116,16 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN openDialogRequest() } - const renderShowDokumen = (file) => { - let arrayFile = file.split(".") + 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 (fileExt == "pdf" || fileExt == "png" || fileExt == "jpg" || fileExt == "jpeg" || fileExt == "gif") { + if (["pdf", "png", "jpg", "jpeg", "gif"].includes(fileExt)) { return ( - + ) } @@ -159,7 +154,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN {record.isDir && }{" "} - {text.file ? renderShowDokumen(text.file) : ""} + {text.file ? renderShowDokumen(text) : ""} , }, @@ -205,7 +200,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN } const onConfirmDelete = async () => { - let urlDel = DOCUMENT_DELETE(idDelete, parseInt(idTask)) + let urlDel = DOCUMENT_DELETE(idDelete, parseInt(companyId)) const result = await axios.delete(urlDel, HEADER) .then(res => res) .catch((error) => error.response); @@ -223,7 +218,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN } const onConfirmDeleteFolder = async () => { - let urlDel = FOLDER_DOCUMENT_PROYEK_DELETE(idDelete) + let urlDel = FOLDER_DOCUMENT_PROYEK_DELETE(idDelete, parseInt(companyId)) const result = await axios.delete(urlDel, HEADER) .then(res => res) .catch((error) => error.response); @@ -319,6 +314,9 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN idTask={parseInt(idTask)} parentIdNewFolder={parentIdNewFolder} dataEdit={dataEdit} + companyId={companyId} + token={token} + role_name={role_name} /> { - const token = localStorage.getItem("token"); const HEADER = { headers: { "Content-Type": "application/json", diff --git a/src/views/SimproV2/CreatedProyek/DialogGantt.js b/src/views/SimproV2/CreatedProyek/DialogGantt.js index 92fe367..62ff784 100644 --- a/src/views/SimproV2/CreatedProyek/DialogGantt.js +++ b/src/views/SimproV2/CreatedProyek/DialogGantt.js @@ -13,18 +13,7 @@ import DialogUserGantt from './DialogUserGantt'; import { Link } from 'react-router-dom'; const { Option } = Select -const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, hierarchyId, hierarchyName, openDialogHierarchy, isLogin, token, role_id, user_id, dataViewStartDate }) => { - if (role_id && user_id && token && isLogin) { - role_id = role_id; - user_id = user_id; - token = token; - isLogin = isLogin; - } else { - role_id = localStorage.getItem("role_id"); - user_id = localStorage.getItem("user_id"); - token = localStorage.getItem("token"); - isLogin = localStorage.getItem("isLogin"); - } +const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, companyId, hierarchyId, hierarchyName, openDialogHierarchy, isLogin, token, role_id, user_id, dataViewStartDate }) => { const HEADER = { headers: { "Content-Type": "application/json", @@ -140,11 +129,12 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName diff --git a/src/views/SimproV2/Gantt/GanttFrame.js b/src/views/SimproV2/Gantt/GanttFrame.js index aa9f79c..fed3f82 100644 --- a/src/views/SimproV2/Gantt/GanttFrame.js +++ b/src/views/SimproV2/Gantt/GanttFrame.js @@ -4,9 +4,9 @@ import { BASE_SIMPRO_LUMEN } from '../../../const/ApiConst'; const GanttFrame = React.memo((props) => { const history = useHistory(); - const { versionGanttId, idProject, ro, timestamp, dataViewStartDate, token, company_id, role_name } = props; - const iframeSrc = `https://project-gantt.ospro.id/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}×tamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&company_id=${company_id}`; - // const iframeSrc = `http://localhost:8444/generic-ospro-gantt/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}×tamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&company_id=${company_id}`; + const { versionGanttId, idProject, ro, timestamp, dataViewStartDate, token, companyId, role_name } = props; + const iframeSrc = `https://project-gantt.ospro.id/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}×tamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&company_id=${companyId}`; + // const iframeSrc = `http://localhost:8444/generic-ospro-gantt/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}×tamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&company_id=${companyId}`; const [batchEntityData, setBatchEntityData] = useState(null); useEffect(() => { diff --git a/src/views/SimproV2/Gantt/index.js b/src/views/SimproV2/Gantt/index.js index 817985c..e07e9d8 100644 --- a/src/views/SimproV2/Gantt/index.js +++ b/src/views/SimproV2/Gantt/index.js @@ -15,13 +15,13 @@ import GanttFrame from "./GanttFrame"; let roCount = 0; const Gantt = (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 = '', companyId = 0, 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; + companyId = props.company_id; all_project = props.all_project; role_name = props.role_name; isLogin = props.isLogin; @@ -114,7 +114,7 @@ const Gantt = (props) => { token={token} ro={ro} role_name={role_name} - company_id={company_id} + companyId={companyId} timestamp={timestamp} /> )}