1
1
import React
2
- // { useState, useRef } TODO comment back in
3
2
from 'react'
4
3
import PropTypes from 'prop-types'
5
4
import {
6
- // Button,
7
- // CloseButton,
8
- // Form,
9
- // InputGroup,
10
- // ListGroup,
11
5
Offcanvas ,
12
6
Tab ,
13
7
Tabs ,
14
8
} from 'react-bootstrap'
15
- // import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
16
9
import FilesTable from '../../../components/FilesTable/FilesTable'
17
- // import { apiV2CompatibleStrings, convertToBase64 } from '../../../resources/utilityFunctions'
18
10
import { allowNull } from '../../../resources/utilityFunctions'
19
11
20
12
const ViewFiles = ( { initialFiles, handleClose } ) => {
21
- // TODO(summercook):
22
- // - comment back in the following 2 lines & above imports once posting messages/attachments is working
23
- // const fileRef = useRef(null)
24
- // const [files, setFiles] = useState([])
25
-
26
13
const documentTabs = [
27
14
{
28
15
eventKey : 'files' ,
@@ -36,71 +23,12 @@ const ViewFiles = ({ initialFiles, handleClose }) => {
36
23
} ,
37
24
]
38
25
39
- // TODO(summercook):
40
- // - comment back in the following 3 methods once posting messages/attachments is working
41
- // may need to use the handleSendingMessagesOrFiles to post
42
- // const handleSubmit = (event) => {
43
- // event.preventDefault()
44
- // onSubmit({ files: apiV2CompatibleStrings(files) })
45
- // }
46
-
47
- // const handleAddFile = async (event) => {
48
- // event.preventDefault()
49
- // try {
50
- // // "event.target.files" returns a FileList, which looks like an array but does not respond to array methods
51
- // // except "length". we are using the spread syntax to set "files" to be an iterable array
52
- // const fileArray = [...event.target.files]
53
- // const newBase64Files = await Promise.all(convertToBase64(fileArray))
54
- // const newFiles = fileArray.map((file, index) => ({ [file.name]: newBase64Files[index] }))
55
-
56
- // setFiles([...files, ...newFiles])
57
- // fileRef.current.value = ''
58
- // } catch (error) {
59
- // throw new Error(error)
60
- // }
61
- // }
62
-
63
- // const handleDeleteFile = (file) => {
64
- // const remainingFiles = files.filter((obj) => obj !== file)
65
- // setFiles(remainingFiles)
66
- // }
67
26
return (
68
27
< Offcanvas show onHide = { handleClose } placement = 'end' scroll = 'true' >
69
28
< Offcanvas . Header className = 'd-flex border-bottom px-3 py-2 bg-light' closeButton >
70
29
< Offcanvas . Title > Documents</ Offcanvas . Title >
71
30
</ Offcanvas . Header >
72
31
< Offcanvas . Body className = 'border rounded p-2 m-3' >
73
- { /* TODO(summercook): see above comment */ }
74
- { /* <Form>
75
- <h6 className='mt-3'>Upload Additional Documents</h6>
76
- <InputGroup controlId='attachments' className='mb-3'>
77
- <Form.Control
78
- multiple
79
- type='file'
80
- onChange={handleAddFile}
81
- ref={fileRef}
82
- />
83
- <Button
84
- variant='outline-primary'
85
- onClick={handleSubmit}
86
- type='submit'
87
- >
88
- <FontAwesomeIcon icon='fa-upload' />
89
- </Button>
90
- </InputGroup>
91
- </Form>
92
- <ListGroup variant='flush'>
93
- {files.map((file) => {
94
- const fileName = Object.keys(file)[0]
95
-
96
- return (
97
- <ListGroup.Item key={fileName} className='d-flex align-items-center'>
98
- <span>{fileName}</span>
99
- <CloseButton onClick={() => handleDeleteFile(file)} className='ms-auto' />
100
- </ListGroup.Item>
101
- )
102
- }) }
103
- </ListGroup> */ }
104
32
< Tabs defaultActiveKey = 'files' id = 'document-tabs' justify fill >
105
33
{ documentTabs && documentTabs . map ( ( tab ) => {
106
34
const { eventKey, title, status } = tab
@@ -115,8 +43,6 @@ const ViewFiles = ({ initialFiles, handleClose }) => {
115
43
< FilesTable
116
44
files = { filteredFiles }
117
45
status = { status }
118
- // TODO(summercook): see above comment
119
- // handleDeleteFile={handleDeleteFile}
120
46
/>
121
47
</ Tab >
122
48
)
0 commit comments