- {Object.keys(directorySections).map((listingType, index) => {
+ {directorySections.map((section, index) => {
return (
)
diff --git a/app/javascript/modules/listings/GenericDirectory.tsx b/app/javascript/modules/listings/GenericDirectory.tsx
index ff91ffbfa..3068b291b 100644
--- a/app/javascript/modules/listings/GenericDirectory.tsx
+++ b/app/javascript/modules/listings/GenericDirectory.tsx
@@ -17,6 +17,12 @@ import { RailsListing } from "./SharedHelpers"
import "./ListingDirectory.scss"
import { MailingListSignup } from "../../components/MailingListSignup"
import DirectoryPageNavigationBar from "./DirectoryPageNavigationBar"
+import {
+ DIRECTORY_TYPE_SALES,
+ RENTAL_DIRECTORY_SECTIONS,
+ SALE_DIRECTORY_SECTIONS,
+} from "../constants"
+import { IconHomeCheck } from "./assets/icon-home-check"
interface RentalDirectoryProps {
listingsAPI: (filters?: EligibilityFilters) => Promise
@@ -64,6 +70,8 @@ export const GenericDirectory = (props: RentalDirectoryProps) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [filters])
+ const hasFiltersSet = filters !== null
+
const observerRef = useRef(null)
useEffect(() => {
const handleIntersectionEvents = (events: IntersectionObserverEntry[]) => {
@@ -86,7 +94,34 @@ export const GenericDirectory = (props: RentalDirectoryProps) => {
observerRef.current = new IntersectionObserver(handleIntersectionEvents)
}, [activeItem])
- const hasFiltersSet = filters !== null
+ const directorySections =
+ props.directoryType === DIRECTORY_TYPE_SALES
+ ? SALE_DIRECTORY_SECTIONS
+ : RENTAL_DIRECTORY_SECTIONS
+
+ const directorySectionInfo = {
+ open: {
+ ref: "enter-a-lottery",
+ icon: "house",
+ numListings: listings.open.length,
+ },
+ fcfs: {
+ ref: "buy-now",
+ icon: IconHomeCheck,
+ numListings: listings.fcfsSalesNotYetOpen.length + listings.fcfsSalesOpen.length,
+ },
+ upcoming: {
+ ref: "upcoming-lotteries",
+ icon: "clock",
+ numListings: listings.upcoming.length,
+ },
+ results: {
+ ref: "lottery-results",
+ icon: "result",
+ numListings: listings.results.length,
+ },
+ }
+
return (
@@ -94,15 +129,10 @@ export const GenericDirectory = (props: RentalDirectoryProps) => {
<>
{props.getPageHeader(filters, setFilters, match)}
{
+ return { key: section, ...directorySectionInfo[section] }
+ })}
activeItem={activeItem}
- setActiveItem={setActiveItem}
/>
{
hasFiltersSet
)}
- {props.directoryType === "forSale" && (
+ {props.directoryType === DIRECTORY_TYPE_SALES && (
{
diff --git a/app/javascript/modules/listings/assets/icon-home-check.tsx b/app/javascript/modules/listings/assets/icon-home-check.tsx
index afbc104c9..34c09380a 100644
--- a/app/javascript/modules/listings/assets/icon-home-check.tsx
+++ b/app/javascript/modules/listings/assets/icon-home-check.tsx
@@ -3,8 +3,8 @@ import React from "react"
export const IconHomeCheck = (