feat: cho phép người dùng chọn tọa độ trên bản đồ khi sửa ảnh

This commit is contained in:
2026-06-20 07:40:50 +07:00
parent 9da8a9494d
commit 5081546cdf
11 changed files with 450 additions and 217 deletions
+23
View File
@@ -12,6 +12,7 @@ import { AddPhotoModal } from '@/components/AddPhotoModal';
import { MapContainer, TileLayer, Marker, Popup, useMapEvents, Polyline, useMap, Tooltip } from 'react-leaflet';
import _MarkerClusterGroup from 'react-leaflet-cluster';
const MarkerClusterGroup = (_MarkerClusterGroup as any).default || _MarkerClusterGroup;
import { CoordinateSelectModal } from '../components/CoordinateSelectModal';
import {
Map as MapIcon,
Wallet,
@@ -527,6 +528,7 @@ export const TourDetailPage = ({
const [editPhotoLat, setEditPhotoLat] = useState<number | ''>('');
const [editPhotoLng, setEditPhotoLng] = useState<number | ''>('');
const [isSavingPhotoEdit, setIsSavingPhotoEdit] = useState(false);
const [isMapOpen, setIsMapOpen] = useState(false);
useEffect(() => {
if (selectedPhotoForDisplay) {
@@ -2062,6 +2064,17 @@ export const TourDetailPage = ({
</div>
</div>
<div className="flex justify-start">
<button
type="button"
onClick={() => setIsMapOpen(true)}
className="flex items-center gap-1.5 px-3 py-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200 text-gray-700 hover:text-gray-900 rounded-xl text-[10px] font-bold transition-all"
>
<MapPin className="w-3.5 h-3.5 text-rose-500" />
Chọn trên bản đ
</button>
</div>
<div className="flex justify-end gap-2 mt-2">
<button
onClick={() => setIsEditingPhoto(false)}
@@ -2637,6 +2650,16 @@ export const TourDetailPage = ({
onCommentAdded={() => handleCommentIncrement(commentLocationId)}
onCommentDeleted={() => handleCommentDecrement(commentLocationId)}
/>
<CoordinateSelectModal
isOpen={isMapOpen}
onClose={() => setIsMapOpen(false)}
initialLat={typeof editPhotoLat === 'number' ? editPhotoLat : undefined}
initialLng={typeof editPhotoLng === 'number' ? editPhotoLng : undefined}
onSelect={(lat, lng) => {
setEditPhotoLat(lat);
setEditPhotoLng(lng);
}}
/>
</div>
);
};