Sửa đổi dữ liệu của hệ thống theo ARCHITECTURE.md
This commit is contained in:
Vendored
+5
-4
@@ -7,14 +7,15 @@ export const useTourStore = create((set, get) => ({
|
||||
setTour: (tour) => set({ currentTour: tour }),
|
||||
updateLegs: (legs) => set({ legs }),
|
||||
fetchTour: async (id) => {
|
||||
const currentUserId = 1;
|
||||
const response = await fetch(`http://localhost:3001/api/v1/tours/${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.members?.find((m) => m.userId === currentUserId)?.role || 'VIEWER_EXTERNAL';
|
||||
const role = data.participants?.[0]?.role || 'VIEWER_ONLY';
|
||||
set({ currentTour: data, legs: data.legs || [], userRole: role });
|
||||
},
|
||||
fetchPublicTours: async () => {
|
||||
const response = await fetch(`http://localhost:3001/api/v1/tours/explore`);
|
||||
const API_BASE = `http://${window.location.hostname}:3001`;
|
||||
const response = await fetch(`${API_BASE}/api/v1/tours/explore`);
|
||||
const data = await response.json();
|
||||
set({ publicTours: data });
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user