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

feat:types for map #1856

Merged
merged 28 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b814594
feat:types for map
sunilsabatp Aug 31, 2023
c6cce2b
type for register_tree_map
sunilsabatp Aug 31, 2023
889be14
fix: types for map
sunilsabatp Sep 4, 2023
209aef6
fix: type for singlecontribution
sunilsabatp Sep 5, 2023
22fdd54
fix: type feedback
sunilsabatp Sep 18, 2023
21a0f33
fix: type errors
sunilsabatp Sep 19, 2023
4d2a642
fix: add species of Import tree
sunilsabatp Sep 21, 2023
0dadc03
fix: Eslint error
sunilsabatp Sep 21, 2023
52a48a9
resolved merge conflict
sunilsabatp Sep 21, 2023
93b881a
Merge 'develop' to feature/type_for_map
mohitb35 Sep 27, 2023
b47be79
doc: adds comment reg DrawMap functionality
mohitb35 Sep 28, 2023
241e513
refactor: renames ContributionProps for clarity
mohitb35 Sep 28, 2023
24df054
fix: resolve TS warning for TreesIcon usage
mohitb35 Sep 29, 2023
01d3291
fix: TS errors
adityasabat34 Oct 9, 2023
4d6bbad
resolved merge conflict
adityasabat34 Oct 9, 2023
d64e30d
fix: Type issue for Map
adityasabat34 Oct 17, 2023
b14548d
type for Map(feedback)
sunilsabatp Nov 22, 2023
27440c1
resolve type errors for PlantLocationPage
sunilsabatp Nov 28, 2023
afba940
resolve the merge conflict
sunilsabatp Nov 28, 2023
674e19b
feedback(MapComponent)
sunilsabatp Nov 29, 2023
cfb95c8
fix type_issue for staticMap
sunilsabatp Dec 4, 2023
74f28b8
fix type issue for PlantLocation component
sunilsabatp Dec 5, 2023
79d114e
fix type issue for PlantLocationPage
sunilsabatp Dec 6, 2023
bb761fa
Don't show slider if image is missing
sunilsabatp Dec 8, 2023
493f31b
remove any from the Mytrees
sunilsabatp Dec 12, 2023
3d016a5
remove any from the PlantLocationPage
sunilsabatp Dec 12, 2023
39221be
fix application side error
sunilsabatp Jan 17, 2024
8281959
resolve merge conflict
sunilsabatp Jan 23, 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
25 changes: 21 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,12 @@
"@types/d3-ease": "^1.0.9",
"@types/express-slow-down": "^1.3.2",
"@types/file-saver": "^2.0.5",
"@types/geojson-validation": "^1.0.0",
"@types/node": "^14.0.26",
"@types/react": "^16.9.49",
"@types/react-dom": "^18.0.11",
"@types/react-map-gl": "^5.2.11",
"@types/react-json-editor-ajrm": "^2.5.3",
"@types/react-map-gl": "^6.1.3",
"@types/styled-jsx": "^2.2.8",
"@types/uuid": "^8.3.0",
"@typescript-eslint/eslint-plugin": "^5.41.0",
Expand Down
2 changes: 1 addition & 1 deletion src/features/common/CopyToClipboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Alert = styled(MuiAlert)(({ theme }) => {

interface Props {
text: string;
isButton: boolean;
isButton?: boolean;
}

export default function CopyToClipboard({
Expand Down
202 changes: 202 additions & 0 deletions src/features/common/types/map.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
import {
TreeProjectClassification,
CountryCode,
CurrencyCode,
TreeProjectMetadata,
DefaultPaymentConfig,
Tpo,
UnitTypes,
} from '@planet-sdk/common';
import { Nullable } from '@planet-sdk/common/build/types/util';
import { ContributionProps } from "../../user/RegisterTrees/RegisterTrees/SingleContribution";
import { FlyToInterpolator } from "react-map-gl";



export interface ViewportProps {
height: number | string ;
width: number | string ;
zoom: number | undefined;
latitude?: number;
longitude?: number;
center?: number[];
transitionDuration?: number | undefined;
transitionInterpolator?: FlyToInterpolator | undefined;
transitionEasing?: (normalizedTime: number) => number
}

export interface ProjectGeoJsonProps {
type: 'Feature';
geometry: {
type: string;
coordinates: number[];
};
properties: {
allowDonations: boolean;
classification: TreeProjectClassification;
countPlanted: number;
countTarget: number;
country: CountryCode;
currency: CurrencyCode;
id: string;
image: string;
isApproved: boolean;
isFeatured: boolean;
isTopProject: boolean;
location: Nullable<string>;
metadata: TreeProjectMetadata;
minTreeCount: number;
name: string;
paymentDefaults: Nullable<DefaultPaymentConfig>;
purpose: 'trees';
unit: 'tree';
slug: string;
taxDeductionCountries: CountryCode[];
tpo: Tpo;
treeCost: number;
unitCost: number;
unitType: UnitTypes;
};
}


export interface RegisterTreeGeometry {
features?: [];
coordinates: [number, number] | number[][];
type: 'Polygon' | 'Point';
}

export interface RegisterTreesFormProps {
setContributionGUID: React.Dispatch<React.SetStateAction<string>>;
setContributionDetails: React.Dispatch<
React.SetStateAction<ContributionProps | null>
>;
setRegistered: React.Dispatch<React.SetStateAction<boolean>>;
}



// Map styling

export interface MapStyle {
version: number
sprite: string
glyphs: string
sources: Sources
layers: Layer[]
metadata: Metadata
}

export type RequiredMapStyle = Omit<MapStyle, "sprite", "glyphs","metadata">

export interface Sources {
esri: Esri
}

export interface Esri {
type: string
scheme: string
tilejson: string
format: string
maxzoom: number
tiles: string[]
name: string
}

export interface Layer {
id: string
type: string
paint: Paint
layout: Layout
showProperties?: boolean
source?: string
"source-layer"?: string
minzoom?: number
maxzoom?: number
filter?: any[]
}

export interface Paint {
"background-color"?: string
"fill-color": any
"fill-outline-color"?: string
"fill-pattern"?: string
"fill-opacity"?: number
"line-color": any
"line-width": any
"line-dasharray"?: number[]
"text-color"?: string
"text-halo-color"?: string
"fill-translate"?: FillTranslate
"fill-translate-anchor"?: string
"line-opacity"?: number
"text-halo-blur"?: number
"text-halo-width"?: number
}

export interface FillTranslate {
stops: [number, number[]][]
}

export interface Layout {
visibility?: string
"line-join"?: string
"line-cap"?: string
"symbol-placement"?: string
"symbol-avoid-edges"?: boolean
"icon-image"?: string
"symbol-spacing"?: number
"icon-rotation-alignment"?: string
"icon-allow-overlap"?: boolean
"icon-padding"?: number
"text-font"?: string[]
"text-size": any
"text-letter-spacing": any
"text-line-height"?: number
"text-max-width"?: number
"text-field"?: string
"text-padding"?: number
"text-max-angle"?: number
"text-offset"?: number[]
"text-rotation-alignment"?: string
"text-transform"?: string
"text-optional"?: boolean
}

export interface Metadata {
arcgisStyleUrl: string
arcgisOriginalItemTitle: string
arcgisQuickEditorWarning: boolean
arcgisQuickEditor: ArcgisQuickEditor
arcgisEditorExtents: ArcgisEditorExtent[]
arcgisMinimapVisibility: boolean
}

export interface ArcgisQuickEditor {
labelTextColor: string
labelHaloColor: string
baseColor: string
spriteProcessing: boolean
labelContrast: number
labelColorMode: string
colorMode: string
colors: Colors
boundaries: string
}

export interface Colors {
boundaries: string
}

export interface ArcgisEditorExtent {
spatialReference: SpatialReference
xmin: number
ymin: number
xmax: number
ymax: number
}

export interface SpatialReference {
wkid: number
latestWkid?: number
}
31 changes: 24 additions & 7 deletions src/features/common/types/plantLocation.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
import { DateString } from './common';
import { Polygon, Point } from 'geojson';
import { Links } from './payments';
import { Polygon, Point } from 'geojson';

export interface Geometry {
coordinates: number[][][];
type: string;
properties: Properties;
}
export interface GeometryOfSinglePlant {
coordinates: number[];
type: string;
properties: Properties;
}

export interface Properties {
id: string;
}

export interface PlantLocationBase {
hid: string;
Expand All @@ -23,34 +38,35 @@ export interface PlantLocationBase {
status: string | null; // currently always null. Should we do something here?
statusReason: string | null; // currently always null. Should we do something here?
}

export interface PlantLocationSingle extends PlantLocationBase {
type: 'single';
type: PlantLocationType;
scientificName: string | null;
scientificSpecies: string | null;
tag: string | null;
measurements: Measurements;
originalGeometry: Point;
geometry: Point;
geometry: GeometryOfSinglePlant;
sampleTrees: SamplePlantLocation[];
}

export interface PlantLocationMulti extends PlantLocationBase {
type: 'multi';
type: PlantLocationType;
nextMeasurementDate: DateString | null;
plantDateStart: DateString | null;
plantDateEnd: DateString | null;
sampleTreeCount: number;
samplePlantLocations: SamplePlantLocation[];
plantedSpecies: PlantedSpecies[];
originalGeometry: Polygon;
geometry: Polygon;
geometry: Geometry;
sampleTrees: SamplePlantLocation[];
}

export type PlantLocation = PlantLocationSingle | PlantLocationMulti;

export interface SamplePlantLocation
extends Omit<PlantLocationBase, 'plantProject'> {
type: 'sample';
type: Type;
/** parent plant location */
parent: string;
/** tpo profile id */
Expand All @@ -63,6 +79,7 @@ export interface SamplePlantLocation
measurements: Measurements;
originalGeometry: Point;
geometry: Point;
sampleTrees?: PlantLocation[];
}

export interface Metadata {
Expand Down
17 changes: 13 additions & 4 deletions src/features/projects/components/ProjectsMap.tsx
prachigarg19 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import { useTranslation } from 'next-i18next';
import { ParamsContext } from '../../common/Layout/QueryParamsContext';
import { PopupData } from './maps/Markers';

interface ShowDetailsProps {
coordinates: [number, number] | null;
show: boolean;
}

export default function ProjectsMap(): ReactElement {
const {
project,
Expand Down Expand Up @@ -63,8 +68,8 @@ export default function ProjectsMap(): ReactElement {
loadMapStyle();
}, []);

const [showDetails, setShowDetails] = React.useState<DetailsType>({
coordinates: [],
const [showDetails, setShowDetails] = React.useState<ShowDetailsProps>({
coordinates: null,
show: false,
});

Expand Down Expand Up @@ -186,8 +191,12 @@ export default function ProjectsMap(): ReactElement {
</div>
{showDetails.show && (
<Popup
latitude={showDetails.coordinates[1]}
longitude={showDetails.coordinates[0]}
latitude={
Copy link
Contributor

Choose a reason for hiding this comment

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

On line number 161 onStateChange is not a part of the MapGL props

showDetails?.coordinates ? showDetails?.coordinates[1] : 0
}
longitude={
showDetails?.coordinates ? showDetails?.coordinates[1] : 0
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Cleanup needed for DetailsType

closeButton={false}
closeOnClick={false}
onClose={() => setPopupData({ show: false })}
Expand Down
Loading