Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3032/new what to expect core #3087

Merged
merged 8 commits into from
Oct 12, 2022
39 changes: 23 additions & 16 deletions sites/public/pages/applications/review/confirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
FormCard,
t,
} from "@bloom-housing/ui-components"
import { ListingReviewOrder } from "@bloom-housing/backend-core/types"
import { ListingEvent, ListingReviewOrder } from "@bloom-housing/backend-core/types"
import {
imageUrlFromListing,
PageView,
Expand All @@ -33,25 +33,34 @@ const ApplicationConfirmation = () => {

const imageUrl = imageUrlFromListing(listing, parseInt(process.env.listingPhotoSize))

const reviewOrder = useMemo(() => {
if (listing) {
if (listing.reviewOrderType == ListingReviewOrder.lottery) {
const lotteryEvent = getLotteryEvent(listing)
const lotteryText = []
const content = useMemo(() => {
let lotteryEvent: ListingEvent
const lotteryText = []

switch (listing?.reviewOrderType) {
case ListingReviewOrder.firstComeFirstServe:
return {
text: t("application.review.confirmation.whatHappensNext.fcfs"),
}
case ListingReviewOrder.lottery:
lotteryEvent = getLotteryEvent(listing)
jaredcwhite marked this conversation as resolved.
Show resolved Hide resolved
if (lotteryEvent?.startTime) {
lotteryText.push(
t("application.review.confirmation.eligibleApplicants.lotteryDate", {
lotteryDate: dayjs(lotteryEvent?.startTime).format("MMMM D, YYYY"),
})
)
}
lotteryText.push(t("application.review.confirmation.eligibleApplicants.lottery"))
return lotteryText.join(" ")
} else {
return t("application.review.confirmation.eligibleApplicants.FCFS")
}
} else {
return ""
lotteryText.push(t("application.review.confirmation.whatHappensNext.lottery"))
return {
text: lotteryText.join(" "),
}
case ListingReviewOrder.waitlist:
return {
text: t("application.review.confirmation.whatHappensNext.waitlist"),
}
default:
return { text: "" }
}
}, [listing, router.locale])

Expand Down Expand Up @@ -93,9 +102,7 @@ const ApplicationConfirmation = () => {
<div className="form-card__group border-b markdown markdown-informational">
<ApplicationTimeline />

<Markdown options={{ disableParsingRawHTML: true }}>
{t("application.review.confirmation.whatHappensNext", { reviewOrder })}
</Markdown>
<Markdown options={{ disableParsingRawHTML: true }}>{content.text}</Markdown>
</div>

<div className="form-card__group border-b markdown markdown-informational">
Expand Down
58 changes: 47 additions & 11 deletions sites/public/pages/applications/review/terms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
5.3 Terms
View of application terms with checkbox
*/
import React, { useContext, useEffect, useState } from "react"
import React, { useContext, useEffect, useMemo, useState } from "react"
import { useRouter } from "next/router"
import {
AppearanceStyleType,
Expand All @@ -14,7 +14,7 @@ import {
AlertBox,
ProgressNav,
} from "@bloom-housing/ui-components"
import { ApplicationSection } from "@bloom-housing/backend-core"
import { ApplicationSection, ListingReviewOrder } from "@bloom-housing/backend-core/types"
import { useForm } from "react-hook-form"
import Markdown from "markdown-to-jsx"
import {
Expand Down Expand Up @@ -87,6 +87,25 @@ const ApplicationTerms = () => {
},
]

const content = useMemo(() => {
switch (listing?.reviewOrderType) {
case ListingReviewOrder.firstComeFirstServe:
return {
text: t("application.review.terms.fcfs.text"),
}
case ListingReviewOrder.lottery:
return {
text: t("application.review.terms.lottery.text"),
}
case ListingReviewOrder.waitlist:
return {
text: t("application.review.terms.waitlist.text"),
}
default:
return { text: "" }
}
}, [listing, router.locale])

useEffect(() => {
pushGtmEvent<PageView>({
event: "pageView",
Expand Down Expand Up @@ -122,20 +141,37 @@ const ApplicationTerms = () => {
)}

<Form id="review-terms" className="mt-4" onSubmit={handleSubmit(onSubmit)}>
<div className="form-card__pager-row">
<div className="form-card__pager-row markdown">
{listing?.applicationDueDate && (
<Markdown options={{ disableParsingRawHTML: false }}>
{t("application.review.terms.textSubmissionDate", {
applicationDueDate: applicationDueDate,
})}
</Markdown>
<>
<Markdown options={{ disableParsingRawHTML: true }}>
{t("application.review.terms.textSubmissionDate", {
applicationDueDate: applicationDueDate,
})}
</Markdown>
<br />
<br />
</>
)}

<Markdown options={{ disableParsingRawHTML: false }}>
{t("application.review.terms.text")}
<Markdown
options={{
disableParsingRawHTML: true,
overrides: {
li: {
component: ({ children, ...props }) => (
<li {...props} className="mb-5">
{children}
</li>
),
},
},
}}
>
{content.text}
</Markdown>

<div className="mt-4">
<div className="mt-6">
<FieldGroup
name="agree"
type="checkbox"
Expand Down
66 changes: 62 additions & 4 deletions sites/public/pages/applications/start/what-to-expect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
0.2 - What To Expect
A notice regarding application process and rules
*/
import React, { useEffect, useContext } from "react"
import React, { useEffect, useContext, useMemo } from "react"
import {
AppearanceStyleType,
Button,
Expand All @@ -12,14 +12,18 @@ import {
Form,
} from "@bloom-housing/ui-components"
import FormsLayout from "../../../layouts/forms"
import { useRouter } from "next/router"
import { useForm } from "react-hook-form"
import { useFormConductor } from "../../../lib/hooks"
import { OnClientSide, PageView, pushGtmEvent, AuthContext } from "@bloom-housing/shared-helpers"
import { UserStatus } from "../../../lib/constants"
import Markdown from "markdown-to-jsx"
import { ListingReviewOrder } from "@bloom-housing/backend-core/types"

const ApplicationWhatToExpect = () => {
const { profile } = useContext(AuthContext)
const { conductor, application, listing } = useFormConductor("whatToExpect")
const router = useRouter()
const currentPageSection = 1

/* Form Handler */
Expand All @@ -28,6 +32,28 @@ const ApplicationWhatToExpect = () => {
conductor.routeToNextOrReturnUrl()
}

const content = useMemo(() => {
switch (listing?.reviewOrderType) {
case ListingReviewOrder.firstComeFirstServe:
return {
steps: t("application.start.whatToExpect.fcfs.steps"),
finePrint: t("application.start.whatToExpect.fcfs.finePrint"),
}
case ListingReviewOrder.lottery:
return {
steps: t("application.start.whatToExpect.lottery.steps"),
finePrint: t("application.start.whatToExpect.lottery.finePrint"),
}
case ListingReviewOrder.waitlist:
return {
steps: t("application.start.whatToExpect.waitlist.steps"),
finePrint: t("application.start.whatToExpect.waitlist.finePrint"),
}
default:
return { steps: "", finePrint: "" }
}
}, [listing, router.locale])

useEffect(() => {
pushGtmEvent<PageView>({
event: "pageView",
Expand Down Expand Up @@ -58,9 +84,41 @@ const ApplicationWhatToExpect = () => {
</h2>
</div>
<div className="form-card__pager-row px-16">
<p className="field-note py-2">{t("application.start.whatToExpect.info1")}</p>
<p className="field-note py-2">{t("application.start.whatToExpect.info2")}</p>
<p className="field-note py-2">{t("application.start.whatToExpect.info3")}</p>
<div className="markdown mt-4">
<Markdown
options={{
disableParsingRawHTML: true,
overrides: {
ol: {
component: ({ children, ...props }) => (
<ol {...props} className="large-numbers">
{children}
</ol>
),
},
},
}}
>
{content.steps}
</Markdown>

<Markdown
options={{
disableParsingRawHTML: true,
overrides: {
li: {
component: ({ children, ...props }) => (
<li {...props} className="mb-5">
{children}
</li>
),
},
},
}}
>
{content.finePrint}
</Markdown>
</div>
</div>
<Form onSubmit={handleSubmit(onSubmit)}>
<div className="form-card__pager">
Expand Down
Loading