Bổ sung tính năng sửa chữa, cập nhật địa điểm trong chặng

This commit is contained in:
2026-06-14 10:16:09 +07:00
parent ec650fb45d
commit 838aec562f
19 changed files with 285 additions and 45 deletions
+30
View File
@@ -145,6 +145,36 @@ export const useTourStore = create((set, get) => ({
throw new Error('Lỗi khi thêm địa điểm');
get().fetchTour(tourId);
},
updateLocation: async (locationId, data) => {
const API_BASE = `http://${window.location.hostname}:3001`;
const response = await fetch(`${API_BASE}/api/v1/locations/${locationId}`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${localStorage.getItem('token')}`
},
body: JSON.stringify(data),
});
if (!response.ok)
throw new Error('Lỗi khi cập nhật địa điểm');
const { currentTour } = get();
if (currentTour)
get().fetchTour(currentTour.id);
},
deleteLocation: async (locationId) => {
const API_BASE = `http://${window.location.hostname}:3001`;
const response = await fetch(`${API_BASE}/api/v1/locations/${locationId}`, {
method: 'DELETE',
headers: {
'Authorization': `Bearer ${localStorage.getItem('token')}`
},
});
if (!response.ok)
throw new Error('Lỗi khi xóa địa điểm');
const { currentTour } = get();
if (currentTour)
get().fetchTour(currentTour.id);
},
updateTourStartPoint: async (tourId, data) => {
const API_BASE = `http://${window.location.hostname}:3001`;
const response = await fetch(`${API_BASE}/api/v1/tours/${tourId}/start-point`, {