diff --git a/sites/public/__tests__/components/listing/GetApplication.test.tsx b/sites/public/__tests__/components/listing/GetApplication.test.tsx index 387b0ab8eb..1caad57efa 100644 --- a/sites/public/__tests__/components/listing/GetApplication.test.tsx +++ b/sites/public/__tests__/components/listing/GetApplication.test.tsx @@ -28,6 +28,7 @@ describe("", () => { preview={false} listingStatus="active" listingName={"Listing name"} + listingId="123" /> ) expect(getByText("How to Apply")).toBeTruthy() @@ -59,6 +60,7 @@ describe("", () => { preview={false} listingStatus="active" listingName={"Listing name"} + listingId="123" /> ) expect(queryByTestId("get-application-section")).toBeNull() @@ -86,6 +88,7 @@ describe("", () => { preview={false} listingStatus="pending" listingName={"Listing name"} + listingId="123" /> ) expect(getByText("Apply Online").closest("button")?.disabled).toBe(true) @@ -113,6 +116,7 @@ describe("", () => { preview={true} listingStatus="pending" listingName={"Listing name"} + listingId="123" /> ) expect(getByText("Apply Online").closest("a")?.getAttribute("href")).toBe("online-app-url") @@ -140,6 +144,7 @@ describe("", () => { preview={false} listingStatus="active" listingName={"Listing name"} + listingId="123" /> ) expect(queryByText("Apply Online")).toBe(null) diff --git a/sites/public/src/components/listing/GetApplication.tsx b/sites/public/src/components/listing/GetApplication.tsx index 6c92c1235c..af0f87f516 100644 --- a/sites/public/src/components/listing/GetApplication.tsx +++ b/sites/public/src/components/listing/GetApplication.tsx @@ -15,7 +15,6 @@ import { Button } from "@bloom-housing/ui-seeds" import { useForm } from "react-hook-form" import { downloadExternalPDF } from "../../lib/helpers" import { ListingStatus } from "@bloom-housing/backend-core" - export interface PaperApplication { fileURL: string languageString: string @@ -32,6 +31,8 @@ export interface ApplicationsProps { applicationsOpenDate?: string /** The name of the listing */ listingName: string + /** The id of the listing */ + listingId: string /** The URL for an online applications */ onlineApplicationURL?: string /** Any number of paper application objects, including their URL and language */ diff --git a/sites/public/src/components/listing/ListingView.tsx b/sites/public/src/components/listing/ListingView.tsx index 32151b7825..6457ea847c 100644 --- a/sites/public/src/components/listing/ListingView.tsx +++ b/sites/public/src/components/listing/ListingView.tsx @@ -1,4 +1,4 @@ -import React from "react" +import React, { useContext } from "react" import ReactDOMServer from "react-dom/server" import Markdown from "markdown-to-jsx" import { @@ -53,6 +53,7 @@ import { UnitTables, getSummariesTable, IMAGE_FALLBACK_URL, + AuthContext, } from "@bloom-housing/shared-helpers" import dayjs from "dayjs" import { ErrorPage } from "../../pages/_error" @@ -69,6 +70,7 @@ interface ListingProps { } export const ListingView = (props: ListingProps) => { + const { initialStateLoaded, profile } = useContext(AuthContext) let buildingSelectionCriteria, preferencesSection const { listing } = props const { @@ -346,10 +348,17 @@ export const ListingView = (props: ListingProps) => { return date ? dayjs(date).format(format) : null } + const redirectIfSignedOut = () => + process.env.showMandatedAccounts && initialStateLoaded && !profile + const applySidebar = () => ( <> { applicationPickUpAddress={getAddress(listing.applicationPickUpAddressType, "pickUp")} preview={props.preview} listingName={listing.name} + listingId={listing.id} listingStatus={listing.status} /> {!(