diff --git a/frontend/src/pages/TourDetailPage.tsx b/frontend/src/pages/TourDetailPage.tsx index 0374e12..cdd0340 100644 --- a/frontend/src/pages/TourDetailPage.tsx +++ b/frontend/src/pages/TourDetailPage.tsx @@ -361,6 +361,7 @@ export const TourDetailPage = ({ const fetchJoinRequests = useTourStore(state => state.fetchJoinRequests); const acceptJoinRequest = useTourStore(state => state.acceptJoinRequest); const rejectJoinRequest = useTourStore(state => state.rejectJoinRequest); + const deleteTour = useTourStore(state => state.deleteTour); const confirm = useConfirm(); const notify = useNotification(); @@ -654,6 +655,25 @@ export const TourDetailPage = ({ notify({ title: 'Thành công', message: 'Đã lưu vào ghi chú chung!', type: 'success' }); }; + // Hàm xử lý xóa Tour vĩnh viễn + const handleDeleteTour = async () => { + if (!currentTour) return; + const isConfirmed = await confirm({ + title: 'Xóa Tour vĩnh viễn?', + message: 'Toàn bộ dữ liệu về lộ trình, chi phí và hình ảnh của chuyến đi này sẽ bị xóa bỏ hoàn toàn. Bạn có chắc chắn muốn thực hiện?' + }); + + if (isConfirmed) { + try { + await deleteTour(currentTour.id); + notify({ title: 'Thành công', message: 'Hành trình đã được xóa.', type: 'success' }); + onBack(); // Quay về trang khám phá sau khi xóa thành công + } catch (error: any) { + notify({ title: 'Lỗi', message: error.message || 'Không thể xóa hành trình.', type: 'error' }); + } + } + }; + // Xác định Điểm xuất phát và Điểm kết thúc hiển thị dưới widget tài chính const startPoint = useMemo(() => legs.flatMap(l => l.locations).find(loc => loc.plannedStart && new Date(loc.plannedStart).getTime() === 0), @@ -1459,9 +1479,19 @@ export const TourDetailPage = ({ )} -
Tính năng cài đặt khác đang được cập nhật...
+ {/* Danger Zone - Khu vực dành cho các hành động quan trọng */} +Một khi đã xóa, bạn sẽ không thể khôi phục lại dữ liệu của hành trình này.
+