From f6b2cc54ed67569b2dfb32bda478cbd1ccd64bf8 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Fri, 6 Dec 2024 06:18:29 +0000 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=BB=8A=E3=83=93=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=82=E4=BD=8D=E7=BD=AE=E8=A1=A8=E7=A4=BA=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EachTrainInfo/TrainDataView.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/components/ActionSheetComponents/EachTrainInfo/TrainDataView.js b/components/ActionSheetComponents/EachTrainInfo/TrainDataView.js index 26d7334..c649ab6 100644 --- a/components/ActionSheetComponents/EachTrainInfo/TrainDataView.js +++ b/components/ActionSheetComponents/EachTrainInfo/TrainDataView.js @@ -19,6 +19,23 @@ export const TrainDataView = ({ const { isLandscape } = useDeviceOrientationChange(); const { inject } = useCurrentTrain(); const [mapsStationData, setMapsStationData] = useState(undefined); + + const [platformNumber, setPlatformNumber] = useState(); + const [platformDescription, setPlatformDescription] = useState(); + useEffect(() => { + //currentTrainData.Pos = "鴨川~端岡"; //test + if (!currentTrainData) return; + fetch( + `https://n8n.haruk.in/webhook/JR-shikoku-PosID?PosNum=${currentTrainData?.PosNum}&Line=${currentTrainData?.Line}` + ) + .then((res) => res.json()) + .then((data) => { + setPlatformNumber(data?.type == "Station" ? data?.platform : undefined); + setPlatformDescription( + data?.type == "Station" ? data?.description : undefined + ); + }); + }, [currentTrainData]); useEffect(() => { getStationList2().then(setMapsStationData); }, []); @@ -26,7 +43,7 @@ export const TrainDataView = ({ const trainPositionText = (trainData) => { const { isBetween, Pos } = trainPosition(trainData); if (isBetween === true) return `${Pos.from}~${Pos.to}`; - else return Pos.Pos == "" ? "" : `${Pos.Pos}`; + else return Pos.Pos == "" ? "" : `${Pos.Pos}${platformNumber ? ` ${platformNumber}番線`:""}${platformDescription ? `\n${platformNumber}番線`:""}`; }; return (