import React, { useEffect } from "react"; const Step4Environment = ({ data, updateData }) => { const toggleTerrain = (terrain) => { const current = data.terrain || []; const updated = current.includes(terrain) ? current.filter((t) => t !== terrain) : [...current, terrain]; updateData({ terrain: updated }); }; // Автоматически определяем сезон из даты потери useEffect(() => { if (data.lost_time && !data.season) { const date = new Date(data.lost_time); const month = date.getMonth() + 1; // 1-12 let season = 'лето'; if (month >= 3 && month <= 5) season = 'весна'; else if (month >= 6 && month <= 8) season = 'лето'; else if (month >= 9 && month <= 11) season = 'осень'; else season = 'зима'; // 12, 1, 2 updateData({ season }); } }, [data.lost_time]); const handleGetLocation = () => { if (!navigator.geolocation) { updateData({ gps_error: 'Геолокация не поддерживается вашим браузером' }); return; } updateData({ gps_loading: true, gps_error: null }); navigator.geolocation.getCurrentPosition( (position) => { updateData({ tnp_lat: position.coords.latitude.toFixed(6), tnp_lon: position.coords.longitude.toFixed(6), gps_loading: false, gps_error: null }); }, (error) => { updateData({ gps_error: 'Ошибка получения координат: ' + error.message, gps_loading: false }); }, { enableHighAccuracy: true, timeout: 10000, maximumAge: 0 } ); }; return (
Адрес будет преобразован в координаты автоматически