Cho phép chọn trực tiếp điểm trên bản đồ
This commit is contained in:
+12
-1
@@ -5,11 +5,13 @@ interface TourState {
|
||||
legs: any[];
|
||||
publicTours: any[];
|
||||
userRole: string | null;
|
||||
activeLegId: string | null;
|
||||
setTour: (tour: any) => void;
|
||||
updateLegs: (legs: any[]) => void;
|
||||
createTour: (tourData: any) => Promise<any>;
|
||||
addLocation: (tourId: string, locationData: any) => Promise<void>;
|
||||
optimizeRouting: (legId: string) => Promise<void>;
|
||||
setActiveLegId: (id: string | null) => void;
|
||||
fetchTour: (id: string) => Promise<void>;
|
||||
fetchPublicTours: () => Promise<void>;
|
||||
}
|
||||
@@ -19,8 +21,10 @@ export const useTourStore = create<TourState>((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: string) => {
|
||||
const API_BASE = `http://${window.location.hostname}:3001`;
|
||||
const response = await fetch(`${API_BASE}/api/v1/tours/${id}`);
|
||||
@@ -28,7 +32,14 @@ export const useTourStore = create<TourState>((set, get) => ({
|
||||
|
||||
// Lấy role từ danh sách participants (dữ liệu mẫu từ seed)
|
||||
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