diff --git a/services/ui-src/src/components/app/App.tsx b/services/ui-src/src/components/app/App.tsx index a44655381..4e614a8a3 100644 --- a/services/ui-src/src/components/app/App.tsx +++ b/services/ui-src/src/components/app/App.tsx @@ -18,6 +18,7 @@ import { // utils import { fireTealiumPageView, + isApparentReportPage, makeMediaQueryClasses, UserContext, useStore, @@ -33,7 +34,12 @@ export const App = () => { // fire tealium page view on route change useEffect(() => { - fireTealiumPageView(user, window.location.href, pathname); + fireTealiumPageView( + user, + window.location.href, + pathname, + isApparentReportPage(pathname) + ); }, [key]); const authenticatedRoutes = ( diff --git a/services/ui-src/src/components/reports/ReportPageFooter.test.tsx b/services/ui-src/src/components/reports/ReportPageFooter.test.tsx index a48c69cb0..23ec121c0 100644 --- a/services/ui-src/src/components/reports/ReportPageFooter.test.tsx +++ b/services/ui-src/src/components/reports/ReportPageFooter.test.tsx @@ -3,10 +3,28 @@ import { axe } from "jest-axe"; // components import { ReportPageFooter } from "components"; //utils -import { mockForm } from "utils/testing/setupJest"; +import { mockForm, RouterWrappedComponent } from "utils/testing/setupJest"; -const reportPageComponentWithoutForm = ; -const reportPageComponentWithForm = ; +const mockRoutes = { + previousRoute: "/mock-previous-route", + nextRoute: "/mock-next-route", +}; + +jest.mock("utils", () => ({ + ...jest.requireActual("utils"), + useFindRoute: () => mockRoutes, +})); + +const reportPageComponentWithoutForm = ( + + + +); +const reportPageComponentWithForm = ( + + + +); describe("Test ReportPageFooter without form", () => { test("Check that ReportPageFooter without form renders", () => { diff --git a/services/ui-src/src/components/reports/ReportPageFooter.tsx b/services/ui-src/src/components/reports/ReportPageFooter.tsx index 2fe391d36..86c02757a 100644 --- a/services/ui-src/src/components/reports/ReportPageFooter.tsx +++ b/services/ui-src/src/components/reports/ReportPageFooter.tsx @@ -1,14 +1,22 @@ +import { useNavigate } from "react-router-dom"; // components import { Box, Button, Flex, Image, Spinner } from "@chakra-ui/react"; // utils +import { useFindRoute, useStore } from "utils"; import { FormJson } from "types"; // assets import nextIcon from "assets/icons/icon_next_white.png"; import previousIcon from "assets/icons/icon_previous_blue.png"; export const ReportPageFooter = ({ submitting, form, ...props }: Props) => { - const hidePrevious = false; + const navigate = useNavigate(); const formIsDisabled = false; + const report = useStore().report; + const { previousRoute, nextRoute } = useFindRoute( + report?.formTemplate.flatRoutes, + report?.formTemplate.basePath + ); + const hidePrevious = previousRoute === "/wp" || previousRoute === "/sar"; return ( @@ -16,7 +24,7 @@ export const ReportPageFooter = ({ submitting, form, ...props }: Props) => { {!hidePrevious && (