Skip to content

Commit

Permalink
fix: base styling + functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinBuyck committed Dec 10, 2024
1 parent a2e2128 commit 0032493
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 7 deletions.
1 change: 1 addition & 0 deletions api/src/dtos/shared/base-filter.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export enum Compare {
'IN' = 'IN',
'>=' = '>=',
'<=' = '<=',
'LIKE' = 'LIKE',
'NA' = 'NA', // For filters that don't use the comparison param
}

Expand Down
11 changes: 10 additions & 1 deletion api/src/services/listing.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,27 @@ export class ListingService implements OnModuleInit {
}
if (filter[ListingFilterKeys.monthlyRent]) {
const comparison = filter['$comparison'];
//sanitize user input here
whereClauseArray.push(
`(combined_units->>'monthlyRent')::FLOAT ${comparison} '${
filter[ListingFilterKeys.monthlyRent]
}'`,
);
}
if (filter[ListingFilterKeys.name]) {
const comparison = filter['$comparison'];
whereClauseArray.push(
`UPPER(combined.name) ${comparison} UPPER('%${
filter[ListingFilterKeys.name]
}%')`,
);
}
});
}

// Only return active listings
whereClauseArray.push("combined.status = 'active'");

console.log(whereClauseArray);
const whereClause = whereClauseArray?.length
? `where ${whereClauseArray.join(' AND ')}`
: '';
Expand Down
2 changes: 1 addition & 1 deletion doorway-ui-components/src/forms/Field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
font-size: 0.75rem;
font-weight: 500;

input.rent-input {
input.typed-input {
border-radius: 12px;
border-width: 2px;
background-color: white;
Expand Down
2 changes: 2 additions & 0 deletions shared-helpers/src/locales/general.json
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,8 @@
"listings.priorityUnits": "Priority Units",
"listings.priorityUnitsDescription": "This building has units set aside if any of the following apply to you or someone in your household:",
"listings.processInfo": "Process Info",
"listings.propertyName": "Property Name",
"listings.popertyName.helper": "Enter full or partial property name",
"listings.publicLottery.header": "Public Lottery",
"listings.remainingUnitsAfterPreferenceConsideration": "After all preference holders have been considered, any remaining units will be available to other qualified applicants.",
"listings.remainingUnitsAfterPrograms": "One or more questions in the application will help to determine whether or not you are eligible for the housing programs listed above. After you have submitted your application, the property manager will ask you to verify your housing program eligibility by providing documentation or another form of verification.",
Expand Down
2 changes: 2 additions & 0 deletions shared-helpers/src/types/backend-swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6523,6 +6523,7 @@ export enum EnumListingFilterParamsComparison {
"IN" = "IN",
">=" = ">=",
"<=" = "<=",
"LIKE" = "LIKE",
"NA" = "NA",
}
export enum ListingViews {
Expand Down Expand Up @@ -6702,6 +6703,7 @@ export enum EnumMultiselectQuestionFilterParamsComparison {
"IN" = "IN",
">=" = ">=",
"<=" = "<=",
"LIKE" = "LIKE",
"NA" = "NA",
}
export enum InputType {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.input-section {
display: flex;
flex-direction: column;
@apply p-2;
padding: var(--bloom-s4);
@media (min-width: $screen-md) {
flex-direction: row;
}
Expand Down
30 changes: 28 additions & 2 deletions sites/public/src/components/listings/search/LandingSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function LandingSearch(props: LandingSearchProps) {
availability: null,
minRent: "",
monthlyRent: "",
propertyName: "",
counties: countyLabels,
ids: null,
}
Expand All @@ -47,6 +48,7 @@ export function LandingSearch(props: LandingSearchProps) {
const [openCountyMapModal, setOpenCountyMapModal] = useState(false)

const createListingsUrl = (formValues: ListingSearchParams) => {
console.log(formValues)
const searchUrl = buildSearchString(formValues)
return "/listings?search=" + searchUrl
}
Expand All @@ -57,7 +59,7 @@ export function LandingSearch(props: LandingSearchProps) {
Object.assign(newValues, formValues)
newValues[name] = value
setFormValues(newValues)
// console.log(`${name} has been set to ${value}`) // uncomment to debug
console.log(`${name} has been set to ${value}`) // uncomment to debug
}

const updateValueMulti = (name: string, labels: string[]) => {
Expand Down Expand Up @@ -130,6 +132,14 @@ export function LandingSearch(props: LandingSearchProps) {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [monthlyRentFormatted])

const propertyName = watch("propertyName")
useEffect(() => {
if (propertyName) {
updateValue("propertyName", propertyName)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [propertyName])

return (
<Card className="bg-accent-cool-light">
<div className={styles["input-section"]}>
Expand Down Expand Up @@ -170,7 +180,23 @@ export function LandingSearch(props: LandingSearchProps) {
defaultValue={formValues.monthlyRent}
placeholder="$"
className="doorway-field p-0 md:-mt-1"
inputClassName="rent-input"
inputClassName="typed-input"
labelClassName="input-label"
/>
</div>
<div className={styles["input-section"]}>
<div className={styles["input-section_title"]}>{t("listings.propertyName")}</div>
<Field
type="text"
id="propertyName"
name="propertyName"
subNote={t("listings.popertyName.helper")}
register={register}
setValue={setValue}
getValues={getValues}
defaultValue={formValues.propertyName}
className="doorway-field p-0 md:-mt-1"
inputClassName="typed-input"
labelClassName="input-label"
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function ListingsSearchCombined(props: ListingsSearchCombinedProps) {
bathrooms: null,
minRent: "",
monthlyRent: "",
propertyName: "",
counties: props.counties.map((county) => county.label),
availability: null,
ids: undefined,
Expand Down Expand Up @@ -96,6 +97,7 @@ function ListingsSearchCombined(props: ListingsSearchCombinedProps) {
// Search the listings by both the filter & the visible markers - but search the markers by only the filter, so that you can scroll out of the currently searched view and still see the markers
const listingIdsOnlyQb = generateSearchQuery(modifiedParams)
const genericQb = generateSearchQuery(searchFilter)
console.log(genericQb)

let newListings = null
let newMeta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export function ListingsSearchModal(props: ListingsSearchModalProps) {
bathrooms: null,
minRent: "",
monthlyRent: "",
propertyName: "",
counties: countyLabels,
availability: null,
ids: undefined,
Expand Down Expand Up @@ -208,6 +209,7 @@ export function ListingsSearchModal(props: ListingsSearchModalProps) {
const { register, getValues, setValue, watch } = useForm()
const monthlyRentFormatted = watch("monthlyRent")
const minRentFormatted = watch("minRent")
const propertyName = watch("propertyName")
const currencyFormatting = /,|\.\d{2}/g

// workarounds to leverage UI-C's currency formatting without full refactor
Expand All @@ -227,6 +229,13 @@ export function ListingsSearchModal(props: ListingsSearchModalProps) {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [monthlyRentFormatted])

useEffect(() => {
if (propertyName) {
updateValue("propertyName", propertyName)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [propertyName])

return (
<Dialog
className="listings-search-dialog"
Expand Down Expand Up @@ -282,7 +291,7 @@ export function ListingsSearchModal(props: ListingsSearchModalProps) {
defaultValue={formValues.minRent}
placeholder={t("t.minPrice")}
className="doorway-field"
inputClassName="rent-input"
inputClassName="typed-input"
labelClassName="input-label"
></Field>
<div style={hyphenContainerStyle}>
Expand All @@ -298,11 +307,27 @@ export function ListingsSearchModal(props: ListingsSearchModalProps) {
defaultValue={formValues.monthlyRent}
placeholder={t("t.maxPrice")}
className="doorway-field"
inputClassName="rent-input"
inputClassName="typed-input"
labelClassName="input-label"
></Field>
</div>
</div>
<div style={inputSectionStyle}>
<div style={sectionTitle}>{t("listings.propertyName")}</div>
<Field
type="text"
id="propertyName"
name="propertyName"
subNote={t("listings.popertyName.helper")}
register={register}
setValue={setValue}
getValues={getValues}
defaultValue={formValues.propertyName}
className="doorway-field"
inputClassName="typed-input"
labelClassName="input-label"
/>
</div>

<div style={inputSectionStyle}>
<div style={sectionTitleTopBorder}>{t("t.counties")}</div>
Expand Down
4 changes: 4 additions & 0 deletions sites/public/src/lib/listings/listing-query-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export class ListingQueryBuilder {
return this.addFilter(field, EnumListingFilterParamsComparison["<>"], value)
}

whereLike(field: string, value: string) {
return this.addFilter(field, EnumListingFilterParamsComparison["LIKE"], value)
}

whereIn(field: string, value: string[]) {
return this.addFilter(field, EnumListingFilterParamsComparison["IN"], value)
}
Expand Down
4 changes: 4 additions & 0 deletions sites/public/src/lib/listings/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type ListingSearchParams = {
bathrooms: string
minRent: string
monthlyRent: string
propertyName: string
counties: string[]
availability: FilterAvailabilityEnum
ids: string[]
Expand Down Expand Up @@ -121,6 +122,9 @@ export function generateSearchQuery(params: ListingSearchParams) {
if (params.monthlyRent && params.monthlyRent != "") {
qb.whereLessThanEqual("monthlyRent", params.monthlyRent)
}
if (params.propertyName && params.propertyName != "") {
qb.whereLike("name", params.propertyName)
}

// Find listings in these counties
if (Array.isArray(params.counties) && params.counties.length > 0) {
Expand Down

0 comments on commit 0032493

Please sign in to comment.