refactor: Tooltip-Generierung für Linien ausgelagert und Anzeige von Stationsnamen (LD_Name) hinzugefügt
- `generateLineTooltipContent` in eigene Datei extrahiert - `useLineData` angepasst, um Stationen aus `gisStationsStaticDistrict` zu übergeben - Anzeige der Station im Tooltip nun über `LD_Name` statt `matchingLine.name` - Bugfix: "Station: N/A" wird nun korrekt angezeigt
This commit is contained in:
@@ -5,6 +5,7 @@ import { selectGisLinesStatusFromWebservice } from "@/redux/slices/webservice/gi
|
||||
import { fetchGisLinesThunk } from "@/redux/thunks/database/polylines/fetchGisLinesThunk";
|
||||
import { fetchGisLinesStatusThunk } from "@/../redux/thunks/webservice/fetchGisLinesStatusThunk";
|
||||
import { generateLineTooltipContent } from "./generateLineTooltipContent";
|
||||
import { selectGisStationsStaticDistrict } from "@/redux/slices/webservice/gisStationsStaticDistrictSlice";
|
||||
|
||||
const useLineData = () => {
|
||||
const dispatch = useDispatch();
|
||||
@@ -13,6 +14,7 @@ const useLineData = () => {
|
||||
const linesData = useSelector(state => state.gisLinesFromDatabase.data);
|
||||
const [lineColors, setLineColors] = useState({});
|
||||
const [tooltipContents, setTooltipContents] = useState({});
|
||||
const stations = useSelector(selectGisStationsStaticDistrict)?.Points ?? [];
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetchGisLinesThunk());
|
||||
@@ -70,13 +72,18 @@ const useLineData = () => {
|
||||
|
||||
colorsByModule[key] = values.messages.length > 0 ? values.messages[0].prioColor : "green";
|
||||
|
||||
newTooltipContents[key] = generateLineTooltipContent(statis, matchingLine, values);
|
||||
newTooltipContents[key] = generateLineTooltipContent(
|
||||
statis,
|
||||
matchingLine,
|
||||
values,
|
||||
stations
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
setLineColors(colorsByModule);
|
||||
setTooltipContents(newTooltipContents);
|
||||
}, [statisData, linesData]);
|
||||
}, [statisData, linesData, stations]);
|
||||
|
||||
return { lineColors, tooltipContents };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user