Skip to content

Commit

Permalink
2022-05-02 release (#1223)
Browse files Browse the repository at this point in the history
* chore: merge dev

* Fix code style issues with Prettier

* fix: remove flattened-keys json

Co-authored-by: Lint Action <[email protected]>
  • Loading branch information
seanmalbert and lint-action authored May 3, 2022
1 parent 5fdff5d commit 246fa25
Show file tree
Hide file tree
Showing 44 changed files with 243 additions and 324 deletions.
2 changes: 1 addition & 1 deletion backend/core/src/listings/dto/listing-filter-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class ListingFilterParams extends BaseFilter {
})
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@IsString({ groups: [ValidationsGroupsEnum.default] })
[ListingFilterKeys.bedrooms]?: string;
[ListingFilterKeys.bedRoomSize]?: string;

@Expose()
@ApiProperty({
Expand Down
1 change: 1 addition & 0 deletions backend/core/src/listings/listings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class ListingsService {
.leftJoin("listing_programs.program", "programs")
.leftJoin("listings.unitGroups", "unitgroups")
.leftJoin("unitgroups.amiLevels", "amilevels")
.leftJoin("unitgroups.unitType", "unitTypes")
.groupBy("listings.id")

innerFilteredQuery = ListingsService.addOrderByToQb(innerFilteredQuery, params)
Expand Down
2 changes: 1 addition & 1 deletion backend/core/src/listings/tests/listings.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ describe("ListingsService", () => {

expect(listings.items).toEqual(mockListings)
expect(mockInnerQueryBuilder.andWhere).toHaveBeenCalledWith(
"(coalesce(unitGroups.open_waitlist, false) = :openWaitlist)",
"(coalesce(unitgroups.open_waitlist, false) = :openWaitlist)",
{
openWaitlist: true,
}
Expand Down
67 changes: 28 additions & 39 deletions backend/core/src/shared/query-filter/custom_filters.ts
Original file line number Diff line number Diff line change
@@ -1,56 +1,42 @@
import { getMetadataArgsStorage, WhereExpression } from "typeorm"
import { UnitGroup } from "../../units-summary/entities/unit-group.entity"
import { UnitType } from "../../unit-types/entities/unit-type.entity"
import { WhereExpression } from "typeorm"
import { ListingMarketingTypeEnum } from "../../../types"

export function addAvailabilityQuery(qb: WhereExpression, filterValue: string) {
const val = filterValue?.split(",")
const whereClause = []
const inputArgs: Record<string, number | boolean | ListingMarketingTypeEnum> = {}
val.forEach((option) => {
switch (option) {
case "vacantUnits":
qb.andWhere("(unitGroups.total_available >= :vacantUnits)", {
vacantUnits: 1,
})
whereClause.push("unitgroups.total_available >= :vacantUnits")
inputArgs.vacantUnits = 1
return
case "openWaitlist":
if (!val.includes("closedWaitlist")) {
qb.andWhere("(coalesce(unitGroups.open_waitlist, false) = :openWaitlist)", {
openWaitlist: true,
})
}
whereClause.push("coalesce(unitgroups.open_waitlist, false) = :openWaitlist")
inputArgs.openWaitlist = true
return
case "closedWaitlist":
if (!val.includes("openWaitlist")) {
qb.andWhere("(coalesce(unitGroups.open_waitlist, false) = :closedWaitlist)", {
closedWaitlist: false,
})
}
whereClause.push("coalesce(unitgroups.open_waitlist, false) = :closedWaitlist")
inputArgs.closedWaitlist = false
return
case "comingSoon":
whereClause.push("listings.marketing_type = :marketing_type")
inputArgs.marketing_type = ListingMarketingTypeEnum.comingSoon
return
default:
return
}
})
qb.andWhere(`(${whereClause.join(" OR ")})`, { ...inputArgs })
}

export function addBedroomsQuery(qb: WhereExpression, filterValue: number[]) {
const typeOrmMetadata = getMetadataArgsStorage()
const unitGroupEntityMetadata = typeOrmMetadata.tables.find((table) => table.target === UnitGroup)
const unitTypeEntityMetadata = typeOrmMetadata.tables.find((table) => table.target === UnitType)
const whereParameterName = "unitGroups_numBedrooms"

const unitGroupUnitTypeJoinTableName = `${unitGroupEntityMetadata.name}_unit_type_${unitTypeEntityMetadata.name}`
qb.andWhere(
`
(
SELECT bool_or(num_bedrooms IN (:...${whereParameterName})) FROM ${unitGroupEntityMetadata.name}
LEFT JOIN ${unitGroupUnitTypeJoinTableName} ON ${unitGroupUnitTypeJoinTableName}.unit_group_id = ${unitGroupEntityMetadata.name}.id
LEFT JOIN ${unitTypeEntityMetadata.name} ON ${unitTypeEntityMetadata.name}.id = ${unitGroupUnitTypeJoinTableName}.unit_types_id
WHERE ${unitGroupEntityMetadata.name}.listing_id = listings.id
) = true
`,
{
[whereParameterName]: filterValue,
}
)
export function addBedroomsQuery(qb: WhereExpression, filterValue: string) {
const val = filterValue.split(",").filter((elem) => !!elem)
if (val.length) {
qb.andWhere("unitTypes.name IN (:...unitTypes) ", {
unitTypes: val,
})
}
return
}

Expand Down Expand Up @@ -111,8 +97,11 @@ export function addRegionFilter(qb: WhereExpression, filterValue: string) {

export function addAccessibilityFilter(qb: WhereExpression, filterValue: string) {
const val = filterValue.split(",").filter((elem) => !!elem)
val.forEach((key) => {
qb.andWhere(`listing_features.${key} = true`)
})
const whereClause = val
.map((key) => {
return `listing_features.${key} = true`
})
.join(" OR ")
qb.andWhere(`(${whereClause})`)
return
}
7 changes: 1 addition & 6 deletions backend/core/src/shared/query-filter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,7 @@ export function addFilters<FilterParams extends Array<any>, FilterFieldMap>(
continue
case ListingFilterKeys.bedrooms:
case ListingFilterKeys.bedRoomSize:
addBedroomsQuery(
qb,
typeof filterValue === "string"
? filterValue.split(",").map((val) => Number(val))
: [filterValue]
)
addBedroomsQuery(qb, filterValue)
continue
case ListingFilterKeys.minAmiPercentage:
addMinAmiPercentageFilter(qb, parseInt(filterValue), includeNulls)
Expand Down
1 change: 1 addition & 0 deletions backend/core/src/shared/units-transformations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { UnitGroupSummary } from "../units/types/unit-group-summary"

import { HouseholdMaxIncomeSummary } from "../units/types/household-max-income-summary"
import { UnitSummaries } from "../units/types/unit-summaries"

Expand Down
2 changes: 1 addition & 1 deletion sites/public/layouts/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const Layout = (props) => {
},
{
title: t("pageTitle.resources"),
href: "/resources",
href: "/additional-resources",
},
]
if (profile) {
Expand Down
1 change: 1 addition & 0 deletions sites/public/layouts/eligibility.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface EligibilityLayoutProps {
const EligibilityLayout = (props: EligibilityLayoutProps) => {
const router = useRouter()
const { eligibilityRequirements } = useContext(EligibilityContext)

const handleSubmit = props.formMethods.handleSubmit

const onBack = async (data) => {
Expand Down
17 changes: 10 additions & 7 deletions sites/public/lib/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,23 @@ export const getListingTag = (tag: ImageTag) => {
return (
<Tag
styleType={AppearanceStyleType.accentLight}
className={"mr-2 mb-2 font-bold px-3 py-2"}
className={"me-2 mb-2 font-bold px-3 py-2"}
key={tag.text}
>
{tag.iconType && (
<Icon
size={"medium"}
symbol={tag.iconType}
fill={tag.iconColor ?? IconFillColors.primary}
className={"mr-2"}
className={"me-2"}
/>
)}
{tag.text}
</Tag>
)
}

export const getImageCardTag = (listing): ImageTag[] => {
export const getImageCardTag = (listing: Listing): ImageTag[] => {
const tag = getImageTagLabelFromListing(listing)
return tag
? [
Expand All @@ -136,10 +136,13 @@ export const getImageCardTag = (listing): ImageTag[] => {
listing?.marketingType === ListingMarketingTypeEnum.comingSoon
? AppearanceStyleType.closed
: AppearanceStyleType.accentLight,
tooltip: {
id: "verified",
text: t("listings.managerHasConfirmedInformation"),
},
tooltip:
listing?.isVerified && listing?.marketingType !== ListingMarketingTypeEnum.comingSoon // show tooltip only for confirmed badge
? {
id: "verified",
text: t("listings.managerHasConfirmedInformation"),
}
: undefined,
},
]
: null
Expand Down
6 changes: 4 additions & 2 deletions sites/public/page_content/locale_overrides/general.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"welcome.title": "Find affordable rental housing in Detroit",
"welcome.heroText": "Your resource to find income-restricted multi-family housing and apartments.",
"welcome.heroText": "Your resource to find multi-family housing based on your income and household needs",
"welcome.signUp": "Get emailed whenever a new listing is posted",
"welcome.seeMoreOpportunitiesTruncated": "See more affordable housing resources",
"welcome.viewAdditionalHousingTruncated": "View resources",
Expand All @@ -20,5 +20,7 @@
"leasingAgent.dueToHighCallVolume": "",
"listingFilters.resetButton": "Show all listings",
"listings.communityPrograms": "Community Programs",
"listings.communityProgramsDescription": "This program includes opportunities for members of specific communities"
"listings.communityProgramsDescription": "This program includes opportunities for members of specific communities",
"pageTitle.additionalResources": "Additional Housing Resources",
"pageDescription.additionalResources": "We encourage you to browse additional resources in your search for housing."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### [City of Detroit Civil Rights, Inclusion, and Opportunity Department](https://detroitmi.gov/departments/civil-rights-inclusion-opportunity-department)

CRIO's Civil Rights team investigates discrimination complaints and provides language and translation services. It also houses the Office of Disability Affairs for the City of Detroit.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### [Enforce Property Conditions](https://detroitmi.gov/departments/buildings-safety-engineering-and-environmental-department)

If your landlord fails to provide a well-maintained home, you can submit complaints regarding property maintenance code violations directly to the City of Detroit BSEED. Please contact BSEED at [313-628-2451](tel:+1-313-628-2451) to discuss complaints.
3 changes: 3 additions & 0 deletions sites/public/page_content/resources/eviction_prevention.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Eviction Prevention and Legal Assistance

Several agencies in Detroit provide legal assistance to low-income households facing eviction and other issues. Organizations to call include the [United Community Housing Coalition](https://www.uchcdetroit.org/) ([313-963-3310](tel:+1-313-963-3310)), [Lakeshore Legal Aid](https://lakeshorelegalaid.org/) ([888-783-8190](tel:+1-888-783-8190)), and the [Legal Aid and Defender Association](https://ladadetroit.org/) ([313-967-5800](tel:+1-313-967-5800)).
3 changes: 3 additions & 0 deletions sites/public/page_content/resources/fair_housing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### [Fair Housing](https://www.fairhousingdetroit.org/)

The Fair Housing Center of Metropolitan Detroit works to make sure residents have equal access to housing and are not discriminated against based on their identity. They provide housing assistance and counseling, as well as assistance to those pursuing legal cases related to fair housing issues. For more information, call [313-579-3247](tel:+1-313-579-3247).
3 changes: 3 additions & 0 deletions sites/public/page_content/resources/financial_counseling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### [Financial Counseling](https://detroitmi.gov/departments/department-neighborhoods/financial-empowerment-center-fec)

The Financial Empowerment Center (FEC) offers professional, one-on-one financial counseling as a free public service to enable residents to address their financial challenges, needs, and plan for their futures. To schedule an appointment, call [313-322-6222](tel:+1-313-322-6222).
3 changes: 3 additions & 0 deletions sites/public/page_content/resources/home_repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### [Home Repair](https://detroitmi.gov/departments/housing-and-revitalization-department/residents)

No-interest home repair loans are available for eligible households. The City of Detroit also operates programs to ensure lead hazards are removed from homes.
3 changes: 3 additions & 0 deletions sites/public/page_content/resources/homelessness_services.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### [Homelessness Services and Shelter Access](http://www.camdetroit.org/)

Access emergency shelter by contacting CAM Detroit. Call CAM Detroit at [(313) 305-0311](tel:+1-313-305-0311). For the most up to date information on CAM hours, visit [www.camdetroit.org](http://www.camdetroit.org/). In-person services are available for veterans at 4646 John R. St., Red Tower, 2nd Floor, Detroit MI 48201.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### [Homeowner Property Tax Relief](https://detroitmi.gov/government/boards/property-assessment-board-review/homeowners-property-exemption-hope)

City/County programs can help income eligible homeowners reduce current and back taxes. You must re-apply annually.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### [City of Detroit Housing and Revitalization Department](https://detroitmi.gov/departments/housing-and-revitalization-department)

The Housing and Revitalization Department supports the development, rehabilitation, and preservation of affordable housing in the City of Detroit. For more information, call [313-224-6380](tel:+1-313-224-6380).
3 changes: 3 additions & 0 deletions sites/public/page_content/resources/housing_commission.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### [Detroit Housing Commission](https://www.dhcmi.org/Default.aspx)

The Detroit Housing Commission operates affordable for low- and moderate-income Detroiters. The DHC also operates waitlists for its properties. For more information, call the DHC Administrative Office at [313-877-8000](tel:+1-313-877-8000) or the Assisted Housing (Section 8) Customer Service Center at [313-877-8807](tel:+1-313-877-8807).
3 changes: 3 additions & 0 deletions sites/public/page_content/resources/housing_counseling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### [Housing Counseling](https://housing.state.mi.us/webportal/default.aspx?page=counseling_start)

Several agencies in the Detroit area provide housing counselors that can help you connect to resources. A certified housing counselor can help you understand your rights, get ready to purchase a home, and identify additional assistance you may be eligible for.
3 changes: 3 additions & 0 deletions sites/public/page_content/resources/housing_network.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### [Detroit Housing Network](https://detroithousingnetwork.org/)

The Detroit Housing Network is comprised of several community organizations that provide a variety of housing services to residents, including financial and mortgage counseling and property tax and home repair assistance.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### [Housing Relocation Assistance](https://www.uchcdetroit.org/)

United Community Housing Coalition works with individuals and families who are facing eviction to identify decent and affordable housing opportunities and assist with relocation. Call UCHC at [313-963-3310](tel:+1-313-963-3310).
3 changes: 3 additions & 0 deletions sites/public/page_content/resources/land_bank_authority.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### [Detroit Land Bank Authority](https://buildingdetroit.org/)

The Land Bank offers homeownership opportunities for Detroiters. For more information, call [844-BUY-DLBA](tel:+1-844-BUY-DLBA).
3 changes: 3 additions & 0 deletions sites/public/page_content/resources/michigan_211.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### [Michigan 211](https://www.mi211.org/)

Michigan 211 is a free service available 24 hours a day. By calling 211, you can connect with a staff member, who will help direct you to resources in your community. They can connect you to a variety of resources, including food, help with housing, assistance paying bills, etc.
3 changes: 3 additions & 0 deletions sites/public/page_content/resources/project_clean_slate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### [Project Clean Slate (criminal expungements)](https://detroitmi.gov/departments/law-department/project-clean-slate)

Project Clean Slate is a free City of Detroit program that helps residents expunge criminal convictions and improve access to better employment, housing, and educational opportunities.
7 changes: 7 additions & 0 deletions sites/public/page_content/resources/sidebar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#### Contact

**City of Detroit Housing and Revitalization Department**

For listing and application questions, please contact the Property Agent displayed on the listing.

For general program inquiries, you may call the Housing and Revitalization Department at [313-224-6380](tel:+13132246380).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### [Tax Foreclosure Prevention](http://www.uchcdetroit.org/)

Make It Home (MIH) is a home-purchase program that gives tenants living in foreclosed homes the option to purchase their home before the foreclosure auction. Call United Community Housing Coalition (UCHC) at [(313) 405-7726](tel:+1-313-405-7726). UCHC also offers counseling and homeowner solutions for those who might be at risk of foreclosure.
3 changes: 3 additions & 0 deletions sites/public/page_content/resources/utilities_assistance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### [Utilities Assistance](https://www.waynemetro.org/energy-and-water-assistance/)

Wayne Metro offers multiple programs to assist residents with paying their water bills and other utilities. To learn more, call [313-388-9799](tel:+1-313-388-9799). The Heat and Warmth Fund ([THAW](https://thawfund.org/)) also works with partners to distribute utilities assistance to households in need. To contact THAW, call [1-800-866-8429](tel:+1-800-866-8429).
58 changes: 47 additions & 11 deletions sites/public/pages/additional-resources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,35 @@ import Layout from "../layouts/application"
import {
t,
InfoCardGrid,
InfoCard,
PageHeader,
MarkdownSection,
AuthContext,
} from "@bloom-housing/ui-components"
import { UserStatus } from "../lib/constants"
import { PageView, pushGtmEvent } from "@bloom-housing/shared-helpers"
import Resource from "../src/Resource"
import RenderIf from "../src/RenderIf"

// Import Markdown resource cards:
import housingAndRevitalization from "../page_content/resources/housing_and_revitalization.md"
import enforcePropertyConditions from "../page_content/resources/enforce_property_conditions.md"
import housingNetwork from "../page_content/resources/housing_network.md"
import evictionPrevention from "../page_content/resources/eviction_prevention.md"
import housingCounseling from "../page_content/resources/housing_counseling.md"
import homeRepair from "../page_content/resources/home_repair.md"
import fairHousing from "../page_content/resources/fair_housing.md"
import homelessnessServices from "../page_content/resources/homelessness_services.md"
import utilitiesAssistance from "../page_content/resources/utilities_assistance.md"
import taxForeclosurePrevention from "../page_content/resources/tax_foreclosure_prevention.md"
import homeownerPropertyTaxRelief from "../page_content/resources/homeowner_property_tax_relief.md"
import michigan211 from "../page_content/resources/michigan_211.md"
import financialCounseling from "../page_content/resources/financial_counseling.md"
import housingCommission from "../page_content/resources/housing_commission.md"
import landBankAuthority from "../page_content/resources/land_bank_authority.md"
import projectCleanSlate from "../page_content/resources/project_clean_slate.md"
import civilRightsInclusionOpportunity from "../page_content/resources/civil_rights_inclusion_opportunity.md"
import housingRelocationAssistance from "../page_content/resources/housing_relocation_assistance.md"
import sidebarContent from "../page_content/resources/sidebar.md"

const AdditionalResources = () => {
const pageTitle = t("pageTitle.additionalResources")
Expand Down Expand Up @@ -41,16 +63,29 @@ const AdditionalResources = () => {
<article className="markdown max-w-5xl m-auto md:flex">
<div className="pt-4 md:w-8/12 md:py-0 serif-paragraphs">
<MarkdownSection>
<Markdown
options={{
overrides: {
InfoCard,
InfoCardGrid,
},
}}
<InfoCardGrid
title="Resources"
subtitle="The City of Detroit Housing and Revitalization Department has compiled a list of resources to help you find and maintain your housing."
>
Page content here
</Markdown>
<Resource>{housingAndRevitalization}</Resource>
<Resource>{enforcePropertyConditions}</Resource>
<Resource>{housingNetwork}</Resource>
<Resource>{evictionPrevention}</Resource>
<Resource>{housingCounseling}</Resource>
<Resource>{homeRepair}</Resource>
<Resource>{fairHousing}</Resource>
<Resource>{homelessnessServices}</Resource>
<Resource>{utilitiesAssistance}</Resource>
<Resource>{taxForeclosurePrevention}</Resource>
<Resource>{homeownerPropertyTaxRelief}</Resource>
<Resource>{michigan211}</Resource>
<Resource>{financialCounseling}</Resource>
<Resource>{housingCommission}</Resource>
<Resource>{landBankAuthority}</Resource>
<Resource>{projectCleanSlate}</Resource>
<Resource>{civilRightsInclusionOpportunity}</Resource>
<Resource>{housingRelocationAssistance}</Resource>
</InfoCardGrid>
</MarkdownSection>
</div>
<aside className="pt-4 pb-10 md:w-4/12 md:pl-4 md:py-0 md:shadow-left">
Expand All @@ -65,10 +100,11 @@ const AdditionalResources = () => {
</h4>
),
},
RenderIf,
},
}}
>
Sidebar content here
{sidebarContent}
</Markdown>
</MarkdownSection>
</aside>
Expand Down
Loading

0 comments on commit 246fa25

Please sign in to comment.