Skip to content

Commit

Permalink
feat: simplify server marker
Browse files Browse the repository at this point in the history
  • Loading branch information
Jujulego committed Feb 16, 2025
1 parent 2f74d74 commit fe2736c
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 61 deletions.
21 changes: 7 additions & 14 deletions app/(with-map)/server/[ip]/big-data-cloud/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { decodeIp, type WithMapServerIpParams } from '@/app/(with-map)/server/[ip]/params';
import MapFlyTo from '@/components/map/MapFlyTo';
import MapSpin from '@/components/map/MapSpin';
import AutonomousSystemItem from '@/components/server/AutonomousSystemItem';
import PayloadItem from '@/components/server/PayloadItem';
Expand Down Expand Up @@ -55,19 +54,13 @@ export default async function WMServerIpBDCPage({ params }: WMServerIpBDCPagePro
<PayloadItem payload={data} />

{ coordinates ? (
<>
<ServerMarker
latitude={coordinates.latitude}
longitude={coordinates.longitude}
tooltip="Big Data Cloud"
selected
sx={{ color: 'bigDataCloud.main' }}
/>
<MapFlyTo latitude={coordinates.latitude} longitude={coordinates.longitude} zoom={5} />
</>
) : (
<MapSpin />
) }
<ServerMarker
coordinates={coordinates}
tooltip="Big Data Cloud"
selected
sx={{ color: 'bigDataCloud.main' }}
/>
) : <MapSpin /> }

Check warning on line 63 in app/(with-map)/server/[ip]/big-data-cloud/page.tsx

View check run for this annotation

Codecov / codecov/patch

app/(with-map)/server/[ip]/big-data-cloud/page.tsx#L57-L63

Added lines #L57 - L63 were not covered by tests
</List>
);
}
21 changes: 7 additions & 14 deletions app/(with-map)/server/[ip]/ip-data/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { decodeIp, type WithMapServerIpParams } from '@/app/(with-map)/server/[ip]/params';
import MapFlyTo from '@/components/map/MapFlyTo';
import MapSpin from '@/components/map/MapSpin';
import AutonomousSystemItem from '@/components/server/AutonomousSystemItem';

Check warning on line 3 in app/(with-map)/server/[ip]/ip-data/page.tsx

View check run for this annotation

Codecov / codecov/patch

app/(with-map)/server/[ip]/ip-data/page.tsx#L3

Added line #L3 was not covered by tests
import PayloadItem from '@/components/server/PayloadItem';
Expand Down Expand Up @@ -54,19 +53,13 @@ export default async function WMServerIpDataPage({ params }: WMServerIpDataPageP
<PayloadItem payload={data} />

{ coordinates ? (
<>
<ServerMarker
latitude={coordinates.latitude}
longitude={coordinates.longitude}
tooltip="ipdata"
selected
sx={{ color: 'ipdata.main' }}
/>
<MapFlyTo latitude={coordinates.latitude} longitude={coordinates.longitude} zoom={5} />
</>
) : (
<MapSpin />
) }
<ServerMarker
coordinates={coordinates}
tooltip="ipdata"
selected
sx={{ color: 'ipdata.main' }}
/>
) : <MapSpin /> }

Check warning on line 62 in app/(with-map)/server/[ip]/ip-data/page.tsx

View check run for this annotation

Codecov / codecov/patch

app/(with-map)/server/[ip]/ip-data/page.tsx#L56-L62

Added lines #L56 - L62 were not covered by tests
</List>
);
}
5 changes: 1 addition & 4 deletions app/(with-map)/server/[ip]/ip-geolocation/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { decodeIp, type WithMapServerIpParams } from '@/app/(with-map)/server/[ip]/params';
import MapFlyTo from '@/components/map/MapFlyTo';
import MapSpin from '@/components/map/MapSpin';
import AutonomousSystemItem from '@/components/server/AutonomousSystemItem';

Check warning on line 3 in app/(with-map)/server/[ip]/ip-geolocation/page.tsx

View check run for this annotation

Codecov / codecov/patch

app/(with-map)/server/[ip]/ip-geolocation/page.tsx#L3

Added line #L3 was not covered by tests
import PayloadItem from '@/components/server/PayloadItem';
Expand Down Expand Up @@ -54,13 +53,11 @@ export default async function WMServerIpGeolocationPage({ params }: WMServerIpGe
<PayloadItem payload={data} />

<ServerMarker
latitude={coordinates.latitude}
longitude={coordinates.longitude}
coordinates={coordinates}

Check warning on line 56 in app/(with-map)/server/[ip]/ip-geolocation/page.tsx

View check run for this annotation

Codecov / codecov/patch

app/(with-map)/server/[ip]/ip-geolocation/page.tsx#L55-L56

Added lines #L55 - L56 were not covered by tests
tooltip="ipgeolocation"
selected
sx={{ color: 'ipGeolocation.main' }}
/>
<MapFlyTo latitude={coordinates.latitude} longitude={coordinates.longitude} zoom={5} />
</List>
);
}
16 changes: 6 additions & 10 deletions app/(with-map)/server/[ip]/ip-info/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,12 @@ export default async function WMServerIpInfoPage({ params }: WMServerIpInfoPageP
<PayloadItem payload={data} />

{ coordinates ? (
<>
<ServerMarker
latitude={coordinates.latitude}
longitude={coordinates.longitude}
tooltip="IPinfo"
selected
sx={{ color: 'ipInfo.main' }}
/>
<MapFlyTo latitude={coordinates.latitude} longitude={coordinates.longitude} zoom={5} />
</>
<ServerMarker
coordinates={coordinates}
tooltip="IPinfo"
selected
sx={{ color: 'ipInfo.main' }}
/>

Check warning on line 52 in app/(with-map)/server/[ip]/ip-info/page.tsx

View check run for this annotation

Codecov / codecov/patch

app/(with-map)/server/[ip]/ip-info/page.tsx#L47-L52

Added lines #L47 - L52 were not covered by tests
) : <MapSpin /> }
</List>
);
Expand Down
21 changes: 7 additions & 14 deletions app/(with-map)/server/[ip]/ip-quality-score/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { decodeIp, type WithMapServerIpParams } from '@/app/(with-map)/server/[ip]/params';
import MapFlyTo from '@/components/map/MapFlyTo';
import MapSpin from '@/components/map/MapSpin';
import AutonomousSystemItem from '@/components/server/AutonomousSystemItem';

Check warning on line 3 in app/(with-map)/server/[ip]/ip-quality-score/page.tsx

View check run for this annotation

Codecov / codecov/patch

app/(with-map)/server/[ip]/ip-quality-score/page.tsx#L3

Added line #L3 was not covered by tests
import PayloadItem from '@/components/server/PayloadItem';
Expand Down Expand Up @@ -55,19 +54,13 @@ export default async function WMServerIpIPQSPage({ params }: WMServerIpIPQSPageP
<PayloadItem payload={data} />

{ coordinates ? (
<>
<ServerMarker
latitude={coordinates.latitude}
longitude={coordinates.longitude}
tooltip="IPQS"
selected
sx={{ color: 'ipQualityScore.main' }}
/>
<MapFlyTo latitude={coordinates.latitude} longitude={coordinates.longitude} zoom={5} />
</>
) : (
<MapSpin />
) }
<ServerMarker
coordinates={coordinates}
tooltip="IPQS"
selected
sx={{ color: 'ipQualityScore.main' }}
/>
) : <MapSpin /> }

Check warning on line 63 in app/(with-map)/server/[ip]/ip-quality-score/page.tsx

View check run for this annotation

Codecov / codecov/patch

app/(with-map)/server/[ip]/ip-quality-score/page.tsx#L57-L63

Added lines #L57 - L63 were not covered by tests
</List>
);
}
1 change: 1 addition & 0 deletions components/animal/AnimalMarker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default function AnimalMarker({ coordinates }: AnimalMarkerProps) {
}
}, [coordinates, flyTo, isReady]);

Check warning on line 22 in components/animal/AnimalMarker.tsx

View check run for this annotation

Codecov / codecov/patch

components/animal/AnimalMarker.tsx#L18-L22

Added lines #L18 - L22 were not covered by tests

// Render
return (
<MapMarker latitude={coordinates.latitude} longitude={coordinates.longitude}>
<m.div
Expand Down
20 changes: 15 additions & 5 deletions components/server/ServerMarker.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
'use client';

import MapMarker from '@/components/map/MapMarker';
import { useMapFlyTo } from '@/lib/map/useMapFlyTo';

Check warning on line 4 in components/server/ServerMarker.tsx

View check run for this annotation

Codecov / codecov/patch

components/server/ServerMarker.tsx#L3-L4

Added lines #L3 - L4 were not covered by tests
import type { Coordinates } from '@/lib/utils/coordinates';
import { mergeSx } from '@/lib/utils/mui';
import PlaceIcon from '@mui/icons-material/Place';

Check warning on line 7 in components/server/ServerMarker.tsx

View check run for this annotation

Codecov / codecov/patch

components/server/ServerMarker.tsx#L6-L7

Added lines #L6 - L7 were not covered by tests
import { type SxProps, type Theme } from '@mui/material/styles';
import Tooltip from '@mui/material/Tooltip';
import { m } from 'motion/react';
import { type ReactNode } from 'react';
import { type ReactNode, useEffect } from 'react';

Check warning on line 11 in components/server/ServerMarker.tsx

View check run for this annotation

Codecov / codecov/patch

components/server/ServerMarker.tsx#L9-L11

Added lines #L9 - L11 were not covered by tests

// Component
export interface ServerMarkerProps {
readonly latitude: number;
readonly longitude: number;
readonly coordinates: Coordinates;
readonly tooltip?: ReactNode;
readonly selected?: boolean;
readonly sx?: SxProps<Theme>;
}

export default function ServerMarker({ latitude, longitude, tooltip, selected, sx }: ServerMarkerProps) {
export default function ServerMarker({ coordinates, tooltip, selected, sx }: ServerMarkerProps) {
const { flyTo, isReady } = useMapFlyTo();

Check warning on line 22 in components/server/ServerMarker.tsx

View check run for this annotation

Codecov / codecov/patch

components/server/ServerMarker.tsx#L21-L22

Added lines #L21 - L22 were not covered by tests

useEffect(() => {
if (isReady) {
flyTo({ latitude: coordinates.latitude, longitude: coordinates.longitude, zoom: 5 });
}
}, [coordinates, flyTo, isReady]);

Check warning on line 28 in components/server/ServerMarker.tsx

View check run for this annotation

Codecov / codecov/patch

components/server/ServerMarker.tsx#L24-L28

Added lines #L24 - L28 were not covered by tests

// Render
return (
<MapMarker latitude={latitude} longitude={longitude}>
<MapMarker latitude={coordinates.latitude} longitude={coordinates.longitude}>
<m.div
initial={{ scale: 0, translateY: '8.33%' }}
style={{
Expand Down

0 comments on commit fe2736c

Please sign in to comment.