Skip to content

Commit

Permalink
1611/what to expect editable in listings management (bloom-housing#1681)
Browse files Browse the repository at this point in the history
* 1611/what to expect editable

* fixup unit test

* changelog
  • Loading branch information
emilyjablonski authored Aug 19, 2021
1 parent cafd6e7 commit 2e744e8
Show file tree
Hide file tree
Showing 17 changed files with 60 additions and 103 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ All notable changes to this project will be documented in this file. The format
- removed roles for public users and assigned a "partner" role for leasing agents([#1628](https://github.com/bloom-housing/bloom/pull/1628))
- Updates redis reset call to flush all keys
- Updated listing's importer to handle latest reserved community type changes ([#1667](https://github.com/bloom-housing/bloom/pull/1667)) (Emily Jablonski)
- Change whatToExpect to be a string instead of a json blob, make it editable in listings management ([#1681](https://github.com/bloom-housing/bloom/pull/1681)) (Emily Jablonski)

- Fixed:
- Added checks for property in listing.dto transforms
Expand Down
6 changes: 1 addition & 5 deletions backend/core/archer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,7 @@ export const ArcherListing: Listing = {
showWaitlist: false,
reviewOrderType: EnumListingReviewOrderType.firstComeFirstServe,
urlSlug: "listing-slug-abcdef",
whatToExpect: {
applicantsWillBeContacted: "Applicant will be contacted.",
allInfoWillBeVerified: "All info will be verified.",
bePreparedIfChosen: "Be prepared if chosen.",
},
whatToExpect: "Applicant will be contacted. All info will be verified. Be prepared if chosen.",
status: ListingStatus.active,
postmarkedApplicationsReceivedByDate: new Date("2019-12-05"),
applicationAddress: {
Expand Down
8 changes: 3 additions & 5 deletions backend/core/src/listings/entities/listing.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
} from "typeorm"
import { Application } from "../../applications/entities/application.entity"
import { User } from "../../auth/entities/user.entity"
import { WhatToExpect } from "../../shared/dto/whatToExpect.dto"
import { Preference } from "../../preferences/entities/preference.entity"
import { Expose, Type } from "class-transformer"
import {
Expand Down Expand Up @@ -351,12 +350,11 @@ class Listing extends BaseEntity {
@IsNumber({}, { groups: [ValidationsGroupsEnum.default] })
waitlistMaxSize?: number | null

@Column({ type: "jsonb", nullable: true })
@Column({ type: "text", nullable: true })
@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@ValidateNested({ groups: [ValidationsGroupsEnum.default] })
@Type(() => WhatToExpect)
whatToExpect?: WhatToExpect | null
@IsString({ groups: [ValidationsGroupsEnum.default] })
whatToExpect?: string | null

@Column({
type: "enum",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { MigrationInterface, QueryRunner } from "typeorm"

export class changeWhatToExpectToString1629220482499 implements MigrationInterface {
name = "changeWhatToExpectToString1629220482499"

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "listings" DROP COLUMN "what_to_expect"`)
await queryRunner.query(`ALTER TABLE "listings" ADD "what_to_expect" text`)
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "listings" DROP COLUMN "what_to_expect"`)
await queryRunner.query(`ALTER TABLE "listings" ADD "what_to_expect" jsonb`)
}
}
6 changes: 1 addition & 5 deletions backend/core/src/seeds/listings/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,7 @@ export const defaultListing: ListingSeedType = {
waitlistOpenSpots: null,
isWaitlistOpen: false,
waitlistMaxSize: null,
whatToExpect: {
allInfoWillBeVerified: "Custom all info will be verified text",
applicantsWillBeContacted: "Custom applicant will be contacted text",
bePreparedIfChosen: "Custom be prepared if chosen text",
},
whatToExpect: "Custom what to expect text",
}

// Preferences
Expand Down
15 changes: 0 additions & 15 deletions backend/core/src/shared/dto/whatToExpect.dto.ts

This file was deleted.

6 changes: 1 addition & 5 deletions backend/core/types/src/archer-listing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,11 +580,7 @@ export const ArcherListing: Listing = {
countyCode: CountyCode.Alameda,
events: [],
urlSlug: "listing-slug-abcdef",
whatToExpect: {
allInfoWillBeVerified: "",
applicantsWillBeContacted: "",
bePreparedIfChosen: "",
},
whatToExpect: null,
status: ListingStatus.active,
applicationAddress: {
id: "id",
Expand Down
18 changes: 3 additions & 15 deletions backend/core/types/src/backend-swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4063,17 +4063,6 @@ export interface UnitsSummarized {
hmi: HMI
}

export interface WhatToExpect {
/** */
applicantsWillBeContacted?: string

/** */
allInfoWillBeVerified?: string

/** */
bePreparedIfChosen?: string
}

export interface Listing {
/** */
applicationPickUpAddressType?: ListingApplicationAddressType
Expand Down Expand Up @@ -4289,7 +4278,7 @@ export interface Listing {
waitlistMaxSize?: number

/** */
whatToExpect?: CombinedWhatToExpectTypes
whatToExpect?: string

/** */
applicationConfig?: object
Expand Down Expand Up @@ -4623,7 +4612,7 @@ export interface ListingCreate {
waitlistMaxSize?: number

/** */
whatToExpect?: CombinedWhatToExpectTypes
whatToExpect?: string

/** */
applicationConfig?: object
Expand Down Expand Up @@ -4987,7 +4976,7 @@ export interface ListingUpdate {
waitlistMaxSize?: number

/** */
whatToExpect?: CombinedWhatToExpectTypes
whatToExpect?: string

/** */
applicationConfig?: object
Expand Down Expand Up @@ -5463,5 +5452,4 @@ export type CombinedImageTypes = AssetCreate
export type CombinedLeasingAgentAddressTypes = AddressUpdate
export type CombinedResultTypes = AssetCreate
export type CombinedUserRolesTypes = UserRoles
export type CombinedWhatToExpectTypes = WhatToExpect
export type CombinedJurisdictionTypes = Id
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { useContext } from "react"
import moment from "moment"
import { t, GridSection, ViewItem } from "@bloom-housing/ui-components"
import { t, GridSection, ViewItem, GridCell } from "@bloom-housing/ui-components"
import { ListingContext } from "../../ListingContext"
import { getLotteryEvent } from "../../../../lib/helpers"
import { EnumListingReviewOrderType } from "@bloom-housing/backend-core/types"
import { getDetailFieldNumber } from "./helpers"
import { getDetailFieldNumber, getDetailFieldString } from "./helpers"

const DetailRankingsAndResults = () => {
const listing = useContext(ListingContext)
Expand Down Expand Up @@ -81,6 +81,13 @@ const DetailRankingsAndResults = () => {
</ViewItem>
</GridSection>
)}
<GridSection columns={1}>
<GridCell>
<ViewItem label={t("listings.whatToExpectLabel")}>
{getDetailFieldString(listing.whatToExpect)}
</ViewItem>
</GridCell>
</GridSection>
</GridSection>
)
}
Expand Down
7 changes: 2 additions & 5 deletions sites/partners/src/listings/PaperListingForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,8 @@ const defaults: FormListing = {
waitlistMaxSize: null,
isWaitlistOpen: null,
waitlistOpenSpots: null,
whatToExpect: {
applicantsWillBeContacted: "",
allInfoWillBeVerified: "",
bePreparedIfChosen: "",
},
whatToExpect:
"Applicants will be contacted by the property agent in rank order until vacancies are filled. All of the information that you have provided will be verified and your eligibility confirmed. Your application will be removed from the waitlist if you have made any fraudulent statements. If we cannot verify a housing preference that you have claimed, you will not receive the preference but will not be otherwise penalized. Should your application be chosen, be prepared to fill out a more detailed application and provide required supporting documents.",
units: [],
accessibility: "",
amenities: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,18 @@ const RankingsAndResults = ({ listing }: RankingsAndResultsProps) => {
/>
</GridSection>
)}
<GridSection columns={3}>
<GridCell span={2}>
<Textarea
label={t("listings.whatToExpectLabel")}
name={"whatToExpect"}
id={"whatToExpect"}
fullWidth={true}
register={register}
maxLength={600}
/>
</GridCell>
</GridSection>
</GridSection>
</div>
)
Expand Down
14 changes: 4 additions & 10 deletions ui-components/__tests__/page_components/WhatToExpect.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,13 @@ afterEach(cleanup)
describe("<WhatToExpect>", () => {
it("renders with default what-to-expects", () => {
const { getByText } = render(<WhatToExpect listing={archer} />)
expect(getByText(t("whatToExpect.applicantsWillBeContacted"))).toBeTruthy()
expect(getByText(t("whatToExpect.allInfoWillBeVerified"))).toBeTruthy()
expect(getByText(t("whatToExpect.bePreparedIfChosen"))).toBeTruthy()
expect(getByText(t("whatToExpect.default"))).toBeTruthy()
})
it("renders with custom what-to-expects", () => {
const newListing = archer
newListing.whatToExpect = {}
newListing.whatToExpect.applicantsWillBeContacted = "Applicants Custom"
newListing.whatToExpect.allInfoWillBeVerified = "Info Verified Custom"
newListing.whatToExpect.bePreparedIfChosen = "Be Prepared Custom"
newListing.whatToExpect = "Custom what to expect text"

const { getByText } = render(<WhatToExpect listing={archer} />)
expect(getByText("Applicants Custom")).toBeTruthy()
expect(getByText("Info Verified Custom")).toBeTruthy()
expect(getByText("Be Prepared Custom")).toBeTruthy()
expect(getByText("Custom what to expect text")).toBeTruthy()
})
})
4 changes: 1 addition & 3 deletions ui-components/src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -740,8 +740,6 @@
},
"whatToExpect": {
"label": "Lo que puede esperar",
"applicantsWillBeContacted": "Los solicitantes serán contactados por el agente de la propiedad en orden de clasificación hasta que se hayan llenado todas las vacantes.",
"allInfoWillBeVerified": "Toda la información que usted ha proporcionado será verificada y su elegibilidad será confirmada. Su solicitud será retirada de la lista de espera si usted hizo alguna declaración fraudulenta. Si nos es imposible verificar una preferencia de vivienda que usted haya solicitado, no recibirá la preferencia pero no será penalizado de ninguna otra manera.",
"bePreparedIfChosen": "Si su solicitud fuera elegida, esté preparado para llenar una solicitud más detallada y proporcionar los documentos de apoyo requeridos."
"default": "Los solicitantes serán contactados por el agente de la propiedad en orden de clasificación hasta que se hayan llenado todas las vacantes. Toda la información que usted ha proporcionado será verificada y su elegibilidad será confirmada. Su solicitud será retirada de la lista de espera si usted hizo alguna declaración fraudulenta. Si nos es imposible verificar una preferencia de vivienda que usted haya solicitado, no recibirá la preferencia pero no será penalizado de ninguna otra manera. Si su solicitud fuera elegida, esté preparado para llenar una solicitud más detallada y proporcionar los documentos de apoyo requeridos."
}
}
5 changes: 2 additions & 3 deletions ui-components/src/locales/general.json
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,7 @@
"submitForWaitlist": "Submit an application for an open slot on the waitlist.",
"unitsAndWaitlist": "Available Units and Waitlist"
},
"whatToExpectLabel": "Tell the applicant what to expect from the process",
"whereDropOffQuestion": "Where are applications dropped off?",
"wherePickupQuestion": "Where are applications picked up?",
"yearBuilt": "Year Built",
Expand Down Expand Up @@ -1263,8 +1264,6 @@
},
"whatToExpect": {
"label": "What to Expect",
"applicantsWillBeContacted": "Applicants will be contacted by the property agent in rank order until vacancies are filled.",
"allInfoWillBeVerified": "All of the information that you have provided will be verified and your eligibility confirmed. Your application will be removed from the waitlist if you have made any fraudulent statements. If we cannot verify a housing preference that you have claimed, you will not receive the preference but will not be otherwise penalized.",
"bePreparedIfChosen": "Should your application be chosen, be prepared to fill out a more detailed application and provide required supporting documents."
"default": "Applicants will be contacted by the property agent in rank order until vacancies are filled. All of the information that you have provided will be verified and your eligibility confirmed. Your application will be removed from the waitlist if you have made any fraudulent statements. If we cannot verify a housing preference that you have claimed, you will not receive the preference but will not be otherwise penalized. Should your application be chosen, be prepared to fill out a more detailed application and provide required supporting documents."
}
}
4 changes: 1 addition & 3 deletions ui-components/src/locales/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,6 @@
},
"whatToExpect": {
"label": "Những điều Sẽ xảy ra",
"applicantsWillBeContacted": "Các ứng viên sẽ được nhân viên đại diện bất động sản liên lạc theo thứ tự xếp hạng cho đến khi hết chỗ trống.",
"allInfoWillBeVerified": "Tất cả thông tin quý vị đã cung cấp sẽ được xác nhận và xác nhận tình trạng điều kiện hội đủ của quý vị. Đơn ghi danh của quý vị sẽ bị xóa khỏi danh sách chờ nếu quý vị có bất kỳ tuyên bố sai sự thật nào. Nếu chúng tôi không thể xác nhận lựa chọn ưu tiên nhà ở mà quý vị đã yêu cầu, quý vị sẽ không nhận được lựa chọn ưu tiên đó nhưng sẽ không bị phạt.",
"bePreparedIfChosen": "Nếu đơn ghi danh của quý vị được chọn, hãy chuẩn bị để điền vào mẫu đơn chi tiết hơn và cung cấp các tài liệu hỗ trợ cần thiết."
"default": "Các ứng viên sẽ được nhân viên đại diện bất động sản liên lạc theo thứ tự xếp hạng cho đến khi hết chỗ trống. Tất cả thông tin quý vị đã cung cấp sẽ được xác nhận và xác nhận tình trạng điều kiện hội đủ của quý vị. Đơn ghi danh của quý vị sẽ bị xóa khỏi danh sách chờ nếu quý vị có bất kỳ tuyên bố sai sự thật nào. Nếu chúng tôi không thể xác nhận lựa chọn ưu tiên nhà ở mà quý vị đã yêu cầu, quý vị sẽ không nhận được lựa chọn ưu tiên đó nhưng sẽ không bị phạt. Nếu đơn ghi danh của quý vị được chọn, hãy chuẩn bị để điền vào mẫu đơn chi tiết hơn và cung cấp các tài liệu hỗ trợ cần thiết."
}
}
4 changes: 1 addition & 3 deletions ui-components/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,6 @@
},
"whatToExpect": {
"label": "預期事項",
"applicantsWillBeContacted": "物業經紀人將按排名次序聯絡申請人,直到沒有空缺為止。",
"allInfoWillBeVerified": "您提供的所有資料都會受到查證,以確定您的資格。如果您作出任何不實陳述,則您的申請會從候補名單被刪除。如果我們無法證實您要求的住房優先權,您將不會獲得該優先權,但不會受到其他處罰。",
"bePreparedIfChosen": "若您的申請被選中,請準備填寫一份更加詳盡的申請表,並提供所需的證明文件。"
"default": "物業經紀人將按排名次序聯絡申請人,直到沒有空缺為止。您提供的所有資料都會受到查證,以確定您的資格。如果您作出任何不實陳述,則您的申請會從候補名單被刪除。如果我們無法證實您要求的住房優先權,您將不會獲得該優先權,但不會受到其他處罰。若您的申請被選中,請準備填寫一份更加詳盡的申請表,並提供所需的證明文件。"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,13 @@ interface WhatToExpectProps {

const WhatToExpect = (props: WhatToExpectProps) => {
const listing = props.listing
let applicantsWillBeContacted = listing.whatToExpect?.applicantsWillBeContacted
let allInfoWillBeVerified = listing.whatToExpect?.allInfoWillBeVerified
let bePreparedIfChosen = listing.whatToExpect?.bePreparedIfChosen

applicantsWillBeContacted =
applicantsWillBeContacted || applicantsWillBeContacted == ""
? applicantsWillBeContacted
: t("whatToExpect.applicantsWillBeContacted")

allInfoWillBeVerified =
allInfoWillBeVerified || allInfoWillBeVerified == ""
? allInfoWillBeVerified
: t("whatToExpect.allInfoWillBeVerified")

bePreparedIfChosen =
bePreparedIfChosen || bePreparedIfChosen == ""
? bePreparedIfChosen
: t("whatToExpect.bePreparedIfChosen")

return (
<section className="aside-block">
<h4 className="text-caps-underline">{t("whatToExpect.label")}</h4>
<p className="text-tiny text-gray-800">{applicantsWillBeContacted}</p>
<details className="disclosure">
<summary>read more</summary>
<p className="text-tiny text-gray-800">{allInfoWillBeVerified}</p>
<p className="text-tiny text-gray-800">{bePreparedIfChosen}</p>
</details>
<p className="text-tiny text-gray-800">
{listing.whatToExpect ? listing.whatToExpect : t("whatToExpect.default")}
</p>
</section>
)
}
Expand Down

0 comments on commit 2e744e8

Please sign in to comment.