Skip to content

Commit

Permalink
Participants loading data, table label setup
Browse files Browse the repository at this point in the history
  • Loading branch information
acoard-aot committed Sep 29, 2023
1 parent 3aef9d8 commit 78a0ba6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ function NotationItem({ notation, index, onClickAddParticipant }: { notation: No


<SiteDetailsTable
label='Notation Participants'
headers={[
{label: 'Name', accessor: 'name'},
{label: 'Role', accessor: 'role'},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,30 @@ import SubSearch from "./sub-search/SubSearch";
import { RootState } from "@/store";
import { useSelector } from "react-redux";
import SiteDetailsTable from "./table/SiteDetailsTable";
import { useParams } from "react-router-dom";
import { Site } from "@/api/sites";

export default function Participants() {
const editMode = useSelector((state: RootState) => state.edit.editMode);
const { siteID } = useParams();
const siteIDNum = parseInt(siteID);
const site: Site = useSelector((state: RootState) => state.site.value.find(searchedSite => searchedSite.siteID === siteIDNum));
// const dispatch = useDispatch();

return (
<div>
<h4>Site Participants go here</h4>

<SubSearch label="Participants" showResultsDropdown={true}/>


<SiteDetailsTable
label='Site Participants'
headers={[
{label: 'Participant', accessor: 'participant'},
{label: 'Participant', accessor: 'name'},
{label: 'Role(s)', accessor: 'roles'},
{label: 'Start Date', accessor: 'startDate'},
{label: 'End Date', accessor: 'endDate'},
{label: 'Notes', accessor: 'notes'},
]}
data={[
{participant: 'SHELL CANADA', roles: ['ORGANIZATION'], startDate: 'today', endDate: 'yesterday', notes: '', siteRegistry: false}
]}
data={site.participants}

/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { SiteRegistryIconButton } from '@/components/SiteRegistryIcon';

interface SiteDetailsTableProps {
onClickAdd?
label: string;
headers: { label: string, accessor: string}[]
// rows: any[];
data: {
Expand All @@ -21,7 +22,7 @@ interface SiteDetailsTableProps {
// Site Registry togglez
// editMode

export default function SiteDetailsTable({ onClickAdd, headers, data }: SiteDetailsTableProps) {
export default function SiteDetailsTable({ onClickAdd, headers, data, label }: SiteDetailsTableProps) {
// const isMinistry = useSelector((state: RootState) => state.user.isMinistry);
const editMode = useSelector((state: RootState) => state.edit.editMode);

Expand All @@ -39,11 +40,11 @@ export default function SiteDetailsTable({ onClickAdd, headers, data }: SiteDeta

{/* TODO - Rip this out and make its own component, but how handle differing columns and fields elegantly? children props / slots most likely. */}
{/* SiteDetailsTable */}
<div className={`${siteDetailsStyles.metadataGridItem} ${siteDetailsStyles.formLabel} mt-4 px-2`}>Notation Participants</div>
<div className={`${siteDetailsStyles.metadataGridItem} ${siteDetailsStyles.formLabel} mt-4 px-2`}>{label}</div>
<Table bordered hover>
<thead>
<tr>
{editMode && <th><Form.Check aria-label="Select all Notation Participants" /></th>}
{editMode && <th><Form.Check aria-label="Select all {label}" /></th>}
{headers?.map((header, index) => <th key={index}>{header.label}</th>)}
{editMode && <th>SR</th>}
</tr>
Expand All @@ -53,7 +54,7 @@ export default function SiteDetailsTable({ onClickAdd, headers, data }: SiteDeta
{data?.map((row, index) => {
return (
<tr key={index}>
{editMode && <td><Form.Check aria-label="Select this notation participant" /></td>}
{editMode && <td><Form.Check aria-label="Select this {label}" /></td>}
{headers?.map((header, index) => <td key={index}><TableEditItem value={row[header.accessor]} /></td>)}
{editMode && <td> <SiteRegistryIconButton siteRegistry={row.siteRegistry} /></td>}
</tr>
Expand Down

0 comments on commit 78a0ba6

Please sign in to comment.