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

Handler schema #454

Merged
merged 4 commits into from
Apr 27, 2023
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
12 changes: 12 additions & 0 deletions .idea/runConfigurations/Vitest_Run.xml

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

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

2 changes: 1 addition & 1 deletion client/src/components/Manifest/Handler/AddHandler.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HtModal } from 'components/Ht';
import { HandlerSearchForm } from 'components/Manifest/Handler/index';
import { HandlerType } from 'components/Manifest/manifestSchema';
import { HandlerType } from 'components/Manifest';
import React from 'react';
import { Col, Row } from 'react-bootstrap';

Expand Down
15 changes: 4 additions & 11 deletions client/src/components/Manifest/Handler/HandlerForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ErrorMessage } from '@hookform/error-message';
import { HtForm } from 'components/Ht';
import { AddressForm } from 'components/Manifest/Address';
import { HandlerTypeEnum } from 'components/Manifest/manifestSchema';
Expand Down Expand Up @@ -55,7 +54,9 @@ export function HandlerForm({ handlerType, readOnly }: HandlerFormProps): ReactE
readOnly={readOnly}
placeholder={'EPA ID number'}
{...register(`generator.epaSiteId`)}
className={errors.generator?.epaSiteId && 'is-invalid'}
/>
<div className="invalid-feedback">{errors.generator?.epaSiteId?.message}</div>
</HtForm.Group>
</Col>
<Col className="col-sm-8">
Expand All @@ -68,19 +69,11 @@ export function HandlerForm({ handlerType, readOnly }: HandlerFormProps): ReactE
type="text"
placeholder={`${handlerType} Name`}
{...register(`generator.name`)}
className={errors.generator?.name && 'is-invalid'}
/>
<div className="invalid-feedback">{errors.generator?.name?.message}</div>
</HtForm.Group>
</Col>
<ErrorMessage
errors={errors}
name={`epaSiteId`}
render={({ message }) => <span className="text-danger">{message}</span>}
/>
<ErrorMessage
errors={errors}
name={`name`}
render={({ message }) => <span className="text-danger">{message}</span>}
/>
</Row>
<AddressForm addressType={'siteAddress'} handlerType={handlerType} readOnly={readOnly} />
<Row className="mb-2">
Expand Down
65 changes: 0 additions & 65 deletions client/src/components/Manifest/Handler/handlerSchema.ts

This file was deleted.

2 changes: 1 addition & 1 deletion client/src/components/Manifest/Handler/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Handler, handlerSchema, Signer } from 'components/Manifest/manifestSchema';
import { HandlerForm } from './HandlerForm';
import { HandlerSearchForm } from './HandlerSearchForm';
import { TransporterSearchForm } from './TransporterSearchForm';
import { AddHandler } from './AddHandler';
import { Handler, handlerSchema, Signer } from './handlerSchema';

export { HandlerForm, TransporterSearchForm, HandlerSearchForm, AddHandler, handlerSchema };
export type { Handler, Signer };
10 changes: 0 additions & 10 deletions client/src/components/Manifest/ManifestForm.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@ describe('ManifestForm', () => {
test('only has "edit manifest" button when readonly', async () => {
// ToDo: to test when readOnly={true}, we need manifestData as prop
});
test('potential ship date cannot be in past', async () => {
renderWithProviders(<ManifestForm readOnly={false} />);
const potentialShipDateInput = screen.getByLabelText(/potential ship date/i);
fireEvent.change(potentialShipDateInput, { target: { value: '2021-04-21' } });
const saveBtn = screen.getByRole('button', { name: /save/i });
fireEvent.click(saveBtn);
await waitFor(() => {
expect(potentialShipDateInput).toHaveClass('is-invalid');
});
});
test('displays e-Manifest managed dates', async () => {
const manifestDate = new Date();
const expectedDateValue = manifestDate.toISOString().slice(0, 10);
Expand Down
6 changes: 3 additions & 3 deletions client/src/components/Manifest/ManifestForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function ManifestForm({
};

// Generator controls
const generator: Handler = manifestMethods.getValues('generator');
const generator: Handler | undefined = manifestMethods.getValues('generator');

// Transporter controls
const [transFormShow, setTransFormShow] = useState<boolean>(false);
Expand Down Expand Up @@ -97,7 +97,7 @@ export function ManifestForm({
// Tsdf controls
const [tsdfFormShow, setTsdfFormShow] = useState<boolean>(false);
const toggleTsdfFormShow = () => setTsdfFormShow(!tsdfFormShow);
const tsdf: Handler = manifestMethods.getValues('designatedFacility');
const tsdf: Handler | undefined = manifestMethods.getValues('designatedFacility');

const signAble =
manifestStatus === 'Scheduled' ||
Expand Down Expand Up @@ -320,7 +320,7 @@ export function ManifestForm({
siteType={'Generator'}
mtnHandler={generator}
handleClick={setupSign}
disabled={generator.signed || !signAble}
disabled={generator?.signed || !signAble}
/>
</Col>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { faFileSignature } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { HtForm } from 'components/Ht';
import { Handler } from 'components/Manifest/manifestSchema';
import React from 'react';
import { Button, Col, Container, Form, ListGroup, Row } from 'react-bootstrap';
import { SubmitHandler, useForm } from 'react-hook-form';
Expand All @@ -10,7 +11,6 @@ import { addNotification, RootState, useAppDispatch, useAppSelector } from 'stor
import { htApi } from 'services';
import { AxiosError, AxiosResponse } from 'axios';
import { QuickerSignature } from 'components/Manifest/QuickerSign/quickerSignSchema';
import { Handler } from 'components/Manifest/Handler';
import { Transporter } from 'components/Manifest/Transporter';

interface QuickerSignProps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HtModal } from 'components/Ht';
import { Handler } from 'components/Manifest/manifestSchema';
import React from 'react';
import { QuickerSignForm } from './QuickerSignForm';
import { Handler } from 'components/Manifest/Handler';

interface QuickerSignModalProps {
handleClose: () => void;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { faFeather } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Handler } from 'components/Manifest/manifestSchema';
import React from 'react';
import { ButtonProps } from 'react-bootstrap';
import { RcraApiUserBtn } from 'components/buttons';
import { Handler } from 'components/Manifest/Handler';

interface QuickerSignData {
handler: Handler | undefined;
Expand All @@ -12,7 +12,7 @@ interface QuickerSignData {

interface QuickerSignModalBtnProps extends ButtonProps {
siteType: 'Generator' | 'Transporter' | 'Tsdf';
mtnHandler: Handler;
mtnHandler?: Handler;
handleClick: (data: QuickerSignData) => void;
iconOnly?: boolean;
}
Expand All @@ -29,6 +29,9 @@ export function QuickerSignModalBtn({
disabled,
iconOnly = false,
}: QuickerSignModalBtnProps) {
if (mtnHandler === undefined) {
return null;
}
return (
<RcraApiUserBtn
onClick={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import { renderWithProviders } from 'test-utils';
import { TransporterTable } from './index';
import { createMockTransporter } from 'test-utils/fixtures';
import { Transporter } from 'components/Manifest/Transporter/transporterSchema';
import { Transporter } from 'components/Manifest';

const HANDLER_ID_1 = 'siteId1';
const HANDLER_ID_2 = 'siteId2';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { TransporterRowActions } from './TransporterRowActions';
import { UseFieldArrayReturn } from 'react-hook-form';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { QuickerSignModalBtn } from 'components/Manifest/QuickerSign';
import { Transporter } from 'components/Manifest/Transporter/transporterSchema';
import { Transporter } from 'components/Manifest';

interface TransporterTableProps {
transporters?: Array<Transporter>;
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Manifest/Transporter/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AddTransporter } from './AddTransporter';
import { TransporterTable } from './TransporterTable';
import { Transporter } from './transporterSchema';
import { Transporter } from 'components/Manifest';

export { AddTransporter, TransporterTable };
export type { Transporter };
13 changes: 0 additions & 13 deletions client/src/components/Manifest/Transporter/transporterSchema.ts

This file was deleted.

12 changes: 10 additions & 2 deletions client/src/components/Manifest/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { ManifestForm } from './ManifestForm';
import { Manifest } from './manifestSchema';
import {
Handler,
HandlerType,
Signer,
RejectionInfo,
transporterSchema,
Transporter,
} from './manifestSchema';

export { ManifestForm };
export type { Manifest };
export { ManifestForm, HandlerType, transporterSchema };
export type { Manifest, Handler, Signer, RejectionInfo, Transporter };
Loading