Skip to content

Commit

Permalink
[TM-905] add nullish coalescing operators
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarLima1 committed Jun 7, 2024
1 parent a048c85 commit de4f2bf
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 12 deletions.
5 changes: 0 additions & 5 deletions src/components/elements/Map-mapbox/GeoJSON.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ export interface MultiPolygon extends GeoJsonObject {
type: "MultiPolygon";
coordinates: Position[][][];
}
// uncomment this block if you need the GeometryCollection type
// export interface GeometryCollection<G extends Geometry = Geometry> extends GeoJsonObject {
// type: "GeometryCollection";
// geometries: G[];
// }

export type GeoJsonProperties = { [name: string]: unknown } | null;

Expand Down
7 changes: 2 additions & 5 deletions src/components/elements/Map-mapbox/Map.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import "mapbox-gl/dist/mapbox-gl.css";

import _ from "lodash";
//@ts-ignore
//@ts-ignore
import mapboxgl from "mapbox-gl";
//@ts-ignore
import React, { useEffect } from "react";
import { DetailedHTMLProps, HTMLAttributes, useState } from "react";
import { When } from "react-if";
Expand Down Expand Up @@ -113,8 +110,8 @@ export const MapContainer = ({
const context = useSitePolygonData();
const { isUserDrawingEnabled } = isUserDrawing
? { isUserDrawingEnabled: isUserDrawing }
: context || { isUserDrawingEnabled: false };
const { toggleUserDrawing, toggleAttribute, reloadSiteData } = context || {};
: context ?? { isUserDrawingEnabled: false };
const { toggleUserDrawing, toggleAttribute, reloadSiteData } = context ?? {};
if (!mapFunctions) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const CheckPolygonControl = (props: CheckSitePolygonProps) => {
<div key={polygon.id} className="flex items-center gap-2">
<Icon name={polygon.valid ? IconNames.ROUND_GREEN_TICK : IconNames.ROUND_RED_CROSS} className="h-4 w-4" />
<Text variant="text-10-light" className="text-white">
{`${polygon.label || "Unnamed Polygon"} ${polygon.checked ? "" : "(not checked yet)"}`}
{`${polygon.label ?? "Unnamed Polygon"} ${polygon.checked ? "" : "(not checked yet)"}`}
</Text>
</div>
))}
Expand Down
2 changes: 1 addition & 1 deletion src/components/elements/Map-mapbox/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { LayerType, LayerWithStyle, TooltipType } from "./Map.d";
const GEOSERVER = "https://geoserver-prod.wri-restoration-marketplace-api.com";

export const getFeatureProperties = <T extends any>(properties: any, key: string): T | undefined => {
return properties[key] || properties[`user_${key}`];
return properties[key] ?? properties[`user_${key}`];
};

export const convertToGeoJSON = (featureCollection: FeatureCollection) => {
Expand Down

0 comments on commit de4f2bf

Please sign in to comment.