|
1 | 1 | import React, { useContext } from "react" |
2 | 2 | import { t, MinimalTable, TableThumbnail } from "@bloom-housing/ui-components" |
3 | 3 | import { FieldValue, Grid } from "@bloom-housing/ui-seeds" |
| 4 | +import { AuthContext } from "@bloom-housing/shared-helpers" |
| 5 | +import { FeatureFlagEnum } from "@bloom-housing/shared-helpers/src/types/backend-swagger" |
4 | 6 | import { ListingContext } from "../../ListingContext" |
5 | 7 | import { getDetailFieldString } from "./helpers" |
6 | 8 | import SectionWithGrid from "../../../shared/SectionWithGrid" |
7 | 9 |
|
8 | 10 | const DetailAdditionalEligibility = () => { |
9 | 11 | const listing = useContext(ListingContext) |
| 12 | + const { doJurisdictionsHaveFeatureFlagOn } = useContext(AuthContext) |
| 13 | + |
| 14 | + const disableBuildingSelectionCriteria = doJurisdictionsHaveFeatureFlagOn( |
| 15 | + FeatureFlagEnum.disableBuildingSelectionCriteria, |
| 16 | + listing.jurisdictions.id |
| 17 | + ) |
10 | 18 |
|
11 | 19 | return ( |
12 | 20 | <SectionWithGrid heading={t("listings.sections.additionalEligibilityTitle")} inset> |
@@ -43,50 +51,51 @@ const DetailAdditionalEligibility = () => { |
43 | 51 | </Grid.Row> |
44 | 52 |
|
45 | 53 | {(listing.buildingSelectionCriteria || |
46 | | - listing.listingsBuildingSelectionCriteriaFile?.fileId) && ( |
47 | | - <Grid.Row columns={1}> |
48 | | - <Grid.Cell> |
49 | | - <FieldValue label={t("listings.buildingSelectionCriteria")}> |
50 | | - {listing.listingsBuildingSelectionCriteriaFile?.fileId ? ( |
51 | | - <MinimalTable |
52 | | - id="buildingSelectionCriteriaTable" |
53 | | - headers={{ preview: "t.preview", fileName: "t.fileName" }} |
54 | | - data={[ |
55 | | - { |
56 | | - preview: { |
57 | | - content: ( |
58 | | - <TableThumbnail> |
59 | | - <img |
60 | | - alt="PDF preview" |
61 | | - src={listing.listingsBuildingSelectionCriteriaFile.fileId} |
62 | | - /> |
63 | | - </TableThumbnail> |
64 | | - ), |
| 54 | + listing.listingsBuildingSelectionCriteriaFile?.fileId) && |
| 55 | + !disableBuildingSelectionCriteria && ( |
| 56 | + <Grid.Row columns={1}> |
| 57 | + <Grid.Cell> |
| 58 | + <FieldValue label={t("listings.buildingSelectionCriteria")}> |
| 59 | + {listing.listingsBuildingSelectionCriteriaFile?.fileId ? ( |
| 60 | + <MinimalTable |
| 61 | + id="buildingSelectionCriteriaTable" |
| 62 | + headers={{ preview: "t.preview", fileName: "t.fileName" }} |
| 63 | + data={[ |
| 64 | + { |
| 65 | + preview: { |
| 66 | + content: ( |
| 67 | + <TableThumbnail> |
| 68 | + <img |
| 69 | + alt="PDF preview" |
| 70 | + src={listing.listingsBuildingSelectionCriteriaFile.fileId} |
| 71 | + /> |
| 72 | + </TableThumbnail> |
| 73 | + ), |
| 74 | + }, |
| 75 | + fileName: { |
| 76 | + content: `${listing.listingsBuildingSelectionCriteriaFile.fileId |
| 77 | + .split("/") |
| 78 | + .slice(-1) |
| 79 | + .join()}.pdf`, |
| 80 | + }, |
65 | 81 | }, |
66 | | - fileName: { |
67 | | - content: `${listing.listingsBuildingSelectionCriteriaFile.fileId |
68 | | - .split("/") |
69 | | - .slice(-1) |
70 | | - .join()}.pdf`, |
| 82 | + ]} |
| 83 | + /> |
| 84 | + ) : ( |
| 85 | + <MinimalTable |
| 86 | + id="buildingSelectionCriteriaTable" |
| 87 | + headers={{ url: "t.url" }} |
| 88 | + data={[ |
| 89 | + { |
| 90 | + url: { content: listing.buildingSelectionCriteria }, |
71 | 91 | }, |
72 | | - }, |
73 | | - ]} |
74 | | - /> |
75 | | - ) : ( |
76 | | - <MinimalTable |
77 | | - id="buildingSelectionCriteriaTable" |
78 | | - headers={{ url: "t.url" }} |
79 | | - data={[ |
80 | | - { |
81 | | - url: { content: listing.buildingSelectionCriteria }, |
82 | | - }, |
83 | | - ]} |
84 | | - /> |
85 | | - )} |
86 | | - </FieldValue> |
87 | | - </Grid.Cell> |
88 | | - </Grid.Row> |
89 | | - )} |
| 92 | + ]} |
| 93 | + /> |
| 94 | + )} |
| 95 | + </FieldValue> |
| 96 | + </Grid.Cell> |
| 97 | + </Grid.Row> |
| 98 | + )} |
90 | 99 | </SectionWithGrid> |
91 | 100 | ) |
92 | 101 | } |
|
0 commit comments