Thêm tính năng trong mục 4.1 của ARCHITECTURE.md
This commit is contained in:
Vendored
+11
-1
@@ -19,7 +19,17 @@ export const useTourStore = create((set, get) => ({
|
||||
const data = await response.json();
|
||||
set({ publicTours: data });
|
||||
},
|
||||
optimizeRouting: async () => {
|
||||
optimizeRouting: async (legId) => {
|
||||
const API_BASE = `http://${window.location.hostname}:3001`;
|
||||
const response = await fetch(`${API_BASE}/api/v1/routing/optimize/${legId}`, {
|
||||
method: 'POST'
|
||||
});
|
||||
const { locations, totalDistance } = await response.json();
|
||||
const { currentTour } = get();
|
||||
if (currentTour) {
|
||||
const updatedLegs = currentTour.legs.map((l) => l.id === legId ? { ...l, locations: locations, totalDistance: totalDistance } : l);
|
||||
set({ currentTour: { ...currentTour, legs: updatedLegs }, legs: updatedLegs });
|
||||
}
|
||||
},
|
||||
}));
|
||||
//# sourceMappingURL=useTourStore.js.map
|
||||
Reference in New Issue
Block a user