Skip to content
Merged
Changes from 1 commit
Commits
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
31 changes: 8 additions & 23 deletions static/js/tools/map/place_details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ import {
import { MAP_CONTAINER_ID } from "./chart";
import { Context, DisplayOptions, PlaceInfo, StatVar } from "./context";
import {
getAllChildPlaceTypes,
getParentPlaces,
getRedirectLink,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

With the removal of the usages here, it appears the functions getRedirectLink and getAllChildPlaceTypes are no longer used anywhere. To improve code maintainability, please consider removing them from static/js/tools/map/util.ts to remove dead code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False. getRedirectLink is still used by the disaster maps and getAllChildPlaceTypes is still used by the disaster maps and place search. I am leaving them as is.

} from "./util";

interface PlaceDetailsPropType {
Expand Down Expand Up @@ -133,8 +131,8 @@ export function PlaceDetails(props: PlaceDetailsPropType): JSX.Element {
);
}

function highlightPlace(e: React.MouseEvent<HTMLAnchorElement>): void {
const target = e.target as HTMLAnchorElement;
function highlightPlace(e: React.MouseEvent<HTMLElement>): void {
const target = e.target as HTMLElement;
const placeDcid = target.dataset.geodcid;
highlightPlaceToggle(
document.getElementById(MAP_CONTAINER_ID),
Expand All @@ -143,8 +141,8 @@ function highlightPlace(e: React.MouseEvent<HTMLAnchorElement>): void {
);
}

function unhighlightPlace(e: React.MouseEvent<HTMLAnchorElement>): void {
const target = e.target as HTMLAnchorElement;
function unhighlightPlace(e: React.MouseEvent<HTMLElement>): void {
const target = e.target as HTMLElement;
const placeDcid = target.dataset.geodcid;
highlightPlaceToggle(
document.getElementById(MAP_CONTAINER_ID),
Expand Down Expand Up @@ -183,31 +181,18 @@ function getListItemElement(
enclosingPlace,
placeInfo.parentPlaces
);
const redirectLink = getRedirectLink(
statVar,
place,
parentPlaces,
placeInfo.mapPointPlaceType,
display
);
const shouldBeClickable = !_.isEmpty(
getAllChildPlaceTypes(place, parentPlaces)
);

return (
<div key={place.dcid}>
{itemNumber && `${itemNumber}. `}
{shouldBeClickable ? (
<a
href={redirectLink}
{
<span
data-geodcid={place.dcid}
onMouseEnter={highlightPlace}
onMouseLeave={unhighlightPlace}
>
{place.name}
</a>
) : (
`${place.name}`
)}
</span>}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The curly braces {...} around the <span> element are not necessary here. You can remove them to make the JSX cleaner and more readable.

      <span
        data-geodcid={place.dcid}
        onMouseEnter={highlightPlace}
        onMouseLeave={unhighlightPlace}
      >
        {place.name}
      </span>

{date}: {value}
</div>
);
Expand Down
Loading