import React, { useState, useEffect } from 'react'; import { ItineraryTimeline } from './ItineraryTimeline'; import { ExpenseManager } from './ExpenseManager'; import { useTourStore } from './useTourStore'; import { Map as MapIcon, Wallet, Image as ImageIcon, Calendar, Users, ChevronLeft } from 'lucide-react'; export const TourDetailPage = () => { const [activeTab, setActiveTab] = useState<'plan' | 'expense' | 'photo'>('plan'); const { currentTour, fetchTour, userRole } = useTourStore(); useEffect(() => { // Gọi ID 1 (Dữ liệu từ file seed) để kiểm tra fetchTour(1); }, [fetchTour]); // Định nghĩa các tab dựa trên quyền hạn (RBAC) từ store const tabs = [ { id: 'plan', label: 'Lộ trình', icon: MapIcon, visible: ['OWNER', 'EDITOR', 'MEMBER_PLAN_ONLY'].includes(userRole || '') }, { id: 'expense', label: 'Chi phí', icon: Wallet, visible: ['OWNER', 'EDITOR'].includes(userRole || '') }, { id: 'photo', label: 'Ảnh', icon: ImageIcon, visible: true }, ].filter(t => t.visible); // Tự động chuyển tab nếu người dùng không có quyền xem 'plan' useEffect(() => { if (userRole === 'MEMBER_PHOTO_ONLY') { setActiveTab('photo'); } }, [userRole]); // Mock dữ liệu header (Trong thực tế sẽ lấy từ currentTour) const tourInfo = { title: currentTour?.title || "Hành trình khám phá TP.HCM", date: "20 - 21 Tháng 11, 2023", members: 5, budget: "2.500.000 VND" }; return (