| | |
| | | import React, { useState, useRef, useEffect, useMemo } from "react"; |
| | | import React from "react"; |
| | | import { useTranslate } from "react-admin"; |
| | | import { |
| | | Fab, |
| | | Box, |
| | | Backdrop, |
| | | useTheme, |
| | | } from '@mui/material'; |
| | | import { Fab } from '@mui/material'; |
| | | import CropFreeIcon from '@mui/icons-material/CropFree'; |
| | | import CircularProgress from '@mui/material/CircularProgress'; |
| | | import * as Tool from '../tool'; |
| | | |
| | | const AreaFab = (props) => { |
| | | const { curZone, showAreas, setShowAreas, notify } = props; |
| | | const { curZone, showAreas, setShowAreas } = props; |
| | | const translate = useTranslate(); |
| | | const theme = useTheme(); // theme.palette.primary.main |
| | | |
| | | const [loading, setLoading] = React.useState(false); |
| | | |
| | | const handleClick = () => { |
| | | if (showAreas) { |
| | | // setShowAreas(false); |
| | | Tool.hideAreas(curZone, setShowAreas); |
| | | } else { |
| | | // setShowAreas(true); |
| | | Tool.showAreas(curZone, setShowAreas, setLoading); |
| | | } |
| | | } |
| | |
| | | sprite.destroy({ children: true, texture: false, baseTexture: false }); |
| | | }; |
| | | |
| | | export const loadAreas = (curZone, setCurSprite) => { |
| | | export const loadAreas = (curZone, setCurSprite, callback) => { |
| | | if (!mapContainer) return; |
| | | clearAreas(); |
| | | fetchAreaList(curZone).then((areas) => { |
| | |
| | | mapContainer.addChild(graphics); |
| | | } |
| | | }); |
| | | if (callback) { |
| | | callback(areas); |
| | | } |
| | | }); |
| | | }; |
| | | |
| | |
| | | areaDrawingCleanup(); |
| | | } |
| | | }; |
| | | |
| | | export const showAreas = (curZone, setShowAreas, setLoading) => { |
| | | setLoading(true); |
| | | loadAreas(curZone, null, (areas) => { |
| | | setLoading(false); |
| | | setShowAreas(true); |
| | | }) |
| | | }; |
| | | |
| | | export const hideAreas = (curZone, setShowAreas) => { |
| | | clearAreas(); |
| | | if (setShowAreas) { |
| | | setShowAreas(false); |
| | | } |
| | | }; |