Skip to content

Commit 986444c

Browse files
committed
refactor filestable and actions
1 parent 5b5a8e7 commit 986444c

File tree

3 files changed

+82
-39
lines changed

3 files changed

+82
-39
lines changed

src/components/FilesTable/FilesTable.jsx

Lines changed: 54 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,63 @@ import React from 'react'
22
import PropTypes from 'prop-types'
33
import { Table } from 'react-bootstrap'
44

5-
const FilesTable = (addClass, files) => {
6-
let headers = ['']
7-
return (
8-
<Table striped bordered hover size='sm' className={`${addClass}`}>
9-
<thead>
10-
<tr>
11-
{headers.map((header) => {
12-
return (
13-
<th>
5+
const FilesTable = ({addClass, files}) => {
6+
let headers = [{
7+
name: 'File Name',
8+
key: 'file-name'
9+
},
10+
{
11+
name: 'Uploaded By',
12+
key: 'uploaded-by'
13+
},
14+
{
15+
name: 'Size',
16+
key: 'size'
17+
},
18+
{
19+
name: 'Created At',
20+
key: 'created-at'
21+
},
22+
{
23+
name: '',
24+
key: 'buttons'
25+
}]
1426

15-
</th>
27+
if (files.length === 0) {
28+
return (
29+
<h6>You don't have any of these documents yet.</h6>
30+
)
31+
} else {
32+
return (
33+
<Table striped bordered hover size='sm' className={`${addClass}`}>
34+
<thead>
35+
<tr>
36+
{headers.map((header) => {
37+
return (
38+
<th key={header.key}>
39+
{header.name}
40+
</th>
41+
)
42+
})}
43+
</tr>
44+
</thead>
45+
<tbody>
46+
{files.map((file) => {
47+
const { uuid, filename, uploadedBy, contentLength, createdAt } = file
48+
return (
49+
<tr key={uuid} className='small'>
50+
<td>{filename}</td>
51+
<td>{uploadedBy}</td>
52+
<td>{contentLength}</td>
53+
<td>{createdAt}</td>
54+
<td><button></button></td>
55+
</tr>
1656
)
1757
})}
18-
</tr>
19-
</thead>
20-
<tbody>
21-
{/* {files.map((file) => {
22-
return (
23-
<tr>
24-
25-
</tr>
26-
)
27-
})} */}
28-
</tbody>
29-
</Table>
30-
)
31-
}
58+
</tbody>
59+
</Table>
60+
)
61+
}}
3262

3363
FilesTable.propTypes = {
3464
addClass: PropTypes.string,

src/compounds/ActionsGroup/ActionsGroup.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import ViewFiles from './actions/ViewFiles'
77
import './actions-group.scss'
88

99
const ActionsGroup = ({ files, handleSendingMessages }) => {
10-
console.log(files)
1110
const [show, setShow] = useState(false)
1211
const [action, setAction] = useState(null)
1312

@@ -20,7 +19,6 @@ const ActionsGroup = ({ files, handleSendingMessages }) => {
2019
setAction(null)
2120
setShow(false)
2221
}
23-
2422
return (
2523
<>
2624
<ListGroup className='actions-group'>

src/compounds/ActionsGroup/actions/ViewFiles.jsx

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,40 @@ import { Offcanvas, Tab, Tabs } from 'react-bootstrap'
44
import FilesTable from '../../../components/FilesTable/FilesTable'
55

66
const ViewFiles = ({ files, handleClose, show }) => {
7+
const documentTabs = [
8+
{
9+
eventKey: 'files',
10+
title: 'Attachments',
11+
status: 'Other File'
12+
},
13+
{
14+
eventKey: 'status-updates',
15+
title: 'Status Updates',
16+
status: 'Status Update'
17+
},
18+
{
19+
eventKey: 'payment-status-files',
20+
title: 'Payment Status Files',
21+
// TODO(@summer-cook): fill this in when Sherman adds a file of this type
22+
status: 'TODO:FILL THIS IN'
23+
},
24+
]
725
return (
826
<Offcanvas show={show} onHide={handleClose} placement='end' scroll='true'>
927
<Offcanvas.Header className='d-flex border-bottom px-3 py-2 bg-light' closeButton>
1028
<Offcanvas.Title>Documents</Offcanvas.Title>
1129
</Offcanvas.Header>
1230
<Offcanvas.Body className='border rounded p-2 m-3'>
13-
<Tabs
14-
defaultActiveKey="files"
15-
id="document-tabs"
16-
>
17-
<Tab eventKey="files" title="Attachments" className='p-2'>
18-
<FilesTable files={files} />
19-
</Tab>
20-
<Tab eventKey="status-updates" title="Status Updates" className='p-2'>
21-
goodbye
22-
</Tab>
23-
<Tab eventKey="payment-status-files" title="Payment Status Files" className='p-2'>
24-
goodbye
25-
</Tab>
31+
<Tabs defaultActiveKey="files" id="document-tabs">
32+
{documentTabs && documentTabs.map(tab => {
33+
const { eventKey, title, status } = tab
34+
let filteredFiles = files.filter(f => (status === f.status) || (status === 'Other File' && f.status === null))
35+
return (
36+
<Tab eventKey={eventKey} title={title} className='p-2'>
37+
<FilesTable files={filteredFiles} status={status} />
38+
</Tab>
39+
)
40+
})}
2641
</Tabs>
2742
</Offcanvas.Body>
2843
</Offcanvas>

0 commit comments

Comments
 (0)