削除コマンドを実装
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 { TrainPosition } from "./LED_inside_Component/TrainPosition";
|
||||
import { TrainPositionDataPush } from "./LED_inside_Component/TrainPositionDataPush";
|
||||
import { TrainPositionDataDelete } from "./LED_inside_Component/TrainPositionDataDelete";
|
||||
|
||||
type Props = {
|
||||
d: {
|
||||
@ -104,12 +105,20 @@ export const EachData: FC<Props> = (props) => {
|
||||
const [platformDescription, setPlatformDescription] = useState<string>();
|
||||
|
||||
const [dialog, setDialog] = useState(false);
|
||||
const [deleteDialog, setDeleteDialog] = useState(false);
|
||||
const [posInput, setPosInput] = useState("");
|
||||
const [descInput, setDescInput] = useState("");
|
||||
const [stationInput, setStationInput] = useState("");
|
||||
const [stationNumberInput, setStationNumberInput] = useState("");
|
||||
return (
|
||||
<>
|
||||
<TrainPositionDataDelete
|
||||
dialog={deleteDialog}
|
||||
setDialog={setDeleteDialog}
|
||||
currentTrainData={currentTrainData}
|
||||
stationInput={stationInput}
|
||||
stationNumberInput={stationNumberInput}
|
||||
/>
|
||||
<TrainPositionDataPush
|
||||
dialog={dialog}
|
||||
setDialog={setDialog}
|
||||
@ -154,6 +163,7 @@ export const EachData: FC<Props> = (props) => {
|
||||
setDescInput={setDescInput}
|
||||
setPosInput={setPosInput}
|
||||
setDialog={setDialog}
|
||||
setDeleteDialog={setDeleteDialog}
|
||||
setPlatformDescription={setPlatformDescription}
|
||||
setPlatformNumber={setPlatformNumber}
|
||||
platformDescription={platformDescription}
|
||||
|
@ -23,6 +23,7 @@ type Props = {
|
||||
setDescInput: (desc: string) => void;
|
||||
setPosInput: (pos: string) => void;
|
||||
setDialog: (dialog: boolean) => void;
|
||||
setDeleteDialog: (dialog: boolean) => void;
|
||||
platformDescription: string;
|
||||
platformNumber: number;
|
||||
setPlatformDescription: (desc: string) => void;
|
||||
@ -38,6 +39,7 @@ export const TrainPosition: FC<Props> = ({
|
||||
setDescInput,
|
||||
setPosInput,
|
||||
setDialog,
|
||||
setDeleteDialog,
|
||||
setPlatformDescription,
|
||||
setPlatformNumber,
|
||||
platformDescription,
|
||||
@ -86,12 +88,24 @@ export const TrainPosition: FC<Props> = ({
|
||||
}}
|
||||
onLongPress={() => {
|
||||
const { isBetween, Pos } = trainPosition(currentTrainData);
|
||||
if (isBetween === true) return;
|
||||
setStationInput(Pos.Pos);
|
||||
setStationNumberInput(getStationID(currentTrainData?.Pos, stationList));
|
||||
setDescInput(platformDescription || "");
|
||||
setPosInput(platformNumber?.toString() || "");
|
||||
setDialog(true);
|
||||
if (isBetween === true) {
|
||||
if (platformNumber == undefined && platformDescription == undefined)
|
||||
return;
|
||||
setStationInput(`${Pos.from}→${Pos.to}間`);
|
||||
setStationNumberInput(
|
||||
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" }}>
|
||||
|
@ -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