feat: Fixed path for routes

This commit is contained in:
2025-06-09 14:07:51 +03:00
parent 64c15b2622
commit 2ca1f2cba4
13 changed files with 706 additions and 32 deletions

View File

@ -35,6 +35,7 @@ import {
Pencil,
Save,
Plus,
Loader2,
} from "lucide-react";
import { toast } from "react-toastify";
import { singleClick, doubleClick } from "ol/events/condition";
@ -1061,7 +1062,7 @@ const MapControls: React.FC<MapControlsProps> = ({
},
{
mode: "drawing-sight",
title: "Место",
title: "Достопримечательность",
longTitle: "Добавить достопримечательность",
icon: <Landmark size={16} className="mr-1 sm:mr-2" />,
action: () => mapService.startDrawingSight(),
@ -1109,6 +1110,7 @@ const MapSightbar: React.FC<MapSightbarProps> = ({
}) => {
const [activeSection, setActiveSection] = useState<string | null>("layers");
const navigate = useNavigate();
const [isLoading, setIsLoading] = useState(false);
const toggleSection = (id: string) =>
setActiveSection(activeSection === id ? null : id);
@ -1124,7 +1126,9 @@ const MapSightbar: React.FC<MapSightbarProps> = ({
(id: string | number | undefined, recourse: string) => {
if (
mapService &&
window.confirm("Вы действительно хотите удалить этот объект?")
window.confirm(
"Вы действительно хотите удалить этот объект? Утерянные данные не могут быть восстановлены."
)
)
mapService.deleteFeature(id, recourse);
},
@ -1144,8 +1148,16 @@ const MapSightbar: React.FC<MapSightbarProps> = ({
[navigate]
);
const handleSave = useCallback(() => {
mapStore.handleSave(mapService?.getAllFeaturesAsGeoJSON() || "");
const handleSave = useCallback(async () => {
const geoJSON = mapService?.getAllFeaturesAsGeoJSON();
if (geoJSON) {
setIsLoading(true);
await mapStore.handleSave(geoJSON);
toast.success("Данные успешно сохранены");
} else {
toast.error("Ошибка при сохранении данных");
}
setIsLoading(false);
}, [mapService]);
const stations = mapFeatures.filter(
@ -1470,10 +1482,15 @@ const MapSightbar: React.FC<MapSightbarProps> = ({
<button
onClick={handleSave}
className="m-3 w-[90%] flex items-center justify-center px-4 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600 transition-colors"
className="m-3 w-[90%] h-[40px] flex items-center justify-center px-4 py-2 bg-blue-500 disabled:bg-blue-300 text-white rounded-md hover:bg-blue-600 transition-colors"
disabled={isLoading}
>
<Save size={16} className="mr-2" />
Сохранить изменения
{isLoading ? (
<Loader2 size={16} className="animate-spin" />
) : (
"Сохранить изменения"
)}
</button>
</div>
);