From aec911206459842f892715eb3b26789a00c40ddc Mon Sep 17 00:00:00 2001 From: 3dtours Date: Mon, 15 Jun 2026 20:55:36 +0700 Subject: [PATCH] =?UTF-8?q?C=C3=A0i=20=C4=91=E1=BA=B7t=20t=C3=ADnh=20n?= =?UTF-8?q?=C4=83ng=20ng=C6=B0=E1=BB=9Di=20qu=E1=BA=A3n=20l=C3=AD=20c?= =?UTF-8?q?=E1=BA=ADp=20nh=E1=BA=ADt=20s=E1=BB=91=20ng=C6=B0=E1=BB=9Di=20t?= =?UTF-8?q?ham=20gia?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/store/useTourStore.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/frontend/src/store/useTourStore.ts b/frontend/src/store/useTourStore.ts index 5b6de67..f017b90 100644 --- a/frontend/src/store/useTourStore.ts +++ b/frontend/src/store/useTourStore.ts @@ -10,6 +10,7 @@ interface TourState { setTour: (tour: any) => void; updateLegs: (legs: any[]) => void; createTour: (tourData: any) => Promise; + updateTourDetails: (tourId: string, data: any) => Promise; updateTour: (id: string, data: any) => Promise; deleteTour: (id: string) => Promise; addLeg: (tourId: string, data: any) => Promise; @@ -106,6 +107,23 @@ export const useTourStore = create((set, get) => ({ await get().fetchPublicTours(); return tour; }, + updateTourDetails: async (tourId: string, data: any) => { + const API_BASE = `http://${window.location.hostname}:3001`; + const token = localStorage.getItem('token'); + const response = await fetch(`${API_BASE}/api/v1/tours/${tourId}`, { + method: 'PATCH', + headers: { + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${token}` + }, + body: JSON.stringify(data), + }); + + if (!response.ok) { + const errorData = await response.json().catch(() => ({})); + throw new Error(errorData.message || errorData.error || 'Lỗi khi cập nhật thông tin tour'); + } + }, updateTour: async (id: string, data: any) => { const API_BASE = `http://${window.location.hostname}:3001`; const response = await fetch(`${API_BASE}/api/v1/tours/${id}`, {