feat: thêm nút xóa tour trong phần cài đặt của Tour
This commit is contained in:
@@ -361,6 +361,7 @@ export const TourDetailPage = ({
|
|||||||
const fetchJoinRequests = useTourStore(state => state.fetchJoinRequests);
|
const fetchJoinRequests = useTourStore(state => state.fetchJoinRequests);
|
||||||
const acceptJoinRequest = useTourStore(state => state.acceptJoinRequest);
|
const acceptJoinRequest = useTourStore(state => state.acceptJoinRequest);
|
||||||
const rejectJoinRequest = useTourStore(state => state.rejectJoinRequest);
|
const rejectJoinRequest = useTourStore(state => state.rejectJoinRequest);
|
||||||
|
const deleteTour = useTourStore(state => state.deleteTour);
|
||||||
|
|
||||||
const confirm = useConfirm();
|
const confirm = useConfirm();
|
||||||
const notify = useNotification();
|
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' });
|
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
|
// 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(() =>
|
const startPoint = useMemo(() =>
|
||||||
legs.flatMap(l => l.locations).find(loc => loc.plannedStart && new Date(loc.plannedStart).getTime() === 0),
|
legs.flatMap(l => l.locations).find(loc => loc.plannedStart && new Date(loc.plannedStart).getTime() === 0),
|
||||||
@@ -1459,9 +1479,19 @@ export const TourDetailPage = ({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="p-8 text-center bg-gray-50 rounded-3xl border border-dashed border-gray-200">
|
{/* Danger Zone - Khu vực dành cho các hành động quan trọng */}
|
||||||
<Settings className="w-10 h-10 text-gray-300 mx-auto mb-3" />
|
<div className="p-6 bg-red-50 rounded-3xl border border-red-100 animate-in zoom-in-95">
|
||||||
<p className="text-gray-500 font-medium">Tính năng cài đặt khác đang được cập nhật...</p>
|
<div className="flex items-center gap-3 mb-4 text-red-600">
|
||||||
|
<Trash2 className="w-6 h-6" />
|
||||||
|
<h3 className="text-lg font-bold">Vùng nguy hiểm</h3>
|
||||||
|
</div>
|
||||||
|
<p className="text-sm text-red-500 mb-6 font-medium">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.</p>
|
||||||
|
<button
|
||||||
|
onClick={handleDeleteTour}
|
||||||
|
className="w-full py-4 bg-red-600 hover:bg-red-700 text-white font-black uppercase tracking-widest rounded-2xl transition-all shadow-lg shadow-red-100 active:scale-95"
|
||||||
|
>
|
||||||
|
Xóa Tour vĩnh viễn
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user