Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1274 intimate partner violence #1310

Merged
merged 22 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
64d9de5
1274 Add UCSF intimate partner violence data to front-end UCSF configs
Jul 12, 2023
e1b3590
Merge branch 'master' into 1274-intimate-partner-violence
Jul 27, 2023
b7e9970
Merge branch 'master' of https://github.com/ShelterTechSF/askdarcel-w…
Jul 28, 2023
b1b0176
Merge branch 'master' of https://github.com/ShelterTechSF/askdarcel-w…
Aug 2, 2023
e53b6e0
1274 add intimate partner violence handout and conditional logic to d…
Aug 9, 2023
7e733c3
Include host origin in domestic violence pdf image src route
Aug 9, 2023
186edfa
Switch out intimate partner violence icon
Aug 14, 2023
938473f
Replace checklist graphic text with html/css
Sep 2, 2023
975114a
Merge branch 'master' of https://github.com/ShelterTechSF/askdarcel-w…
Sep 21, 2023
5607979
1274 Slight updates to Intimate Partner PDF CSS. Use short descriptio…
Sep 22, 2023
bfee17a
Merge branch 'master' of https://github.com/ShelterTechSF/askdarcel-w…
Sep 28, 2023
e474620
1274 Increase refinements limit on UCSF whitelabel to ensure we displ…
Sep 29, 2023
66e510e
1274 Remove anyone in need refinement from intimate partner violence
Sep 29, 2023
aba8ed4
1274 Add function to wipe sensitvie terms from UCSF Intimate Partner …
Oct 17, 2023
31f771b
1274 Order Intimate Partner eligibilities by cultural/ethnic identity…
Oct 26, 2023
f8fcf0c
1274 PR clean up
Oct 31, 2023
bbda01c
1274 fix refinement list limit in whitelabel config
Nov 2, 2023
069fe77
PR feedback
Dec 6, 2023
2b260e7
1274 Show service type/categories first in UCSF discovery steps (#1312)
schroerbrian Dec 11, 2023
f091bd7
1274 24 hour availability sort (#1314)
schroerbrian Jan 29, 2024
5bff0bd
Prettier
Jan 29, 2024
55a5849
1274 ipv subcategory sort (#1315)
schroerbrian Feb 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { ResourceGuides, ResourceGuide } from "./pages/ResourceGuides";
import { SearchResultsPage } from "./pages/SearchResultsPage/SearchResultsPage";
import { ServiceListingPage } from "./pages/ServiceListingPage";
import { ServicePdfPage } from "./pages/Pdf/ServicePdfPage";
import { IntimatePartnerViolencePdfPage } from "./pages/Pdf/IntimatePartnerViolencePdfPage";
import { TermsOfServicePage } from "./pages/legal/TermsOfService";
import { UcsfHomePage } from "./pages/UcsfHomePage/UcsfHomePage";
import { UcsfDiscoveryForm } from "./pages/UcsfDiscoveryForm/UcsfDiscoveryForm";
Expand Down Expand Up @@ -193,6 +194,11 @@ export const App = () => {
path="/service-handout/:id"
component={ServicePdfPage}
/>
<Route
exact
path="/intimate-partner-violence-handout/:id"
component={IntimatePartnerViolencePdfPage}
/>
<Route
exact
path="/terms-of-service"
Expand Down
Binary file added app/assets/img/domestic-violence-checklist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 42 additions & 10 deletions app/components/search/SearchResults/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
SearchResults as SearchResultsProps,
} from "react-instantsearch/connectors";
import { whiteLabel } from "utils";
import { CATEGORIES } from "pages/ServiceDiscoveryForm/constants";
import { SearchMap } from "components/search/SearchMap/SearchMap";
import ResultsPagination from "components/search/Pagination/ResultsPagination";
import { Texting } from "components/Texting";
Expand All @@ -20,9 +21,11 @@ import styles from "./SearchResults.module.scss";
const SearchResults = ({
searchResults,
expandList,
categoryId,
}: {
searchResults: SearchResultsProps;
expandList: boolean;
categoryId?: string;
}) => {
const [centerCoords] = useState(null);
const [googleMapObject, setMapObject] = useState<google.maps.Map | null>(
Expand All @@ -42,7 +45,12 @@ const SearchResults = ({

if (!searchResults) return null;

const hits = transformHits(searchResults.hits as unknown as SearchHit[]);
const category = CATEGORIES.find((c) => c.id === categoryId);
const sortBy24HourAvailability = Boolean(category?.sortBy24HourAvailability);
const hits = transformHits(
searchResults.hits as unknown as SearchHit[],
sortBy24HourAvailability
);

return (
<div className={styles.searchResultsAndMapContainer}>
Expand All @@ -60,7 +68,12 @@ const SearchResults = ({
search term.
</div>
{hits.map((hit, index) => (
<SearchResult hit={hit} index={index} key={hit.id} />
<SearchResult
hit={hit}
index={index}
categoryId={categoryId}
key={hit.id}
/>
))}
<ResultsPagination noResults={!hits || !hits.length} />
</div>
Expand All @@ -74,10 +87,29 @@ const SearchResults = ({
);
};

const SearchResult = ({ hit, index }: { hit: SearchHit; index: number }) => {
const SearchResult = ({
hit,
index,
categoryId,
}: {
hit: SearchHit;
index: number;
categoryId: string | undefined;
}) => {
const [textingIsOpen, setTextingIsOpen] = useState(false);
const [clinicianActionsIsOpen, setClinicianActionsIsOpen] = useState(false);
const [handoutModalIsOpen, setHandoutModalIsOpen] = useState(false);
type HandoutLanguage = "es" | "tl" | "zh-TW" | "vi" | "ru" | "ar";
const handoutUrl = (hitId: number, language: HandoutLanguage | null) => {
const handoutRoute =
categoryId === "2000006"
schroerbrian marked this conversation as resolved.
Show resolved Hide resolved
? "intimate-partner-violence-handout"
: "service-handout";

return `/${handoutRoute}/${hitId}${
language ? `?handoutLanguage=${language}` : ""
}`;
};

let listing: TextListing;
if (hit.type === "service") {
Expand Down Expand Up @@ -210,37 +242,37 @@ const SearchResult = ({ hit, index }: { hit: SearchHit; index: number }) => {
{
key: -1,
description: "English",
url: `/service-handout/${hit.id}`,
url: handoutUrl(hit.id, null),
},
{
key: -2,
description: "Spanish",
url: `/service-handout/${hit.id}?handoutLanguage=es`,
url: handoutUrl(hit.id, "es"),
},
{
key: -3,
description: "Tagalog",
url: `/service-handout/${hit.id}?handoutLanguage=tl`,
url: handoutUrl(hit.id, "tl"),
},
{
key: -4,
description: "Chinese (Traditional)",
url: `/service-handout/${hit.id}?handoutLanguage=zh-TW`,
url: handoutUrl(hit.id, "zh-TW"),
},
{
key: -5,
description: "Vietnamese",
url: `/service-handout/${hit.id}?handoutLanguage=vi`,
url: handoutUrl(hit.id, "vi"),
},
{
key: -6,
description: "Russian",
url: `/service-handout/${hit.id}?handoutLanguage=ru`,
url: handoutUrl(hit.id, "ru"),
},
{
key: -7,
description: "Arabic",
url: `/service-handout/${hit.id}?handoutLanguage=ar`,
url: handoutUrl(hit.id, "ar"),
},
]}
/>
Expand Down
32 changes: 30 additions & 2 deletions app/components/search/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useState, useMemo } from "react";

import type { Category } from "models/Meta";

import {
eligibilitiesMapping,
categoriesMapping,
Expand All @@ -21,20 +23,42 @@ const Sidebar = ({
categorySlug = "",
subcategories = [],
subcategoryNames = [],
sortAlgoliaSubcategoryRefinements = false,
}: {
setSearchRadius: (radius: string) => void;
searchRadius: string;
isSearchResultsPage: boolean;
eligibilities?: object[];
categorySlug?: string;
subcategories?: object[];
subcategories?: Category[];
subcategoryNames?: string[];
sortAlgoliaSubcategoryRefinements?: boolean;
}) => {
const [filterMenuVisible, setfilterMenuVisible] = useState(false);
let categoryRefinementJsx: React.ReactElement | null = null;
let eligibilityRefinementJsx: React.ReactElement | null = null;
const orderByLabel = (a: { label: string }, b: { label: string }) =>
a.label.localeCompare(b.label);

const orderByPriorityRanking = (
a: { label: string },
b: { label: string }
) => {
// Our API has the ability to sort subcategories using the "child_priority_rank" on the
// CategoryRelationship table. In cases where we want to sort our sidebar categories
// following this order, we can use this sorting function, which sorts the categories
// that we receive from Algolia using the order that we get from the API.
const priorityA = subcategoryNames.indexOf(a.label);
const priorityB = subcategoryNames.indexOf(b.label);

// If an element in the data returned from Algolia does not exist in the API's ordered array
// (i.e., Algolia is out of sync with our API), move the element to the back of the list.
if (priorityA < 0) return 1;
if (priorityB < 0) return -1;

return priorityA - priorityB;
};

const onChangeValue = (evt: React.ChangeEvent<HTMLInputElement>) => {
setSearchRadius(evt.target.value);
};
Expand Down Expand Up @@ -128,7 +152,11 @@ const Sidebar = ({
transformItems={(items: { label: string }[]) =>
items
.filter(({ label }) => subcategoryNames.includes(label))
.sort(orderByLabel)
.sort(
sortAlgoliaSubcategoryRefinements
? orderByPriorityRanking
: orderByLabel
)
}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const EligibilityRefinements = ({

return (
<>
<div className={styles.refinementsBox_title}>Client Identity</div>
<div className={styles.refinementsBox_title}>Patient Identity</div>
<ol className={styles.refinementsLabels}>
{resourceEligibilityGroups.map((eligibilityGroup) => (
<li key={eligibilityGroup.label} className={styles.listContainer}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export const SubcategoryRefinements = ({
selectedSubcategories: SelectedSubcategories;
setSelectedSubcategories: (categories: SelectedSubcategories) => void;
}) => {
// This prevents the UI from flashing before the subcategories are fetched
if (subcategories.length === 0) return null;

// Add generic "See All" element to subcategory array if it is not there yet
if (!subcategories[0] || subcategories[0].id !== seeAllPseudoId) {
subcategories.unshift({ id: seeAllPseudoId, name: "See All" });
Expand Down
Loading
Loading