Thêm tính năng xóa thành viên ra khỏi tour

This commit is contained in:
2026-06-14 17:43:28 +07:00
parent 4bec095a40
commit bb15b2bf15
15 changed files with 154 additions and 21 deletions
+14
View File
@@ -242,6 +242,20 @@ export const useTourStore = create((set, get) => ({
set({ currentTour: { ...currentTour, legs: updatedLegs }, legs: updatedLegs });
}
},
removeMember: async (tourId, userId) => {
const API_BASE = `http://${window.location.hostname}:3001`;
const response = await fetch(`${API_BASE}/api/v1/tours/${tourId}/members/${userId}`, {
method: 'DELETE',
headers: {
Authorization: `Bearer ${localStorage.getItem('token')}`,
},
});
if (!response.ok)
throw new Error('Lỗi khi xóa thành viên');
const { currentTour } = get();
if (currentTour)
get().fetchTour(currentTour.id);
},
addMember: async (tourId, member) => {
const API_BASE = `http://${window.location.hostname}:3001`;
const response = await fetch(`${API_BASE}/api/v1/tours/${tourId}/members`, {