From 48fcb5247bb22f4c973874242b1f6df628b378e0 Mon Sep 17 00:00:00 2001 From: AiraBilqis Date: Mon, 25 Mar 2024 14:40:04 +0700 Subject: [PATCH] file uploaded --- .../SimproV2/CreatedProyek/DialogDocument.js | 15 +- .../CreatedProyek/FormFolderDocument.js | 192 +++++++++--------- 2 files changed, 103 insertions(+), 104 deletions(-) diff --git a/src/views/SimproV2/CreatedProyek/DialogDocument.js b/src/views/SimproV2/CreatedProyek/DialogDocument.js index 9184cfa..1314dca 100644 --- a/src/views/SimproV2/CreatedProyek/DialogDocument.js +++ b/src/views/SimproV2/CreatedProyek/DialogDocument.js @@ -28,14 +28,13 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN const [dataEdit, setDataEdit] = useState(null) const [parentIdNewFolder, setParentIdNewFolder] = useState(0) const [loading, setLoading] = useState(true); - const company_id = window.localStorage.getItem('company_id'); useEffect(() => { - if (idTask > 0) { + if (parseInt(idTask) > 0) { setLoading(true); getDataDocument(); } - }, [idTask, openDialog]) + }, [parseInt(idTask), openDialog]) useEffect(() => { if (!openDialog) { @@ -46,7 +45,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN }, [openDialog]) const getDataDocument = async () => { - const url = FOLDER_DOCUMENT_PROYEK_GET_TREE(idTask) + const url = FOLDER_DOCUMENT_PROYEK_GET_TREE(parseInt(idTask)) const result = await axios .get(url, HEADER) .then(res => res) @@ -76,7 +75,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN } const handleDownload = (id, file) => { - fetch(DOCUMENT_DOWNLOAD(id, company_id), { + fetch(DOCUMENT_DOWNLOAD(id, parseInt(idTask)), { headers: new Headers({ 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` @@ -206,7 +205,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN } const onConfirmDelete = async () => { - let urlDel = DOCUMENT_DELETE(idDelete, idTask) + let urlDel = DOCUMENT_DELETE(idDelete, parseInt(idTask)) const result = await axios.delete(urlDel, HEADER) .then(res => res) .catch((error) => error.response); @@ -317,7 +316,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN openDialog={openDialogReq} closeDialog={closeDialogReq} toggleDialog={toggleDialogReq} - idTask={idTask} + idTask={parseInt(idTask)} parentIdNewFolder={parentIdNewFolder} dataEdit={dataEdit} /> @@ -326,7 +325,7 @@ const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekN openDialog={openDialogNewFolder} closeDialog={closeDialogNewFolder} toggleDialog={toggleDialogNewFolder} - idTask={idTask} + idTask={parseInt(idTask)} parentIdNewFolder={parentIdNewFolder} dataEdit={dataEdit} /> diff --git a/src/views/SimproV2/CreatedProyek/FormFolderDocument.js b/src/views/SimproV2/CreatedProyek/FormFolderDocument.js index de7d56d..32fe696 100644 --- a/src/views/SimproV2/CreatedProyek/FormFolderDocument.js +++ b/src/views/SimproV2/CreatedProyek/FormFolderDocument.js @@ -1,96 +1,96 @@ -import React, { useEffect, useState } from 'react' -import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; -import { Button, Form, FormGroup, Label, Input, Col, Row } from 'reactstrap'; -import axios from "../../../const/interceptorApi"; -import { DOCUMENT_ADD, FOLDER_DOCUMENT_PROYEK_ADD } from '../../../const/ApiConst'; -import 'antd/dist/antd.css'; -import { NotificationManager } from 'react-notifications'; - -const DialogRequestFolder = ({ openDialog, closeDialog, toggleDialog, idTask, parentIdNewFolder }) => { - const token = localStorage.getItem("token") - const HEADER = { - headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${token}` - } - } - const [id, setId] = useState(0) - const [folderName, setFolderName] = useState('') - - - const handleClearData = () => { - setId(0) - setFolderName('') - } - - useEffect(() => { - handleClearData() - }, [openDialog]) - - const handleSave = () => { - saveFolder() - handleClearData() - } - - const saveFolder = async () => { - - - - - let payload = { - "proyek_id": idTask, - "name_folder": folderName - } - - if (parentIdNewFolder > 0) { - payload.parent_id = parentIdNewFolder - } - - const result = await axios - .post(FOLDER_DOCUMENT_PROYEK_ADD, payload, HEADER) - .then(res => res) - .catch((error) => error.response); - - if (result && result.data && result.data.code == 200) { - NotificationManager.success('Success create folder!!', 'Success'); - closeDialog("upload"); - } else { - NotificationManager.error('Failed to create folder!!', 'Failed'); - } - } - - const handleCancel = () => { - closeDialog('cancel') - handleClearData() - } - - const renderForm = () => { - return ( -
- - - setFolderName(e.target.value)} /> - -
- ) - } - - - return ( - <> - - Create New Folder - - {renderForm()} - - - {' '} - - - - - ) - -} - -export default DialogRequestFolder; \ No newline at end of file +import React, { useEffect, useState } from 'react' +import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; +import { Button, Form, FormGroup, Label, Input, Col, Row } from 'reactstrap'; +import axios from "../../../const/interceptorApi"; +import { FOLDER_DOCUMENT_PROYEK_ADD } from '../../../const/ApiConst'; +import 'antd/dist/antd.css'; +import { NotificationManager } from 'react-notifications'; + +const DialogRequestFolder = ({ openDialog, closeDialog, toggleDialog, idTask, parentIdNewFolder }) => { + const token = localStorage.getItem("token") + const HEADER = { + headers: { + "Content-Type": "application/json", + "Authorization": `Bearer ${token}` + } + } + const [id, setId] = useState(0) + const [folderName, setFolderName] = useState('') + + + const handleClearData = () => { + setId(0) + setFolderName('') + } + + useEffect(() => { + handleClearData() + }, [openDialog]) + + const handleSave = () => { + saveFolder() + handleClearData() + } + + const saveFolder = async () => { + + + + + let payload = { + "proyek_id": idTask, + "name_folder": folderName + } + + if (parentIdNewFolder > 0) { + payload.parent_id = parentIdNewFolder + } + + const result = await axios + .post(FOLDER_DOCUMENT_PROYEK_ADD, payload, HEADER) + .then(res => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code == 200) { + NotificationManager.success('Success create folder!!', 'Success'); + closeDialog("upload"); + } else { + NotificationManager.error('Failed to create folder!!', 'Failed'); + } + } + + const handleCancel = () => { + closeDialog('cancel') + handleClearData() + } + + const renderForm = () => { + return ( +
+ + + setFolderName(e.target.value)} /> + +
+ ) + } + + + return ( + <> + + Create New Folder + + {renderForm()} + + + {' '} + + + + + ) + +} + +export default DialogRequestFolder;