-
Notifications
You must be signed in to change notification settings - Fork 5
/
SubrecipientTableUploadLinksDisplay.tsx
59 lines (52 loc) · 1.8 KB
/
SubrecipientTableUploadLinksDisplay.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { FindSubrecipients } from 'types/graphql'
import { Link, routes } from '@redwoodjs/router'
type SubrecipientUpload =
| FindSubrecipients['subrecipients'][number]['validSubrecipientUploads'][number]
| FindSubrecipients['subrecipients'][number]['invalidSubrecipientUploads'][number]
interface SubrecipientTableUploadLinksDisplayProps {
validSubrecipientUploads: FindSubrecipients['subrecipients'][number]['validSubrecipientUploads']
invalidSubrecipientUploads: FindSubrecipients['subrecipients'][number]['invalidSubrecipientUploads']
}
const SubrecipientTableUploadLinksDisplay = ({
validSubrecipientUploads,
invalidSubrecipientUploads,
}: SubrecipientTableUploadLinksDisplayProps) => {
const renderUploadLink = (subrecipientUpload: SubrecipientUpload) => {
const { id, upload } = subrecipientUpload
return (
<Link
key={id}
to={routes.upload({ id: upload.id })}
title={`Show upload ${upload.id} detail`}
className="d-block link-underline link-underline-opacity-0"
>
Upload {upload.id}
</Link>
)
}
const renderUploadSection = (
title: string,
uploads: SubrecipientUpload[]
) => (
<>
<div className="fw-bold">{title}</div>
<div className="mb-3">{uploads.map(renderUploadLink)}</div>
</>
)
return (
<>
{validSubrecipientUploads.length > 0 &&
renderUploadSection('Latest Valid Upload:', [
validSubrecipientUploads[0],
])}
{validSubrecipientUploads.length > 1 &&
renderUploadSection(
'Other Valid Uploads:',
validSubrecipientUploads.slice(1)
)}
{invalidSubrecipientUploads.length > 0 &&
renderUploadSection('Invalid Uploads:', invalidSubrecipientUploads)}
</>
)
}
export default SubrecipientTableUploadLinksDisplay