|
| 1 | +import Box from "@cloudscape-design/components/box"; |
| 2 | +import Header from "@cloudscape-design/components/header"; |
| 3 | +import SpaceBetween from "@cloudscape-design/components/space-between"; |
| 4 | +import Table from "@cloudscape-design/components/table"; |
| 5 | +import TextFilter from "@cloudscape-design/components/text-filter"; |
| 6 | + |
| 7 | +import ApplicantStatus from "@/app/admin/applicants/components/ApplicantStatus"; |
| 8 | +import { Participant } from "@/lib/admin/useParticipants"; |
| 9 | + |
| 10 | +import ParticipantAction from "./ParticipantAction"; |
| 11 | +import RoleBadge from "./RoleBadge"; |
| 12 | + |
| 13 | +interface ParticipantsTableProps { |
| 14 | + participants: Participant[]; |
| 15 | + loading: boolean; |
| 16 | +} |
| 17 | + |
| 18 | +function ParticipantsTable({ participants, loading }: ParticipantsTableProps) { |
| 19 | + // TODO: sorting |
| 20 | + // TODO: search functionality |
| 21 | + // TODO: role and status filters |
| 22 | + |
| 23 | + const emptyMessage = ( |
| 24 | + <Box margin={{ vertical: "xs" }} textAlign="center" color="inherit"> |
| 25 | + <SpaceBetween size="m"> |
| 26 | + <b>No participants</b> |
| 27 | + </SpaceBetween> |
| 28 | + </Box> |
| 29 | + ); |
| 30 | + |
| 31 | + return ( |
| 32 | + <Table |
| 33 | + // TODO: aria labels |
| 34 | + columnDefinitions={[ |
| 35 | + { |
| 36 | + id: "uid", |
| 37 | + header: "UID", |
| 38 | + cell: (item) => item._id, |
| 39 | + sortingField: "uid", |
| 40 | + isRowHeader: true, |
| 41 | + }, |
| 42 | + { |
| 43 | + id: "firstName", |
| 44 | + header: "First name", |
| 45 | + cell: (item) => item.first_name, |
| 46 | + sortingField: "firstName", |
| 47 | + }, |
| 48 | + { |
| 49 | + id: "lastName", |
| 50 | + header: "Last name", |
| 51 | + cell: (item) => item.last_name, |
| 52 | + sortingField: "lastName", |
| 53 | + }, |
| 54 | + { |
| 55 | + id: "role", |
| 56 | + header: "Role", |
| 57 | + cell: RoleBadge, |
| 58 | + sortingField: "role", |
| 59 | + }, |
| 60 | + { |
| 61 | + id: "status", |
| 62 | + header: "Status", |
| 63 | + cell: ApplicantStatus, |
| 64 | + sortingField: "status", |
| 65 | + }, |
| 66 | + { |
| 67 | + id: "action", |
| 68 | + header: "Action", |
| 69 | + cell: ParticipantAction, |
| 70 | + }, |
| 71 | + ]} |
| 72 | + header={ |
| 73 | + <Header counter={`(${participants.length})`}>Participants</Header> |
| 74 | + } |
| 75 | + items={participants} |
| 76 | + loading={loading} |
| 77 | + loadingText="Loading participants" |
| 78 | + resizableColumns |
| 79 | + variant="full-page" |
| 80 | + stickyColumns={{ first: 1, last: 0 }} |
| 81 | + trackBy="_id" |
| 82 | + empty={emptyMessage} |
| 83 | + filter={ |
| 84 | + <TextFilter filteringPlaceholder="Find participants" filteringText="" /> |
| 85 | + } |
| 86 | + // TODO: pagination |
| 87 | + // TODO: collection preferences |
| 88 | + /> |
| 89 | + ); |
| 90 | +} |
| 91 | + |
| 92 | +export default ParticipantsTable; |
0 commit comments