diff --git a/bun.lockb b/bun.lockb index 8298edf302..9721f31b6c 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/react-app/package.json b/react-app/package.json index b830968153..df1aa13248 100644 --- a/react-app/package.json +++ b/react-app/package.json @@ -63,7 +63,7 @@ "react-dropzone": "^14.2.3", "react-hook-form": "^7.46.2", "react-loader-spinner": "^6.1.6", - "react-router-dom": "^6.10.0", + "react-router": "^7.0.2", "react-select": "^5.7.4", "shared-types": "*", "shared-utils": "*", diff --git a/react-app/src/components/ActionForm/actionForm.components.tsx b/react-app/src/components/ActionForm/actionForm.components.tsx index 479337c83a..4f4d872d2d 100644 --- a/react-app/src/components/ActionForm/actionForm.components.tsx +++ b/react-app/src/components/ActionForm/actionForm.components.tsx @@ -1,5 +1,5 @@ import { FAQ_TAB } from "@/router"; -import { Link } from "react-router-dom"; +import { Link } from "react-router"; import { z } from "zod"; export const AttachmentFileFormatInstructions = () => ( diff --git a/react-app/src/components/ActionForm/index.tsx b/react-app/src/components/ActionForm/index.tsx index bb52221235..fbb6020834 100644 --- a/react-app/src/components/ActionForm/index.tsx +++ b/react-app/src/components/ActionForm/index.tsx @@ -21,7 +21,7 @@ import { import { DefaultValues, FieldPath, useForm, UseFormReturn } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; -import { Navigate, useLocation, useNavigate, useParams } from "react-router-dom"; +import { Navigate, useLocation, useNavigate, useParams } from "react-router"; import { getFormOrigin } from "@/utils"; import { CheckDocumentFunction, documentPoller } from "@/utils/Poller/documentPoller"; import { API } from "aws-amplify"; @@ -168,12 +168,16 @@ export const ActionForm = ({ } const formOrigins = getFormOrigin({ authority, id }); - banner({ - ...bannerPostSubmission, - pathnameToDisplayOn: formOrigins.pathname, - }); navigate(formOrigins); + + // artificially delaying allows the banner to be displayed after navigation + setTimeout(() => { + banner({ + ...bannerPostSubmission, + pathnameToDisplayOn: formOrigins.pathname, + }); + }, 50); } catch (error) { console.error(error); banner({ @@ -229,7 +233,7 @@ export const ActionForm = ({ )} {additionalInformation && ( {additionalInformation.title}{" "} diff --git a/react-app/src/components/Banner/banner.test.tsx b/react-app/src/components/Banner/banner.test.tsx index 95a95458bb..3ca32ec78b 100644 --- a/react-app/src/components/Banner/banner.test.tsx +++ b/react-app/src/components/Banner/banner.test.tsx @@ -1,5 +1,5 @@ import { ReactNode } from "react"; -import { Link, MemoryRouter, Route, Routes } from "react-router-dom"; +import { Link, MemoryRouter, Route, Routes } from "react-router"; import { describe, expect, test } from "vitest"; import { act, render } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; @@ -8,14 +8,8 @@ import { banner, Banner } from "."; const wrapper = ({ children }: { children: ReactNode }) => ( - } - /> - } - /> + } /> + } /> {children} diff --git a/react-app/src/components/Banner/banner.tsx b/react-app/src/components/Banner/banner.tsx index 48adf4c858..68103c4f59 100644 --- a/react-app/src/components/Banner/banner.tsx +++ b/react-app/src/components/Banner/banner.tsx @@ -1,7 +1,7 @@ import { useEffect, useState } from "react"; import { Alert, AlertVariant } from "../Alert"; import { Check, X } from "lucide-react"; -import { useLocation } from "react-router-dom"; +import { useLocation } from "react-router"; import { Observer } from "@/utils/basic-observable"; export type Banner = { @@ -57,10 +57,7 @@ export const Banner = () => { if (activeBanner && activeBanner.pathnameToDisplayOn === pathname) { return ( - +
diff --git a/react-app/src/components/BreadCrumb/BreadCrumb.test.tsx b/react-app/src/components/BreadCrumb/BreadCrumb.test.tsx index 691aa7c2de..76c381a0c9 100644 --- a/react-app/src/components/BreadCrumb/BreadCrumb.test.tsx +++ b/react-app/src/components/BreadCrumb/BreadCrumb.test.tsx @@ -2,7 +2,7 @@ import { describe, test, expect, beforeEach } from "vitest"; import { render, screen } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { BreadCrumb, BreadCrumbBar, BreadCrumbs } from "./BreadCrumb"; -import { BrowserRouter, Route, Routes, useLocation } from "react-router-dom"; +import { BrowserRouter, Route, Routes, useLocation } from "react-router"; import { optionCrumbsFromPath } from "./create-breadcrumbs"; import { Authority } from "shared-types"; diff --git a/react-app/src/components/BreadCrumb/BreadCrumb.tsx b/react-app/src/components/BreadCrumb/BreadCrumb.tsx index 8acee4c708..cfca4089c8 100644 --- a/react-app/src/components/BreadCrumb/BreadCrumb.tsx +++ b/react-app/src/components/BreadCrumb/BreadCrumb.tsx @@ -1,4 +1,4 @@ -import { Link } from "react-router-dom"; +import { Link } from "react-router"; import { type ReactNode } from "react"; import { ChevronRight } from "lucide-react"; @@ -29,11 +29,7 @@ export const BreadCrumbs = ({ options }: BreadCrumbsProps) => { .toSorted((option, prevOption) => option.order - prevOption.order) .map(({ displayText, to }, index, optionsArray) => { return ( - + {displayText} ); @@ -78,11 +74,7 @@ export const BreadCrumbSeperator = () => ; export const BreadCrumbBar = ({ children }: React.PropsWithChildren) => { return ( -
diff --git a/react-app/src/components/Form/content/FormLoadingSpinner.tsx b/react-app/src/components/Form/content/FormLoadingSpinner.tsx index 06979225fd..d5f3337cfe 100644 --- a/react-app/src/components/Form/content/FormLoadingSpinner.tsx +++ b/react-app/src/components/Form/content/FormLoadingSpinner.tsx @@ -1,11 +1,9 @@ -import { useNavigation } from "react-router-dom"; +import { useNavigation } from "react-router"; import { useFormContext } from "react-hook-form"; import { LoadingSpinner } from "@/components"; export const FormLoadingSpinner = () => { const { state } = useNavigation(); const { formState } = useFormContext(); - return ( - (state === "submitting" || formState.isSubmitting) && - ); + return (state === "submitting" || formState.isSubmitting) && ; }; diff --git a/react-app/src/components/Form/content/PackageSection.tsx b/react-app/src/components/Form/content/PackageSection.tsx index 728adaf410..ee1640d3f9 100644 --- a/react-app/src/components/Form/content/PackageSection.tsx +++ b/react-app/src/components/Form/content/PackageSection.tsx @@ -1,5 +1,5 @@ import { BLANK_VALUE } from "@/consts"; -import { useParams } from "react-router-dom"; +import { useParams } from "react-router"; import { AuthorityUnion } from "shared-types"; export const getIdLabel = (authority: AuthorityUnion) => { diff --git a/react-app/src/components/Form/old-content.tsx b/react-app/src/components/Form/old-content.tsx index 58c8ac78ed..60eb53e3be 100644 --- a/react-app/src/components/Form/old-content.tsx +++ b/react-app/src/components/Form/old-content.tsx @@ -6,7 +6,7 @@ import { } from "@/components"; import { FAQ_TAB } from "@/router"; import { Info } from "lucide-react"; -import { Link } from "react-router-dom"; +import { Link } from "react-router"; type FormIntroTextProps = { hasProgressLossReminder?: boolean; diff --git a/react-app/src/components/Layout/index.test.tsx b/react-app/src/components/Layout/index.test.tsx index 5d04ab71e7..96d2e41372 100644 --- a/react-app/src/components/Layout/index.test.tsx +++ b/react-app/src/components/Layout/index.test.tsx @@ -25,8 +25,8 @@ vi.mock("@/components", () => ({ // Navigation mock const mockNavigate = vi.fn(); -vi.mock("react-router-dom", async () => { - const actual = await vi.importActual("react-router-dom"); +vi.mock("react-router", async () => { + const actual = await vi.importActual("react-router"); return { ...actual, useNavigate: () => mockNavigate, diff --git a/react-app/src/components/Layout/index.tsx b/react-app/src/components/Layout/index.tsx index 713839c6fd..d661c2c88a 100644 --- a/react-app/src/components/Layout/index.tsx +++ b/react-app/src/components/Layout/index.tsx @@ -1,4 +1,4 @@ -import { NavLink, NavLinkProps, Outlet, Link, useNavigate } from "react-router-dom"; +import { NavLink, NavLinkProps, Outlet, Link, useNavigate } from "react-router"; import oneMacLogo from "@/assets/onemac-logo.png"; import { useMediaQuery } from "@/hooks"; import { Bars3Icon, XMarkIcon } from "@heroicons/react/24/outline"; diff --git a/react-app/src/components/Opensearch/main/useOpensearch.ts b/react-app/src/components/Opensearch/main/useOpensearch.ts index c6eb10e903..4a0006088b 100644 --- a/react-app/src/components/Opensearch/main/useOpensearch.ts +++ b/react-app/src/components/Opensearch/main/useOpensearch.ts @@ -5,7 +5,7 @@ import { getOsData, useOsSearch, useGetUser } from "@/api"; import { useLzUrl } from "@/hooks"; import { OsTab } from "./types"; import { createSearchFilterable } from "../utils"; -import { useLocation } from "react-router-dom"; +import { useLocation } from "react-router"; export const DEFAULT_FILTERS: Record> = { spas: { @@ -104,13 +104,11 @@ export const useOsAggregate = () => { }, { field: - user?.isCms && - !user.user?.["custom:cms-roles"].includes(UserRoles.HELPDESK) + user?.isCms && !user.user?.["custom:cms-roles"].includes(UserRoles.HELPDESK) ? "cmsStatus.keyword" : "stateStatus.keyword", name: - user?.isCms && - !user.user?.["custom:cms-roles"].includes(UserRoles.HELPDESK) + user?.isCms && !user.user?.["custom:cms-roles"].includes(UserRoles.HELPDESK) ? "cmsStatus.keyword" : "stateStatus.keyword", type: "terms", diff --git a/react-app/src/components/RHF/RHFTextDisplay.tsx b/react-app/src/components/RHF/RHFTextDisplay.tsx index cf25f752c3..80f96999ca 100644 --- a/react-app/src/components/RHF/RHFTextDisplay.tsx +++ b/react-app/src/components/RHF/RHFTextDisplay.tsx @@ -1,5 +1,5 @@ import { cn } from "@/utils"; -import { Link } from "react-router-dom"; +import { Link } from "react-router"; import { RHFTextField } from "shared-types"; interface RHFTextDisplayProps { @@ -34,15 +34,10 @@ export const RHFTextDisplay = (props: RHFTextDisplayProps) => { case "italic": return {t.text}; case "numberedSet": - return ( - {`${t.text} ${props.index + 1}`} - ); + return {`${t.text} ${props.index + 1}`}; case "link": return ( - + {t.text} ); diff --git a/react-app/src/components/RHF/tests/RHFTextDisplay.test.tsx b/react-app/src/components/RHF/tests/RHFTextDisplay.test.tsx index 99c00a13ff..f87370e2f6 100644 --- a/react-app/src/components/RHF/tests/RHFTextDisplay.test.tsx +++ b/react-app/src/components/RHF/tests/RHFTextDisplay.test.tsx @@ -1,6 +1,6 @@ import { describe, test, expect } from "vitest"; import { render } from "@testing-library/react"; -import { BrowserRouter } from "react-router-dom"; +import { BrowserRouter } from "react-router"; import { RHFTextDisplay } from ".."; import { RHFTextField } from "shared-types"; diff --git a/react-app/src/components/ScrollToTop/index.ts b/react-app/src/components/ScrollToTop/index.ts index 6a001cff8b..12a010f602 100644 --- a/react-app/src/components/ScrollToTop/index.ts +++ b/react-app/src/components/ScrollToTop/index.ts @@ -1,5 +1,5 @@ import { useEffect } from "react"; -import { useLocation } from "react-router-dom"; +import { useLocation } from "react-router"; export const ScrollToTop = () => { const { pathname } = useLocation(); diff --git a/react-app/src/components/UsaBanner/UsaBanner.test.tsx b/react-app/src/components/UsaBanner/UsaBanner.test.tsx index f7b3f46128..a60684a23f 100644 --- a/react-app/src/components/UsaBanner/UsaBanner.test.tsx +++ b/react-app/src/components/UsaBanner/UsaBanner.test.tsx @@ -3,15 +3,13 @@ import userEvent from "@testing-library/user-event"; import { describe, expect, test, vi } from "vitest"; import { UsaBanner } from "."; -vi.mock("react-router-dom", () => ({ +vi.mock("react-router", () => ({ useLoaderData: vi.fn().mockImplementation(() => ({ error: "" })), })); describe("UsaBanner", () => { test("clicking on button expands banner information (small)", async () => { - const { queryAllByRole, queryByText } = render( - , - ); + const { queryAllByRole, queryByText } = render(); const button = queryAllByRole("button")[0]; await userEvent.click(button); @@ -20,9 +18,7 @@ describe("UsaBanner", () => { }); test("clicking on button expands banner information (large)", async () => { - const { queryAllByRole, queryByText } = render( - , - ); + const { queryAllByRole, queryByText } = render(); const button = queryAllByRole("button")[1]; await userEvent.click(button); @@ -47,9 +43,7 @@ describe("UsaBanner", () => { }); test("government building icon renders", async () => { - const { queryByTestId, queryAllByRole } = render( - , - ); + const { queryByTestId, queryAllByRole } = render(); const button = queryAllByRole("button")[0]; await userEvent.click(button); diff --git a/react-app/src/components/UsaBanner/index.tsx b/react-app/src/components/UsaBanner/index.tsx index 66a12030dd..b04f43379e 100644 --- a/react-app/src/components/UsaBanner/index.tsx +++ b/react-app/src/components/UsaBanner/index.tsx @@ -1,5 +1,5 @@ import { useState } from "react"; -import { useLoaderData } from "react-router-dom"; +import { useLoaderData } from "react-router"; import { ChevronDown, ChevronUp } from "lucide-react"; import config from "@/config"; import { LockIcon } from "../LockIcon"; @@ -57,14 +57,8 @@ export const UsaBanner = ({ isUserMissingRole }: UsaBannerProps) => { return (
- A United States Flag icon -

- An official website of the United States government -

+ A United States Flag icon +

An official website of the United States government