farhan048
1 year ago
16 changed files with 881 additions and 591 deletions
@ -1,141 +1,149 @@ |
|||||||
import React, { useEffect, useState } from 'react' |
import React, { useEffect, useState } from 'react' |
||||||
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; |
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; |
||||||
import { Button, Form } from 'reactstrap'; |
import { Button, Form } from 'reactstrap'; |
||||||
import axios from "../../../const/interceptorApi"; |
import axios from "../../../const/interceptorApi"; |
||||||
import { PROJECT_TO_CHECKLIST_K3_ADDS, PROJECT_TO_CHECKLIST_K3_SEARCH } from '../../../const/ApiConst'; |
import { PROJECT_TO_CHECKLIST_K3_ADDS, PROJECT_TO_CHECKLIST_K3_SEARCH } from '../../../const/ApiConst'; |
||||||
import { Transfer } from 'antd'; |
import { Transfer, Spin } from 'antd'; |
||||||
import 'antd/dist/antd.css'; |
import 'antd/dist/antd.css'; |
||||||
|
import { NotificationManager } from 'react-notifications'; |
||||||
const AssignK3Project = ({ openDialog, closeDialog, toggleDialog, idTask, dataK3, proyekName }) => { |
|
||||||
const token = localStorage.getItem("token") |
const AssignK3Project = ({ openDialog, closeDialog, toggleDialog, idTask, dataK3, proyekName }) => { |
||||||
const HEADER = { |
const token = localStorage.getItem("token") |
||||||
headers: { |
const [loading, setLoading] = useState(true); |
||||||
"Content-Type": "application/json", |
|
||||||
"Authorization": `Bearer ${token}` |
const HEADER = { |
||||||
} |
headers: { |
||||||
} |
"Content-Type": "application/json", |
||||||
const [id, setId] = useState(0) |
"Authorization": `Bearer ${token}` |
||||||
const [targetKeys, setTargetKeys] = useState([]) |
} |
||||||
|
} |
||||||
|
const [id, setId] = useState(0) |
||||||
const handleClearData = () => { |
const [targetKeys, setTargetKeys] = useState([]) |
||||||
setId(0) |
|
||||||
setTargetKeys([]) |
|
||||||
} |
const handleClearData = () => { |
||||||
|
setId(0) |
||||||
useEffect(() => { |
setTargetKeys([]) |
||||||
if(!openDialog){ |
} |
||||||
handleClearData() |
|
||||||
} |
useEffect(() => { |
||||||
}, [openDialog]) |
if(!openDialog){ |
||||||
|
handleClearData() |
||||||
useEffect(() => { |
} |
||||||
if(idTask && idTask > 0){ |
}, [openDialog]) |
||||||
getK3toProject() |
|
||||||
} |
useEffect(() => { |
||||||
}, [idTask]) |
if (idTask && idTask > 0) { |
||||||
|
setLoading(true); |
||||||
const getK3toProject = async () => { |
getK3toProject() |
||||||
const payload = { |
} |
||||||
"columns": [ |
}, [idTask]) |
||||||
{ "name": "proyek_id", "logic_operator": "=", "value": idTask, "operator": "AND" } |
|
||||||
] |
const getK3toProject = async () => { |
||||||
} |
const payload = { |
||||||
const result = await axios |
"columns": [ |
||||||
.post(PROJECT_TO_CHECKLIST_K3_SEARCH, payload, HEADER) |
{ "name": "proyek_id", "logic_operator": "=", "value": idTask, "operator": "AND" } |
||||||
.then(res => res) |
] |
||||||
.catch((error) => error.response); |
} |
||||||
|
const result = await axios |
||||||
if(result && result.status==200){ |
.post(PROJECT_TO_CHECKLIST_K3_SEARCH, payload, HEADER) |
||||||
console.log("cek get project to checklist k3",result.data.data) |
.then(res => res) |
||||||
let data = result.data.data || [] |
.catch((error) => error.response); |
||||||
let newTargetKeys = [] |
|
||||||
if (data.length > 0) { |
if(result && result.status==200){ |
||||||
data.map((val,index)=> { |
console.log("cek get project to checklist k3",result.data.data) |
||||||
newTargetKeys.push(val.checklist_k3_id) |
let data = result.data.data || [] |
||||||
}); |
let newTargetKeys = [] |
||||||
} |
if (data.length > 0) { |
||||||
setTargetKeys(newTargetKeys) |
data.map((val,index)=> { |
||||||
}else{ |
newTargetKeys.push(val.checklist_k3_id) |
||||||
|
}); |
||||||
} |
} |
||||||
} |
setTargetKeys(newTargetKeys) |
||||||
|
setLoading(false); |
||||||
const handleSave = async () => { |
}else{ |
||||||
await saveAssign() |
setLoading(false); |
||||||
handleClearData() |
NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); |
||||||
} |
} |
||||||
|
} |
||||||
const saveAssign= async () => { |
|
||||||
|
const handleSave = async () => { |
||||||
const formData = { |
await saveAssign() |
||||||
checklist_k3_id:targetKeys, |
handleClearData() |
||||||
proyek_id:idTask |
} |
||||||
} |
|
||||||
|
const saveAssign= async () => { |
||||||
const result = await axios |
|
||||||
.post(PROJECT_TO_CHECKLIST_K3_ADDS, formData, HEADER) |
const formData = { |
||||||
.then(res => res) |
checklist_k3_id:targetKeys, |
||||||
.catch((error) => error.response); |
proyek_id:idTask |
||||||
|
} |
||||||
|
|
||||||
if(result && result.status==200){ |
const result = await axios |
||||||
closeDialog('success') |
.post(PROJECT_TO_CHECKLIST_K3_ADDS, formData, HEADER) |
||||||
}else{ |
.then(res => res) |
||||||
closeDialog('failed') |
.catch((error) => error.response); |
||||||
} |
|
||||||
} |
|
||||||
|
if(result && result.status==200){ |
||||||
const handleCancel = () => { |
closeDialog('success') |
||||||
closeDialog('cancel') |
}else{ |
||||||
handleClearData() |
closeDialog('failed') |
||||||
} |
} |
||||||
|
} |
||||||
const handleChange = targetKeys => { |
|
||||||
setTargetKeys(targetKeys) |
const handleCancel = () => { |
||||||
}; |
closeDialog('cancel') |
||||||
|
handleClearData() |
||||||
const renderForm = () => { |
} |
||||||
return ( |
|
||||||
<div style={{ |
const handleChange = targetKeys => { |
||||||
alignContent: "center", |
setTargetKeys(targetKeys) |
||||||
justifyContent: "center !imporant", |
}; |
||||||
paddingLeft: 20, |
|
||||||
paddingRight: 20, |
const renderForm = () => { |
||||||
overflow: "auto" |
return ( |
||||||
}}> |
<div style={{ |
||||||
<Transfer
|
alignContent: "center", |
||||||
showSearch |
justifyContent: "center !imporant", |
||||||
titles={['Available K3', 'Assigned to Project']} |
paddingLeft: 20, |
||||||
dataSource={dataK3} |
paddingRight: 20, |
||||||
targetKeys={targetKeys} |
overflow: "auto" |
||||||
onChange={handleChange} |
}}> |
||||||
render={item => item.title} |
<Transfer |
||||||
listStyle={{ |
showSearch |
||||||
width: 250, |
titles={['Available K3', 'Assigned to Project']} |
||||||
height: 300, |
dataSource={dataK3} |
||||||
}} |
targetKeys={targetKeys} |
||||||
/> |
onChange={handleChange} |
||||||
</div> |
render={item => item.title} |
||||||
) |
listStyle={{ |
||||||
} |
width: 250, |
||||||
|
height: 300, |
||||||
|
}} |
||||||
return ( |
/> |
||||||
<> |
</div> |
||||||
<Modal size="lg" style={{maxWidth: '600px', width: '100%'}} isOpen={openDialog} toggle={toggleDialog}> |
) |
||||||
<ModalHeader className="capitalize" toggle={closeDialog}>Assign K3 to Project {proyekName !== '' ? `- ${proyekName}` : ''}</ModalHeader> |
} |
||||||
<ModalBody> |
|
||||||
{renderForm()} |
|
||||||
</ModalBody> |
return ( |
||||||
<ModalFooter> |
<> |
||||||
<Button color="primary" onClick={() => handleSave()}>Save</Button>{' '} |
<Modal size="lg" style={{maxWidth: '600px', width: '100%'}} isOpen={openDialog} toggle={toggleDialog}> |
||||||
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Cancel</Button> |
<ModalHeader className="capitalize" toggle={closeDialog}>Assign K3 to Project {proyekName !== '' ? `- ${proyekName}` : ''}</ModalHeader> |
||||||
</ModalFooter> |
<ModalBody> |
||||||
</Modal> |
<Spin tip="Loading..." spinning={loading}> |
||||||
</> |
{renderForm()} |
||||||
) |
</Spin> |
||||||
|
</ModalBody> |
||||||
} |
<ModalFooter> |
||||||
|
<Button color="primary" onClick={() => handleSave()}>Save</Button>{' '} |
||||||
export default AssignK3Project; |
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Cancel</Button> |
||||||
|
</ModalFooter> |
||||||
|
</Modal> |
||||||
|
</> |
||||||
|
) |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
export default AssignK3Project; |
||||||
|
@ -1,341 +1,347 @@ |
|||||||
import React, { useEffect, useState, useMemo } from 'react' |
import React, { useEffect, useState, useMemo } from 'react' |
||||||
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; |
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; |
||||||
import { Button } from 'reactstrap'; |
import { Button } from 'reactstrap'; |
||||||
import { Table, Tooltip, Popover } from 'antd'; |
import { Table, Tooltip, Popover, Spin } from 'antd'; |
||||||
import 'antd/dist/antd.css'; |
import 'antd/dist/antd.css'; |
||||||
import moment from 'moment'; |
import moment from 'moment'; |
||||||
import SweetAlert from 'react-bootstrap-sweetalert'; |
import SweetAlert from 'react-bootstrap-sweetalert'; |
||||||
import { DOCUMENT_DOWNLOAD, DOCUMENT_GET, BASE_SIMPRO_LUMEN_FILE, REQUEST_MATERIAL_EDIT, DOCUMENT_DELETE, DOCUMENT_SEARCH, FOLDER_DOCUMENT_PROYEK_GET_TREE, FOLDER_DOCUMENT_PROYEK_DELETE } from '../../../const/ApiConst'; |
import { DOCUMENT_DOWNLOAD, DOCUMENT_GET, BASE_SIMPRO_LUMEN_FILE, REQUEST_MATERIAL_EDIT, DOCUMENT_DELETE, DOCUMENT_SEARCH, FOLDER_DOCUMENT_PROYEK_GET_TREE, FOLDER_DOCUMENT_PROYEK_DELETE } from '../../../const/ApiConst'; |
||||||
import axios from "../../../const/interceptorApi" |
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 }) => { |
||||||
const token = localStorage.getItem("token") |
const token = localStorage.getItem("token") |
||||||
const HEADER = { |
const HEADER = { |
||||||
headers: { |
headers: { |
||||||
"Content-Type": "application/json", |
"Content-Type": "application/json", |
||||||
"Authorization": `Bearer ${token}` |
"Authorization": `Bearer ${token}` |
||||||
} |
} |
||||||
} |
} |
||||||
const config = { |
const config = { |
||||||
headers: |
headers: |
||||||
{ |
{ |
||||||
Authorization: `Bearer ${token}`, |
Authorization: `Bearer ${token}`, |
||||||
"Content-type": `application/json` |
"Content-type": `application/json` |
||||||
} |
} |
||||||
}; |
}; |
||||||
const [dataDocument, setDataDocument] = useState([]) |
const [dataDocument, setDataDocument] = useState([]) |
||||||
const [openDialogReq, setOpenDialogReq] = useState(false) |
const [openDialogReq, setOpenDialogReq] = useState(false) |
||||||
const [openDialogNewFolder, setOpenDialogNewFolder] = useState(false) |
const [openDialogNewFolder, setOpenDialogNewFolder] = useState(false) |
||||||
const [alertDelete, setAlertDelete] = useState(false) |
const [alertDelete, setAlertDelete] = useState(false) |
||||||
const [alertDeleteFolder, setAlertDeleteFolder] = useState(false) |
const [alertDeleteFolder, setAlertDeleteFolder] = useState(false) |
||||||
const [idDelete, setIdDelete] = useState(0) |
const [idDelete, setIdDelete] = useState(0) |
||||||
const [dataEdit, setDataEdit] = useState(null) |
const [dataEdit, setDataEdit] = useState(null) |
||||||
const [parentIdNewFolder, setParentIdNewFolder] = useState(0) |
const [parentIdNewFolder, setParentIdNewFolder] = useState(0) |
||||||
|
const [loading, setLoading] = useState(true); |
||||||
useEffect(() => { |
|
||||||
if (idTask > 0) { |
useEffect(() => { |
||||||
getDataDocument(); |
if (idTask > 0) { |
||||||
} |
setLoading(true); |
||||||
}, [idTask, openDialog]) |
getDataDocument(); |
||||||
|
} |
||||||
useEffect(() => { |
}, [idTask, openDialog]) |
||||||
if (!openDialog) { |
|
||||||
setDataDocument([]); |
useEffect(() => { |
||||||
} else { |
if (!openDialog) { |
||||||
|
setDataDocument([]); |
||||||
} |
} else { |
||||||
}, [openDialog]) |
|
||||||
|
} |
||||||
|
}, [openDialog]) |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const getDataDocument = async () => { |
|
||||||
const url = FOLDER_DOCUMENT_PROYEK_GET_TREE(idTask) |
|
||||||
const result = await axios |
const getDataDocument = async () => { |
||||||
.get(url, config) |
const url = FOLDER_DOCUMENT_PROYEK_GET_TREE(idTask) |
||||||
.then(res => res) |
const result = await axios |
||||||
.catch((error) => error.response); |
.get(url, config) |
||||||
if (result && result.data && result.data.code == 200) { |
.then(res => res) |
||||||
setDataDocument(result.data.data); |
.catch((error) => error.response); |
||||||
} else { |
if (result && result.data && result.data.code == 200) { |
||||||
NotificationManager.error('Gagal mengambil data, Silahkan coba lagi!!', 'Failed'); |
setDataDocument(result.data.data); |
||||||
} |
setLoading(false); |
||||||
} |
} else { |
||||||
|
setLoading(false); |
||||||
const handleCancel = () => { |
NotificationManager.error('Gagal mengambil data, Silahkan coba lagi!!', 'Failed'); |
||||||
setDataDocument([]); |
} |
||||||
closeDialog('cancel', 'none') |
} |
||||||
} |
|
||||||
|
const handleCancel = () => { |
||||||
const handleDelete = (id) => { |
setDataDocument([]); |
||||||
setIdDelete(id) |
closeDialog('cancel', 'none') |
||||||
setAlertDelete(true) |
} |
||||||
} |
|
||||||
|
const handleDelete = (id) => { |
||||||
const handleDeleteFolder = (id) => { |
setIdDelete(id) |
||||||
setIdDelete(id) |
setAlertDelete(true) |
||||||
setAlertDeleteFolder(true) |
} |
||||||
} |
|
||||||
|
const handleDeleteFolder = (id) => { |
||||||
const handleDownload = (id, file) => { |
setIdDelete(id) |
||||||
fetch(DOCUMENT_DOWNLOAD(id), { |
setAlertDeleteFolder(true) |
||||||
headers: new Headers({ |
} |
||||||
'Content-Type': 'application/json', |
|
||||||
'Authorization': `Bearer ${token}` |
const handleDownload = (id, file) => { |
||||||
}) |
fetch(DOCUMENT_DOWNLOAD(id), { |
||||||
}) |
headers: new Headers({ |
||||||
.then(response => { |
'Content-Type': 'application/json', |
||||||
response.blob().then(blob => { |
'Authorization': `Bearer ${token}` |
||||||
const url = window.URL.createObjectURL(new Blob([blob])); |
}) |
||||||
let a = document.createElement('a'); |
}) |
||||||
a.href = url; |
.then(response => { |
||||||
a.download = file; |
response.blob().then(blob => { |
||||||
a.click(); |
const url = window.URL.createObjectURL(new Blob([blob])); |
||||||
a.remove(); |
let a = document.createElement('a'); |
||||||
}); |
a.href = url; |
||||||
//window.location.href = response.url;
|
a.download = file; |
||||||
}); |
a.click(); |
||||||
// const urlDownload = DOCUMENT_DOWNLOAD(id);
|
a.remove(); |
||||||
// window.open(urlDownload);
|
}); |
||||||
} |
//window.location.href = response.url;
|
||||||
|
}); |
||||||
const handleShow = (file) => { |
// const urlDownload = DOCUMENT_DOWNLOAD(id);
|
||||||
const urlShow = `${BASE_SIMPRO_LUMEN_FILE}/${file}` |
// window.open(urlDownload);
|
||||||
window.open(urlShow); |
} |
||||||
} |
|
||||||
|
const handleShow = (file) => { |
||||||
const handleNewFolderParent = (folderId) => { |
const urlShow = `${BASE_SIMPRO_LUMEN_FILE}/${file}` |
||||||
setParentIdNewFolder(folderId) |
window.open(urlShow); |
||||||
setOpenDialogNewFolder(true) |
} |
||||||
} |
|
||||||
|
const handleNewFolderParent = (folderId) => { |
||||||
const handleNewFolderWOParent = () => { |
setParentIdNewFolder(folderId) |
||||||
setParentIdNewFolder(0) |
setOpenDialogNewFolder(true) |
||||||
setOpenDialogNewFolder(true) |
} |
||||||
} |
|
||||||
|
const handleNewFolderWOParent = () => { |
||||||
const handleNewFileParent = (folderId) => { |
setParentIdNewFolder(0) |
||||||
setParentIdNewFolder(folderId) |
setOpenDialogNewFolder(true) |
||||||
openDialogRequest() |
} |
||||||
} |
|
||||||
|
const handleNewFileParent = (folderId) => { |
||||||
const handleNewFileWOParent = () => { |
setParentIdNewFolder(folderId) |
||||||
setParentIdNewFolder(0) |
openDialogRequest() |
||||||
openDialogRequest() |
} |
||||||
} |
|
||||||
|
const handleNewFileWOParent = () => { |
||||||
const renderShowDokumen = (file) => { |
setParentIdNewFolder(0) |
||||||
let arrayFile = file.split(".") |
openDialogRequest() |
||||||
let length = arrayFile.length |
} |
||||||
length = length - 1 |
|
||||||
const fileExt = arrayFile[length]; |
const renderShowDokumen = (file) => { |
||||||
if (fileExt == "pdf" || fileExt == "png" || fileExt == "jpg" || fileExt == "jpeg" || fileExt == "gif") { |
let arrayFile = file.split(".") |
||||||
return ( |
let length = arrayFile.length |
||||||
<Tooltip title="View Document"> |
length = length - 1 |
||||||
<Button size={"sm"} color='info' style={{ color: "#FFFFFF" }} onClick={() => handleShow(file)}><i className="fa fa-eye"></i></Button> |
const fileExt = arrayFile[length]; |
||||||
</Tooltip> |
if (fileExt == "pdf" || fileExt == "png" || fileExt == "jpg" || fileExt == "jpeg" || fileExt == "gif") { |
||||||
) |
return ( |
||||||
} |
<Tooltip title="View Document"> |
||||||
} |
<Button size={"sm"} color='info' style={{ color: "#FFFFFF" }} onClick={() => handleShow(file)}><i className="fa fa-eye"></i></Button> |
||||||
const RenderTable = useMemo(() => { |
</Tooltip> |
||||||
const columns = [ |
) |
||||||
{ |
} |
||||||
title: 'Action', |
} |
||||||
dataIndex: '', |
const RenderTable = useMemo(() => { |
||||||
key: 'id', |
const columns = [ |
||||||
className: "nowrap", |
{ |
||||||
render: (text, record) => |
title: 'Action', |
||||||
<> |
dataIndex: '', |
||||||
{!record.isDir && <Tooltip title="Delete Document"> |
key: 'id', |
||||||
<Button size={"sm"} color='danger' onClick={() => handleDelete(text.id)}><i className="fa fa-trash"></i></Button> |
className: "nowrap", |
||||||
</Tooltip>}{" "} |
render: (text, record) => |
||||||
{record.isDir && <Tooltip title="Delete Folder"> |
<> |
||||||
<Button size={"sm"} color='danger' onClick={() => handleDeleteFolder(text.id)}><i className="fa fa-trash"></i></Button> |
{!record.isDir && <Tooltip title="Delete Document"> |
||||||
</Tooltip>}{" "} |
<Button size={"sm"} color='danger' onClick={() => handleDelete(text.id)}><i className="fa fa-trash"></i></Button> |
||||||
{!record.isDir && <Tooltip title="Download Document"> |
</Tooltip>}{" "} |
||||||
<Button size={"sm"} color='primary' onClick={() => handleDownload(text.id, text.file)}><i className="fa fa-download"></i></Button> |
{record.isDir && <Tooltip title="Delete Folder"> |
||||||
</Tooltip>}{" "} |
<Button size={"sm"} color='danger' onClick={() => handleDeleteFolder(text.id)}><i className="fa fa-trash"></i></Button> |
||||||
{record.isDir && <Tooltip title="New Folder"> |
</Tooltip>}{" "} |
||||||
<Button size="sm" color="success" onClick={() => handleNewFolderParent(record.id)}><i className="fa fa-folder"></i></Button> |
{!record.isDir && <Tooltip title="Download Document"> |
||||||
</Tooltip>}{" "} |
<Button size={"sm"} color='primary' onClick={() => handleDownload(text.id, text.file)}><i className="fa fa-download"></i></Button> |
||||||
{record.isDir && <Tooltip title="New File"> |
</Tooltip>}{" "} |
||||||
<Button size="sm" color="primary" onClick={() => handleNewFileParent(record.id)}><i className="fa fa-file"></i></Button> |
{record.isDir && <Tooltip title="New Folder"> |
||||||
</Tooltip>}{" "} |
<Button size="sm" color="success" onClick={() => handleNewFolderParent(record.id)}><i className="fa fa-folder"></i></Button> |
||||||
{text.file ? renderShowDokumen(text.file) : ""} |
</Tooltip>}{" "} |
||||||
</> |
{record.isDir && <Tooltip title="New File"> |
||||||
, |
<Button size="sm" color="primary" onClick={() => handleNewFileParent(record.id)}><i className="fa fa-file"></i></Button> |
||||||
}, |
</Tooltip>}{" "} |
||||||
{ title: 'Document Name', dataIndex: 'name_folder', key: 'name_folder', render: (text, record) => record.isDir ? record.name_folder : record.file }, |
{text.file ? renderShowDokumen(text.file) : ""} |
||||||
{ title: 'Type', dataIndex: 'isDir', key: 'isDir', render: (text, record) => record.isDir ? 'Folder' : 'File' }, |
</> |
||||||
{ title: 'Upload Date', dataIndex: 'created_at', key: 'created_at', render: (text, record) => (<div style={{ whiteSpace: "nowrap" }}>{text ? moment(text).format("D-M-YYYY") : "-"}</div>) } |
, |
||||||
]; |
}, |
||||||
|
{ title: 'Document Name', dataIndex: 'name_folder', key: 'name_folder', render: (text, record) => record.isDir ? record.name_folder : record.file }, |
||||||
return ( |
{ title: 'Type', dataIndex: 'isDir', key: 'isDir', render: (text, record) => record.isDir ? 'Folder' : 'File' }, |
||||||
<Table |
{ title: 'Upload Date', dataIndex: 'created_at', key: 'created_at', render: (text, record) => (<div style={{ whiteSpace: "nowrap" }}>{text ? moment(text).format("D-M-YYYY") : "-"}</div>) } |
||||||
size="small" |
]; |
||||||
columns={columns} |
|
||||||
rowKey={"id"} |
return ( |
||||||
dataSource={dataDocument} |
<Table |
||||||
pagination={{ position: ["bottomLeft"] }} |
size="small" |
||||||
/> |
columns={columns} |
||||||
) |
rowKey={"id"} |
||||||
}, [dataDocument]) |
dataSource={dataDocument} |
||||||
|
pagination={{ position: ["bottomLeft"] }} |
||||||
const closeDialogReq = (type) => { |
/> |
||||||
if (type == "upload") { |
) |
||||||
getDataDocument(); |
}, [dataDocument]) |
||||||
} |
|
||||||
setOpenDialogReq(false); |
const closeDialogReq = (type) => { |
||||||
} |
if (type == "upload") { |
||||||
|
getDataDocument(); |
||||||
const toggleDialogReq = () => { |
} |
||||||
setOpenDialogReq(!openDialogReq) |
setOpenDialogReq(false); |
||||||
} |
} |
||||||
|
|
||||||
const openDialogRequest = () => { |
const toggleDialogReq = () => { |
||||||
setOpenDialogReq(true) |
setOpenDialogReq(!openDialogReq) |
||||||
} |
} |
||||||
|
|
||||||
const cancelDelete = () => { |
const openDialogRequest = () => { |
||||||
setAlertDelete(false) |
setOpenDialogReq(true) |
||||||
setIdDelete(0) |
} |
||||||
} |
|
||||||
|
const cancelDelete = () => { |
||||||
const cancelDeleteFolder = () => { |
setAlertDelete(false) |
||||||
setAlertDeleteFolder(false) |
setIdDelete(0) |
||||||
setIdDelete(0) |
} |
||||||
} |
|
||||||
|
const cancelDeleteFolder = () => { |
||||||
const onConfirmDelete = async () => { |
setAlertDeleteFolder(false) |
||||||
let urlDel = DOCUMENT_DELETE(idDelete) |
setIdDelete(0) |
||||||
const result = await axios.delete(urlDel, HEADER) |
} |
||||||
.then(res => res) |
|
||||||
.catch((error) => error.response); |
const onConfirmDelete = async () => { |
||||||
|
let urlDel = DOCUMENT_DELETE(idDelete) |
||||||
if (result && result.data && result.data.code === 200) { |
const result = await axios.delete(urlDel, HEADER) |
||||||
getDataDocument() |
.then(res => res) |
||||||
setIdDelete(0) |
.catch((error) => error.response); |
||||||
setAlertDelete(false) |
|
||||||
NotificationManager.success(`Dokumen project berhasil dihapus`, 'Success!!'); |
if (result && result.data && result.data.code === 200) { |
||||||
} else { |
getDataDocument() |
||||||
setIdDelete(0) |
setIdDelete(0) |
||||||
setAlertDelete(false) |
setAlertDelete(false) |
||||||
NotificationManager.error(`Dokumen project gagal dihapus`, 'Failed!!'); |
NotificationManager.success(`Dokumen project berhasil dihapus`, 'Success!!'); |
||||||
} |
} else { |
||||||
} |
setIdDelete(0) |
||||||
|
setAlertDelete(false) |
||||||
const onConfirmDeleteFolder = async () => { |
NotificationManager.error(`Dokumen project gagal dihapus`, 'Failed!!'); |
||||||
let urlDel = FOLDER_DOCUMENT_PROYEK_DELETE(idDelete) |
} |
||||||
const result = await axios.delete(urlDel, HEADER) |
} |
||||||
.then(res => res) |
|
||||||
.catch((error) => error.response); |
const onConfirmDeleteFolder = async () => { |
||||||
|
let urlDel = FOLDER_DOCUMENT_PROYEK_DELETE(idDelete) |
||||||
if (result && result.data && result.data.code === 200) { |
const result = await axios.delete(urlDel, HEADER) |
||||||
getDataDocument() |
.then(res => res) |
||||||
setIdDelete(0) |
.catch((error) => error.response); |
||||||
setAlertDeleteFolder(false) |
|
||||||
NotificationManager.success(`Folder berhasil dihapus`, 'Success!!'); |
if (result && result.data && result.data.code === 200) { |
||||||
} else { |
getDataDocument() |
||||||
setIdDelete(0) |
setIdDelete(0) |
||||||
setAlertDeleteFolder(false) |
setAlertDeleteFolder(false) |
||||||
NotificationManager.error(`Folder gagal dihapus`, 'Failed!!'); |
NotificationManager.success(`Folder berhasil dihapus`, 'Success!!'); |
||||||
} |
} else { |
||||||
} |
setIdDelete(0) |
||||||
|
setAlertDeleteFolder(false) |
||||||
const closeDialogNewFolder = (type) => { |
NotificationManager.error(`Folder gagal dihapus`, 'Failed!!'); |
||||||
if (type == "upload") { |
} |
||||||
getDataDocument(); |
} |
||||||
} |
|
||||||
setOpenDialogNewFolder(false); |
const closeDialogNewFolder = (type) => { |
||||||
setParentIdNewFolder(0); |
if (type == "upload") { |
||||||
} |
getDataDocument(); |
||||||
|
} |
||||||
const toggleDialogNewFolder = () => { |
setOpenDialogNewFolder(false); |
||||||
setOpenDialogNewFolder(!openDialogNewFolder) |
setParentIdNewFolder(0); |
||||||
} |
} |
||||||
|
|
||||||
return ( |
const toggleDialogNewFolder = () => { |
||||||
<> |
setOpenDialogNewFolder(!openDialogNewFolder) |
||||||
<Modal size="xl" isOpen={openDialog} toggle={toggleDialog}> |
} |
||||||
<ModalHeader className="capitalize withBtn" toggle={closeDialog} style={{ width: "100%" }}> |
|
||||||
<div>Project Documents - {proyekName} </div> |
return ( |
||||||
{/* <Button onClick={openDialogRequest} size='sm' color="primary"><i className='fa fa-plus'></i></Button> */} |
<> |
||||||
{/* <Popover placement="bottom" title="Add" content={popupAddDoc()} trigger="click"> |
<Modal size="xl" isOpen={openDialog} toggle={toggleDialog}> |
||||||
<Button size='sm' color="primary"><i className='fa fa-plus'></i></Button> |
<ModalHeader className="capitalize withBtn" toggle={closeDialog} style={{ width: "100%" }}> |
||||||
</Popover> */} |
<div>Project Documents - {proyekName} </div> |
||||||
<div> |
{/* <Button onClick={openDialogRequest} size='sm' color="primary"><i className='fa fa-plus'></i></Button> */} |
||||||
<Tooltip title="New Folder"> |
{/* <Popover placement="bottom" title="Add" content={popupAddDoc()} trigger="click"> |
||||||
<Button size="sm" color="success" onClick={handleNewFolderWOParent}><i className="fa fa-folder"></i></Button> |
<Button size='sm' color="primary"><i className='fa fa-plus'></i></Button> |
||||||
</Tooltip> |
</Popover> */} |
||||||
<span style={{ marginLeft: 5, marginRight: 5 }}></span> |
<div> |
||||||
<Tooltip title="New File"> |
<Tooltip title="New Folder"> |
||||||
<Button size="sm" color="primary" onClick={handleNewFileWOParent}><i className="fa fa-file"></i></Button> |
<Button size="sm" color="success" onClick={handleNewFolderWOParent}><i className="fa fa-folder"></i></Button> |
||||||
</Tooltip> |
</Tooltip> |
||||||
</div> |
<span style={{ marginLeft: 5, marginRight: 5 }}></span> |
||||||
{/* <Button onClick={openDialogRequest} size='sm' color="primary"><i className='fa fa-folder'></i></Button> */} |
<Tooltip title="New File"> |
||||||
</ModalHeader> |
<Button size="sm" color="primary" onClick={handleNewFileWOParent}><i className="fa fa-file"></i></Button> |
||||||
<ModalBody> |
</Tooltip> |
||||||
<div style={{ width: '100%', overflow: "auto" }}> |
</div> |
||||||
{RenderTable} |
{/* <Button onClick={openDialogRequest} size='sm' color="primary"><i className='fa fa-folder'></i></Button> */} |
||||||
</div> |
</ModalHeader> |
||||||
</ModalBody> |
<ModalBody> |
||||||
{/* <ModalFooter> |
<Spin tip="Loading..." spinning={loading}> |
||||||
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button> |
<div style={{ width: '100%', overflow: "auto" }}> |
||||||
</ModalFooter> */} |
{RenderTable} |
||||||
</Modal> |
</div> |
||||||
<NotificationContainer /> |
</Spin> |
||||||
<SweetAlert |
</ModalBody> |
||||||
show={alertDelete} |
{/* <ModalFooter> |
||||||
warning |
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button> |
||||||
showCancel |
</ModalFooter> */} |
||||||
confirmBtnText="Delete" |
</Modal> |
||||||
confirmBtnBsStyle="danger" |
<NotificationContainer /> |
||||||
title={`Are you sure?`} |
<SweetAlert |
||||||
onConfirm={onConfirmDelete} |
show={alertDelete} |
||||||
onCancel={() => cancelDelete()} |
warning |
||||||
focusCancelBtn |
showCancel |
||||||
> |
confirmBtnText="Delete" |
||||||
Delete this data |
confirmBtnBsStyle="danger" |
||||||
</SweetAlert> |
title={`Are you sure?`} |
||||||
|
onConfirm={onConfirmDelete} |
||||||
<SweetAlert |
onCancel={() => cancelDelete()} |
||||||
show={alertDeleteFolder} |
focusCancelBtn |
||||||
warning |
> |
||||||
showCancel |
Delete this data |
||||||
confirmBtnText="Delete" |
</SweetAlert> |
||||||
confirmBtnBsStyle="danger" |
|
||||||
title={`Are you sure?`} |
<SweetAlert |
||||||
onConfirm={onConfirmDeleteFolder} |
show={alertDeleteFolder} |
||||||
onCancel={() => cancelDeleteFolder()} |
warning |
||||||
focusCancelBtn |
showCancel |
||||||
> |
confirmBtnText="Delete" |
||||||
Delete this folder |
confirmBtnBsStyle="danger" |
||||||
</SweetAlert> |
title={`Are you sure?`} |
||||||
|
onConfirm={onConfirmDeleteFolder} |
||||||
<DialogRequest |
onCancel={() => cancelDeleteFolder()} |
||||||
openDialog={openDialogReq} |
focusCancelBtn |
||||||
closeDialog={closeDialogReq} |
> |
||||||
toggleDialog={toggleDialogReq} |
Delete this folder |
||||||
idTask={idTask} |
</SweetAlert> |
||||||
parentIdNewFolder={parentIdNewFolder} |
|
||||||
dataEdit={dataEdit} |
<DialogRequest |
||||||
/> |
openDialog={openDialogReq} |
||||||
|
closeDialog={closeDialogReq} |
||||||
<DialogRequestFolder |
toggleDialog={toggleDialogReq} |
||||||
openDialog={openDialogNewFolder} |
idTask={idTask} |
||||||
closeDialog={closeDialogNewFolder} |
parentIdNewFolder={parentIdNewFolder} |
||||||
toggleDialog={toggleDialogNewFolder} |
dataEdit={dataEdit} |
||||||
idTask={idTask} |
/> |
||||||
parentIdNewFolder={parentIdNewFolder} |
|
||||||
dataEdit={dataEdit} |
<DialogRequestFolder |
||||||
/> |
openDialog={openDialogNewFolder} |
||||||
</> |
closeDialog={closeDialogNewFolder} |
||||||
) |
toggleDialog={toggleDialogNewFolder} |
||||||
|
idTask={idTask} |
||||||
} |
parentIdNewFolder={parentIdNewFolder} |
||||||
|
dataEdit={dataEdit} |
||||||
export default DialogDocument; |
/> |
||||||
|
</> |
||||||
|
) |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
export default DialogDocument; |
||||||
|
Loading…
Reference in new issue