Cho phép chọn trực tiếp điểm trên bản đồ

This commit is contained in:
2026-06-13 21:34:07 +07:00
parent 25fcd5d926
commit 578b03d808
12 changed files with 489 additions and 248 deletions
+9 -1
View File
@@ -4,14 +4,22 @@ export const useTourStore = create((set, get) => ({
legs: [],
publicTours: [],
userRole: null,
activeLegId: null,
setTour: (tour) => set({ currentTour: tour }),
updateLegs: (legs) => set({ legs }),
setActiveLegId: (id) => set({ activeLegId: id }),
fetchTour: async (id) => {
const API_BASE = `http://${window.location.hostname}:3001`;
const response = await fetch(`${API_BASE}/api/v1/tours/${id}`);
const data = await response.json();
const role = data.participants?.[0]?.role || 'VIEWER_ONLY';
set({ currentTour: data, legs: data.legs || [], userRole: role });
const legs = data.legs || [];
set({
currentTour: data,
legs: legs,
userRole: role,
activeLegId: legs.length > 0 ? legs[0].id : null
});
},
fetchPublicTours: async () => {
const API_BASE = `http://${window.location.hostname}:3001`;