Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | 53x 16x 16x 16x 16x 16x 16x 48x 53x 53x 53x 48x 53x | import { Box, Stack } from "@mui/material";
import { GoogleMaps } from "@services/google-api";
import { TGeoMap } from "@features/TransactionsRiskProfile/data.types";
import useLoadGoogleScript from "@hooks/google-api/useLoadGoogleScript";
import { useCustomThemeV2 } from "@theme/hooks/useCustomThemeV2";
import { useAppTheme } from "@theme/v2/Provider";
import { MinusIcon, PlusIcon } from "@phosphor-icons/react";
import GiveIconButton from "@shared/IconButton/GiveIconButton";
import { styled } from "@theme/v2/Provider";
import GiveTruncateText from "@shared/Text/GiveTruncateText";
import GiveText from "@shared/Text/GiveText";
import { formatCoordinate } from "@features/TransactionPanel/utils";
import { useMarkerGoogleMapsProps } from "@hooks/useMarkerGoogleMapsProps";
const IPAddressLocationMapV2 = ({ data }: { data: TGeoMap }) => {
const { isLoaded } = useLoadGoogleScript();
const { isMobileView } = useCustomThemeV2();
const markerGoogleMapsProps = useMarkerGoogleMapsProps();
const mapCoordinates =
data.latitude && data.longitude
? {
lat: data.latitude,
lng: data.longitude,
}
: undefined;
const overlayItems = [
{
label: "Longitude",
value: data.longitude
? formatCoordinate(data.longitude, "longitude")
: "-",
},
{
label: "Latitude",
value: data.latitude ? formatCoordinate(data.latitude, "longitude") : "-",
},
{
label: "Timezone",
value: data.timezone,
},
];
return (
<Box position="relative">
<GoogleMaps
coordinates={mapCoordinates}
isLoaded={isLoaded}
viewMarker={true}
initialZoom={16}
{...markerGoogleMapsProps}
containerStyle={{
width: "100%",
height: "200px",
marginInline: "auto",
}}
customOptions={{
disableDefaultUI: true,
}}
{...(!isMobileView && { CustomZoomControl })}
/>
{mapCoordinates && !isMobileView && (
<OverlayContainer>
{overlayItems.map((item) => (
<OverlayItem key={item.label} {...item} />
))}
</OverlayContainer>
)}
</Box>
);
};
const CustomZoomControl = ({
onZoomIn,
onZoomOut,
}: {
onZoomIn: () => void;
onZoomOut: () => void;
}) => {
const { palette } = useAppTheme();
return (
<Stack
style={{
position: "absolute",
bottom: 8,
right: 16,
backgroundColor: palette.common.white,
borderRadius: "8px",
}}
>
<StyledZoomButton onClick={onZoomIn} Icon={PlusIcon} size="mediumSmall" />
<StyledZoomButton
onClick={onZoomOut}
Icon={MinusIcon}
size="mediumSmall"
/>
</Stack>
);
};
const StyledZoomButton = styled(GiveIconButton)({
backgroundColor: "transparent",
boxShadow: "none",
"&:hover": {
backgroundColor: "transparent",
},
});
const OverlayItem = ({
label,
value = "",
}: {
label: string;
value?: string | number;
}) => {
return (
<Stack direction="column" gap="2px" width="max-content">
<GiveText variant="bodyXXS" color="secondary">
{label}
</GiveText>
<GiveTruncateText lineClamp={1} variant="bodyXXS">
{value}
</GiveTruncateText>
</Stack>
);
};
const OverlayContainer = styled(Stack)(({ theme }) => ({
borderRadius: "12px",
background: theme.palette?.surface?.primary,
padding: "8px 16px",
flexDirection: "row",
gap: "20px",
alignItems: "center",
position: "absolute",
bottom: 8,
right: 0,
left: 0,
marginInline: "auto",
width: "min-content",
}));
export default IPAddressLocationMapV2;
|