Skip to content

Commit

Permalink
fix: don't show lottery dates when open waitlist is selected (#4522)
Browse files Browse the repository at this point in the history
* fix: don't show lottery dates when open waitlist is selected

* feat: make selection logic more clear

* fix: improved events filtering logic

* fix: lottery opt in should be null if not lottery type
  • Loading branch information
jaredcwhite authored Jan 10, 2025
1 parent 34dad18 commit 6248a9a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ const RankingsAndResults = ({ listing, isAdmin }: RankingsAndResultsProps) => {
name: "listingAvailabilityQuestion",
})

// Ensure the lottery fields only show when it's "available units" listing
const showLotteryFields =
availabilityQuestion !== "openWaitlist" && reviewOrder === "reviewOrderLottery"

const yesNoRadioOptions = [
{
label: t("t.yes"),
Expand Down Expand Up @@ -95,7 +99,7 @@ const RankingsAndResults = ({ listing, isAdmin }: RankingsAndResultsProps) => {
</Grid.Cell>
</Grid.Row>
)}
{reviewOrder === "reviewOrderLottery" && (
{showLotteryFields && (
<>
{process.env.showLottery && (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ export default class AdditionalMetadataFormatter extends Formatter {
? ReviewOrderTypeEnum.lottery
: ReviewOrderTypeEnum.firstComeFirstServe

if (this.data.reviewOrderType !== ReviewOrderTypeEnum.lottery) {
this.data.lotteryOptIn = null
} else {
if (this.data.lotteryOptIn === null) delete this.data.lotteryOptIn
}

if (this.data.listingAvailabilityQuestion === "openWaitlist") {
this.data.reviewOrderType = ReviewOrderTypeEnum.waitlist
}
Expand Down
18 changes: 14 additions & 4 deletions sites/partners/src/lib/listings/BooleansFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,20 @@ export default class BooleansFormatter extends Formatter {
when: this.data.referralOpportunityChoice === YesNoEnum.yes,
falseCase: () => (this.data.referralOpportunityChoice === YesNoEnum.no ? false : null),
})
this.processBoolean("lotteryOptIn", {
when: this.data.lotteryOptInQuestion === YesNoEnum.yes,
falseCase: () => (this.data.lotteryOptInQuestion === YesNoEnum.no ? false : null),
})

if (
this.data.reviewOrderQuestion !== "reviewOrderLottery" ||
this.data.listingAvailabilityQuestion === "openWaitlist"
) {
this.data.lotteryOptIn = null
} else {
this.processBoolean("lotteryOptIn", {
when: this.data.lotteryOptInQuestion === YesNoEnum.yes,
falseCase: () => (this.data.lotteryOptInQuestion === YesNoEnum.no ? false : null),
})
if (this.data.lotteryOptIn === null) delete this.data.lotteryOptIn
}

this.processBoolean("includeCommunityDisclaimer", {
when: this.data.includeCommunityDisclaimerQuestion === YesNoEnum.yes,
falseCase: () =>
Expand Down
5 changes: 3 additions & 2 deletions sites/partners/src/lib/listings/EventsFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ export default class EventsFormatter extends Formatter {
)
)
if (
this.data.listingAvailabilityQuestion !== "openWaitlist" &&
this.data.reviewOrderQuestion === "reviewOrderLottery" &&
this.data.lotteryDate &&
this.data.lotteryDate.day &&
this.data.lotteryDate.month &&
this.data.lotteryDate.year &&
this.data.reviewOrderQuestion === "reviewOrderLottery"
this.data.lotteryDate.year
) {
events.push({
type: ListingEventsTypeEnum.publicLottery,
Expand Down

0 comments on commit 6248a9a

Please sign in to comment.