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
46 changes: 25 additions & 21 deletions sites/public/pages/applications/review/confirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,32 @@ 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 = []
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")
const content = useMemo(() => {
if (listing?.reviewOrderType == ListingReviewOrder.firstComeFirstServe) {
jaredcwhite marked this conversation as resolved.
Show resolved Hide resolved
return {
text: t("application.review.confirmation.whatHappensNext.fcfs"),
}
} else if (listing?.reviewOrderType == ListingReviewOrder.lottery) {
const lotteryEvent = getLotteryEvent(listing)
const lotteryText = []
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.whatHappensNext.lottery"))
return {
text: lotteryText.join(" "),
}
} else if (listing?.reviewOrderType == ListingReviewOrder.waitlist) {
return {
text: t("application.review.confirmation.whatHappensNext.waitlist"),
}
} else {
return ""
}

return { text: "" }
}, [listing, router.locale])

useEffect(() => {
Expand Down Expand Up @@ -93,9 +99,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
57 changes: 46 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,24 @@ const ApplicationTerms = () => {
},
]

const content = useMemo(() => {
if (listing?.reviewOrderType == ListingReviewOrder.firstComeFirstServe) {
return {
text: t("application.review.terms.fcfs.text"),
}
} else if (listing?.reviewOrderType == ListingReviewOrder.lottery) {
return {
text: t("application.review.terms.lottery.text"),
}
} else if (listing?.reviewOrderType == ListingReviewOrder.waitlist) {
return {
text: t("application.review.terms.waitlist.text"),
}
}

return { text: "" }
}, [listing, router.locale])

useEffect(() => {
pushGtmEvent<PageView>({
event: "pageView",
Expand Down Expand Up @@ -122,20 +140,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
65 changes: 61 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,27 @@ const ApplicationWhatToExpect = () => {
conductor.routeToNextOrReturnUrl()
}

const content = useMemo(() => {
if (listing?.reviewOrderType == ListingReviewOrder.firstComeFirstServe) {
return {
steps: t("application.start.whatToExpect.fcfs.steps"),
finePrint: t("application.start.whatToExpect.fcfs.finePrint"),
}
} else if (listing?.reviewOrderType == ListingReviewOrder.lottery) {
return {
steps: t("application.start.whatToExpect.lottery.steps"),
finePrint: t("application.start.whatToExpect.lottery.finePrint"),
}
} else if (listing?.reviewOrderType == ListingReviewOrder.waitlist) {
return {
steps: t("application.start.whatToExpect.waitlist.steps"),
finePrint: t("application.start.whatToExpect.waitlist.finePrint"),
}
}

return { steps: "", finePrint: "" }
}, [listing, router.locale])

useEffect(() => {
pushGtmEvent<PageView>({
event: "pageView",
Expand Down Expand Up @@ -58,9 +83,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