Browse Source

add state

pull/1/head
wahyun 9 months ago
parent
commit
f08e16d67d
  1. 7
      src/views/SimproV2/CreatedProyek/AsignCustProject.js
  2. 8
      src/views/SimproV2/CreatedProyek/AsignHrProject.js
  3. 34
      src/views/SimproV2/CreatedProyek/DialogDocument.js
  4. 2
      src/views/SimproV2/CreatedProyek/DialogFormProyek.js
  5. 24
      src/views/SimproV2/CreatedProyek/DialogGantt.js
  6. 6
      src/views/SimproV2/Gantt/GanttFrame.js
  7. 6
      src/views/SimproV2/Gantt/index.js

7
src/views/SimproV2/CreatedProyek/AsignCustProject.js

@ -13,8 +13,7 @@ import { NotificationContainer, NotificationManager } from 'react-notifications'
import SweetAlert from 'react-bootstrap-sweetalert'; import SweetAlert from 'react-bootstrap-sweetalert';
import FormAsignCust from './DialogAssignCust'; import FormAsignCust from './DialogAssignCust';
const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, company_id }) => { const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, company_id, token }) => {
const token = localStorage.getItem("token")
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -42,7 +41,7 @@ const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proy
}, },
"columns": [ "columns": [
{ "name": "name", "logic_operator": "ilike", "value": "", "table_name": "m_users" }, { "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" } { "name": "is_customer", "logic_operator": "=", "value": "true" }
], ],
"joins": [ "joins": [
@ -84,7 +83,7 @@ const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proy
} }
const onConfirmDelete = async () => { 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) const result = await axios.delete(urlDel, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);

8
src/views/SimproV2/CreatedProyek/AsignHrProject.js

@ -11,8 +11,7 @@ import SweetAlert from 'react-bootstrap-sweetalert';
import FormAsignHr from './FormAsignHr'; import FormAsignHr from './FormAsignHr';
import { formatThousand } from '../../../const/CustomFunc'; import { formatThousand } from '../../../const/CustomFunc';
const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, company_id, proyekName }) => { const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, company_id, proyekName, token }) => {
const token = localStorage.getItem("token")
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -93,7 +92,7 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, compan
"length": -1 "length": -1
}, },
"columns": [ "columns": [
{ "name": "company_id", "logic_operator": "=", "value": company_id }, { "name": "company_id", "logic_operator": "=", "value": parseInt(company_id) },
], ],
"orders": { "orders": {
"columns": [ "columns": [
@ -119,8 +118,7 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, compan
"length": -1 "length": -1
}, },
"columns": [ "columns": [
{ "name": "created_by", "logic_operator": "ilike", "value": "" }, { "name": "company_id", "logic_operator": "=", "value": parseInt(company_id) },
{ "name": "company_id", "logic_operator": "=", "value": company_id },
], ],
"joins": [], "joins": [],
"orders": { "orders": {

34
src/views/SimproV2/CreatedProyek/DialogDocument.js

@ -10,9 +10,7 @@ import axios from "../../../const/interceptorApi"
import { NotificationContainer, NotificationManager } from 'react-notifications'; import { NotificationContainer, NotificationManager } from 'react-notifications';
import DialogRequest from './FormDocument'; import DialogRequest from './FormDocument';
import DialogRequestFolder from './FormFolderDocument'; import DialogRequestFolder from './FormFolderDocument';
const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName }) => { const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, companyId, token, role_name, companyName }) => {
const token = localStorage.getItem("token")
const role = window.localStorage.getItem('role_name');
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -34,7 +32,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
setLoading(true); setLoading(true);
getDataDocument(); getDataDocument();
} }
}, [parseInt(idTask), openDialog]) }, [openDialog])
useEffect(() => { useEffect(() => {
if (!openDialog) { if (!openDialog) {
@ -75,7 +73,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
} }
const handleDownload = (id, file) => { const handleDownload = (id, file) => {
fetch(DOCUMENT_DOWNLOAD(id, parseInt(idTask)), { fetch(DOCUMENT_DOWNLOAD(id, parseInt(companyId)), {
headers: new Headers({ headers: new Headers({
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': `Bearer ${token}` 'Authorization': `Bearer ${token}`
@ -93,12 +91,8 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
}); });
} }
const handleShow = (file) => { const handleShow = (file, dateFile) => {
let configApp = ''; const urlShow = `${BASE_SIMPRO_LUMEN_FILE_COMPANY(file, companyName, dateFile)}`
if (role !== 'Super Admin') {
configApp = JSON.parse(window.localStorage.getItem('configApp'));
}
const urlShow = `${BASE_SIMPRO_LUMEN_FILE_COMPANY(file, configApp != '' ? configApp.company_name : 'undifined')}`
window.open(urlShow); window.open(urlShow);
} }
@ -122,15 +116,16 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
openDialogRequest() openDialogRequest()
} }
const renderShowDokumen = (file) => { const renderShowDokumen = (data) => {
let arrayFile = file.split(".") let arrayFile = data.file.split(".")
const dateFile = moment(data.created_at).format('YYYY-MM');
let length = arrayFile.length let length = arrayFile.length
length = length - 1 length = length - 1
const fileExt = arrayFile[length]; const fileExt = arrayFile[length];
if (fileExt == "pdf" || fileExt == "png" || fileExt == "jpg" || fileExt == "jpeg" || fileExt == "gif") { if (["pdf", "png", "jpg", "jpeg", "gif"].includes(fileExt)) {
return ( return (
<Tooltip title="View Document"> <Tooltip title="View Document">
<Button size={"sm"} color='info' style={{ color: "#FFFFFF" }} onClick={() => handleShow(file)}><i className="fa fa-eye"></i></Button> <Button size={"sm"} color='info' style={{ color: "#FFFFFF" }} onClick={() => handleShow(data.file, dateFile)}><i className="fa fa-eye"></i></Button>
</Tooltip> </Tooltip>
) )
} }
@ -159,7 +154,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
{record.isDir && <Tooltip title="New File"> {record.isDir && <Tooltip title="New File">
<Button size="sm" color="primary" onClick={() => handleNewFileParent(record.id)}><i className="fa fa-file"></i></Button> <Button size="sm" color="primary" onClick={() => handleNewFileParent(record.id)}><i className="fa fa-file"></i></Button>
</Tooltip>}{" "} </Tooltip>}{" "}
{text.file ? renderShowDokumen(text.file) : ""} {text.file ? renderShowDokumen(text) : ""}
</> </>
, ,
}, },
@ -205,7 +200,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
} }
const onConfirmDelete = async () => { const onConfirmDelete = async () => {
let urlDel = DOCUMENT_DELETE(idDelete, parseInt(idTask)) let urlDel = DOCUMENT_DELETE(idDelete, parseInt(companyId))
const result = await axios.delete(urlDel, HEADER) const result = await axios.delete(urlDel, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -223,7 +218,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
} }
const onConfirmDeleteFolder = async () => { 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) const result = await axios.delete(urlDel, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
@ -319,6 +314,9 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
idTask={parseInt(idTask)} idTask={parseInt(idTask)}
parentIdNewFolder={parentIdNewFolder} parentIdNewFolder={parentIdNewFolder}
dataEdit={dataEdit} dataEdit={dataEdit}
companyId={companyId}
token={token}
role_name={role_name}
/> />
<DialogRequestFolder <DialogRequestFolder

2
src/views/SimproV2/CreatedProyek/DialogFormProyek.js

@ -37,9 +37,9 @@ const DialogFormProyek = ({
projectImage, projectImage,
company_id, company_id,
role_name, role_name,
token,
companyList companyList
}) => { }) => {
const token = localStorage.getItem("token");
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",

24
src/views/SimproV2/CreatedProyek/DialogGantt.js

@ -13,18 +13,7 @@ import DialogUserGantt from './DialogUserGantt';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
const { Option } = Select const { Option } = Select
const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, hierarchyId, hierarchyName, openDialogHierarchy, isLogin, token, role_id, user_id, dataViewStartDate }) => { const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, companyId, 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 HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -140,11 +129,12 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName
<Link to={{ <Link to={{
pathname: `/projects/${text.id}/${idTask}/gantt`, pathname: `/projects/${text.id}/${idTask}/gantt`,
state: { state: {
isLogin: isLogin, isLogin,
token: token, token,
role_id: role_id, role_id,
user_id: user_id, user_id,
dataViewStartDate: dataViewStartDate company_id: companyId,
dataViewStartDate
} }
}}> }}>
<Tooltip title="Gantt"> <Tooltip title="Gantt">

6
src/views/SimproV2/Gantt/GanttFrame.js

@ -4,9 +4,9 @@ import { BASE_SIMPRO_LUMEN } from '../../../const/ApiConst';
const GanttFrame = React.memo((props) => { const GanttFrame = React.memo((props) => {
const history = useHistory(); const history = useHistory();
const { versionGanttId, idProject, ro, timestamp, dataViewStartDate, token, company_id, role_name } = props; 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}&timestamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&company_id=${company_id}`; 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}&timestamp=${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}&timestamp=${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}&timestamp=${timestamp}&start=${dataViewStartDate}&role_name=${role_name}&company_id=${companyId}`;
const [batchEntityData, setBatchEntityData] = useState(null); const [batchEntityData, setBatchEntityData] = useState(null);
useEffect(() => { useEffect(() => {

6
src/views/SimproV2/Gantt/index.js

@ -15,13 +15,13 @@ import GanttFrame from "./GanttFrame";
let roCount = 0; let roCount = 0;
const Gantt = (props) => { 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) { if (props && props.role_id && props.user_id) {
role_id = props.role_id; role_id = props.role_id;
user_id = props.user_id; user_id = props.user_id;
token = props.token; token = props.token;
isLogin = props.isLogin; isLogin = props.isLogin;
company_id = props.company_id; companyId = props.company_id;
all_project = props.all_project; all_project = props.all_project;
role_name = props.role_name; role_name = props.role_name;
isLogin = props.isLogin; isLogin = props.isLogin;
@ -114,7 +114,7 @@ const Gantt = (props) => {
token={token} token={token}
ro={ro} ro={ro}
role_name={role_name} role_name={role_name}
company_id={company_id} companyId={companyId}
timestamp={timestamp} timestamp={timestamp}
/> />
)} )}

Loading…
Cancel
Save