import { Delete, Route } from "@mui/icons-material"; import { Box, Button, Stack, Typography } from "@mui/material"; import { useReducer } from "react"; import DrawPolygon from "./DrawBound"; const statusType = [ { id: 0, message: "برای آغاز ترسیم محدوده، کلیک کنید!", buttons: [ { label: "شروع ترسیم محدوده", key: "start", color: "warning", icon: , onclick: (controlDispach) => { controlDispach({ type: "SET_STATUS", status: 1 }); }, }, ], }, { id: 1, message: "محدوده‌ی موردنظر را با کلیک روی نقشه مشخص کنید. برای اتمام، روی نقطه‌ی ابتدایی کلیک کنید!", buttons: [], }, { id: 2, message: "برای اصلاح محدوده، گوشه‌ها را بکشید. برای ترسیم دوباره، آن را حذف کنید", buttons: [ { label: "حذف", key: "end", color: "error", icon: , onclick: (controlDispach) => { controlDispach({ type: "SET_STATUS", status: 0 }); }, }, ], }, ]; const createInitialState = (drawBound) => { if (drawBound) { return { status: 2 }; } return { status: 0 }; }; const reducer = (state, action) => { switch (action.type) { case "SET_STATUS": return { ...state, status: action.status }; default: return state; } }; const MapDrawPolygon = ({ drawBound, setDrawBound }) => { const [control, controlDispach] = useReducer(reducer, drawBound, createInitialState); return ( <> theme.palette.secondary.main, borderBottomLeftRadius: 8, borderBottomRightRadius: 8, py: 0.5, px: 2, }} > {statusType.find((st) => st.id == control.status).message} {statusType .find((st) => st.id == control.status) .buttons.map((button) => ( ))} ); }; export default MapDrawPolygon;