diff --git a/sites/public/__tests__/components/listing/GetApplication.test.tsx b/sites/public/__tests__/components/listing/GetApplication.test.tsx index 098e9657df..387b0ab8eb 100644 --- a/sites/public/__tests__/components/listing/GetApplication.test.tsx +++ b/sites/public/__tests__/components/listing/GetApplication.test.tsx @@ -26,6 +26,7 @@ describe("", () => { zipCode: "90210", }} preview={false} + listingStatus="active" listingName={"Listing name"} /> ) @@ -56,12 +57,13 @@ describe("", () => { zipCode: "90210", }} preview={false} + listingStatus="active" listingName={"Listing name"} /> ) expect(queryByTestId("get-application-section")).toBeNull() }) - it("disables apply online button in preview state", () => { + it("disables apply online button if draft listing and not in preview state", () => { const { getByText } = render( ", () => { street: "Pick Up Address Street", zipCode: "90210", }} - preview={true} + preview={false} + listingStatus="pending" listingName={"Listing name"} /> ) expect(getByText("Apply Online").closest("button")?.disabled).toBe(true) }) + it("enables apply online button if draft listing and in preview state", () => { + const { getByText } = render( + + ) + expect(getByText("Apply Online").closest("a")?.getAttribute("href")).toBe("online-app-url") + }) it("hides buttons if application is not open", () => { const { getByText, queryByText } = render( ", () => { zipCode: "90210", }} preview={false} + listingStatus="active" listingName={"Listing name"} /> ) diff --git a/sites/public/src/components/listing/GetApplication.tsx b/sites/public/src/components/listing/GetApplication.tsx index f4faf90368..6c92c1235c 100644 --- a/sites/public/src/components/listing/GetApplication.tsx +++ b/sites/public/src/components/listing/GetApplication.tsx @@ -14,6 +14,7 @@ import { 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 @@ -39,7 +40,9 @@ export interface ApplicationsProps { paperMethod?: boolean /** The date mailed applications must be received by */ postmarkedApplicationsReceivedByDate?: string - /** Whether or not to hide actionable application buttons */ + /** Informs whether or not to hide actionable application buttons */ + listingStatus?: string + /** Whether or not to block submission of test application */ preview?: boolean strings?: { applicationsOpenInFuture?: string @@ -57,8 +60,8 @@ const GetApplication = (props: ApplicationsProps) => { const showSection = props.onlineApplicationURL || (props.applicationsOpen && props.paperMethod && !!props.paperApplications?.length) + const disableApplyButton = !props.preview && props.listingStatus !== ListingStatus.active const [showDownloadModal, setShowDownloadModal] = useState(false) - // eslint-disable-next-line @typescript-eslint/unbound-method const { register, watch } = useForm() const paperApplicationURL: string = watch( @@ -84,11 +87,11 @@ const GetApplication = (props: ApplicationsProps) => { )} {props.applicationsOpen && props.onlineApplicationURL && (
- {props.preview ? ( + {disableApplyButton ? (