-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1383/listings management, ranking and results (#1433)
- Loading branch information
1 parent
97d0d25
commit a30fb13
Showing
14 changed files
with
273 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
sites/partners/src/listings/PaperListingDetails/sections/DetailRankingsAndResults.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React, { useContext } from "react" | ||
import { t, GridSection, ViewItem } from "@bloom-housing/ui-components" | ||
import { ListingContext } from "../../ListingContext" | ||
|
||
const DetailRankingsAndResults = () => { | ||
const listing = useContext(ListingContext) | ||
|
||
return ( | ||
<GridSection | ||
className="bg-primary-lighter" | ||
title={t("listings.sections.rankingsResultsTitle")} | ||
grid={false} | ||
inset | ||
> | ||
<GridSection columns={3}> | ||
<ViewItem label={t("listings.waitlist.openQuestion")}> | ||
{listing.isWaitlistOpen ? t("t.yes") : t("t.no")} | ||
</ViewItem> | ||
</GridSection> | ||
{listing.isWaitlistOpen && ( | ||
<GridSection columns={3}> | ||
<ViewItem label={t("listings.waitlist.sizeQuestion")}> | ||
{listing.waitlistMaxSize ? t("t.yes") : t("t.no")} | ||
</ViewItem> | ||
</GridSection> | ||
)} | ||
{listing.waitlistMaxSize && ( | ||
<GridSection columns={3}> | ||
<ViewItem label={t("listings.waitlist.maxSize")}>{listing.waitlistMaxSize}</ViewItem> | ||
<ViewItem label={t("listings.waitlist.currentSize")}> | ||
{listing.waitlistCurrentSize} | ||
</ViewItem> | ||
<ViewItem label={t("listings.waitlist.openSize")}>{listing.waitlistOpenSpots}</ViewItem> | ||
</GridSection> | ||
)} | ||
</GridSection> | ||
) | ||
} | ||
|
||
export default DetailRankingsAndResults |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
sites/partners/src/listings/PaperListingForm/sections/RankingsAndResults.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import React from "react" | ||
import { useFormContext } from "react-hook-form" | ||
import { t, GridSection, Field, FieldGroup, GridCell } from "@bloom-housing/ui-components" | ||
|
||
import { YesNoAnswer } from "../../../applications/PaperApplicationForm/FormTypes" | ||
import { FormListing } from "../index" | ||
|
||
type RankingsAndResultsProps = { | ||
listing?: FormListing | ||
} | ||
|
||
const RankingsAndResults = ({ listing }: RankingsAndResultsProps) => { | ||
const formMethods = useFormContext() | ||
|
||
// eslint-disable-next-line @typescript-eslint/unbound-method | ||
const { register, watch } = formMethods | ||
|
||
const waitlistOpen: YesNoAnswer = watch( | ||
"waitlistOpenQuestion", | ||
listing?.isWaitlistOpen ? YesNoAnswer.Yes : YesNoAnswer.No | ||
) | ||
const showWaitlistSize: YesNoAnswer = watch( | ||
"waitlistSizeQuestion", | ||
listing?.waitlistMaxSize ? YesNoAnswer.Yes : YesNoAnswer.No | ||
) | ||
|
||
const yesNoRadioOptions = [ | ||
{ | ||
label: t("t.yes"), | ||
value: YesNoAnswer.Yes, | ||
}, | ||
{ | ||
label: t("t.no"), | ||
value: YesNoAnswer.No, | ||
}, | ||
] | ||
|
||
return ( | ||
<div> | ||
<GridSection grid={false} separator> | ||
<span className="form-section__title">{t("listings.sections.rankingsResultsTitle")}</span> | ||
<span className="form-section__description"> | ||
{t("listings.sections.rankingsResultsSubtitle")} | ||
</span> | ||
<GridSection columns={8} className={"flex items-center"}> | ||
<GridCell span={2}> | ||
<p className="field-label m-4 ml-0">{t("listings.waitlist.openQuestion")}</p> | ||
</GridCell> | ||
<FieldGroup | ||
name="waitlistOpenQuestion" | ||
type="radio" | ||
register={register} | ||
fields={[ | ||
{ | ||
...yesNoRadioOptions[0], | ||
id: "waitlistOpenYes", | ||
defaultChecked: listing && listing.isWaitlistOpen, | ||
}, | ||
|
||
{ | ||
...yesNoRadioOptions[1], | ||
id: "waitlistOpenNo", | ||
defaultChecked: listing && !listing.isWaitlistOpen, | ||
}, | ||
]} | ||
/> | ||
</GridSection> | ||
{waitlistOpen === YesNoAnswer.Yes && ( | ||
<GridSection columns={8} className={"flex items-center"}> | ||
<GridCell span={2}> | ||
<p className="field-label m-4 ml-0">{t("listings.waitlist.sizeQuestion")}</p> | ||
</GridCell> | ||
<FieldGroup | ||
name="waitlistSizeQuestion" | ||
type="radio" | ||
register={register} | ||
fields={[ | ||
{ | ||
...yesNoRadioOptions[0], | ||
id: "showWaitlistSizeYes", | ||
defaultChecked: listing && listing.waitlistMaxSize !== null, | ||
}, | ||
{ | ||
...yesNoRadioOptions[1], | ||
id: "showWaitlistSizeNo", | ||
defaultChecked: listing && !listing.waitlistMaxSize, | ||
}, | ||
]} | ||
/> | ||
</GridSection> | ||
)} | ||
{showWaitlistSize === YesNoAnswer.Yes && waitlistOpen === YesNoAnswer.Yes && ( | ||
<GridSection columns={3} className={"flex items-center"}> | ||
<Field | ||
name="waitlistMaxSize" | ||
id="waitlistMaxSize" | ||
register={register} | ||
label={t("listings.waitlist.maxSizeQuestion")} | ||
placeholder={t("listings.waitlist.maxSize")} | ||
type={"number"} | ||
/> | ||
<Field | ||
name="waitlistCurrentSize" | ||
id="waitlistCurrentSize" | ||
register={register} | ||
label={t("listings.waitlist.currentSizeQuestion")} | ||
placeholder={t("listings.waitlist.currentSize")} | ||
type={"number"} | ||
/> | ||
<Field | ||
name="waitlistOpenSpots" | ||
id="waitlistOpenSpots" | ||
register={register} | ||
label={t("listings.waitlist.openSizeQuestion")} | ||
placeholder={t("listings.waitlist.openSize")} | ||
type={"number"} | ||
/> | ||
</GridSection> | ||
)} | ||
</GridSection> | ||
</div> | ||
) | ||
} | ||
|
||
export default RankingsAndResults |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.