feat: Tạo trang bản đồ chỉ đường độc lập TourNavigationPage
- Thêm trang TourNavigationPage.tsx hiển thị full màn hình với top-bar, bản đồ fullscreen và nút la bàn nổi ở góc dưới bên phải - Cập nhật ItineraryTimeline.tsx: thay thế LocationNavigationModal bằng callback onOpenNavigationPage để chuyển đến trang mới - Đăng ký trang tourNavigation trong App.tsx với navigationPayload - Cập nhật TourDetailPage.tsx truyền onOpenNavigationPage xuống - Thêm INSTALL_MAP.md hướng dẫn thực hiện tính năng
This commit is contained in:
+27
-7
@@ -9,6 +9,7 @@ import { JoinTourPage } from './pages/JoinTourPage';
|
||||
import { MemberDashboard } from './pages/MemberDashboard';
|
||||
import { AdminDashboard } from './pages/AdminDashboard';
|
||||
import { ShareJourneyPage } from './pages/ShareJourneyPage';
|
||||
import { TourNavigationPage } from './pages/TourNavigationPage';
|
||||
import { ConfirmProvider } from './hooks/useConfirm';
|
||||
import { NotificationProvider } from './hooks/useNotification';
|
||||
|
||||
@@ -21,12 +22,13 @@ function App() {
|
||||
|
||||
const [user, setUser] = useState<any>(null);
|
||||
const [shareJourneyToken, setShareJourneyToken] = useState<string | null>(journeyTokenVal);
|
||||
const [currentPage, setCurrentPage] = useState<'landing' | 'dashboard' | 'admin' | 'explore' | 'tourDetail' | 'signup' | 'myPhotos' | 'notes' | 'joinTour' | 'shareJourney'>(
|
||||
const [currentPage, setCurrentPage] = useState<'landing' | 'dashboard' | 'admin' | 'explore' | 'tourDetail' | 'signup' | 'myPhotos' | 'notes' | 'joinTour' | 'shareJourney' | 'tourNavigation'>(
|
||||
journeyTokenVal ? 'shareJourney' : (viewTourId ? 'tourDetail' : (window.location.pathname === '/join-tour' || params.has('token') ? 'joinTour' : 'landing'))
|
||||
);
|
||||
const [currentTourId, setCurrentTourId] = useState<string | null>(viewTourId);
|
||||
const [isPublicTourView, setIsPublicTourView] = useState(!!viewTourId);
|
||||
const [previousPage, setPreviousPage] = useState<'explore' | 'dashboard' | 'landing'>('explore');
|
||||
const [navigationPayload, setNavigationPayload] = useState<{ tourId: string; origin: { lat: number; lng: number }; destination: { lat: number; lng: number; name: string }; tourTitle: string } | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
@@ -122,26 +124,30 @@ function App() {
|
||||
};
|
||||
|
||||
const handleBackFromTourDetail = () => {
|
||||
// Check if this was a public view BEFORE clearing the flag
|
||||
const wasPublicView = isPublicTourView;
|
||||
|
||||
setCurrentTourId(null);
|
||||
setIsPublicTourView(false);
|
||||
|
||||
// If user was viewing a public tour, redirect to index/landing page
|
||||
// Otherwise redirect based on authentication and previous page
|
||||
if (wasPublicView) {
|
||||
// Public tour view - always redirect to index/landing
|
||||
setCurrentPage('landing');
|
||||
} else if (user) {
|
||||
// Authenticated user viewing their own tour - go back to previous page
|
||||
setCurrentPage(previousPage);
|
||||
} else {
|
||||
// Not authenticated and not public view - go to landing
|
||||
setCurrentPage('landing');
|
||||
}
|
||||
};
|
||||
|
||||
const handleOpenNavigationPage = (payload: { tourId: string; origin: { lat: number; lng: number }; destination: { lat: number; lng: number; name: string }; tourTitle: string }) => {
|
||||
setNavigationPayload(payload);
|
||||
setCurrentPage('tourNavigation');
|
||||
};
|
||||
|
||||
const handleBackFromNavigation = () => {
|
||||
setNavigationPayload(null);
|
||||
setCurrentPage('tourDetail');
|
||||
};
|
||||
|
||||
const handleBackFromSignup = () => {
|
||||
const pendingInviteToken = localStorage.getItem('pendingInviteToken');
|
||||
if (pendingInviteToken) {
|
||||
@@ -259,6 +265,7 @@ function App() {
|
||||
onBack={handleBackFromTourDetail}
|
||||
isPublicView={isPublicTourView}
|
||||
onOpenNotes={() => setCurrentPage('notes')}
|
||||
onOpenNavigationPage={handleOpenNavigationPage}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -267,6 +274,19 @@ function App() {
|
||||
return <MyNotePage tourId={currentTourId!} onBack={() => setCurrentPage('tourDetail')} />;
|
||||
}
|
||||
|
||||
if (currentPage === 'tourNavigation' && navigationPayload) {
|
||||
return (
|
||||
<TourNavigationPage
|
||||
tourId={navigationPayload.tourId}
|
||||
routeData={{
|
||||
origin: navigationPayload.origin,
|
||||
destination: navigationPayload.destination
|
||||
}}
|
||||
onBack={handleBackFromNavigation}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (currentPage === 'explore') {
|
||||
return (
|
||||
<ExploreMap
|
||||
|
||||
Reference in New Issue
Block a user