feat: tạo hook useConfirm.tsx để dùng chung toàn hệ thống

This commit is contained in:
2026-06-16 12:29:09 +07:00
parent 047170d4be
commit 29d39ae7b0
4 changed files with 297 additions and 18 deletions
+23 -16
View File
@@ -4,6 +4,7 @@ import { ExploreMap } from './pages/ExploreMap';
import { TourDetailPage } from './pages/TourDetailPage';
import { SignupPage } from './pages/SignupPage';
import { useTourStore } from './store/useTourStore';
import { ConfirmProvider } from './hooks/useConfirm';
function App() {
const params = new URLSearchParams(window.location.search);
@@ -81,25 +82,31 @@ function App() {
setCurrentPage('landing'); // Quay về trang Landing sau khi đăng ký thành công
};
if (currentPage === 'tourDetail') {
return (
<TourDetailPage
tourId={currentTourId!} // tourId được đảm bảo không null ở đây
onBack={handleBackFromTourDetail}
isPublicView={isPublicTourView}
/>
);
}
return (
<ConfirmProvider>
{(() => {
if (currentPage === 'tourDetail') {
return (
<TourDetailPage
tourId={currentTourId!}
onBack={handleBackFromTourDetail}
isPublicView={isPublicTourView}
/>
);
}
if (currentPage === 'explore') {
return <ExploreMap onBack={handleBackFromTourDetail} onLogout={handleLogout} user={user} onViewTour={handleViewTour} />;
}
if (currentPage === 'explore') {
return <ExploreMap onBack={handleBackFromTourDetail} onLogout={handleLogout} user={user} onViewTour={handleViewTour} />;
}
if (currentPage === 'signup') {
return <SignupPage onBack={handleBackFromSignup} onSuccess={handleSignupSuccess} />;
}
if (currentPage === 'signup') {
return <SignupPage onBack={handleBackFromSignup} onSuccess={handleSignupSuccess} />;
}
return <LandingPage onContinue={() => setCurrentPage('explore')} onGoToSignup={() => setCurrentPage('signup')} onGoToMap={() => setCurrentPage('explore')} onLoginSuccess={handleLoginSuccess} isInitialSetup={false} />;
return <LandingPage onContinue={() => setCurrentPage('explore')} onGoToSignup={() => setCurrentPage('signup')} onGoToMap={() => setCurrentPage('explore')} onLoginSuccess={handleLoginSuccess} isInitialSetup={false} />;
})()}
</ConfirmProvider>
);
}
export default App;