|
|
|
@ -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 ( |
|
|
|
|
<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> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
@ -159,7 +154,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN
|
|
|
|
|
{record.isDir && <Tooltip title="New File"> |
|
|
|
|
<Button size="sm" color="primary" onClick={() => handleNewFileParent(record.id)}><i className="fa fa-file"></i></Button> |
|
|
|
|
</Tooltip>}{" "} |
|
|
|
|
{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} |
|
|
|
|
/> |
|
|
|
|
|
|
|
|
|
<DialogRequestFolder |
|
|
|
|