diff --git a/App.tsx b/App.tsx index 698149f..4450eac 100644 --- a/App.tsx +++ b/App.tsx @@ -1,17 +1,27 @@ -import React, { useState } from 'react'; -import { LandingPage } from './LandingPage'; -import { TourDetailPage } from './TourDetailPage'; -import { ExploreMap } from './ExploreMap'; -import { SignupPage } from './SignupPage'; +import React, { useState, useEffect } from 'react'; +import { LandingPage } from './LandingPage.js'; +import { TourDetailPage } from './TourDetailPage.js'; +import { ExploreMap } from './ExploreMap.js'; +import { SignupPage } from './SignupPage.js'; const App = () => { type View = 'landing' | 'explore' | 'detail' | 'signup'; const [view, setView] = useState('landing'); + const [isInitialSetup, setIsInitialSetup] = useState(false); + + useEffect(() => { + // Kiểm tra xem hệ thống đã được cài đặt chưa + fetch('http://localhost:3001/api/v1/auth/status') + .then(res => res.json()) + .then(data => setIsInitialSetup(data.isInitialSetup)) + .catch(() => setIsInitialSetup(false)); + }, [view]); return (
{view === 'landing' && ( setView('explore')} onGoToSignup={() => setView('signup')} onGoToMap={() => setView('explore')} diff --git a/ExpenseManager.tsx b/ExpenseManager.tsx index d9d3175..f390364 100644 --- a/ExpenseManager.tsx +++ b/ExpenseManager.tsx @@ -1,6 +1,6 @@ import React, { useState, useMemo } from 'react'; import { Wallet, Users, Info } from 'lucide-react'; -import { useTourStore } from './useTourStore'; +import { useTourStore } from './useTourStore.js'; export const ExpenseManager = () => { const { legs } = useTourStore(); diff --git a/ExploreMap.tsx b/ExploreMap.tsx index d262e15..b332a12 100644 --- a/ExploreMap.tsx +++ b/ExploreMap.tsx @@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'; import { MapContainer, TileLayer, Marker, Popup, useMap } from 'react-leaflet'; import L from 'leaflet'; import 'leaflet/dist/leaflet.css'; -import { useTourStore } from './useTourStore'; +import { useTourStore } from './useTourStore.js'; import { X, Navigation, Image as ImageIcon } from 'lucide-react'; // Fix lỗi icon mặc định của Leaflet diff --git a/ItineraryTimeline.tsx b/ItineraryTimeline.tsx index c18a7ee..c401b98 100644 --- a/ItineraryTimeline.tsx +++ b/ItineraryTimeline.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { format, differenceInMinutes, parseISO } from 'date-fns'; import { CheckCircle2, Circle, Clock, MapPin, AlertCircle } from 'lucide-react'; -import { useTourStore } from './useTourStore'; +import { useTourStore } from './useTourStore.js'; const TimeVariance = ({ planned, actual }: { planned: string, actual: string | null }) => { if (!actual) return null; diff --git a/LandingPage.tsx b/LandingPage.tsx index e51d686..362576b 100644 --- a/LandingPage.tsx +++ b/LandingPage.tsx @@ -1,6 +1,6 @@ import React, { useState, useMemo } from 'react'; -import { LogIn, Compass, ArrowRight, Map as MapIcon, UserPlus } from 'lucide-react'; -import { LoginModal } from './LoginModal'; +import { LogIn, Compass, ArrowRight, Map as MapIcon, UserPlus, ShieldCheck } from 'lucide-react'; +import { LoginModal } from './LoginModal.js'; const TRAVEL_IMAGES = [ "https://images.unsplash.com/photo-1476514525535-07fb3b4ae5f1?auto=format&fit=crop&q=80", @@ -15,9 +15,10 @@ interface LandingPageProps { onContinue?: () => void; onGoToSignup?: () => void; onGoToMap?: () => void; + isInitialSetup?: boolean; } -export const LandingPage: React.FC = ({ onContinue, onGoToSignup, onGoToMap }) => { +export const LandingPage: React.FC = ({ onContinue, onGoToSignup, onGoToMap, isInitialSetup }) => { const [isLoginModalOpen, setIsLoginModalOpen] = useState(false); // Chọn ngẫu nhiên một hình ảnh khi người dùng truy cập trang @@ -68,16 +69,41 @@ export const LandingPage: React.FC = ({ onContinue, onGoToSign
-

- Lên kế hoạch cho hành trình tiếp theo -

-

- Khám phá các địa điểm nổi bật qua bản đồ cộng đồng hoặc đăng nhập để bắt đầu tự tạo chuyến đi cho riêng mình. -

+ {isInitialSetup ? ( + <> +
+ CẤU HÌNH HỆ THỐNG LẦN ĐẦU +
+

+ Thiết lập Quản trị viên +

+

+ Chào mừng! Hệ thống vừa được cài đặt. Vui lòng tạo tài khoản đầu tiên để quản lý và vận hành trang web. +

+ + ) : ( + <> +

+ Lên kế hoạch cho hành trình tiếp theo +

+

+ Khám phá các địa điểm nổi bật qua bản đồ cộng đồng hoặc đăng nhập để bắt đầu tự tạo chuyến đi cho riêng mình. +

+ + )}
- {/* Nút Khám phá Bản đồ (Cho khách công cộng) */} + {isInitialSetup && ( + + )} +