Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3d59b36850 | |||
| f1d659b273 |
@@ -1,9 +1,16 @@
|
||||
import React, { useRef, useState } from 'react'
|
||||
import React, { useEffect, useRef, useState } from 'react'
|
||||
import LoadingSpinner from '../Spinners/LoadingSpinner'
|
||||
import axios from 'axios'
|
||||
|
||||
import usersService from '../../services/UsersService'
|
||||
|
||||
export default function AttachFile({data}) {
|
||||
|
||||
const apiCall = new usersService()
|
||||
|
||||
let [uploadedList, setUploadedList] = useState({loading: true, data:{}})
|
||||
let [reloadList, setReloadList] = useState(false) // Triggers list of upload reload
|
||||
|
||||
const [requestStatus, setRequestStatus] = useState({loading: false, status:false, message:''})
|
||||
|
||||
const inputFile = useRef()
|
||||
@@ -29,7 +36,6 @@ export default function AttachFile({data}) {
|
||||
formData.append(input, inputs[input]);
|
||||
}
|
||||
|
||||
console.log('data', formData, inputs)
|
||||
axios.post(`${process.env.REACT_APP_MEDIA_LINK}/upload/task`,formData).then(res => {
|
||||
if(res.data.status < 1){
|
||||
inputFile.current.value = null
|
||||
@@ -39,9 +45,9 @@ export default function AttachFile({data}) {
|
||||
}, 3000)
|
||||
return
|
||||
}
|
||||
// console.log('RESPONSE', res.data)
|
||||
setRequestStatus({loading: false, status:true, message:'uploaded'})
|
||||
inputFile.current.value = null
|
||||
setReloadList(prev => !prev) // Triggers list of upload reload
|
||||
setTimeout(()=>{
|
||||
setRequestStatus({loading: false, status:false, message:''})
|
||||
}, 3000)
|
||||
@@ -55,6 +61,15 @@ export default function AttachFile({data}) {
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(()=>{
|
||||
apiCall.jobManagerFiles({job_uid:data?.job_uid}).then(res => {
|
||||
setUploadedList({loading: false, data:res.data})
|
||||
}).catch(err => {
|
||||
console.log(err)
|
||||
setUploadedList({loading: false, data:{}})
|
||||
})
|
||||
},[data, reloadList])
|
||||
|
||||
return (
|
||||
<div className='w-full h-full flex flex-col justify-center items-center rounded-md'>
|
||||
<div className='w-full flex flex-col items-start gap-1 overflow-hidden'>
|
||||
@@ -69,8 +84,33 @@ export default function AttachFile({data}) {
|
||||
</div>
|
||||
<label htmlFor='file' className={`cursor-pointer text-[12px] py-1 px-2 rounded-full border ${ requestStatus.loading && 'pointer-events-none'}`}>+ Add</label>
|
||||
</div>
|
||||
<div className='text-[12px] w-full px-2 py-1 h-20 overflow-y-auto flex justify-center items-center border'>
|
||||
list shows here
|
||||
<div className='text-[12px] w-full px-2 py-1 h-20 overflow-y-auto flex flex-col gap-1 border'>
|
||||
{uploadedList.loading ?
|
||||
<div className='w-full h-full justify-center items-center'>
|
||||
<LoadingSpinner size='6' height='h-full' />
|
||||
</div>
|
||||
:
|
||||
Object.keys(uploadedList.data).length > 0 ?
|
||||
uploadedList.data.result_list.length > 0 ?
|
||||
uploadedList.data.result_list.map((item, index) => (
|
||||
<div className='flex justify-start gap-2'>
|
||||
<span>{index + 1}:</span>
|
||||
<a
|
||||
target='_blank'
|
||||
alt='download-link'
|
||||
key={item.file_uid}
|
||||
className=''
|
||||
href={`${uploadedList?.data?.session_image_server}/${localStorage.getItem("session_token")}/jobfile/${item.file_uid}`}
|
||||
>
|
||||
{item.originalname}
|
||||
</a>
|
||||
</div>
|
||||
))
|
||||
:
|
||||
<p className='text-sm'>No Uploaded files yet</p>
|
||||
:
|
||||
<></>
|
||||
}
|
||||
</div>
|
||||
<input
|
||||
type="file"
|
||||
|
||||
@@ -44,6 +44,7 @@ export const apiConst = {
|
||||
WRENCH_FILE_FAMILY: 400,
|
||||
WRENCH_FILE_FAMILYBANNER: 410,
|
||||
WRENCH_FILE_JOB : 500,
|
||||
JOB_MANAGER_FILES: 13012,
|
||||
WRENCHBOARD_BKO_START: 10000,
|
||||
WRENCHBOARD_BKO_LOGIN: 10010,
|
||||
WRENCHBOARD_BKO_CREATEUSER: 10015,
|
||||
|
||||
@@ -1356,6 +1356,18 @@ class usersService {
|
||||
return this.postAuxEnd("/assignmediatask", postData);
|
||||
}
|
||||
|
||||
// API FUNCTION FOR LISTING JOB MANAGER FILES (TASK FILE UPLAOD)
|
||||
jobManagerFiles(reqData) {
|
||||
var postData = {
|
||||
member_uid: localStorage.getItem("uid"),
|
||||
member_id: localStorage.getItem("member_id"),
|
||||
sessionid: localStorage.getItem("session_token"),
|
||||
action: apiConst.JOB_MANAGER_FILES,
|
||||
...reqData
|
||||
};
|
||||
return this.postAuxEnd("/jobmanagerfiles", postData);
|
||||
}
|
||||
|
||||
/*
|
||||
- 20:27:30.118 FLOG_MAX [757411]: REQ_STRING(username)
|
||||
- 20:27:30.118 FLOG_MAX [757411]: REQ_STRING(password)
|
||||
|
||||
Reference in New Issue
Block a user