Skip to content

Commit

Permalink
feat: 3761/direct to sign in (#3816)
Browse files Browse the repository at this point in the history
* feat: check if user is logged in

* fix: clean up logs

* fix: remove unneeded prop

* fix: sign in before submit application test

* fix: add feature toggle

* fix: sign in before submitApplication tests

* fix: fix test

* fix: add feature flag to circleCI

* fix: remove toggle

* refactor: move redirect logic to ListingView
  • Loading branch information
cade-exygy authored Jan 26, 2024
1 parent c3a6b9c commit e3305e4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe("<Applications>", () => {
preview={false}
listingStatus="active"
listingName={"Listing name"}
listingId="123"
/>
)
expect(getByText("How to Apply")).toBeTruthy()
Expand Down Expand Up @@ -59,6 +60,7 @@ describe("<Applications>", () => {
preview={false}
listingStatus="active"
listingName={"Listing name"}
listingId="123"
/>
)
expect(queryByTestId("get-application-section")).toBeNull()
Expand Down Expand Up @@ -86,6 +88,7 @@ describe("<Applications>", () => {
preview={false}
listingStatus="pending"
listingName={"Listing name"}
listingId="123"
/>
)
expect(getByText("Apply Online").closest("button")?.disabled).toBe(true)
Expand Down Expand Up @@ -113,6 +116,7 @@ describe("<Applications>", () => {
preview={true}
listingStatus="pending"
listingName={"Listing name"}
listingId="123"
/>
)
expect(getByText("Apply Online").closest("a")?.getAttribute("href")).toBe("online-app-url")
Expand Down Expand Up @@ -140,6 +144,7 @@ describe("<Applications>", () => {
preview={false}
listingStatus="active"
listingName={"Listing name"}
listingId="123"
/>
)
expect(queryByText("Apply Online")).toBe(null)
Expand Down
3 changes: 2 additions & 1 deletion sites/public/src/components/listing/GetApplication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 */
Expand Down
14 changes: 12 additions & 2 deletions sites/public/src/components/listing/ListingView.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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"
Expand All @@ -69,6 +70,7 @@ interface ListingProps {
}

export const ListingView = (props: ListingProps) => {
const { initialStateLoaded, profile } = useContext(AuthContext)
let buildingSelectionCriteria, preferencesSection
const { listing } = props
const {
Expand Down Expand Up @@ -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 = () => (
<>
<GetApplication
onlineApplicationURL={getOnlineApplicationURL()}
onlineApplicationURL={
redirectIfSignedOut()
? `/sign-in?redirectUrl=/applications/start/choose-language&listingId=${listing.id}`
: getOnlineApplicationURL()
}
applicationsOpen={!appOpenInFuture}
applicationsOpenDate={getDateString(listing.applicationOpenDate, "MMMM D, YYYY")}
paperApplications={getPaperApplications()}
Expand All @@ -362,6 +371,7 @@ export const ListingView = (props: ListingProps) => {
applicationPickUpAddress={getAddress(listing.applicationPickUpAddressType, "pickUp")}
preview={props.preview}
listingName={listing.name}
listingId={listing.id}
listingStatus={listing.status}
/>
{!(
Expand Down

0 comments on commit e3305e4

Please sign in to comment.