feat: tíng năng trò chuyện giữa các thành viên và tin nhắn trực tiếp cho bạn bè

This commit is contained in:
2026-06-21 09:46:37 +07:00
parent 392a4d4766
commit 8d79cd76f6
15 changed files with 3932 additions and 234 deletions
+46 -7
View File
@@ -6,6 +6,7 @@ import SignupPage from './pages/SignupPage';
import { MyPhotosPage } from './pages/MyPhotosPage';
import { MyNotePage } from './pages/MyNotePage';
import { JoinTourPage } from './pages/JoinTourPage';
import { MemberDashboard } from './pages/MemberDashboard';
import { useTourStore } from './store/useTourStore';
import { ConfirmProvider } from './hooks/useConfirm';
import { NotificationProvider } from './hooks/useNotification';
@@ -15,11 +16,12 @@ function App() {
const viewTourId = params.get('viewTour');
const [user, setUser] = useState<any>(null);
const [currentPage, setCurrentPage] = useState<'landing' | 'explore' | 'tourDetail' | 'signup' | 'myPhotos' | 'notes' | 'joinTour'>(
const [currentPage, setCurrentPage] = useState<'landing' | 'dashboard' | 'explore' | 'tourDetail' | 'signup' | 'myPhotos' | 'notes' | 'joinTour'>(
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');
// Lấy action từ store
const fetchTour = useTourStore(state => state.fetchTour);
@@ -50,7 +52,7 @@ function App() {
setCurrentPage('tourDetail');
} else {
if (loggedInUser) {
setCurrentPage('explore');
setCurrentPage('dashboard');
} else {
setCurrentPage('landing');
}
@@ -65,7 +67,7 @@ function App() {
if (pendingInviteToken) {
setCurrentPage('joinTour');
} else {
setCurrentPage('explore');
setCurrentPage('dashboard');
}
};
@@ -76,18 +78,19 @@ function App() {
setCurrentPage('landing');
};
const handleViewTour = (tourId: string) => {
const handleViewTour = (tourId: string, fromPage?: 'explore' | 'dashboard') => {
setCurrentTourId(tourId);
setIsPublicTourView(false); // Không phải chế độ công khai nếu đến từ bản đồ khám phá
setPreviousPage(fromPage || (currentPage === 'dashboard' ? 'dashboard' : 'explore'));
setCurrentPage('tourDetail');
};
const handleBackFromTourDetail = () => {
setCurrentTourId(null);
setIsPublicTourView(false);
// Quay về trang khám phá nếu đã đăng nhập, ngược lại quay về Landing
// Quay về trang nếu đã đăng nhập, ngược lại quay về Landing
if (user) {
setCurrentPage('explore');
setCurrentPage(previousPage);
} else {
setCurrentPage('landing');
}
@@ -105,6 +108,22 @@ function App() {
const handleSignupSuccess = () => {
// Sau khi đăng ký, ta có thể tự động đăng nhập hoặc quay lại landing/joinTour
const pendingInviteToken = localStorage.getItem('pendingInviteToken');
const token = localStorage.getItem('token');
const storedUser = localStorage.getItem('user');
if (token && storedUser) {
try {
const loggedInUser = JSON.parse(storedUser);
setUser(loggedInUser);
if (pendingInviteToken) {
setCurrentPage('joinTour');
} else {
setCurrentPage('dashboard');
}
return;
} catch (e) {}
}
if (pendingInviteToken) {
setCurrentPage('joinTour');
} else {
@@ -112,10 +131,30 @@ function App() {
}
};
const handleBackFromExplore = () => {
if (user) {
setCurrentPage('dashboard');
} else {
setCurrentPage('landing');
}
};
return (
<ConfirmProvider>
<NotificationProvider>
{(() => {
if (currentPage === 'dashboard') {
return (
<MemberDashboard
user={user}
onLogout={handleLogout}
onExploreTours={() => setCurrentPage('explore')}
onViewTour={handleViewTour}
onOpenMyPhotos={() => setCurrentPage('myPhotos')}
/>
);
}
if (currentPage === 'tourDetail') {
return (
<TourDetailPage
@@ -134,7 +173,7 @@ function App() {
if (currentPage === 'explore') {
return (
<ExploreMap
onBack={handleBackFromTourDetail}
onBack={handleBackFromExplore}
onLogout={handleLogout}
user={user}
onViewTour={handleViewTour}