From 6653cbf65a0bcf75e6b65f58809abb103511aa4a Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Mon, 16 Sep 2024 14:35:46 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=E7=95=AA=E7=B7=9A=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E6=A9=9F=E8=83=BD=E9=96=8B=E7=99=BA=E9=96=8B=E5=A7=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/発車時刻表/EachData.tsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/components/発車時刻表/EachData.tsx b/components/発車時刻表/EachData.tsx index af37d73..9f49e87 100644 --- a/components/発車時刻表/EachData.tsx +++ b/components/発車時刻表/EachData.tsx @@ -92,6 +92,22 @@ export const EachData: FC = (props) => { .split("~")[currentTrainData?.Direction == 1 ? 1 : 0] }間を走行中` : `現在地:${currentTrainData?.Pos}`; + +const [platformNumber, setPlatformNumber] = useState(); +useEffect(()=>{ + fetch("https://n8n.haruk.in/webhook/JR-shikoku-PosID?num="+currentTrainData?.PosNum) + .then(res=>res.json()) + .then(data=>{ + if(data?.type == "Station"){ + setPlatformNumber(data?.platform); + } + else{ + setPlatformNumber(undefined); + } + }) +},[currentTrainData,currentTrain]) + + return ( <> = (props) => { { Linking.openURL( "https://nexcloud.haruk.in/apps/forms/s/TEkBQW5WLcYjLyAzGxncQLtw" From 30393c0fd4b6d07cb1e5ef73a02aa320f8f8fbb3 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Mon, 16 Sep 2024 16:07:39 +0000 Subject: [PATCH 2/3] =?UTF-8?q?Revert=20"release=E5=90=91=E3=81=91?= =?UTF-8?q?=E5=B0=81=E5=8D=B0"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit c56a1961a76d815afdbdb49b4f031e16954d4c3a. --- Apps.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Apps.js b/Apps.js index 5e8ebca..cc526e0 100644 --- a/Apps.js +++ b/Apps.js @@ -28,7 +28,7 @@ export function AppContainer() { Date: Thu, 17 Oct 2024 16:12:36 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=E3=82=AF=E3=82=A8=E3=83=AA=E3=81=AE?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/発車時刻表/EachData.tsx | 26 ++++++++----------- ...rainData.js => checkDuplicateTrainData.ts} | 4 ++- lib/getTrainDelayStatus.ts | 4 ++- lib/trainPositionTextArray.ts | 6 +++++ 4 files changed, 23 insertions(+), 17 deletions(-) rename lib/{checkDuplicateTrainData.js => checkDuplicateTrainData.ts} (63%) diff --git a/components/発車時刻表/EachData.tsx b/components/発車時刻表/EachData.tsx index 024380b..6feb5e5 100644 --- a/components/発車時刻表/EachData.tsx +++ b/components/発車時刻表/EachData.tsx @@ -101,20 +101,16 @@ export const EachData: FC = (props) => { else return Pos.Pos == "" ? "" : `現在地:${Pos.Pos}`; }; -const [platformNumber, setPlatformNumber] = useState(); -useEffect(()=>{ - fetch("https://n8n.haruk.in/webhook/JR-shikoku-PosID?num="+currentTrainData?.PosNum) - .then(res=>res.json()) - .then(data=>{ - if(data?.type == "Station"){ - setPlatformNumber(data?.platform); - } - else{ - setPlatformNumber(undefined); - } - }) -},[currentTrainData,currentTrain]) - + const [platformNumber, setPlatformNumber] = useState(); + useEffect(() => { + 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) + ); + }, [currentTrainData, currentTrain]); return ( <> @@ -147,7 +143,7 @@ useEffect(()=>{ trainIDSwitch ? currentTrainData?.PosNum : trainPositionText(currentTrainData) - } ${platformNumber? platformNumber+"番線":""}`} + } ${platformNumber ? platformNumber + "番線" : ""}`} onLongClick={() => { Linking.openURL( "https://nexcloud.haruk.in/apps/forms/s/TEkBQW5WLcYjLyAzGxncQLtw" diff --git a/lib/checkDuplicateTrainData.js b/lib/checkDuplicateTrainData.ts similarity index 63% rename from lib/checkDuplicateTrainData.js rename to lib/checkDuplicateTrainData.ts index e8b3813..881db65 100644 --- a/lib/checkDuplicateTrainData.js +++ b/lib/checkDuplicateTrainData.ts @@ -1,4 +1,6 @@ -export const checkDuplicateTrainData = (currentTrainArray) => { +import { trainDataType } from "./trainPositionTextArray"; + +export const checkDuplicateTrainData = (currentTrainArray: trainDataType[]) => { const notNyujoData = currentTrainArray.filter((d) => d.delay !== "入線"); if (currentTrainArray.length == 1) return currentTrainArray[0]; if (notNyujoData.length == 0) return currentTrainArray[0]; diff --git a/lib/getTrainDelayStatus.ts b/lib/getTrainDelayStatus.ts index af7e163..9fe76c3 100644 --- a/lib/getTrainDelayStatus.ts +++ b/lib/getTrainDelayStatus.ts @@ -1,5 +1,7 @@ +import { trainDataType } from "./trainPositionTextArray"; + type getTrainDelayStatus = ( - current: { delay: number | "入線" | string; Pos: string }, + current: trainDataType, Station_JP: string ) => string | number; export const getTrainDelayStatus: getTrainDelayStatus = ( diff --git a/lib/trainPositionTextArray.ts b/lib/trainPositionTextArray.ts index 22366d9..b9d89c3 100644 --- a/lib/trainPositionTextArray.ts +++ b/lib/trainPositionTextArray.ts @@ -14,6 +14,12 @@ type returnCurrentType = { export type trainDataType = { Pos?: string; Direction?: number; + Index?: number; + Line?: string; + PosNum?: number; + Type?: string; + delay?: string | number; + num?: string; }; type trainData = ( trainData: trainDataType