diff --git a/api/prisma/seed-staging.ts b/api/prisma/seed-staging.ts index 1f02bdbc93..293df7563b 100644 --- a/api/prisma/seed-staging.ts +++ b/api/prisma/seed-staging.ts @@ -55,6 +55,7 @@ export const stagingSeed = async ( FeatureFlagEnum.enableGeocodingRadiusMethod, FeatureFlagEnum.enableHomeType, FeatureFlagEnum.enableIsVerified, + FeatureFlagEnum.enableLeasingAgentAltText, FeatureFlagEnum.enableListingFavoriting, FeatureFlagEnum.enableListingFiltering, FeatureFlagEnum.enableListingOpportunity, @@ -103,6 +104,7 @@ export const stagingSeed = async ( FeatureFlagEnum.enableHomeType, FeatureFlagEnum.enableIsVerified, FeatureFlagEnum.enableLimitedHowDidYouHear, + FeatureFlagEnum.enableLeasingAgentAltText, FeatureFlagEnum.enableListingFavoriting, FeatureFlagEnum.enableListingFiltering, FeatureFlagEnum.enableListingOpportunity, @@ -140,6 +142,7 @@ export const stagingSeed = async ( featureFlags: [ FeatureFlagEnum.enableGeocodingPreferences, FeatureFlagEnum.enableGeocodingRadiusMethod, + FeatureFlagEnum.enableLeasingAgentAltText, FeatureFlagEnum.enableListingFiltering, FeatureFlagEnum.enableListingOpportunity, FeatureFlagEnum.enableListingPagination, @@ -165,6 +168,7 @@ export const stagingSeed = async ( FeatureFlagEnum.enableApplicationStatus, FeatureFlagEnum.enableCreditScreeningFee, FeatureFlagEnum.enableHousingDeveloperOwner, + FeatureFlagEnum.enableLeasingAgentAltText, FeatureFlagEnum.enableListingFileNumber, FeatureFlagEnum.enableListingFiltering, FeatureFlagEnum.enableListingImageAltText, diff --git a/api/src/enums/feature-flags/feature-flags-enum.ts b/api/src/enums/feature-flags/feature-flags-enum.ts index ad6e075b6c..31b8e97348 100644 --- a/api/src/enums/feature-flags/feature-flags-enum.ts +++ b/api/src/enums/feature-flags/feature-flags-enum.ts @@ -23,6 +23,7 @@ export enum FeatureFlagEnum { enableListingFavoriting = 'enableListingFavoriting', enableListingFileNumber = 'enableListingFileNumber', enableListingFiltering = 'enableListingFiltering', + enableLeasingAgentAltText = 'enableLeasingAgentAltText', enableListingImageAltText = 'enableListingImageAltText', enableListingOpportunity = 'enableListingOpportunity', enableListingPagination = 'enableListingPagination', @@ -163,6 +164,10 @@ export const featureFlagMap: { description: 'When true, a filter button is shown on listings browse and users can filter with the options in the drawer', }, + { + name: FeatureFlagEnum.enableLeasingAgentAltText, + description: 'When true, shows alternative text for LA users', + }, { name: FeatureFlagEnum.enableListingImageAltText, description: 'When true, allows partners to add alt text to listing images', diff --git a/api/src/services/listing-csv-export.service.ts b/api/src/services/listing-csv-export.service.ts index 307f8d9d25..f097abb30e 100644 --- a/api/src/services/listing-csv-export.service.ts +++ b/api/src/services/listing-csv-export.service.ts @@ -1080,7 +1080,12 @@ export class ListingCsvExporterService implements CsvExporterServiceInterface { ...[ { path: 'leasingAgentName', - label: 'Leasing Agent Name', + label: doAnyJurisdictionHaveFeatureFlagSet( + user.jurisdictions, + FeatureFlagEnum.enableLeasingAgentAltText, + ) + ? 'Leasing agent or property manager name' + : 'Leasing Agent Name', }, { path: 'leasingAgentEmail', @@ -1092,7 +1097,12 @@ export class ListingCsvExporterService implements CsvExporterServiceInterface { }, { path: 'leasingAgentTitle', - label: 'Leasing Agent Title', + label: doAnyJurisdictionHaveFeatureFlagSet( + user.jurisdictions, + FeatureFlagEnum.enableLeasingAgentAltText, + ) + ? 'Leasing agent or property manager title' + : 'Leasing Agent Title', }, { path: 'leasingAgentOfficeHours', diff --git a/shared-helpers/src/locales/ar.json b/shared-helpers/src/locales/ar.json index 343dea8a0a..e06a7bfbcd 100644 --- a/shared-helpers/src/locales/ar.json +++ b/shared-helpers/src/locales/ar.json @@ -636,6 +636,7 @@ "languages.vi": "Tiếng Việt", "languages.zh": "中文", "leasingAgent.contact": "اتصل بوكيل التأجير", + "leasingAgent.contactManagerProp": "اتصل بوكيل التأجير أو مدير الممتلكات", "leasingAgent.dueToHighCallVolume": "نظرًا لارتفاع حجم المكالمات ، قد تسمع رسالة.", "leasingAgent.officeHours": "ساعات العمل", "listingFilters.clear": "مسح", diff --git a/shared-helpers/src/locales/bn.json b/shared-helpers/src/locales/bn.json index ab04cbf6ea..4f21831437 100644 --- a/shared-helpers/src/locales/bn.json +++ b/shared-helpers/src/locales/bn.json @@ -636,6 +636,7 @@ "languages.vi": "Tiếng Việt", "languages.zh": "中文", "leasingAgent.contact": "লিজিং এজেন্টের সাথে যোগাযোগ করুন", + "leasingAgent.contactManagerProp": "লিজিং এজেন্ট বা সম্পত্তি ব্যবস্থাপকের সাথে যোগাযোগ করুন", "leasingAgent.dueToHighCallVolume": "উচ্চ কল ভলিউমের কারণে আপনি একটি বার্তা শুনতে পারেন।", "leasingAgent.officeHours": "অফিস সময়সূচী", "listingFilters.clear": "পরিষ্কার", diff --git a/shared-helpers/src/locales/es.json b/shared-helpers/src/locales/es.json index adb79d7a24..54c47b8996 100644 --- a/shared-helpers/src/locales/es.json +++ b/shared-helpers/src/locales/es.json @@ -636,6 +636,7 @@ "languages.vi": "Tiếng Việt", "languages.zh": "中文", "leasingAgent.contact": "Comuníquese con el agente de alquiler", + "leasingAgent.contactManagerProp": "Comuníquese con el agente de arrendamiento o el administrador de la propiedad", "leasingAgent.dueToHighCallVolume": "Debido al alto volumen de llamadas, usted podría escuchar un mensaje.", "leasingAgent.officeHours": "Horario de oficina", "listingFilters.clear": "Borrar", diff --git a/shared-helpers/src/locales/general.json b/shared-helpers/src/locales/general.json index 786c8a3a57..1a8c79e369 100644 --- a/shared-helpers/src/locales/general.json +++ b/shared-helpers/src/locales/general.json @@ -633,6 +633,7 @@ "languages.vi": "Tiếng Việt", "languages.zh": "中文", "leasingAgent.contact": "Contact leasing agent", + "leasingAgent.contactManagerProp": "Contact leasing agent or property manager", "leasingAgent.dueToHighCallVolume": "Due to high call volume you may hear a message.", "leasingAgent.officeHours": "Office hours", "listingFilters.clear": "Clear", diff --git a/shared-helpers/src/locales/tl.json b/shared-helpers/src/locales/tl.json index 449c128816..93c9d0099f 100644 --- a/shared-helpers/src/locales/tl.json +++ b/shared-helpers/src/locales/tl.json @@ -636,6 +636,7 @@ "languages.vi": "Tiếng Việt", "languages.zh": "中文", "leasingAgent.contact": "Makipag-ugnayan sa ahente sa pagpapaupa", + "leasingAgent.contactManagerProp": "Makipag-ugnayan sa ahente sa pagpapaupa o tagapamahala ng ari-arian", "leasingAgent.dueToHighCallVolume": "Dahil maraming tumatawag maaari kang makarinig ng mensahe.", "leasingAgent.officeHours": "Oras ng opisina", "listingFilters.clear": "Maaliwalas", diff --git a/shared-helpers/src/locales/vi.json b/shared-helpers/src/locales/vi.json index da6646fd47..275d1d573e 100644 --- a/shared-helpers/src/locales/vi.json +++ b/shared-helpers/src/locales/vi.json @@ -636,6 +636,7 @@ "languages.vi": "Tiếng Việt", "languages.zh": "中文", "leasingAgent.contact": "Liên hệ với đại lý cho thuê", + "leasingAgent.contactManagerProp": "Liên hệ với đại lý cho thuê hoặc người quản lý tài sản", "leasingAgent.dueToHighCallVolume": "Do có nhiều cuộc gọi đến, quý vị có thể nghe thấy một lời nhắn.", "leasingAgent.officeHours": "Giờ làm việc", "listingFilters.clear": "Xóa", diff --git a/shared-helpers/src/locales/zh.json b/shared-helpers/src/locales/zh.json index ea0a7f2167..4ba548fc29 100644 --- a/shared-helpers/src/locales/zh.json +++ b/shared-helpers/src/locales/zh.json @@ -636,6 +636,7 @@ "languages.vi": "Tiếng Việt", "languages.zh": "中文", "leasingAgent.contact": "联系租赁代理", + "leasingAgent.contactManagerProp": "聯絡租賃代理或物業經理", "leasingAgent.dueToHighCallVolume": "由於來電人數眾多,您可能會聽到訊息留言。", "leasingAgent.officeHours": "办公时间", "listingFilters.clear": "清除", diff --git a/shared-helpers/src/types/backend-swagger.ts b/shared-helpers/src/types/backend-swagger.ts index bbc83a7444..b91a410fdc 100644 --- a/shared-helpers/src/types/backend-swagger.ts +++ b/shared-helpers/src/types/backend-swagger.ts @@ -8674,6 +8674,7 @@ export enum FeatureFlagEnum { "enableListingFavoriting" = "enableListingFavoriting", "enableListingFileNumber" = "enableListingFileNumber", "enableListingFiltering" = "enableListingFiltering", + "enableLeasingAgentAltText" = "enableLeasingAgentAltText", "enableListingImageAltText" = "enableListingImageAltText", "enableListingOpportunity" = "enableListingOpportunity", "enableListingPagination" = "enableListingPagination", diff --git a/sites/partners/page_content/locale_overrides/general.json b/sites/partners/page_content/locale_overrides/general.json index 1604caa661..361372274a 100644 --- a/sites/partners/page_content/locale_overrides/general.json +++ b/sites/partners/page_content/locale_overrides/general.json @@ -168,9 +168,11 @@ "flags.updateStatus": "Update status", "flags.combindationRule": "%{email} - %{name}: Email + Name + DOB", "leasingAgent.name": "Leasing agent name", + "leasingAgent.ManagerPropName": "Leasing agent or property manager name", "leasingAgent.namePlaceholder": "Full name", "leasingAgent.officeHoursPlaceholder": "ex: 9:00am - 5:00pm, Monday to Friday", "leasingAgent.title": "Leasing agent title", + "leasingAgent.leasingAgentManagerPropTitle": "Leasing agent or property manager title", "leasingAgent.managementWebsite": "Company website", "leasingAgent.managementWebsitePlaceholder": "https://www.google.com", "listings.actions.close": "Close", @@ -271,6 +273,7 @@ "listings.areReferralOnlyUnits": "Are there units set aside for referral only?", "listings.latitude": "Latitude", "listings.leasingAgentAddress": "Leasing agent address", + "listings.leasingAgentAddressManagerProp": "Leasing agent or property manager address", "listings.listingAvailabilityQuestion": "What is the listing availability?", "listings.listingIsAlreadyLive": "This listing is already live. Updates will affect the applicant experience on the housing portal.", "listings.listingTypeTitle": "What kind of listing is this?", @@ -425,7 +428,10 @@ "listings.sections.introSubtitle": "Let's get started with some basic information about your listing.", "listings.sections.introTitle": "Listing intro", "listings.sections.leasingAgentSubtitle": "Provide details about the leasing agent who will be managing the application process.", + "listings.sections.leasingAgentManagerPropSubtitle": "Provide details about the leasing agent or property manager who will be managing the application process.", "listings.sections.leasingAgentTitle": "Leasing agent", + "listings.sections.leasingAgentManagerPropTitle": "Leasing agent or property manager title", + "listings.sections.leasingAgentManagerPropSectionTitle": "Leasing agent or property manager", "listings.sections.lotteryResultsAdd": "Add results", "listings.sections.lotteryResultsEdit": "Edit results", "listings.sections.lotteryResultsHelperText": "Upload results", diff --git a/sites/partners/src/components/listings/PaperListingDetails/sections/DetailApplicationAddress.tsx b/sites/partners/src/components/listings/PaperListingDetails/sections/DetailApplicationAddress.tsx index 99bdf36e88..300b835325 100644 --- a/sites/partners/src/components/listings/PaperListingDetails/sections/DetailApplicationAddress.tsx +++ b/sites/partners/src/components/listings/PaperListingDetails/sections/DetailApplicationAddress.tsx @@ -5,6 +5,8 @@ import { ListingContext } from "../../ListingContext" import { getDetailFieldString, getDetailFieldTime, getDetailAddress } from "./helpers" import dayjs from "dayjs" import SectionWithGrid from "../../../shared/SectionWithGrid" +import { FeatureFlagEnum } from "@bloom-housing/shared-helpers/src/types/backend-swagger" +import { AuthContext } from "@bloom-housing/shared-helpers" const DetailApplicationAddress = () => { const listing = useContext(ListingContext) @@ -13,6 +15,16 @@ const DetailApplicationAddress = () => { return date ? dayjs(new Date(date)).format("MM/DD/YYYY") : t("t.none") } + const { doJurisdictionsHaveFeatureFlagOn } = useContext(AuthContext) + + const enableLeasingAgentAltText = doJurisdictionsHaveFeatureFlagOn( + FeatureFlagEnum.enableLeasingAgentAltText, + listing.jurisdictions.id + ) + const leasingAgentAddressText = enableLeasingAgentAltText + ? t("listings.leasingAgentAddressManagerProp") + : t("listings.leasingAgentAddress") + return ( @@ -33,7 +45,7 @@ const DetailApplicationAddress = () => { className="seeds-grid-span-2" label={t("listings.applicationAddress.mailApplicationType")} > - {t("listings.leasingAgentAddress")} + {leasingAgentAddressText} )} @@ -65,7 +77,7 @@ const DetailApplicationAddress = () => { className="seeds-grid-span-2" label={t("listings.wherePickupQuestion")} > - {t("listings.leasingAgentAddress")} + {leasingAgentAddressText} )} @@ -111,7 +123,7 @@ const DetailApplicationAddress = () => { className="seeds-grid-span-2" label={t("listings.whereDropOffQuestion")} > - {t("listings.leasingAgentAddress")} + {leasingAgentAddressText} )} diff --git a/sites/partners/src/components/listings/PaperListingDetails/sections/DetailLeasingAgent.tsx b/sites/partners/src/components/listings/PaperListingDetails/sections/DetailLeasingAgent.tsx index 394e616db3..798cd3f956 100644 --- a/sites/partners/src/components/listings/PaperListingDetails/sections/DetailLeasingAgent.tsx +++ b/sites/partners/src/components/listings/PaperListingDetails/sections/DetailLeasingAgent.tsx @@ -16,11 +16,28 @@ const DetailLeasingAgent = () => { listing.jurisdictions.id ) + const enableLeasingAgentAltText = doJurisdictionsHaveFeatureFlagOn( + FeatureFlagEnum.enableLeasingAgentAltText, + listing.jurisdictions.id + ) + + const leasingAgentNameText = enableLeasingAgentAltText + ? t("leasingAgent.ManagerPropName") + : t("leasingAgent.name") + + const leasingAgentTitleText = enableLeasingAgentAltText + ? t("listings.sections.leasingAgentManagerPropTitle") + : t("listings.sections.leasingAgentTitle") + + const leasingAgentAddressText = enableLeasingAgentAltText + ? t("listings.leasingAgentAddressManagerProp") + : t("listings.leasingAgentAddress") + return ( - + - + {getDetailFieldString(listing.leasingAgentName)} @@ -65,7 +82,7 @@ const DetailLeasingAgent = () => { {getDetailAddress( listing.listingsLeasingAgentAddress, "leasingAgentAddress", - t("listings.leasingAgentAddress") + leasingAgentAddressText )} ) diff --git a/sites/partners/src/components/listings/PaperListingForm/index.tsx b/sites/partners/src/components/listings/PaperListingForm/index.tsx index 6e7b58a005..1f8d273ef0 100644 --- a/sites/partners/src/components/listings/PaperListingForm/index.tsx +++ b/sites/partners/src/components/listings/PaperListingForm/index.tsx @@ -482,7 +482,6 @@ const ListingForm = ({ enableUnitGroups, ] ) - return loading === true ? null : ( <> diff --git a/sites/partners/src/components/listings/PaperListingForm/sections/LeasingAgent.tsx b/sites/partners/src/components/listings/PaperListingForm/sections/LeasingAgent.tsx index 8706816dc3..2f0ae3fc1c 100644 --- a/sites/partners/src/components/listings/PaperListingForm/sections/LeasingAgent.tsx +++ b/sites/partners/src/components/listings/PaperListingForm/sections/LeasingAgent.tsx @@ -1,8 +1,8 @@ -import React, { useEffect, useState } from "react" +import React, { useEffect, useState, useContext } from "react" import { useFormContext } from "react-hook-form" import { t, Textarea, Field, PhoneField, Select } from "@bloom-housing/ui-components" import { Grid } from "@bloom-housing/ui-seeds" -import { stateKeys } from "@bloom-housing/shared-helpers" +import { AuthContext, stateKeys } from "@bloom-housing/shared-helpers" import { fieldMessage, defaultFieldProps, @@ -11,6 +11,8 @@ import { getAddressErrorMessage, } from "../../../../lib/helpers" import SectionWithGrid from "../../../shared/SectionWithGrid" +import { ListingContext } from "../../ListingContext" +import { FeatureFlagEnum } from "@bloom-housing/shared-helpers/src/types/backend-swagger" type LeasingAgentProps = { enableCompanyWebsite?: boolean @@ -19,6 +21,8 @@ type LeasingAgentProps = { const LeasingAgent = (props: LeasingAgentProps) => { const formMethods = useFormContext() + const listing = useContext(ListingContext) + const { doJurisdictionsHaveFeatureFlagOn } = useContext(AuthContext) // eslint-disable-next-line @typescript-eslint/unbound-method const { register, control, errors, clearErrors, watch, getValues } = formMethods @@ -47,20 +51,42 @@ const LeasingAgent = (props: LeasingAgentProps) => { ) } + const enableLeasingAgentAltText = doJurisdictionsHaveFeatureFlagOn( + FeatureFlagEnum.enableLeasingAgentAltText, + listing?.jurisdictions?.id + ) + + const leasingAgentNameText = enableLeasingAgentAltText + ? t("leasingAgent.ManagerPropName") + : t("leasingAgent.name") + + const leasingAgentSectionTitleText = enableLeasingAgentAltText + ? t("listings.sections.leasingAgentManagerPropSectionTitle") + : t("listings.sections.leasingAgentTitle") + + const leasingAgentTitleText = enableLeasingAgentAltText + ? t("leasingAgent.leasingAgentManagerPropTitle") + : t("leasingAgent.title") + + const leasingAgentSubtitleText = enableLeasingAgentAltText + ? t("listings.sections.leasingAgentManagerPropSubtitle") + : t("listings.sections.leasingAgentSubtitle") + + const leasingAgentAddressText = enableLeasingAgentAltText + ? t("listings.leasingAgentAddressManagerProp") + : t("listings.leasingAgentAddress") + return ( <>
- + { register={register} {...defaultFieldProps( "leasingAgentTitle", - t("leasingAgent.title"), + leasingAgentTitleText, props.requiredFields, errors, clearErrors @@ -137,7 +163,7 @@ const LeasingAgent = (props: LeasingAgentProps) => { /> - Leasing Agent Address + {t(leasingAgentAddressText)} ", () => { it("shows error state if listing is null", () => { @@ -15,19 +16,33 @@ describe("", () => { }) it("shows listing name if listing is defined", () => { - const view = render() + const view = render( + true, + }} + > + + + ) expect(view.getByRole("heading", { level: 1 })).toHaveTextContent(listing.name) }) it("renders markdown in what to expect", () => { const view = render( -
If you are interested in applying for this property, please get in touch in one of these ways:
  • Phone
  • Email
  • In-person
  • In some instances, the property has a link directly to an application
Once you contact a property, ask if they have any available units if you are looking to move in immediately.
Waitlists:
If none are available, but you are still interested in eventually living at the property, ask how you can be placed on their waitlist.
`, + true, }} - jurisdiction={jurisdiction} - /> + > +
If you are interested in applying for this property, please get in touch in one of these ways:
  • Phone
  • Email
  • In-person
  • In some instances, the property has a link directly to an application
Once you contact a property, ask if they have any available units if you are looking to move in immediately.
Waitlists:
If none are available, but you are still interested in eventually living at the property, ask how you can be placed on their waitlist.
`, + }} + jurisdiction={jurisdiction} + /> + ) expect(view.queryByText("<", { exact: false })).toBeNull() // There are two instances for Desktop vs Mobile @@ -38,19 +53,25 @@ describe("", () => { it("does not renders what to expect additional field when feature flag off", () => { render( - true, }} - /> + > + + ) expect(screen.getAllByText("Normal What to expect")).toHaveLength(2) expect(screen.queryAllByText("What to expect additional text")).toHaveLength(0) @@ -59,29 +80,35 @@ describe("", () => { it("does not renders read more when whatToExpectAdditionalText does not exist", () => { render( - true, }} - jurisdiction={{ - ...jurisdiction, - featureFlags: [ - { - name: FeatureFlagEnum.enableWhatToExpectAdditionalField, - id: "id", - createdAt: new Date(), - updatedAt: new Date(), - active: true, - description: "", - jurisdictions: [], - }, - ], - }} - /> + > + + ) expect(screen.getAllByText("Normal What to expect")).toHaveLength(2) expect(screen.queryAllByRole("button", { name: "read more" })).toHaveLength(0) @@ -89,30 +116,36 @@ describe("", () => { it("renders what to expect additional field when feature flag on", () => { render( - true, }} - /> + > + + ) // There are two instances, one for desktop and one for mobile expect(screen.getAllByText("Normal What to expect")).toHaveLength(2) @@ -125,61 +158,81 @@ describe("", () => { }) it("doesn't show listing updated at for a default jurisdiction", () => { - const view = render() + const view = render( + true, + }} + > + + + ) expect(view.queryByText("Listing updated: Dec 31, 2019")).toBeNull() }) it("shows listing updated at when the jurisdiction allows it", () => { const view = render( - true, }} - /> + > + + ) expect(view.getAllByText("Listing updated: Dec 31, 2019")).toHaveLength(2) }) it("should render positive HUD EBLL clearance for non-regulated listing", () => { render( - true, }} - /> + > + + ) expect(screen.getByRole("heading", { level: 3, name: /^other$/i })).toBeInTheDocument() @@ -191,31 +244,37 @@ describe("", () => { it("should render negative HUD EBLL clearance for non-regulated listing", () => { render( - true, }} - jurisdiction={{ - ...jurisdiction, - featureFlags: [ - { - id: "test_id", - name: FeatureFlagEnum.enableNonRegulatedListings, - active: true, - createdAt: new Date(), - updatedAt: new Date(), - description: "", - jurisdictions: [], - }, - ], - }} - /> + > + + ) expect(screen.getByRole("heading", { level: 3, name: /^other$/i })).toBeInTheDocument() @@ -229,31 +288,37 @@ describe("", () => { it("doesnt render HUD EBLL clearance when non regulated listings feature flag is turned off", () => { render( - true, }} - /> + > + + ) expect(screen.queryByRole("heading", { level: 3, name: /^other$/i })).not.toBeInTheDocument() @@ -267,31 +332,37 @@ describe("", () => { it("doesnt render HUD EBLL clearance when listing is regulated", () => { render( - true, }} - /> + > + + ) expect(screen.queryByRole("heading", { level: 3, name: /^other$/i })).not.toBeInTheDocument() diff --git a/sites/public/__tests__/components/listing/listing_sections/LeasingAgent.test.tsx b/sites/public/__tests__/components/listing/listing_sections/LeasingAgent.test.tsx index bdc2a1c31e..c01255f140 100644 --- a/sites/public/__tests__/components/listing/listing_sections/LeasingAgent.test.tsx +++ b/sites/public/__tests__/components/listing/listing_sections/LeasingAgent.test.tsx @@ -5,56 +5,137 @@ import { formatPhone, LeasingAgent, } from "../../../../src/components/listing/listing_sections/LeasingAgent" +import { listing } from "@bloom-housing/shared-helpers/__tests__/testHelpers" +import { AuthContext } from "@bloom-housing/shared-helpers" +import { screen } from "../../../testUtils" afterEach(cleanup) describe("", () => { it("shows nothing if no content passed", () => { - const { queryByText } = render() - expect(queryByText("Leasing Agent")).toBeNull() + render( + true, + }} + > + + + ) + expect(screen.queryByText("Leasing Agent")).toBeNull() + }) + + it("shows all content enableLeasingAgentAltText on", () => { + const phoneNumber = "(123) 456-7890" + render( + true, + }} + > + + + ) + + expect(screen.getByRole("link", { name: "Website" })).toHaveAttribute( + "href", + "https://example.com" + ) + expect(screen.getByText("Agent Name")).toBeInTheDocument() + expect(screen.getByText("Agent title")).toBeInTheDocument() + expect(screen.getByRole("link", { name: `Call ${phoneNumber}` })).toHaveAttribute( + "href", + "tel:1234567890" + ) + expect(screen.getByRole("link", { name: "Email" })).toHaveAttribute( + "href", + "mailto:leasing@agent.com" + ) + expect(screen.getByText("Due to high call volume you may hear a message.")).toBeInTheDocument() + expect(screen.getByText("Address street, Address unit")).toBeInTheDocument() + expect(screen.getByText("Address city, CA 67890")).toBeInTheDocument() + expect(screen.getByRole("link", { name: "Get directions" })).toHaveAttribute( + "href", + "https://www.google.com/maps/place/Address street, Address unit, Address city, CA 67890" + ) + expect(screen.getByText("Office hours")).toBeInTheDocument() + expect(screen.getByText("Leasing office hours")).toBeInTheDocument() + expect(screen.getByText("Contact leasing agent or property manager")).toBeInTheDocument() }) - it("shows all content", () => { + it("shows all content enableLeasingAgentAltText off", () => { const phoneNumber = "(123) 456-7890" - const { getByText, getByRole } = render( - false, }} - email={"leasing@agent.com"} - name={"Agent Name"} - officeHours={"Leasing office hours"} - phone={phoneNumber} - title={"Agent title"} - managementWebsite={"https://example.com"} - /> + > + + ) - expect(getByText("Contact leasing agent")).toBeDefined() - expect(getByText("Agent Name")).toBeDefined() - expect(getByText("Agent title")).toBeDefined() - expect(getByRole("link", { name: `Call ${phoneNumber}` })).toHaveAttribute( + expect(screen.getByText("Contact leasing agent")).toBeInTheDocument() + expect(screen.getByText("Agent Name")).toBeInTheDocument() + expect(screen.getByText("Agent title")).toBeInTheDocument() + expect(screen.getByRole("link", { name: `Call ${phoneNumber}` })).toHaveAttribute( "href", "tel:1234567890" ) - expect(getByRole("link", { name: "Email" })).toHaveAttribute("href", "mailto:leasing@agent.com") - expect(getByRole("link", { name: "Website" })).toHaveAttribute("href", "https://example.com") - expect(getByText("Due to high call volume you may hear a message.")).toBeDefined() - expect(getByText("Address street, Address unit")).toBeDefined() - expect(getByText("Address city, CA 67890")).toBeDefined() - expect(getByRole("link", { name: "Get directions" })).toHaveAttribute( + expect(screen.getByRole("link", { name: "Email" })).toHaveAttribute( + "href", + "mailto:leasing@agent.com" + ) + expect(screen.getByText("Due to high call volume you may hear a message.")).toBeInTheDocument() + expect(screen.getByText("Address street, Address unit")).toBeInTheDocument() + expect(screen.getByText("Address city, CA 67890")).toBeInTheDocument() + expect(screen.getByRole("link", { name: "Get directions" })).toHaveAttribute( "href", "https://www.google.com/maps/place/Address street, Address unit, Address city, CA 67890" ) - expect(getByText("Office hours")).toBeDefined() - expect(getByText("Leasing office hours")).toBeDefined() + expect(screen.getByText("Office hours")).toBeInTheDocument() + expect(screen.getByText("Leasing office hours")).toBeInTheDocument() }) }) diff --git a/sites/public/src/components/listing/ListingView.tsx b/sites/public/src/components/listing/ListingView.tsx index dc4ebce35c..ff2358c22f 100644 --- a/sites/public/src/components/listing/ListingView.tsx +++ b/sites/public/src/components/listing/ListingView.tsx @@ -98,6 +98,14 @@ export const ListingView = (props: ListingProps) => { FeatureFlagEnum.disableListingPreferences, listing?.jurisdictions?.id ) + const enableLeasingAgentAltText = doJurisdictionsHaveFeatureFlagOn( + FeatureFlagEnum.enableLeasingAgentAltText, + listing.jurisdictions.id + ) + + const leasingAgentContactText = enableLeasingAgentAltText + ? t("leasingAgent.contactManagerProp") + : t("leasingAgent.contact") const appOpenInFuture = openInFuture(listing) const hasNonReferralMethods = listing?.applicationMethods @@ -944,7 +952,7 @@ export const ListingView = (props: ListingProps) => { )} {!appOpenInFuture && ( + {ListingUpdatedAt} ) diff --git a/sites/public/src/components/listing/listing_sections/LeasingAgent.tsx b/sites/public/src/components/listing/listing_sections/LeasingAgent.tsx index 165bf22408..aa8ff04f8b 100644 --- a/sites/public/src/components/listing/listing_sections/LeasingAgent.tsx +++ b/sites/public/src/components/listing/listing_sections/LeasingAgent.tsx @@ -1,39 +1,49 @@ import * as React from "react" import { Card, Heading, Link } from "@bloom-housing/ui-seeds" -import { Address as AddressType } from "@bloom-housing/shared-helpers/src/types/backend-swagger" -import { Address } from "@bloom-housing/shared-helpers" +import { Address, AuthContext } from "@bloom-housing/shared-helpers" import { t } from "@bloom-housing/ui-components" import styles from "../ListingViewSeeds.module.scss" - -type LeasingAgentProps = { - address?: AddressType - email?: string - name?: string - officeHours?: string - phone?: string - title?: string - managementWebsite?: string -} +import { FeatureFlagEnum, Listing } from "@bloom-housing/shared-helpers/src/types/backend-swagger" export const formatPhone = (phone: string) => { return phone.replace(/[-() ]/g, "") } -export const LeasingAgent = ({ - address, - email, - name, - officeHours, - phone, - title, - managementWebsite, -}: LeasingAgentProps) => { - if (!address && !email && !name && !officeHours && !phone && !managementWebsite) return +type LeasingAgentProps = { + listing: Listing +} +export const LeasingAgent = ({ listing }: LeasingAgentProps) => { + const { + listingsLeasingAgentAddress: address, + leasingAgentEmail: email, + leasingAgentName: name, + leasingAgentOfficeHours: officeHours, + leasingAgentPhone: phone, + leasingAgentTitle: title, + } = listing + const { doJurisdictionsHaveFeatureFlagOn } = React.useContext(AuthContext) + const managementWebsite = doJurisdictionsHaveFeatureFlagOn( + FeatureFlagEnum.enableCompanyWebsite, + listing.jurisdictions.id + ) + ? listing.managementWebsite + : undefined + if (!address && !email && !name && !officeHours && !title && !phone && !managementWebsite) return + + const enableLeasingAgentAltText = doJurisdictionsHaveFeatureFlagOn( + FeatureFlagEnum.enableLeasingAgentAltText, + listing.jurisdictions.id + ) + + const leasingAgentContactText = enableLeasingAgentAltText + ? t("leasingAgent.contactManagerProp") + : t("leasingAgent.contact") + return ( - {t("leasingAgent.contact")} + {leasingAgentContactText} {name &&

{name}

} {title &&

{title}

}