Skip to content

Commit

Permalink
customize transporter information accordian button and rename title o…
Browse files Browse the repository at this point in the history
…f transporter row action buttons to better reflect behavior and clean up
  • Loading branch information
dpgraham4401 committed Oct 23, 2023
1 parent 36f86b7 commit 1f7af3b
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 105 deletions.
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "haztrak",
"version": "0.7.0",
"version": "0.6.2",
"private": true,
"scripts": {
"start": "vite",
Expand Down
4 changes: 4 additions & 0 deletions client/src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ $info: #009999;
transform: rotate(-90deg);
}

.rotate-90 {
transform: rotate(90deg);
}

.app-container {
min-height: 350px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function TransporterRowActions({
<>
<Dropdown>
<Dropdown.Toggle
title={`transporter action ${index}`}
title={`transporter ${index + 1} actions`}
className="bg-transparent border-0 text-dark no-caret justify-content-end"
>
<FontAwesomeIcon icon={faEllipsisVertical} className="pe-2 shadow-none" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('TransporterTable', () => {
{}
);
const actionDropdown = await screen.findAllByRole('button', {
name: /transporter action [0-9]/,
name: /transporter [0-9] actions/,
});
expect(actionDropdown).length(2);
});
Expand All @@ -69,7 +69,7 @@ describe('TransporterTable', () => {
{}
);
const actionDropdown = screen.queryAllByRole('button', {
name: /transporter action [0-9]/,
name: /transporter [0-9] actions/,
});
expect(actionDropdown).length(0);
});
Expand All @@ -85,7 +85,7 @@ describe('TransporterTable', () => {
{}
);
const actionDropdowns = await screen.findAllByRole('button', {
name: /transporter action [0-9]/,
name: /transporter [0-9] actions/,
});
for (let i = 1; i < TRAN_ARRAY.length; i++) {
await userEvent.click(actionDropdowns[i]);
Expand All @@ -104,7 +104,7 @@ describe('TransporterTable', () => {
{}
);
const actionDropdowns = await screen.findAllByRole('button', {
name: /transporter action [0-9]/,
name: /transporter [0-9] actions/,
});
for (let i = 0; i < TRAN_ARRAY.length; i++) {
await userEvent.click(actionDropdowns[i]);
Expand Down
127 changes: 127 additions & 0 deletions client/src/components/Manifest/Transporter/TransporterTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import { useAutoAnimate } from '@formkit/auto-animate/react';
import { faAngleRight, faCheck, faSignature } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Transporter } from 'components/Manifest';
import { Manifest } from 'components/Manifest/manifestSchema';
import { QuickerSignData, QuickerSignModalBtn } from 'components/Manifest/QuickerSign';
import React, { useState } from 'react';
import { Accordion, Button, Card, Col, Row, Table, useAccordionButton } from 'react-bootstrap';
import { UseFieldArrayReturn } from 'react-hook-form';
import { TransporterRowActions } from './TransporterRowActions';

interface TransporterTableProps {
transporters?: Array<Transporter>;
arrayFieldMethods: UseFieldArrayReturn<Manifest, 'transporters', 'id'>;
readOnly?: boolean;
setupSign: (data: QuickerSignData) => void;
}

function CustomToggle({ eventKey }: any) {
const [open, setOpen] = useState(false);
const decoratedOnClick = useAccordionButton(eventKey, () => setOpen(!open));

return (
<Button
onClick={decoratedOnClick}
className="bg-transparent border-0 text-dark"
title="more info"
>
<FontAwesomeIcon
icon={faAngleRight}
className={`sb-sidenav-collapse-arrow ${open ? 'rotate-90' : ''} `}
/>
</Button>
);
}

function TransporterTable({
transporters,
arrayFieldMethods,
readOnly,
setupSign,
}: TransporterTableProps) {
const [parent] = useAutoAnimate();

if (!transporters || transporters.length < 1) {
return <></>;
}

if (transporters) {
for (let i = 0; i < transporters?.length; i++) {
transporters[i].order = i + 1;
}
}

return (
<>
<Accordion ref={parent}>
{transporters.map((transporter, index) => {
return (
<Card key={transporter.epaSiteId} className="py-2 px-4 my-2">
<Row className="d-flex justify-content-between">
<Col xs={8} className="d-flex align-items-center">
<div>
<h5 className="d-inline border-3 me-3">{transporter.order} </h5>
<span>{transporter.name}</span>
</div>
</Col>
<Col xs={1}>
{readOnly ? (
<QuickerSignModalBtn
siteType={'Transporter'}
mtnHandler={transporter}
handleClick={setupSign}
iconOnly={true}
disabled={transporter.signed}
/>
) : transporter.signed ? (
<FontAwesomeIcon icon={faSignature} />
) : (
<></>
)}
</Col>
<Col xs={1}>
{readOnly || (
<TransporterRowActions
removeTransporter={arrayFieldMethods.remove}
swapTransporter={arrayFieldMethods.swap}
index={index}
length={transporters?.length}
/>
)}
</Col>
<Col xs={1}>
<CustomToggle eventKey={transporter.epaSiteId}></CustomToggle>
</Col>
</Row>
<Accordion.Collapse eventKey={transporter.epaSiteId}>
<Card.Body>
<Table>
<thead>
<tr>
<th>EPA ID</th>
<th>Phone</th>
<th>Can e-Sign?</th>
</tr>
</thead>
<tbody>
<tr>
<td>{transporter.epaSiteId}</td>
<td>{transporter.contact.phone?.number}</td>
<td className="text-success text-center">
{transporter ? <FontAwesomeIcon icon={faCheck} /> : 'no'}
</td>
</tr>
</tbody>
</Table>
</Card.Body>
</Accordion.Collapse>
</Card>
);
})}
</Accordion>
</>
);
}

export { TransporterTable };

This file was deleted.

This file was deleted.

7 changes: 7 additions & 0 deletions client/src/components/Manifest/UpdateRcra/UpdateRcra.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ interface UpdateRcraProps {
taskId: string;
}

/**
* UpdateRcra is a component that will poll the server for the status of an asynchronous task and
* display that status to the user. If the task is successful, the user will be redirected to the
* manifest view page.
* @param taskId
* @constructor
*/
export function UpdateRcra({ taskId }: UpdateRcraProps) {
const [showToast, setShowToast] = React.useState(true);

Expand Down

0 comments on commit 1f7af3b

Please sign in to comment.