Skip to content

Commit

Permalink
Merge pull request #13664 from transcom/servicesTest
Browse files Browse the repository at this point in the history
Services test
  • Loading branch information
r-mettler authored Sep 10, 2024
2 parents 3657a7f + 512e3a4 commit 980e638
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/components/Office/ShipmentForm/ShipmentForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const ShipmentForm = (props) => {
const { moveCode } = useParams();
const navigate = useNavigate();

const [datesErrorMessage, setDatesErrorMessage] = useState(null);
const [errorMessage, setErrorMessage] = useState(null);
const [successMessage, setSuccessMessage] = useState(null);
const [shipmentAddressUpdateReviewErrorMessage, setShipmentAddressUpdateReviewErrorMessage] = useState(null);
Expand Down Expand Up @@ -202,7 +203,7 @@ const ShipmentForm = (props) => {
useEffect(() => {
const onErrorHandler = (e) => {
const { response } = e;
setErrorMessage(response?.body?.detail);
setDatesErrorMessage(response?.body?.detail);
};
dateSelectionWeekendHolidayCheck(
dateSelectionIsWeekendHoliday,
Expand All @@ -219,7 +220,7 @@ const ShipmentForm = (props) => {
useEffect(() => {
const onErrorHandler = (e) => {
const { response } = e;
setErrorMessage(response?.body?.detail);
setDatesErrorMessage(response?.body?.detail);
};
dateSelectionWeekendHolidayCheck(
dateSelectionIsWeekendHoliday,
Expand Down Expand Up @@ -628,7 +629,7 @@ const ShipmentForm = (props) => {
});
const onErrorHandler = (errResponse) => {
const { response } = errResponse;
setErrorMessage(response?.body?.detail);
setDatesErrorMessage(response?.body?.detail);
};
dateSelectionWeekendHolidayCheck(
dateSelectionIsWeekendHoliday,
Expand Down Expand Up @@ -699,9 +700,15 @@ const ShipmentForm = (props) => {
errorMessage={shipmentAddressUpdateReviewErrorMessage}
setErrorMessage={setShipmentAddressUpdateReviewErrorMessage}
/>
<NotificationScrollToTop dependency={datesErrorMessage} />
{datesErrorMessage && (
<Alert data-testid="datesErrorMessage" type="error" headingLevel="h4" heading="An error occurred">
{datesErrorMessage}
</Alert>
)}
<NotificationScrollToTop dependency={errorMessage} />
{errorMessage && (
<Alert type="error" headingLevel="h4" heading="An error occurred">
<Alert data-testid="errorMessage" type="error" headingLevel="h4" heading="An error occurred">
{errorMessage}
</Alert>
)}
Expand Down

0 comments on commit 980e638

Please sign in to comment.