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:
@@ -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>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user