feat: nhấn nút toggle status để chuyển đến bản đồ di chuyển

This commit is contained in:
2026-06-17 21:30:41 +07:00
parent ffe3cb6ecd
commit 55de887f87
2 changed files with 20 additions and 4 deletions
@@ -42,12 +42,14 @@ export const ItineraryTimeline = ({
onAddLocation, onAddLocation,
onEditLocation, onEditLocation,
onQuickNote, onQuickNote,
onNavigate,
onSuccess, onSuccess,
isPublicView = false isPublicView = false
}: { }: {
onAddLocation?: (legId: string, isStart?: boolean, isEnd?: boolean) => void, onAddLocation?: (legId: string, isStart?: boolean, isEnd?: boolean) => void,
onEditLocation?: (location: any) => void, onEditLocation?: (location: any) => void,
onQuickNote?: (name: string) => void, onQuickNote?: (name: string) => void,
onNavigate?: (location: any) => void,
onSuccess?: () => void, onSuccess?: () => void,
isPublicView?: boolean isPublicView?: boolean
}) => { }) => {
@@ -113,9 +115,10 @@ export const ItineraryTimeline = ({
endDate: '' endDate: ''
}); });
const toggleComplete = async (locationId: string) => { const handleStatusClick = (location: any) => {
// Gọi API PATCH /api/v1/locations/:id để cập nhật trạng thái if (onNavigate) {
console.log("Toggle status for location:", locationId); onNavigate(location);
}
}; };
const handleAddLeg = async () => { const handleAddLeg = async () => {
@@ -371,7 +374,7 @@ export const ItineraryTimeline = ({
{/* Timeline Node */} {/* Timeline Node */}
<div className="z-10 mt-1.5 mr-4"> <div className="z-10 mt-1.5 mr-4">
<button <button
onClick={() => toggleComplete(location.id)} onClick={() => handleStatusClick(location)}
className={`transition-colors duration-200 ${location.status === 'COMPLETED' ? 'text-green-500' : 'text-gray-300 hover:text-blue-500'}`} className={`transition-colors duration-200 ${location.status === 'COMPLETED' ? 'text-green-500' : 'text-gray-300 hover:text-blue-500'}`}
> >
{location.status === 'COMPLETED' ? ( {location.status === 'COMPLETED' ? (
+13
View File
@@ -748,6 +748,18 @@ export const TourDetailPage = ({
}; };
}, [routes, selectedRouteIndex]); }, [routes, selectedRouteIndex]);
const handleNavigateToLocation = (location: any) => {
setViewMode('map');
setMapCenter([location.latitude, location.longitude]);
setLocateTrigger(prev => prev + 1);
notify({
title: 'Bắt đầu chỉ đường',
message: `Đang hiển thị lộ trình từ vị trí của bạn đến ${location.name}`,
type: 'info'
});
};
useEffect(() => { useEffect(() => {
if (initialViewState) { if (initialViewState) {
setMapCenter(initialViewState.center); setMapCenter(initialViewState.center);
@@ -1378,6 +1390,7 @@ export const TourDetailPage = ({
onQuickNote={(locName: string) => handleQuickNote(locName)} onQuickNote={(locName: string) => handleQuickNote(locName)}
onSuccess={() => fetchTour(tourId)} onSuccess={() => fetchTour(tourId)}
isPublicView={isPublicView} isPublicView={isPublicView}
onNavigate={handleNavigateToLocation}
/> />
) : ( ) : (
<div className="h-[60vh] w-full rounded-3xl overflow-hidden shadow-xl border-4 border-white relative"> <div className="h-[60vh] w-full rounded-3xl overflow-hidden shadow-xl border-4 border-white relative">