|
|
@ -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 |
|
|
|