コードの整理
This commit is contained in:
parent
1575b643f7
commit
2e95a35fce
@ -44,13 +44,13 @@ export const EachData: FC<Props> = (props) => {
|
||||
const { currentTrain } = useCurrentTrain();
|
||||
const { originalStationList } = useStationList();
|
||||
const stationList =
|
||||
originalStationList &&
|
||||
lineList.map((d) =>
|
||||
originalStationList[d].map((a) => ({
|
||||
StationNumber: a.StationNumber,
|
||||
StationName: a.Station_JP,
|
||||
}))
|
||||
);
|
||||
originalStationList &&
|
||||
lineList.map((d) =>
|
||||
originalStationList[d].map((a) => ({
|
||||
StationNumber: a.StationNumber,
|
||||
StationName: a.Station_JP,
|
||||
}))
|
||||
);
|
||||
const openTrainInfo = (d: {
|
||||
train: string;
|
||||
lastStation: string;
|
||||
@ -137,12 +137,7 @@ export const EachData: FC<Props> = (props) => {
|
||||
const [stationNumberInput, setStationNumberInput] = useState("");
|
||||
return (
|
||||
<>
|
||||
<Dialog
|
||||
isVisible={dialog}
|
||||
onBackdropPress={() => {
|
||||
setDialog(false);
|
||||
}}
|
||||
>
|
||||
<Dialog isVisible={dialog} onBackdropPress={() => setDialog(false)}>
|
||||
<Text>路線: {currentTrainData?.Line}</Text>
|
||||
<Text>地点ID: {currentTrainData?.PosNum}</Text>
|
||||
<Text>駅名: {stationInput}</Text>
|
||||
@ -162,25 +157,27 @@ export const EachData: FC<Props> = (props) => {
|
||||
<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("");
|
||||
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,
|
||||
}),
|
||||
})
|
||||
.then(() => {
|
||||
alert("位置情報データを送信しました。");
|
||||
setDialog(false);
|
||||
setPosInput("");
|
||||
setDescInput("");
|
||||
})
|
||||
.catch(() => {
|
||||
alert("位置情報データの送信に失敗しました。");
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</Dialog>
|
||||
@ -220,7 +217,9 @@ export const EachData: FC<Props> = (props) => {
|
||||
const { isBetween, Pos } = trainPosition(currentTrainData);
|
||||
if (isBetween === true) return;
|
||||
setStationInput(Pos.Pos);
|
||||
setStationNumberInput(getStationID(currentTrainData?.Pos, stationList));
|
||||
setStationNumberInput(
|
||||
getStationID(currentTrainData?.Pos, stationList)
|
||||
);
|
||||
setDescInput(platformDescription || "");
|
||||
setPosInput(platformNumber?.toString() || "");
|
||||
setDialog(true);
|
||||
|
Loading…
Reference in New Issue
Block a user