Skip to content

Commit

Permalink
fix case error with opa_id
Browse files Browse the repository at this point in the history
  • Loading branch information
nlebovits committed Jun 4, 2024
1 parent d812f49 commit 4c45685
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 30 deletions.
14 changes: 7 additions & 7 deletions src/app/find-properties/[[...opa_id]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,22 @@ const MapPage = ({ params }: MapPageProps) => {

const linkedProperty = featuresInView.find(
(feature) =>
feature.properties.OPA_ID.toString() ===
feature.properties.opa_id.toString() ===
linkedPropertyRef?.current?.toString()
);

if (
linkedProperty &&
linkedProperty.properties.OPA_ID !== selectedProperty?.properties.OPA_ID
linkedProperty.properties.opa_id !== selectedProperty?.properties.opa_id
) {
setSelectedProperty(linkedProperty);
linkedPropertyRef.current = null;
}
}, [featuresInView, selectedProperty?.properties.OPA_ID]);
}, [featuresInView, selectedProperty?.properties.opa_id]);

useEffect(() => {
if (!selectedProperty) return;
const opa_id = selectedProperty.properties.OPA_ID;
const opa_id = selectedProperty.properties.opa_id;
history.replaceState(null, "", `/find-properties/${opa_id}`);
}, [selectedProperty]);

Expand Down Expand Up @@ -312,10 +312,10 @@ const MapPage = ({ params }: MapPageProps) => {
onPress={updateSmallScreenMode}
startContent={
smallScreenMode === "map" ? (
<ListBullets />
<ListBullets />
) : (
<GlobeHemisphereWest />
)
<GlobeHemisphereWest />
)
}
/>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/PropertyCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ function getPriorityClass(priorityLevel: string) {
}

const PropertyCard = ({ feature, setSelectedProperty }: PropertyCardProps) => {
const { address, guncrime_density, tree_canopy_gap, priority_level, OPA_ID } =
const { address, guncrime_density, tree_canopy_gap, priority_level, opa_id } =
feature.properties;

const image = `https://storage.googleapis.com/cleanandgreenphl/${OPA_ID}.jpg`;
const image = `https://storage.googleapis.com/cleanandgreenphl/${opa_id}.jpg`;
const formattedAddress = toTitleCase(address);
const priorityClass = getPriorityClass(priority_level);

Expand Down
4 changes: 2 additions & 2 deletions src/components/PropertyDetailSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,12 @@ const PropertyDetailSection: FC<PropertyDetailSectionProps> = ({
<TableBody items={items}>
{({ properties }) => (
<TableRow
key={properties?.OPA_ID}
key={properties?.opa_id}
onClick={() => {
setSelectedProperty(
items.find(
(item) =>
properties?.OPA_ID === item?.properties?.OPA_ID
properties?.opa_id === item?.properties?.opa_id
) || null
);
}}
Expand Down
12 changes: 4 additions & 8 deletions src/components/SidePanelControlBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

import React, { FC, useRef } from "react";
import { BarClickOptions } from "@/app/find-properties/[[...opa_id]]/page";
import {
BookmarkSimple,
DownloadSimple,
Funnel
} from "@phosphor-icons/react";
import { BookmarkSimple, DownloadSimple, Funnel } from "@phosphor-icons/react";
import { ThemeButton } from "./ThemeButton";
import { useFilter } from "@/context/FilterContext";
import { getPropertyIdsFromLocalStorage } from "@/utilities/localStorage";
Expand Down Expand Up @@ -39,7 +35,7 @@ const SearchBarComponent: FC<SidePanelControlBarProps> = ({
let filterCount = Object.keys(appFilter).length;

if (shouldFilterSavedProperties) {
// Exclude OPA_ID from filterCount, which counts OPA_ID as a filter by default
// Exclude opa_id from filterCount, which counts opa_id as a filter by default
filterCount--;
}

Expand All @@ -50,14 +46,14 @@ const SearchBarComponent: FC<SidePanelControlBarProps> = ({
setShouldFilterSavedProperties(false);
dispatch({
type: "SET_DIMENSIONS",
property: "OPA_ID",
property: "opa_id",
dimensions: [],
});
} else {
setShouldFilterSavedProperties(true);
dispatch({
type: "SET_DIMENSIONS",
property: "OPA_ID",
property: "opa_id",
dimensions: [...propertyIds],
});
}
Expand Down
21 changes: 11 additions & 10 deletions src/components/SinglePropertyDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const SinglePropertyDetail = ({
? JSON.parse(localStorageData)
: {};

const propertyId = parsedLocalStorageData.opa_ids[OPA_ID];
const propertyId = parsedLocalStorageData.opa_ids[opa_id];
propertyId
? setIsPropertySavedToLocalStorage(true)
: setIsPropertySavedToLocalStorage(false);
Expand All @@ -99,10 +99,10 @@ const SinglePropertyDetail = ({
total_due,
tree_canopy_gap,
zipcode,
OPA_ID,
opa_id,
phs_partner_agency,
} = properties;
const image = `https://storage.googleapis.com/cleanandgreenphl/${OPA_ID}.jpg`;
const image = `https://storage.googleapis.com/cleanandgreenphl/${opa_id}.jpg`;
const atlasUrl = `https://atlas.phila.gov/${address}`;
const priorityClass = getPriorityClass(priority_level);

Expand All @@ -118,15 +118,15 @@ const SinglePropertyDetail = ({
let newLocalCache: PropertyIdLocalStorage = {
...localCache,
};
newLocalCache.opa_ids[OPA_ID] = OPA_ID;
newLocalCache.opa_ids[opa_id] = opa_id;
newLocalCache.count++;
localStorage.setItem("opa_ids", JSON.stringify(newLocalCache));
};

const removePropertyIdFromLocalStorage = (
localStorageData: PropertyIdLocalStorage
) => {
delete localStorageData.opa_ids[OPA_ID];
delete localStorageData.opa_ids[opa_id];
localStorageData.count--;
localStorage.setItem("opa_ids", JSON.stringify(localStorageData));
};
Expand Down Expand Up @@ -154,7 +154,7 @@ const SinglePropertyDetail = ({
? JSON.parse(localStorageData)
: {};

if (parsedLocalStorageData.opa_ids[OPA_ID]) {
if (parsedLocalStorageData.opa_ids[opa_id]) {
removePropertyIdFromLocalStorage(parsedLocalStorageData);
setIsPropertySavedToLocalStorage(false);
dispatchFilterAction(parsedLocalStorageData);
Expand All @@ -168,7 +168,7 @@ const SinglePropertyDetail = ({
if (data.count === 0) {
dispatch({
type: "SET_DIMENSIONS",
property: "OPA_ID",
property: "opa_id",
dimensions: [],
});
setShouldFilterSavedProperties(false);
Expand All @@ -177,7 +177,7 @@ const SinglePropertyDetail = ({
let propertyIds = getPropertyIdsFromLocalStorage();
dispatch({
type: "SET_DIMENSIONS",
property: "OPA_ID",
property: "opa_id",
dimensions: [...propertyIds],
});
}
Expand Down Expand Up @@ -231,7 +231,7 @@ const SinglePropertyDetail = ({
onMouseEnter={() => setHover(true)}
onMouseLeave={() => setHover(false)}
onFocus={() => setHover(true)}
onBlur={() => setHover(false) }
onBlur={() => setHover(false)}
/>
</Tooltip>
</div>
Expand All @@ -251,7 +251,8 @@ const SinglePropertyDetail = ({
placement="top"
content="Street View"
classNames={{
content: "bg-gray-900 rounded-[14px] text-white relative top-[5px]",
content:
"bg-gray-900 rounded-[14px] text-white relative top-[5px]",
}}
>
<button
Expand Down
1 change: 0 additions & 1 deletion src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ export const useStagingTiles = false;

export const googleCloudBucketName =
process.env.GOOGLE_CLOUD_BUCKET_NAME || "cleanandgreenphl";

0 comments on commit 4c45685

Please sign in to comment.