feat: Fixed path for routes
This commit is contained in:
@ -26,6 +26,7 @@ class RouteStore {
|
||||
data: [],
|
||||
loaded: false,
|
||||
};
|
||||
|
||||
route: Record<string, Route> = {};
|
||||
|
||||
constructor() {
|
||||
@ -64,6 +65,52 @@ class RouteStore {
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
getRoute = async (id: number) => {
|
||||
if (this.route[id]) return this.route[id];
|
||||
const response = await authInstance.get(`/route/${id}`);
|
||||
|
||||
runInAction(() => {
|
||||
this.route[id] = response.data;
|
||||
});
|
||||
|
||||
return response.data;
|
||||
};
|
||||
|
||||
editRouteData = {
|
||||
carrier: "",
|
||||
carrier_id: 0,
|
||||
center_latitude: 0,
|
||||
center_longitude: 0,
|
||||
governor_appeal: 0,
|
||||
id: 0,
|
||||
path: [] as number[][],
|
||||
rotate: 0,
|
||||
route_direction: false,
|
||||
route_number: "",
|
||||
route_sys_number: "",
|
||||
scale_max: 0,
|
||||
scale_min: 0,
|
||||
video_preview: "",
|
||||
};
|
||||
|
||||
setEditRouteData = (data: any) => {
|
||||
this.editRouteData = { ...this.editRouteData, ...data };
|
||||
};
|
||||
|
||||
editRoute = async (id: number) => {
|
||||
const response = await authInstance.patch(
|
||||
`/route/${id}`,
|
||||
this.editRouteData
|
||||
);
|
||||
|
||||
runInAction(() => {
|
||||
this.route[id] = response.data;
|
||||
this.routes.data = this.routes.data.map((route) =>
|
||||
route.id === id ? response.data : route
|
||||
);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const routeStore = new RouteStore();
|
||||
|
Reference in New Issue
Block a user