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

Update select labels #1768

Merged
merged 8 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ All notable changes to this project will be documented in this file. The format
- Update select width ([#1765](https://github.com/bloom-housing/bloom/pull/1765)) (Dominik Barcikowski)
- Reset page to 1 on limit change ([#1809](https://github.com/bloom-housing/bloom/pull/1809)) (Dominik Barcikowski)
- Update public and partners to support preferred unit ids ([#1774](https://github.com/bloom-housing/bloom/pull/1774)) (Dominik Barcikowski)
- Update select options ([#1768](https://github.com/bloom-housing/bloom/pull/1768)) (Dominik Barcikowski)

- Changed:

Expand Down
10 changes: 7 additions & 3 deletions sites/partners/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,14 @@ export const getLotteryEvent = (listing: FormListing): ListingEvent | undefined
: null
}

// TODO memoize this function
export function arrayToFormOptions<T>(arr: T[], label: string, value: string): FormOption[] {
export function arrayToFormOptions<T>(
arr: T[],
label: string,
value: string,
translateLabel?: string
): FormOption[] {
return arr.map((val: T) => ({
label: val[label],
label: translateLabel ? t(`${translateLabel}.${val[label]}`) : val[label],
value: val[value],
}))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const DetailRankingsAndResults = () => {
<ViewItem label={t("listings.reviewOrderQuestion")}>
{getReviewOrderType() === ListingReviewOrder.firstComeFirstServe
? t("listings.firstComeFirstServe")
: t("listings.lottery")}
: t("listings.lotteryTitle")}
</ViewItem>
</GridSection>
{lotteryEvent && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const DetailUnits = ({ setUnitDrawer }: DetailUnitsProps) => {
() =>
listing?.units.map((unit) => ({
number: unit.number,
unitType: unit.unitType && t(`listings.unitTypes.${unit.unitType.name}`),
unitType: unit.unitType && t(`listings.unit.typeOptions.${unit.unitType.name}`),
amiPercentage: unit.amiPercentage,
monthlyRent: unit.monthlyRent,
sqFeet: unit.sqFeet,
Expand Down
4 changes: 2 additions & 2 deletions sites/partners/src/listings/PaperListingForm/UnitForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ const UnitForm = ({ onSubmit, onClose, defaultUnit, existingId, nextId }: UnitFo
setValue(`maxIncomeHouseholdSize${override.householdSize}`, override.income)
})
}
setValue("amiPercentage", parseInt(defaultUnit["amiPercentage"]))
}
setValue("amiPercentage", parseInt(defaultUnit["amiPercentage"]))
setValue("status", "available")
setValue("rentType", getRentType(defaultUnit))
setLoading(false)
Expand Down Expand Up @@ -269,7 +269,7 @@ const UnitForm = ({ onSubmit, onClose, defaultUnit, existingId, nextId }: UnitFo
"name",
"id"
),
unitTypes: arrayToFormOptions<UnitType>(unitTypes, "name", "id"),
unitTypes: arrayToFormOptions<UnitType>(unitTypes, "name", "id", "listings.unit.typeOptions"),
})
}, [amiCharts, unitPriorities, unitTypes])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const RankingsAndResults = ({ listing }: RankingsAndResultsProps) => {
!listing || listing?.reviewOrderType === ListingReviewOrder.firstComeFirstServe,
},
{
label: t("listings.lottery"),
label: t("listings.lotteryTitle"),
value: "reviewOrderLottery",
id: "reviewOrderLottery",
defaultChecked: listing?.reviewOrderType === ListingReviewOrder.lottery,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const FormUnits = ({ units, setUnits, disableUnitsAccordion }: UnitProps) => {
() =>
units.map((unit) => ({
number: unit.number,
unitType: unit.unitType && t(`listings.unitTypes.${unit.unitType.name}`),
unitType: unit.unitType && t(`listings.unit.typeOptions.${unit.unitType.name}`),
amiPercentage: unit.amiPercentage,
monthlyRent: unit.monthlyRent,
sqFeet: unit.sqFeet,
Expand Down
18 changes: 9 additions & 9 deletions ui-components/src/locales/general.json
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@
"listingSubmitted": "Listing Submitted",
"listingUpdated": "Listing Updated",
"longitude": "Longitude",
"lottery": "Lottery",
"lotteryTitle": "Lottery",
"lotteryDateNotes": "Lottery Date Notes",
"lotteryDateQuestion": "When will the lottery be run?",
"lotteryEndTime": "Lottery End Time",
Expand Down Expand Up @@ -963,14 +963,6 @@
"specialNotes": "Special Notes",
"streetAddressOrPOBox": "Street Address or PO Box",
"totalListings": "Total Listings",
"unitTypes": {
"oneBdrm": "1 BR",
"twoBdrm": "2 BR",
"threeBdrm": "3 BR",
"fourBdrm": "4 BR",
"studio": "Studio",
"SRO": "Single Room Occupancy"
},
"unitsAreFor": "These units are for %{type}.",
"unitsHaveAccessibilityFeaturesFor": "These units have accessibility features for people with %{type}.",
"upcomingLotteries": {
Expand Down Expand Up @@ -1055,6 +1047,14 @@
"available": "Available",
"occupied": "Occupied",
"unavailable": "Unavailable"
},
"typeOptions": {
Copy link
Collaborator

@emilyjablonski emilyjablonski Aug 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These translations already exist, we don't want to have any duplicates

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These translations still exist elsewhere under preferredUnit I think we can delete these added translations and use the others yeah?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dominikx96 , can you please make this update.

Copy link
Collaborator

@seanmalbert seanmalbert Sep 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the options for preferredUnit are a little different and we may not want a one to one here, since those have a + option.

"studio": "Studio",
"oneBdrm": "One Bedroom",
"twoBdrm": "Two Bedroom",
"threeBdrm": "Three Bedroom",
"fourBdrm": "Four Bedroom",
"SRO": "Single Room Occupancy"
}
},
"events": {
Expand Down