Cho phép chọn trực tiếp điểm trên bản đồ
This commit is contained in:
Vendored
+9
-1
@@ -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`;
|
||||
|
||||
Reference in New Issue
Block a user