From f1ed47e5c3e8baea01da3f636ed39efbfdff06fb Mon Sep 17 00:00:00 2001 From: LWangllix Date: Thu, 23 Nov 2023 22:07:56 +0200 Subject: [PATCH 1/4] disable map --- src/components/other/Map.tsx | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/components/other/Map.tsx b/src/components/other/Map.tsx index e565e8a..6e3c0d8 100644 --- a/src/components/other/Map.tsx +++ b/src/components/other/Map.tsx @@ -8,23 +8,30 @@ import Icon from "./Icon"; import LoaderComponent from "./LoaderComponent"; export interface MapProps { - height?: string; - onSave?: (geom: any, data: any) => void; - onClose?: () => void; - error?: string; - queryString?: string; - value?: string; + height: string; + value: string; display: boolean; + } -const Map = ({ height, onSave, onClose, value, display }: MapProps) => { +const Map = ({ height, value, display }: MapProps) => { const [showModal, setShowModal] = useState(false); - const [loading, setLoading] = useState(true); const iframeRef = useRef(null); const isMobile = useMediaQuery(device.mobileL); - const src = `${Url.DRAW}`; + + const getMapUrl = () => { + const url = new URL(Url.DRAW); + const params = new URLSearchParams(url.search); + params.append("preview", "true"); + url.search = params.toString(); + return url.href; + }; + + const src = getMapUrl(); + + const handleLoadMap = () => { setLoading(false); @@ -45,10 +52,6 @@ const Map = ({ height, onSave, onClose, value, display }: MapProps) => { type="button" onClick={(e) => { e.preventDefault(); - if (!!onClose) { - return onClose(); - } - setShowModal(!showModal); }} > @@ -63,7 +66,7 @@ const Map = ({ height, onSave, onClose, value, display }: MapProps) => { ref={iframeRef} src={src} width={"100%"} - height={showModal ? "100%" : `${height || "230px"}`} + height={showModal ? "100%" : `${height}`} style={{ border: 0 }} allowFullScreen={true} onLoad={handleLoadMap} From 565247994e133623896f4b561f9bef8622225dab Mon Sep 17 00:00:00 2001 From: LWangllix Date: Thu, 23 Nov 2023 22:18:05 +0200 Subject: [PATCH 2/4] cleanup --- src/components/other/Map.tsx | 58 ++---------------------------------- 1 file changed, 2 insertions(+), 56 deletions(-) diff --git a/src/components/other/Map.tsx b/src/components/other/Map.tsx index 6e3c0d8..1997c94 100644 --- a/src/components/other/Map.tsx +++ b/src/components/other/Map.tsx @@ -1,10 +1,7 @@ -import { useMediaQuery } from "@material-ui/core"; import { useRef, useState } from "react"; import styled from "styled-components"; import { device } from "../../styles"; import { Url } from "../../utils/texts"; -import Button from "../buttons/Button"; -import Icon from "./Icon"; import LoaderComponent from "./LoaderComponent"; export interface MapProps { @@ -15,11 +12,8 @@ export interface MapProps { } const Map = ({ height, value, display }: MapProps) => { - const [showModal, setShowModal] = useState(false); const [loading, setLoading] = useState(true); const iframeRef = useRef(null); - const isMobile = useMediaQuery(device.mobileL); - const getMapUrl = () => { const url = new URL(Url.DRAW); @@ -28,11 +22,7 @@ const Map = ({ height, value, display }: MapProps) => { url.search = params.toString(); return url.href; }; - const src = getMapUrl(); - - - const handleLoadMap = () => { setLoading(false); @@ -46,27 +36,12 @@ const Map = ({ height, value, display }: MapProps) => { <> {loading ? : null} - {isMobile && ( - { - e.preventDefault(); - setShowModal(!showModal); - }} - > - - - - - )} - ` display: ${({ display }) => (display ? "flex" : "none")}; `; -const StyledIcon = styled(Icon)` - font-size: 2rem; - color: #6b7280; -`; + const InnerContainer = styled.div<{}>` position: relative; @@ -111,32 +83,6 @@ const StyledIframe = styled.iframe<{ height: ${({ height }) => height}; `; -const StyledButton = styled(Button)<{ popup: boolean }>` - position: absolute; - z-index: 10; - top: 100px; - right: ${({ popup }) => (popup ? 28 : 11)}px; - min-width: 28px; - - height: 28px; - @media ${device.mobileL} { - top: 180px; - right: 10px; - } - button { - border-color: #e5e7eb; - background-color: white !important; - width: 30px; - height: 30px; - padding: 0; - box-shadow: 0px 18px 41px #121a5529; - } -`; -const StyledIconContainer = styled.div` - display: flex; - justify-content: center; - align-items: center; -`; export default Map; From d3291f939a605842756722c57a6709954ba3f3cf Mon Sep 17 00:00:00 2001 From: LWangllix Date: Thu, 23 Nov 2023 23:35:07 +0200 Subject: [PATCH 3/4] naming fix --- src/components/forms/Done.tsx | 2 +- src/components/forms/Review.tsx | 2 +- src/components/other/{Map.tsx => PreviewMap.tsx} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename src/components/other/{Map.tsx => PreviewMap.tsx} (100%) diff --git a/src/components/forms/Done.tsx b/src/components/forms/Done.tsx index a0ff6d6..753ad1c 100644 --- a/src/components/forms/Done.tsx +++ b/src/components/forms/Done.tsx @@ -13,8 +13,8 @@ import Button from "../buttons/Button"; import PhotoUploadField from "../fields/PhotoUploadField"; import FishStockingInfo from "../other/Info"; import InfoColumn from "../other/InfoColumn"; -import Map from "../other/Map"; import FishStockingPageTitle from "../other/PageTitle"; +import Map from "../other/PreviewMap"; import SignatureList from "../other/SignatureList"; import FishStockingTable from "../other/Table"; import { fishOrigins } from "./Registration"; diff --git a/src/components/forms/Review.tsx b/src/components/forms/Review.tsx index 07392eb..2e05ae1 100644 --- a/src/components/forms/Review.tsx +++ b/src/components/forms/Review.tsx @@ -22,9 +22,9 @@ import TextAreaField from "../fields/TextAreaField"; import TextField from "../fields/TextField"; import ApproveFishRow from "../other/ApproveFishRow"; import DeleteCard from "../other/DeleteCard"; -import Map from "../other/Map"; import Modal from "../other/Modal"; import FishStockingPageTitle from "../other/PageTitle"; +import Map from "../other/PreviewMap"; import SignatureRow from "../other/SignatureRow"; export interface FishStockingFactFormProps { diff --git a/src/components/other/Map.tsx b/src/components/other/PreviewMap.tsx similarity index 100% rename from src/components/other/Map.tsx rename to src/components/other/PreviewMap.tsx From 1730d2f7e564eaae6a326f738f63359c4bce068d Mon Sep 17 00:00:00 2001 From: LWangllix Date: Thu, 23 Nov 2023 23:39:13 +0200 Subject: [PATCH 4/4] naming fix --- src/components/forms/Done.tsx | 4 ++-- src/components/forms/Review.tsx | 4 ++-- src/components/other/PreviewMap.tsx | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/forms/Done.tsx b/src/components/forms/Done.tsx index 753ad1c..bf0ffc3 100644 --- a/src/components/forms/Done.tsx +++ b/src/components/forms/Done.tsx @@ -14,7 +14,7 @@ import PhotoUploadField from "../fields/PhotoUploadField"; import FishStockingInfo from "../other/Info"; import InfoColumn from "../other/InfoColumn"; import FishStockingPageTitle from "../other/PageTitle"; -import Map from "../other/PreviewMap"; +import PreviewMap from "../other/PreviewMap"; import SignatureList from "../other/SignatureList"; import FishStockingTable from "../other/Table"; import { fishOrigins } from "./Registration"; @@ -190,7 +190,7 @@ const FishStockingCompleted = ({ - + ); }; diff --git a/src/components/forms/Review.tsx b/src/components/forms/Review.tsx index 2e05ae1..e4c2c92 100644 --- a/src/components/forms/Review.tsx +++ b/src/components/forms/Review.tsx @@ -24,7 +24,7 @@ import ApproveFishRow from "../other/ApproveFishRow"; import DeleteCard from "../other/DeleteCard"; import Modal from "../other/Modal"; import FishStockingPageTitle from "../other/PageTitle"; -import Map from "../other/PreviewMap"; +import PreviewMap from "../other/PreviewMap"; import SignatureRow from "../other/SignatureRow"; export interface FishStockingFactFormProps { @@ -333,7 +333,7 @@ const Review = ({ /> - { +const PreviewMap = ({ height, value, display }: MapProps) => { const [loading, setLoading] = useState(true); const iframeRef = useRef(null); @@ -85,4 +85,4 @@ const StyledIframe = styled.iframe<{ -export default Map; +export default PreviewMap;