From 14bf43487ee5c4f446cf65ddc0d3061d368296c8 Mon Sep 17 00:00:00 2001 From: 3dtours Date: Sun, 14 Jun 2026 09:28:33 +0700 Subject: [PATCH] =?UTF-8?q?S=E1=BB=ADa=20hi=E1=BB=83n=20th=E1=BB=8B=20?= =?UTF-8?q?=C4=91i=E1=BB=83m=20=C4=91=E1=BA=A7u=20v=C3=A0=20=C4=91i?= =?UTF-8?q?=E1=BB=83m=20cu=E1=BB=91i=20c=E1=BB=A7a=20ch=E1=BA=B7ng?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AddLocationModal.tsx | 15 +++++++++++ ItineraryTimeline.tsx | 21 +++++++++++++-- TourDetailPage.tsx | 10 ++++++++ dist/AddLocationModal.js | 6 ++++- dist/AddLocationModal.js.map | 2 +- dist/ItineraryTimeline.js | 13 +++++++--- dist/ItineraryTimeline.js.map | 2 +- dist/TourDetailPage.js | 8 ++++++ dist/TourDetailPage.js.map | 2 +- dist/main.js | 42 ++++++++++++++++++++++++++++++ dist/main.js.map | 2 +- dist/tsconfig.build.tsbuildinfo | 2 +- dist/useTourStore.d.ts | 1 + dist/useTourStore.js | 14 ++++++++++ dist/useTourStore.js.map | 2 +- main.ts | 45 +++++++++++++++++++++++++++++++++ useTourStore.ts | 14 ++++++++++ 17 files changed, 189 insertions(+), 12 deletions(-) diff --git a/AddLocationModal.tsx b/AddLocationModal.tsx index 2bf11d6..82c78fd 100644 --- a/AddLocationModal.tsx +++ b/AddLocationModal.tsx @@ -9,20 +9,26 @@ export const AddLocationModal = ({ isOpen, onClose, tourId }: { isOpen: boolean, latitude: 10.7769, longitude: 106.7009, type: 'VISIT', + legId: '', plannedStart: '', plannedEnd: '' }); const [isLoading, setIsLoading] = useState(false); + const legs = useTourStore(state => state.legs); const addLocation = useTourStore(state => state.addLocation); if (!isOpen) return null; + // Mặc định chọn chặng đầu nếu chưa chọn + const currentLegId = formData.legId || (legs.length > 0 ? legs[0].id : ''); + const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setIsLoading(true); try { await addLocation(tourId, { ...formData, + legId: currentLegId, latitude: parseFloat(formData.latitude as any), longitude: parseFloat(formData.longitude as any), }); @@ -58,6 +64,15 @@ export const AddLocationModal = ({ isOpen, onClose, tourId }: { isOpen: boolean, setFormData({...formData, address: e.target.value})} /> +
+ + +
diff --git a/ItineraryTimeline.tsx b/ItineraryTimeline.tsx index ec40592..dd42bf2 100644 --- a/ItineraryTimeline.tsx +++ b/ItineraryTimeline.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { format, differenceInMinutes, parseISO } from 'date-fns'; -import { CheckCircle2, Circle, Clock, MapPin, AlertCircle, Zap, Navigation, Edit2, Trash2, Plus } from 'lucide-react'; +import { CheckCircle2, Circle, Clock, MapPin, AlertCircle, Zap, Navigation, Edit2, Trash2, Plus, List } from 'lucide-react'; import { useTourStore } from './useTourStore.js'; const TimeVariance = ({ planned, actual }: { planned: string, actual: string | null }) => { @@ -36,7 +36,7 @@ const formatTravelTime = (minutes: number) => { }; export const ItineraryTimeline = () => { - const { currentTour, legs, optimizeRouting, userRole, activeLegId, setActiveLegId, addLeg, updateLeg, deleteLeg } = useTourStore(); + const { currentTour, legs, optimizeRouting, userRole, activeLegId, setActiveLegId, addLeg, updateLeg, deleteLeg, initializeLegs } = useTourStore(); const toggleComplete = async (locationId: string) => { // Gọi API PATCH /api/v1/locations/:id để cập nhật trạng thái @@ -50,6 +50,14 @@ export const ItineraryTimeline = () => { } }; + const handleDeclareLegs = async () => { + const countStr = window.prompt("Chuyến đi này bạn muốn chia làm bao nhiêu chặng?", "3"); + const count = parseInt(countStr || "0"); + if (count > 0 && currentTour) { + await initializeLegs(currentTour.id, count); + } + }; + const handleEditLeg = async (leg: any) => { const note = window.prompt("Sửa ghi chú chặng:", leg.note || ""); if (note !== null) { @@ -86,6 +94,15 @@ export const ItineraryTimeline = () => { Chặng {leg.sequence} ))} + {['OWNER', 'MANAGER'].includes(userRole || '') && ( + + )} {['OWNER', 'MANAGER'].includes(userRole || '') && (