Skip to content

Commit

Permalink
10074-bug: add live validation to status report order form
Browse files Browse the repository at this point in the history
  • Loading branch information
Mwindo committed Sep 20, 2024
1 parent c5b0ef8 commit 6f7b9db
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export const petitionsClerkUpdatesCaseDetail = cerebralTest => {
});
expect(cerebralTest.getState('alertError')).toEqual({
messages: ['Select a case type', 'Select a case procedure'],
preventAutoScroll: false,
scrollToErrorNotification: false,
title: 'Please correct the following errors on the page:',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const setValidationAlertErrorsAction = ({
}
}),
),
preventAutoScroll: !props.scrollToErrorNotification,
scrollToErrorNotification: props.scrollToErrorNotification || false,
title: 'Please correct the following errors on the page:',
};
store.set(state.alertError, alertError);
Expand Down
2 changes: 2 additions & 0 deletions web-client/src/presenter/presenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ import { validateRemoveFromTrialSessionSequence } from './sequences/validateRemo
import { validateSelectDocumentTypeSequence } from './sequences/validateSelectDocumentTypeSequence';
import { validateSetForHearingSequence } from './sequences/validateSetForHearingSequence';
import { validateStampSequence } from './sequences/validateStampSequence';
import { validateStatusReportOrderSequence } from '@web-client/presenter/sequences/StatusReportOrder/validateStatusReportOrderSequence';
import { validateTrialSessionHearingNoteSequence } from './sequences/validateTrialSessionHearingNoteSequence';
import { validateTrialSessionNoteSequence } from './sequences/validateTrialSessionNoteSequence';
import { validateTrialSessionPlanningSequence } from './sequences/validateTrialSessionPlanningSequence';
Expand Down Expand Up @@ -1594,6 +1595,7 @@ export const presenterSequences = {
validateSetForHearingSequence:
validateSetForHearingSequence as unknown as Function,
validateStampSequence: validateStampSequence as unknown as Function,
validateStatusReportOrderSequence,
validateTrialSessionHearingNoteSequence:
validateTrialSessionHearingNoteSequence as unknown as Function,
validateTrialSessionNoteSequence:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { clearAlertsAction } from '@web-client/presenter/actions/clearAlertsAction';
import { setValidationAlertErrorsAction } from '@web-client/presenter/actions/setValidationAlertErrorsAction';
import { setValidationErrorsAction } from '../../actions/setValidationErrorsAction';
import { showProgressSequenceDecorator } from '../../utilities/showProgressSequenceDecorator';
import { validateStatusReportOrderFormAction } from '../../actions/StatusReportOrder/validateStatusReportOrderFormAction';

export const validateStatusReportOrderSequence = [
showProgressSequenceDecorator([
clearAlertsAction,
validateStatusReportOrderFormAction,
{
error: [setValidationErrorsAction, setValidationAlertErrorsAction],
success: [clearAlertsAction],
},
]),
] as unknown as () => void;
4 changes: 2 additions & 2 deletions web-client/src/views/ErrorNotification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const ErrorNotification = connect(
alertError?: {
title?: string;
message?: string;
preventAutoScroll?: boolean;
scrollToErrorNotification?: boolean;
};
alertHelper: {
showErrorAlert?: boolean;
Expand All @@ -29,7 +29,7 @@ export const ErrorNotification = connect(

useEffect(() => {
const notification = notificationRef.current;
if (notification && !alertError?.preventAutoScroll) {
if (notification && alertError?.scrollToErrorNotification) {
window.scrollTo(0, 0);
}
});
Expand Down
6 changes: 6 additions & 0 deletions web-client/src/views/StatusReportOrder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export const StatusReportOrder = connect(
sequences.statusReportOrderPdfPreviewSequence,
submitStatusReportOrderSequence: sequences.submitStatusReportOrderSequence,
updateFormValueSequence: sequences.updateStatusReportOrderFormValueSequence,
validateStatusReportOrderSequence:
sequences.validateStatusReportOrderSequence,
validationErrors: state.validationErrors,
},
function StatusReportOrder({
Expand All @@ -36,6 +38,7 @@ export const StatusReportOrder = connect(
statusReportOrderPdfPreviewSequence,
submitStatusReportOrderSequence,
updateFormValueSequence,
validateStatusReportOrderSequence,
validationErrors,
}) {
return (
Expand Down Expand Up @@ -226,6 +229,7 @@ export const StatusReportOrder = connect(
toFormat: constants.DATE_FORMATS.YYYYMMDD,
value: e.target.value,
});
validateStatusReportOrderSequence();
}}
/>
</FormGroup>
Expand Down Expand Up @@ -294,6 +298,7 @@ export const StatusReportOrder = connect(
key: e.target.name,
value: e.target.value,
});
validateStatusReportOrderSequence();
}}
/>
<label
Expand Down Expand Up @@ -326,6 +331,7 @@ export const StatusReportOrder = connect(
key: e.target.name,
value: e.target.value,
});
validateStatusReportOrderSequence();
}}
/>
<label
Expand Down

0 comments on commit 6f7b9db

Please sign in to comment.