Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rearchitect client project structure #451

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .idea/runConfigurations/Compose_Dev.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import ErrorBoundary from 'components/ErrorBoundary';
import { ErrorBoundary } from 'components/ErrorBoundary';
import { HtCard } from 'components/Ht';
import { Sidebar, TopNav } from 'components/Nav';
import PrivateRoute from 'components/PrivateRoute';
import About from 'features/help';
import Home from 'features/home';
import Login from 'features/login';
import Manifest from 'features/manifest';
import Notifications from 'features/notifications';
import Profile from 'features/profile';
import Sites from 'features/site';
import { PrivateRoute } from 'components/PrivateRoute';
import { About } from 'features/help';
import { Home } from 'features/home';
import { Login } from 'features/login';
import { Manifest } from 'features/manifest';
import { Notifications } from 'features/notifications';
import { Profile } from 'features/profile';
import { Sites } from 'features/haztrakSite';
import React, { ReactElement } from 'react';
import { Button, Container } from 'react-bootstrap';
import { Route, Routes, useNavigate } from 'react-router-dom';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from 'react';
import { Button, Col, Form, Row } from 'react-bootstrap';
import { useFieldArray, useFormContext } from 'react-hook-form';
import { Manifest } from 'types/manifest';
import { WasteLine } from 'types/wasteLine';
import { WasteLine } from 'components/Manifest/WasteLine';

interface AdditionalFormProps {
readOnly?: boolean;
Expand All @@ -14,7 +14,7 @@ interface AdditionalFormProps {
// ToDo: this is POC source, clean up work appreciated
// see this example from react-hook-form
// https://codesandbox.io/s/6j1760jkjk
function AdditionalInfoForm({ readOnly }: AdditionalFormProps) {
export function AdditionalInfoForm({ readOnly }: AdditionalFormProps) {
const { register, control } = useFormContext<Manifest | WasteLine>();
const { fields, append, remove } = useFieldArray<Manifest | WasteLine, 'additionalInfo.comments'>(
{
Expand Down Expand Up @@ -129,5 +129,3 @@ function AdditionalInfoForm({ readOnly }: AdditionalFormProps) {
</>
);
}

export default AdditionalInfoForm;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import '@testing-library/jest-dom';
import { fireEvent } from '@testing-library/react';
import React from 'react';
import { cleanup, renderWithProviders, screen } from 'test-utils';
import AdditionalInfoForm from './AdditionalInfoForm';
import { AdditionalInfoForm } from 'components/AdditionalInfo/AdditionalInfoForm';

afterEach(() => {
cleanup();
Expand Down
5 changes: 5 additions & 0 deletions client/src/components/AdditionalInfo/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { AdditionalInfoForm } from './AdditionalInfoForm';
import { AdditionalInfo, AdditionalInfoComment } from './additionalInfoSchema';

export { AdditionalInfoForm };
export type { AdditionalInfo, AdditionalInfoComment };
4 changes: 1 addition & 3 deletions client/src/components/ErrorBoundary/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface State {
error?: Error;
}

class ErrorBoundary extends Component<Props, State> {
export class ErrorBoundary extends Component<Props, State> {
public state: State = {
hasError: false,
error: undefined,
Expand Down Expand Up @@ -56,5 +56,3 @@ class ErrorBoundary extends Component<Props, State> {
return this.props.children;
}
}

export default ErrorBoundary;
4 changes: 2 additions & 2 deletions client/src/components/ErrorBoundary/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import ErrorBoundary from './ErrorBoundary';
import { ErrorBoundary } from './ErrorBoundary';

export default ErrorBoundary;
export { ErrorBoundary };
3 changes: 0 additions & 3 deletions client/src/components/HandlerDetails/index.ts

This file was deleted.

50 changes: 50 additions & 0 deletions client/src/components/HaztrakSite/SiteTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Table } from 'react-bootstrap';
import { HtTooltip } from 'components/Ht';
import { Link } from 'react-router-dom';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faEye, faFileLines } from '@fortawesome/free-solid-svg-icons';
import React from 'react';
import { HaztrakSite } from 'components/HaztrakSite/haztrakSiteSchema';

interface HtSiteTableProps {
sitesData: Array<HaztrakSite>;
}

export function HtSiteTable({ sitesData }: HtSiteTableProps) {
return (
<Table striped hover>
<thead>
<tr>
<th>Site Alias</th>
<th>EPA ID number</th>
<th className="d-grid justify-content-center">Actions</th>
</tr>
</thead>
<tbody>
{sitesData.map((site, i) => {
return (
<tr key={i}>
<td>{site.name}</td>
<td>{site.handler.epaSiteId}</td>
<td className="d-flex justify-content-evenly">
<HtTooltip text={`${site.name} Details`}>
<Link to={`/site/${site.handler.epaSiteId}`} aria-label={`${site.name}Details`}>
<FontAwesomeIcon icon={faEye} />
</Link>
</HtTooltip>
<HtTooltip text={`${site.name}'s manifest`}>
<Link
to={`/site/${site.handler.epaSiteId}/manifest`}
aria-label={`${site.name}Manifests`}
>
<FontAwesomeIcon icon={faFileLines} />
</Link>
</HtTooltip>
</td>
</tr>
);
})}
</tbody>
</Table>
);
}
15 changes: 15 additions & 0 deletions client/src/components/HaztrakSite/haztrakSiteSchema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { z } from 'zod';
import { rcraSite } from 'components/RcraSite';

const haztrakSiteSchema = z.object({
name: z.string(),
handler: rcraSite,
});

/**
* The Haztrak Site type encapsulates the RCRA site model as well as other details specific to
* that site. It is not directly associated with the EPA RCRAInfo system
* directly and can be extended as needed. For example, Haztrak users are given permission to
* haztrak sites, not RCRA sites.
*/
export type HaztrakSite = z.infer<typeof haztrakSiteSchema>;
5 changes: 5 additions & 0 deletions client/src/components/HaztrakSite/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { HtSiteTable } from './SiteTable';
import { HaztrakSite } from './haztrakSiteSchema';

export { HtSiteTable };
export type { HaztrakSite };
4 changes: 1 addition & 3 deletions client/src/components/Ht/HtButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface HtButtonProps extends ButtonProps {
* to easily control alignment
* @constructor
*/
function HtButton(props: HtButtonProps) {
export function HtButton(props: HtButtonProps) {
const align = props.align || 'center';
return (
<Col className={`text-${align}`}>
Expand All @@ -22,5 +22,3 @@ function HtButton(props: HtButtonProps) {
</Col>
);
}

export default HtButton;
2 changes: 1 addition & 1 deletion client/src/components/Ht/HtCard/HtCard.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import '@testing-library/jest-dom';
import React from 'react';
import { cleanup, render, screen } from 'test-utils';
import HtCard from 'components/Ht/HtCard/HtCard';
import { HtCard } from 'components/Ht';

afterEach(() => {
cleanup();
Expand Down
8 changes: 3 additions & 5 deletions client/src/components/Ht/HtCard/HtCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ErrorBoundary from 'components/ErrorBoundary';
import HtSpinner from 'components/Ht/HtSpinner';
import { ErrorBoundary } from 'components/ErrorBoundary';
import { HtSpinner } from 'components/Ht';
import React, { ReactElement } from 'react';
import { Card, CardProps } from 'react-bootstrap';

Expand All @@ -23,7 +23,7 @@ interface SpinnerProps extends CardProps {
* <HtCard.Footer>submit button here<HtCard.Footer>
* </HtCard>
*/
function HtCard(props: CardProps): ReactElement {
export function HtCard(props: CardProps): ReactElement {
const baseAttributes = `my-3 shadow-lg bg-light rounded ${props.className}`;
const classAttributes =
props.border || props.className?.includes('border')
Expand Down Expand Up @@ -110,5 +110,3 @@ HtCard.Body = function (props: CardProps): ReactElement {
HtCard.Spinner = function ({ message, className }: SpinnerProps): ReactElement {
return <HtSpinner message={message} className={className} />;
};

export default HtCard;
4 changes: 2 additions & 2 deletions client/src/components/Ht/HtCard/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import HtCard from 'components/Ht/HtCard/HtCard';
import { HtCard } from 'components/Ht/HtCard/HtCard';

export default HtCard;
export { HtCard };
4 changes: 1 addition & 3 deletions client/src/components/Ht/HtDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface Props {
* ]}
* />
*/
function HtDropdown({ keyName, links }: Props): ReactElement {
export function HtDropdown({ keyName, links }: Props): ReactElement {
return (
<Dropdown>
<Dropdown.Toggle className="bg-transparent ht-ellipsis shadow-none">
Expand All @@ -44,5 +44,3 @@ function HtDropdown({ keyName, links }: Props): ReactElement {
</Dropdown>
);
}

export default HtDropdown;
4 changes: 1 addition & 3 deletions client/src/components/Ht/HtForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
InputGroupProps,
} from 'react-bootstrap';

function HtForm(props: FormProps): ReactElement {
export function HtForm(props: FormProps): ReactElement {
return <Form {...props}>{props.children}</Form>;
}

Expand Down Expand Up @@ -67,5 +67,3 @@ HtForm.Switch = React.forwardRef<HTMLInputElement, FormCheckProps>(
);
}
);

export default HtForm;
2 changes: 1 addition & 1 deletion client/src/components/Ht/HtModal/HtModal.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import '@testing-library/jest-dom';
import React from 'react';
import { cleanup, render, screen } from 'test-utils';
import HtModal from 'components/Ht/HtModal/HtModal';
import { HtModal } from 'components/Ht';

afterEach(() => {
cleanup();
Expand Down
4 changes: 1 addition & 3 deletions client/src/components/Ht/HtModal/HtModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface HtModalHeaderProps extends ModalHeaderProps {
* <HtModal.Title title='sample title' />
* </HtModal>
*/
function HtModal({
export function HtModal({
showModal,
handleClose,
className,
Expand Down Expand Up @@ -99,5 +99,3 @@ HtModal.Body = function (props: ModalProps): ReactElement {
HtModal.Footer = function (props: ModalProps): ReactElement {
return <ModalFooter {...props}>{props.children}</ModalFooter>;
};

export default HtModal;
4 changes: 2 additions & 2 deletions client/src/components/Ht/HtModal/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import HtModal from 'components/Ht/HtModal/HtModal';
import { HtModal } from 'components/Ht/HtModal/HtModal';

export default HtModal;
export { HtModal };
11 changes: 0 additions & 11 deletions client/src/components/Ht/HtP.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion client/src/components/Ht/HtPaginate/HtPaginate.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import '@testing-library/jest-dom';
import { HtPaginate } from 'components/Ht/index';
import { HtPaginate } from 'components/Ht';
import React from 'react';
import { cleanup, render, screen } from 'test-utils';

Expand Down
6 changes: 2 additions & 4 deletions client/src/components/Ht/HtPaginate/HtPaginate.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import usePagination from 'hooks/usePagination';
import { usePagination } from 'hooks/usePagination';
import { Pagination } from 'react-bootstrap';

/**
Expand Down Expand Up @@ -32,7 +32,7 @@ interface HtPaginateProps extends usePaginationProps {
* defaults to 9)
* @constructor
*/
function HtPaginate({
export function HtPaginate({
totalCount,
currentPage,
onPageChange,
Expand Down Expand Up @@ -97,5 +97,3 @@ function HtPaginate({
</div>
);
}

export default HtPaginate;
4 changes: 2 additions & 2 deletions client/src/components/Ht/HtPaginate/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import HtPaginate from './HtPaginate';
import { HtPaginate } from './HtPaginate';

export default HtPaginate;
export { HtPaginate };
4 changes: 1 addition & 3 deletions client/src/components/Ht/HtSpinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface SpinnerProps {
className?: string;
}

function HtSpinner({ message, className }: SpinnerProps): ReactElement {
export function HtSpinner({ message, className }: SpinnerProps): ReactElement {
return (
<>
<p
Expand All @@ -19,5 +19,3 @@ function HtSpinner({ message, className }: SpinnerProps): ReactElement {
</>
);
}

export default HtSpinner;
2 changes: 1 addition & 1 deletion client/src/components/Ht/HtTooltip/HtTooltip.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { cleanup, fireEvent, render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import HtTooltip from 'components/Ht/HtTooltip/index';
import { HtTooltip } from 'components/Ht';

afterEach(() => {
cleanup();
Expand Down
7 changes: 2 additions & 5 deletions client/src/components/Ht/HtTooltip/HtTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface HtToolTipProps extends TooltipProps {
// renderTooltip function passed to OverlayTrigger's overlay property
const renderTooltip = (text: string) => <Tooltip>{text}</Tooltip>;

function HtTooltip(props: HtToolTipProps): ReactElement {
export function HtTooltip(props: HtToolTipProps): ReactElement {
// create copy of props intended for the OverlayTrigger
const overlayProps = (({ text, children, ...props }: HtToolTipProps) => props)(props);
return (
Expand All @@ -37,13 +37,10 @@ interface InfoTooltipProps {
* that explains that this Field is set by EPA's RCRAInfo.
* @constructor
*/
function InfoIconTooltip({ message }: InfoTooltipProps) {
export function InfoIconTooltip({ message }: InfoTooltipProps) {
return (
<HtTooltip text={message}>
<FontAwesomeIcon icon={faInfoCircle} size={'1x'} className={'pb-1 text-muted'} />
</HtTooltip>
);
}

export default HtTooltip;
export { InfoIconTooltip };
5 changes: 2 additions & 3 deletions client/src/components/Ht/HtTooltip/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import HtTooltip, { InfoIconTooltip } from 'components/Ht/HtTooltip/HtTooltip';
import { HtTooltip, InfoIconTooltip } from './HtTooltip';

export default HtTooltip;
export { InfoIconTooltip };
export { InfoIconTooltip, HtTooltip };
5 changes: 1 addition & 4 deletions client/src/components/Ht/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# HT

This directory contains a number of UI components that wrap around lower level components to provide default styling or
functionality.

## Overview
This directory contains a number of wrapper UI components to provide default styling or

Most of what you'll find here are Bootstrap styled components with some default
styling and UI functionality. Components should be flexible enough to work in
Expand Down
Loading