新型投稿機能を仮作成
This commit is contained in:
parent
61dc083f73
commit
1575b643f7
@ -1,5 +1,6 @@
|
|||||||
import React, { FC, useEffect, useState } from "react";
|
import React, { FC, useEffect, useState } from "react";
|
||||||
import { Linking, TouchableOpacity } from "react-native";
|
import { Linking, TouchableOpacity, Text } from "react-native";
|
||||||
|
import { Dialog, Button, Input } from "react-native-elements";
|
||||||
import { checkDuplicateTrainData } from "../../lib/checkDuplicateTrainData";
|
import { checkDuplicateTrainData } from "../../lib/checkDuplicateTrainData";
|
||||||
import { getTrainDelayStatus } from "../../lib/getTrainDelayStatus";
|
import { getTrainDelayStatus } from "../../lib/getTrainDelayStatus";
|
||||||
import { getTrainType } from "../../lib/getTrainType";
|
import { getTrainType } from "../../lib/getTrainType";
|
||||||
@ -12,6 +13,9 @@ import { StatusAndDelay } from "./LED_inside_Component/StatusAndDelay";
|
|||||||
import { TrainName } from "./LED_inside_Component/TrainName";
|
import { TrainName } from "./LED_inside_Component/TrainName";
|
||||||
import { customTrainDataDetector } from "../custom-train-data";
|
import { customTrainDataDetector } from "../custom-train-data";
|
||||||
import { trainDataType, trainPosition } from "../../lib/trainPositionTextArray";
|
import { trainDataType, trainPosition } from "../../lib/trainPositionTextArray";
|
||||||
|
import { getStationID } from "../../lib/eachTrainInfoCoreLib/getStationData";
|
||||||
|
import { useStationList } from "../../stateBox/useStationList";
|
||||||
|
import { lineList } from "../../lib/getStationList";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
d: {
|
d: {
|
||||||
@ -23,6 +27,7 @@ type Props = {
|
|||||||
trainDescriptionSwitch: boolean;
|
trainDescriptionSwitch: boolean;
|
||||||
station: {
|
station: {
|
||||||
Station_JP: string;
|
Station_JP: string;
|
||||||
|
StationNumber: string;
|
||||||
};
|
};
|
||||||
navigate: (screen: string, data?: any) => void;
|
navigate: (screen: string, data?: any) => void;
|
||||||
openStationACFromEachTrainInfo: (station: string) => void;
|
openStationACFromEachTrainInfo: (station: string) => void;
|
||||||
@ -37,6 +42,15 @@ export const EachData: FC<Props> = (props) => {
|
|||||||
openStationACFromEachTrainInfo,
|
openStationACFromEachTrainInfo,
|
||||||
} = props;
|
} = props;
|
||||||
const { currentTrain } = useCurrentTrain();
|
const { currentTrain } = useCurrentTrain();
|
||||||
|
const { originalStationList } = useStationList();
|
||||||
|
const stationList =
|
||||||
|
originalStationList &&
|
||||||
|
lineList.map((d) =>
|
||||||
|
originalStationList[d].map((a) => ({
|
||||||
|
StationNumber: a.StationNumber,
|
||||||
|
StationName: a.Station_JP,
|
||||||
|
}))
|
||||||
|
);
|
||||||
const openTrainInfo = (d: {
|
const openTrainInfo = (d: {
|
||||||
train: string;
|
train: string;
|
||||||
lastStation: string;
|
lastStation: string;
|
||||||
@ -116,8 +130,60 @@ export const EachData: FC<Props> = (props) => {
|
|||||||
});
|
});
|
||||||
}, [currentTrainData, currentTrain]);
|
}, [currentTrainData, currentTrain]);
|
||||||
|
|
||||||
|
const [dialog, setDialog] = useState(false);
|
||||||
|
const [posInput, setPosInput] = useState("");
|
||||||
|
const [descInput, setDescInput] = useState("");
|
||||||
|
const [stationInput, setStationInput] = useState("");
|
||||||
|
const [stationNumberInput, setStationNumberInput] = useState("");
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<Dialog
|
||||||
|
isVisible={dialog}
|
||||||
|
onBackdropPress={() => {
|
||||||
|
setDialog(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text>路線: {currentTrainData?.Line}</Text>
|
||||||
|
<Text>地点ID: {currentTrainData?.PosNum}</Text>
|
||||||
|
<Text>駅名: {stationInput}</Text>
|
||||||
|
<Text>駅ナンバー: {stationNumberInput}</Text>
|
||||||
|
<Input
|
||||||
|
label="番線"
|
||||||
|
inputMode="numeric"
|
||||||
|
value={posInput}
|
||||||
|
onChangeText={setPosInput}
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
label="参考情報"
|
||||||
|
inputMode="text"
|
||||||
|
value={descInput}
|
||||||
|
onChangeText={setDescInput}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
title="送信"
|
||||||
|
onPress={() => {
|
||||||
|
fetch(
|
||||||
|
`https://n8n.haruk.in/webhook/JR-shikoku-PosID`,{
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
PosId: currentTrainData?.PosNum,
|
||||||
|
lineName: currentTrainData?.Line,
|
||||||
|
PlatformNum: parseInt(posInput),
|
||||||
|
Description: descInput,
|
||||||
|
StationName: station.Station_JP,
|
||||||
|
StationId: station.StationNumber
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
setDialog(false);
|
||||||
|
setPosInput("");
|
||||||
|
setDescInput("");
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Dialog>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={{
|
style={{
|
||||||
alignContent: "center",
|
alignContent: "center",
|
||||||
@ -148,12 +214,16 @@ export const EachData: FC<Props> = (props) => {
|
|||||||
? currentTrainData?.PosNum + currentTrainData?.Line
|
? currentTrainData?.PosNum + currentTrainData?.Line
|
||||||
: trainPositionText(currentTrainData)
|
: trainPositionText(currentTrainData)
|
||||||
} ${platformNumber ? platformNumber + "番線" : ""} ${
|
} ${platformNumber ? platformNumber + "番線" : ""} ${
|
||||||
platformDescription ? "("+platformDescription+")" : ""
|
platformDescription ? "(" + platformDescription + ")" : ""
|
||||||
}`}
|
}`}
|
||||||
onLongClick={() => {
|
onLongClick={() => {
|
||||||
Linking.openURL(
|
const { isBetween, Pos } = trainPosition(currentTrainData);
|
||||||
"https://nexcloud.haruk.in/apps/forms/s/TEkBQW5WLcYjLyAzGxncQLtw"
|
if (isBetween === true) return;
|
||||||
);
|
setStationInput(Pos.Pos);
|
||||||
|
setStationNumberInput(getStationID(currentTrainData?.Pos, stationList));
|
||||||
|
setDescInput(platformDescription || "");
|
||||||
|
setPosInput(platformNumber?.toString() || "");
|
||||||
|
setDialog(true);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
Loading…
Reference in New Issue
Block a user