diff --git a/src/containers/alert/index.tsx b/src/containers/alert/index.tsx index e5ae515e7..4bfa4e860 100644 --- a/src/containers/alert/index.tsx +++ b/src/containers/alert/index.tsx @@ -7,7 +7,6 @@ import { useRouter } from 'next/router'; import { analysisAlertAtom, analysisAtom, skipAnalysisAlertAtom } from 'store/analysis'; import { drawingToolAtom, drawingUploadToolAtom } from 'store/drawing-tool'; import { locationsModalAtom } from 'store/locations'; -import { printModeState } from 'store/print-mode'; import { locationToolAtom } from 'store/sidebar'; import { useRecoilState, useRecoilValue, useResetRecoilState, useSetRecoilState } from 'recoil'; @@ -23,7 +22,6 @@ const AnalysisAlert = () => { const { asPath, replace } = useRouter(); const locationTool = useRecoilValue(locationToolAtom); - const isPrintingMode = useRecoilValue(printModeState); const setLocationsModalIsOpen = useSetRecoilState(locationsModalAtom); const [isAnalysisAlertOpen, setAnalysisAlert] = useRecoilState(analysisAlertAtom); const [skipAnalysisAlert, setSkipAnalysisAlert] = useRecoilState(skipAnalysisAlertAtom); @@ -33,8 +31,7 @@ const AnalysisAlert = () => { const queryParams = useMemo(() => asPath.split('?')[1], [asPath]); - const isPrintingId = isPrintingMode ? 'print-mode' : 'no-print'; - const { [`default-desktop-${isPrintingId}`]: map } = useMap(); + const { [`default-desktop`]: map } = useMap(); const handleCancelResetPage = useCallback(() => { setAnalysisAlert(false); diff --git a/src/containers/datasets/drawing-tool/index.tsx b/src/containers/datasets/drawing-tool/index.tsx index d04412469..2cd413f88 100644 --- a/src/containers/datasets/drawing-tool/index.tsx +++ b/src/containers/datasets/drawing-tool/index.tsx @@ -23,8 +23,7 @@ const WidgetDrawingTool = () => { const [{ enabled: isDrawingToolEnabled }, setDrawingToolState] = useRecoilState(drawingToolAtom); const resetDrawingUploadToolState = useResetRecoilState(drawingUploadToolAtom); - const [{ enabled: isDrawingUploadToolEnabled, uploadedGeojson }] = - useRecoilState(drawingUploadToolAtom); + const [{ uploadedGeojson }] = useRecoilState(drawingUploadToolAtom); const setAnalysisState = useSetRecoilState(analysisAtom); const setMapCursor = useSetRecoilState(mapCursorAtom); @@ -57,12 +56,7 @@ const WidgetDrawingTool = () => { ...drawingToolState, enabled: !isDrawingToolEnabled, })); - }, [ - setDrawingToolState, - isDrawingToolEnabled, - isDrawingUploadToolEnabled, - resetDrawingUploadToolState, - ]); + }, [setDrawingToolState, isDrawingToolEnabled, resetDrawingUploadToolState]); useUploadFile(acceptedFiles?.[0], onUploadFile); @@ -82,7 +76,7 @@ const WidgetDrawingTool = () => { - - - - - - - - {/* //*DRAW AREA* */} - - - - {/* //*UPLOAD SHAPEFILE* */} - - - + +

Find locations

+ + + + + + + + + {/* //*DRAW AREA* */} + + + + {/* //*UPLOAD SHAPEFILE* */} + ); }; diff --git a/src/containers/widget/index.tsx b/src/containers/widget/index.tsx index 7f0d5b152..681e3d05f 100644 --- a/src/containers/widget/index.tsx +++ b/src/containers/widget/index.tsx @@ -2,6 +2,7 @@ import React, { useCallback, ReactElement, FC } from 'react'; import cn from 'lib/classnames'; +import { drawingToolAtom, drawingUploadToolAtom } from 'store/drawing-tool'; import { widgetsCollapsedAtom } from 'store/widgets'; import { AnimatePresence, motion } from 'framer-motion'; @@ -28,10 +29,12 @@ type WidgetLayoutProps = { const WidgetWrapper: FC = (props: WidgetLayoutProps) => { const { children, title, id, className, applicability, info } = props; - + const { enabled: isDrawingToolEnabled } = useRecoilValue(drawingToolAtom); + const { enabled: isDrawingUploadToolEnabled } = useRecoilValue(drawingUploadToolAtom); const isLayerActive = useRecoilValue(getLayerActive(id)); - const [widgetsCollapsed, setWidgetsCollapsed] = useRecoilState(widgetsCollapsedAtom); + const [widgetsCollapsed, setWidgetsCollapsed] = + useRecoilState>(widgetsCollapsedAtom); const handleWidgetCollapsed = useCallback(() => { const updatedWidgetsCollapsed = { @@ -54,12 +57,15 @@ const WidgetWrapper: FC = (props: WidgetLayoutProps) => { if (Boolean(children.type() === null)) return null; + const isCollapsed: boolean = + isDrawingToolEnabled || isDrawingUploadToolEnabled ? false : widgetsCollapsed[id]; + return ( = (props: WidgetLayoutProps) => { data-testid={`widget-${id}-content`} className={cn({ 'group-last-of-type:block': true, - hidden: widgetsCollapsed[id], - block: !widgetsCollapsed[id], + hidden: isCollapsed, + block: !isCollapsed, })} > {children} @@ -101,9 +107,9 @@ const WidgetWrapper: FC = (props: WidgetLayoutProps) => { {applicability && (

Data applicability:{' '} diff --git a/src/containers/widgets/index.tsx b/src/containers/widgets/index.tsx index d1d2fbda3..09d8c481e 100644 --- a/src/containers/widgets/index.tsx +++ b/src/containers/widgets/index.tsx @@ -85,7 +85,7 @@ const WidgetsContainer: FC = () => { return enabledWidgets.filter( ({ slug }) => activeWidgets?.includes(slug) || slug === 'widgets_deck_tool' ); - }, [activeWidgets, enabledWidgets]) satisfies WidgetTypes[]; + }, [activeWidgets, enabledWidgets, customGeojson, uploadedGeojson]) satisfies WidgetTypes[]; const setPrintingMode = useSetRecoilState(printModeState); const cat = useWidgetsIdsByCategory(activeWidgets); @@ -121,21 +121,11 @@ const WidgetsContainer: FC = () => { setWidgetsCollapsed(updateWidgetsCollapsed); }, [widgetsCollapsed, widgetsCollapsedChecker, setWidgetsCollapsed]); - const expandedWidgets = Object.keys(widgetsCollapsed).reduce((acc, key) => { - acc[key] = false; - return acc; - }, {}); - const onClickDownload = useCallback(() => { - // setWidgetsCollapsed(expandedWidgets); - // setPrintingMode(true); setTimeout(() => { window.print(); }, 2000); - // setTimeout(() => { - // setPrintingMode(false); - // }, 4000); - }, [expandedWidgets, setPrintingMode, setWidgetsCollapsed]); + }, []); return (