fix: fix bug with stations in the route
This commit is contained in:
@@ -162,7 +162,10 @@ const LinkedItemsContentsInner = <
|
||||
|
||||
const filteredAvailableItems = availableItems.filter((item) => {
|
||||
if (!searchQuery.trim()) return true;
|
||||
return String(item.name).toLowerCase().includes(searchQuery.toLowerCase());
|
||||
const query = searchQuery.toLowerCase();
|
||||
const name = String(item.name || "").toLowerCase();
|
||||
const description = String(item.description || "").toLowerCase();
|
||||
return name.includes(query) || description.includes(query);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
@@ -206,12 +209,11 @@ const LinkedItemsContentsInner = <
|
||||
authInstance
|
||||
.post(`/${parentResource}/${parentId}/${childResource}`, {
|
||||
stations: reorderedItems.map((item) => {
|
||||
const stationData: any = { id: item.id };
|
||||
const transfers = getStationTransfers(item.id, item.transfers);
|
||||
if (transfers) {
|
||||
stationData.transfers = transfers;
|
||||
}
|
||||
return stationData;
|
||||
return {
|
||||
...item,
|
||||
transfers: transfers || item.transfers,
|
||||
};
|
||||
}),
|
||||
})
|
||||
.catch((error) => {
|
||||
@@ -263,24 +265,23 @@ const LinkedItemsContentsInner = <
|
||||
const requestData = {
|
||||
stations: insertAtPosition(
|
||||
linkedItems.map((item) => {
|
||||
const stationData: any = { id: item.id };
|
||||
const transfers = getStationTransfers(item.id, item.transfers);
|
||||
if (transfers) {
|
||||
stationData.transfers = transfers;
|
||||
}
|
||||
return stationData;
|
||||
return {
|
||||
...item,
|
||||
transfers: transfers || item.transfers,
|
||||
};
|
||||
}),
|
||||
position,
|
||||
(() => {
|
||||
const newStationData: any = { id: selectedItemId };
|
||||
if (!selectedItem) return { id: selectedItemId };
|
||||
const transfers = getStationTransfers(
|
||||
selectedItemId,
|
||||
selectedItem?.transfers
|
||||
selectedItem.transfers
|
||||
);
|
||||
if (transfers) {
|
||||
newStationData.transfers = transfers;
|
||||
}
|
||||
return newStationData;
|
||||
return {
|
||||
...selectedItem,
|
||||
transfers: transfers || selectedItem.transfers,
|
||||
};
|
||||
})()
|
||||
),
|
||||
};
|
||||
@@ -365,22 +366,21 @@ const LinkedItemsContentsInner = <
|
||||
setIsLinkingBulk(true);
|
||||
const selectedStations = Array.from(selectedItems).map((id) => {
|
||||
const item = allItems.find((item) => item.id === id);
|
||||
const stationData: any = { id };
|
||||
const transfers = getStationTransfers(id, item?.transfers);
|
||||
if (transfers) {
|
||||
stationData.transfers = transfers;
|
||||
}
|
||||
return stationData;
|
||||
if (!item) return { id };
|
||||
const transfers = getStationTransfers(id, item.transfers);
|
||||
return {
|
||||
...item,
|
||||
transfers: transfers || item.transfers,
|
||||
};
|
||||
});
|
||||
const requestData = {
|
||||
stations: [
|
||||
...linkedItems.map((item) => {
|
||||
const stationData: any = { id: item.id };
|
||||
const transfers = getStationTransfers(item.id, item.transfers);
|
||||
if (transfers) {
|
||||
stationData.transfers = transfers;
|
||||
}
|
||||
return stationData;
|
||||
return {
|
||||
...item,
|
||||
transfers: transfers || item.transfers,
|
||||
};
|
||||
}),
|
||||
...selectedStations,
|
||||
],
|
||||
|
||||
@@ -169,7 +169,7 @@ export const MapDataProvider = observer(
|
||||
}
|
||||
|
||||
function setIconSize(size: number) {
|
||||
const clamped = Math.max(50, Math.min(300, size));
|
||||
const clamped = Math.max(1, Math.min(300, size));
|
||||
setRouteChanges((prev) => {
|
||||
if (prev.icon_size === clamped) {
|
||||
return prev;
|
||||
@@ -179,7 +179,7 @@ export const MapDataProvider = observer(
|
||||
}
|
||||
|
||||
function setFontSize(size: number) {
|
||||
const clamped = Math.max(50, Math.min(300, size));
|
||||
const clamped = Math.max(1, Math.min(300, size));
|
||||
setRouteChanges((prev) => {
|
||||
if (prev.font_size === clamped) {
|
||||
return prev;
|
||||
|
||||
@@ -101,7 +101,7 @@ export function RightSidebar() {
|
||||
if (!Number.isFinite(value)) {
|
||||
return;
|
||||
}
|
||||
const clamped = Math.max(50, Math.min(300, Math.round(value)));
|
||||
const clamped = Math.max(1, Math.min(300, Math.round(value)));
|
||||
setIconSize(clamped);
|
||||
updateIconSize(clamped);
|
||||
};
|
||||
@@ -110,7 +110,7 @@ export function RightSidebar() {
|
||||
if (!Number.isFinite(value)) {
|
||||
return;
|
||||
}
|
||||
const clamped = Math.max(50, Math.min(300, Math.round(value)));
|
||||
const clamped = Math.max(1, Math.min(300, Math.round(value)));
|
||||
setFontSize(clamped);
|
||||
updateFontSize(clamped);
|
||||
};
|
||||
@@ -307,60 +307,58 @@ export function RightSidebar() {
|
||||
}}
|
||||
/>
|
||||
|
||||
<Typography variant="body2" sx={{ color: "#fff", textAlign: "center" }}>
|
||||
Размер иконок: {iconSize}%
|
||||
</Typography>
|
||||
|
||||
<Slider
|
||||
<TextField
|
||||
type="number"
|
||||
label="Размер иконок (%)"
|
||||
variant="filled"
|
||||
value={iconSize}
|
||||
onChange={(_, value) => {
|
||||
if (typeof value === "number") {
|
||||
onChange={(e) => {
|
||||
const value = Number(e.target.value);
|
||||
if (!isNaN(value)) {
|
||||
handleIconSizeChange(value);
|
||||
}
|
||||
}}
|
||||
min={50}
|
||||
max={300}
|
||||
step={1}
|
||||
style={{ backgroundColor: "#222", borderRadius: 4 }}
|
||||
sx={{
|
||||
color: "#fff",
|
||||
"& .MuiSlider-thumb": {
|
||||
backgroundColor: "#fff",
|
||||
"& .MuiInputLabel-root": {
|
||||
color: "#fff",
|
||||
},
|
||||
"& .MuiSlider-track": {
|
||||
backgroundColor: "#fff",
|
||||
},
|
||||
"& .MuiSlider-rail": {
|
||||
backgroundColor: "#666",
|
||||
"& .MuiInputBase-input": {
|
||||
color: "#fff",
|
||||
},
|
||||
}}
|
||||
inputProps={{
|
||||
min: 1,
|
||||
max: 300,
|
||||
step: 1,
|
||||
}}
|
||||
/>
|
||||
|
||||
<Typography variant="body2" sx={{ color: "#fff", textAlign: "center" }}>
|
||||
Размер шрифта: {fontSize}%
|
||||
</Typography>
|
||||
|
||||
<Slider
|
||||
<TextField
|
||||
type="number"
|
||||
label="Размер шрифта (%)"
|
||||
variant="filled"
|
||||
value={fontSize}
|
||||
onChange={(_, value) => {
|
||||
if (typeof value === "number") {
|
||||
onChange={(e) => {
|
||||
const value = Number(e.target.value);
|
||||
if (!isNaN(value)) {
|
||||
handleFontSizeChange(value);
|
||||
}
|
||||
}}
|
||||
min={50}
|
||||
max={300}
|
||||
step={1}
|
||||
style={{ backgroundColor: "#222", borderRadius: 4 }}
|
||||
sx={{
|
||||
color: "#fff",
|
||||
"& .MuiSlider-thumb": {
|
||||
backgroundColor: "#fff",
|
||||
"& .MuiInputLabel-root": {
|
||||
color: "#fff",
|
||||
},
|
||||
"& .MuiSlider-track": {
|
||||
backgroundColor: "#fff",
|
||||
},
|
||||
"& .MuiSlider-rail": {
|
||||
backgroundColor: "#666",
|
||||
"& .MuiInputBase-input": {
|
||||
color: "#fff",
|
||||
},
|
||||
}}
|
||||
inputProps={{
|
||||
min: 1,
|
||||
max: 300,
|
||||
step: 1,
|
||||
}}
|
||||
/>
|
||||
|
||||
<TextField
|
||||
|
||||
@@ -9,6 +9,7 @@ import { coordinatesToLocal, localToCoordinates } from "../utils";
|
||||
import { BACKGROUND_COLOR, SCALE_FACTOR, UP_SCALE } from "../Constants";
|
||||
import { languageStore } from "@shared";
|
||||
import { SightData } from "../types";
|
||||
import { isMediaIdEmpty } from "../../../../shared/lib/index";
|
||||
|
||||
const SIGHT_ICON_URL = "/sight_icon.svg";
|
||||
|
||||
@@ -1960,9 +1961,13 @@ export const WebGLRouteMapPrototype = observer(() => {
|
||||
? { right: 0, transform: "none" }
|
||||
: { left: "50%", transform: "translateX(-50%)" };
|
||||
|
||||
const iconUrl = station.icon
|
||||
? `${import.meta.env.VITE_KRBL_MEDIA}${station.icon}/download?token=${localStorage.getItem("token") ?? ""}`
|
||||
: null;
|
||||
let isMediaIdEmptyResult = isMediaIdEmpty(station.icon);
|
||||
const iconUrl = isMediaIdEmptyResult
|
||||
? null
|
||||
: `${import.meta.env.VITE_KRBL_MEDIA}${
|
||||
station.icon
|
||||
}/download?token=${localStorage.getItem("token") ?? ""}`;
|
||||
|
||||
const iconSizePx = Math.round(primaryFontSize * 1.2);
|
||||
|
||||
const secondaryLineHeight = 1.2;
|
||||
@@ -2282,4 +2287,4 @@ export const WebGLRouteMapPrototype = observer(() => {
|
||||
);
|
||||
});
|
||||
|
||||
export default WebGLRouteMapPrototype;
|
||||
export default WebGLRouteMapPrototype;
|
||||
|
||||
Reference in New Issue
Block a user