削除コマンドを実装
This commit is contained in:
parent
330efc8b99
commit
d64eaf4671
@ -14,6 +14,7 @@ import { TrainName } from "./LED_inside_Component/TrainName";
|
|||||||
import { customTrainDataDetector } from "../custom-train-data";
|
import { customTrainDataDetector } from "../custom-train-data";
|
||||||
import { TrainPosition } from "./LED_inside_Component/TrainPosition";
|
import { TrainPosition } from "./LED_inside_Component/TrainPosition";
|
||||||
import { TrainPositionDataPush } from "./LED_inside_Component/TrainPositionDataPush";
|
import { TrainPositionDataPush } from "./LED_inside_Component/TrainPositionDataPush";
|
||||||
|
import { TrainPositionDataDelete } from "./LED_inside_Component/TrainPositionDataDelete";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
d: {
|
d: {
|
||||||
@ -104,12 +105,20 @@ export const EachData: FC<Props> = (props) => {
|
|||||||
const [platformDescription, setPlatformDescription] = useState<string>();
|
const [platformDescription, setPlatformDescription] = useState<string>();
|
||||||
|
|
||||||
const [dialog, setDialog] = useState(false);
|
const [dialog, setDialog] = useState(false);
|
||||||
|
const [deleteDialog, setDeleteDialog] = useState(false);
|
||||||
const [posInput, setPosInput] = useState("");
|
const [posInput, setPosInput] = useState("");
|
||||||
const [descInput, setDescInput] = useState("");
|
const [descInput, setDescInput] = useState("");
|
||||||
const [stationInput, setStationInput] = useState("");
|
const [stationInput, setStationInput] = useState("");
|
||||||
const [stationNumberInput, setStationNumberInput] = useState("");
|
const [stationNumberInput, setStationNumberInput] = useState("");
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<TrainPositionDataDelete
|
||||||
|
dialog={deleteDialog}
|
||||||
|
setDialog={setDeleteDialog}
|
||||||
|
currentTrainData={currentTrainData}
|
||||||
|
stationInput={stationInput}
|
||||||
|
stationNumberInput={stationNumberInput}
|
||||||
|
/>
|
||||||
<TrainPositionDataPush
|
<TrainPositionDataPush
|
||||||
dialog={dialog}
|
dialog={dialog}
|
||||||
setDialog={setDialog}
|
setDialog={setDialog}
|
||||||
@ -154,6 +163,7 @@ export const EachData: FC<Props> = (props) => {
|
|||||||
setDescInput={setDescInput}
|
setDescInput={setDescInput}
|
||||||
setPosInput={setPosInput}
|
setPosInput={setPosInput}
|
||||||
setDialog={setDialog}
|
setDialog={setDialog}
|
||||||
|
setDeleteDialog={setDeleteDialog}
|
||||||
setPlatformDescription={setPlatformDescription}
|
setPlatformDescription={setPlatformDescription}
|
||||||
setPlatformNumber={setPlatformNumber}
|
setPlatformNumber={setPlatformNumber}
|
||||||
platformDescription={platformDescription}
|
platformDescription={platformDescription}
|
||||||
|
@ -23,6 +23,7 @@ type Props = {
|
|||||||
setDescInput: (desc: string) => void;
|
setDescInput: (desc: string) => void;
|
||||||
setPosInput: (pos: string) => void;
|
setPosInput: (pos: string) => void;
|
||||||
setDialog: (dialog: boolean) => void;
|
setDialog: (dialog: boolean) => void;
|
||||||
|
setDeleteDialog: (dialog: boolean) => void;
|
||||||
platformDescription: string;
|
platformDescription: string;
|
||||||
platformNumber: number;
|
platformNumber: number;
|
||||||
setPlatformDescription: (desc: string) => void;
|
setPlatformDescription: (desc: string) => void;
|
||||||
@ -38,6 +39,7 @@ export const TrainPosition: FC<Props> = ({
|
|||||||
setDescInput,
|
setDescInput,
|
||||||
setPosInput,
|
setPosInput,
|
||||||
setDialog,
|
setDialog,
|
||||||
|
setDeleteDialog,
|
||||||
setPlatformDescription,
|
setPlatformDescription,
|
||||||
setPlatformNumber,
|
setPlatformNumber,
|
||||||
platformDescription,
|
platformDescription,
|
||||||
@ -86,12 +88,24 @@ export const TrainPosition: FC<Props> = ({
|
|||||||
}}
|
}}
|
||||||
onLongPress={() => {
|
onLongPress={() => {
|
||||||
const { isBetween, Pos } = trainPosition(currentTrainData);
|
const { isBetween, Pos } = trainPosition(currentTrainData);
|
||||||
if (isBetween === true) return;
|
if (isBetween === true) {
|
||||||
setStationInput(Pos.Pos);
|
if (platformNumber == undefined && platformDescription == undefined)
|
||||||
setStationNumberInput(getStationID(currentTrainData?.Pos, stationList));
|
return;
|
||||||
setDescInput(platformDescription || "");
|
setStationInput(`${Pos.from}→${Pos.to}間`);
|
||||||
setPosInput(platformNumber?.toString() || "");
|
setStationNumberInput(
|
||||||
setDialog(true);
|
getStationID(currentTrainData?.Pos, stationList)
|
||||||
|
);
|
||||||
|
setPosInput(platformNumber?.toString() || "");
|
||||||
|
setDeleteDialog(true);
|
||||||
|
} else {
|
||||||
|
setStationInput(Pos.Pos);
|
||||||
|
setStationNumberInput(
|
||||||
|
getStationID(currentTrainData?.Pos, stationList)
|
||||||
|
);
|
||||||
|
setDescInput(platformDescription || "");
|
||||||
|
setPosInput(platformNumber?.toString() || "");
|
||||||
|
setDialog(true);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<View style={{ flex: 4, flexDirection: "row" }}>
|
<View style={{ flex: 4, flexDirection: "row" }}>
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
import React, { FC } from "react";
|
||||||
|
import { Text } from "react-native";
|
||||||
|
import { Dialog, Button } from "react-native-elements";
|
||||||
|
import { trainDataType } from "../../../lib/trainPositionTextArray";
|
||||||
|
type Props = {
|
||||||
|
dialog: boolean;
|
||||||
|
setDialog: (dialog: boolean) => void;
|
||||||
|
currentTrainData: trainDataType;
|
||||||
|
stationInput: string;
|
||||||
|
stationNumberInput: string;
|
||||||
|
};
|
||||||
|
export const TrainPositionDataDelete: FC<Props> = ({
|
||||||
|
dialog,
|
||||||
|
setDialog,
|
||||||
|
currentTrainData,
|
||||||
|
stationInput,
|
||||||
|
stationNumberInput,
|
||||||
|
}) => {
|
||||||
|
const sendPlatformData = () => {
|
||||||
|
fetch(`https://n8n.haruk.in/webhook/JR-shikoku-PosID`, {
|
||||||
|
method: "DELETE",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({
|
||||||
|
PosId: currentTrainData?.PosNum,
|
||||||
|
lineName: currentTrainData?.Line,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
alert("位置情報データ削除要求を送信しました。");
|
||||||
|
setDialog(false);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
alert("位置情報データ削除要求の送信に失敗しました。");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<Dialog isVisible={dialog} onBackdropPress={() => setDialog(false)}>
|
||||||
|
<Text>以下のデータを誤情報として削除要求を出しますか?</Text>
|
||||||
|
<Text>路線: {currentTrainData?.Line}</Text>
|
||||||
|
<Text>地点ID: {currentTrainData?.PosNum}</Text>
|
||||||
|
<Text>駅名: {stationInput}</Text>
|
||||||
|
<Text>駅ナンバー: {stationNumberInput}</Text>
|
||||||
|
<Button title="送信" onPress={sendPlatformData} />
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user