暫定的に投稿機能新型を実装
This commit is contained in:
		| @@ -26,19 +26,27 @@ export const TrainDataView = ({ | ||||
|   const [mapsStationData, setMapsStationData] = useState(undefined); | ||||
|  | ||||
|   const [platformNumber, setPlatformNumber] = useState(); | ||||
|   const [lineNumber, setLineNumber] = useState(); | ||||
|   const [platformDescription, setPlatformDescription] = useState(); | ||||
|   useEffect(() => { | ||||
|     //currentTrainData.Pos = "鴨川~端岡"; //test | ||||
|     if (!currentTrainData) return; | ||||
|     fetch( | ||||
|       `https://n8n.haruk.in/webhook/JR-shikoku-PosID?PosNum=${currentTrainData?.PosNum}&Line=${currentTrainData?.Line}` | ||||
|       `https://n8n.haruk.in/webhook/JR-shikoku-PosID-v3?PosId=${currentTrainData?.PosNum}&lineName=${currentTrainData?.Line}&StationName=${currentTrainData?.Pos}` | ||||
|     ) | ||||
|       .then((res) => res.json()) | ||||
|       .then((data) => { | ||||
|         setPlatformNumber(data?.type == "Station" ? data?.platform : undefined); | ||||
|         setPlatformDescription( | ||||
|           data?.type == "Station" ? data?.description : undefined | ||||
|         ); | ||||
|         if (!data) return; | ||||
|         const {type, stationName, lineNumber, platformNumber, position, description} = data; | ||||
|         if (type == "Station") { | ||||
|           setLineNumber(lineNumber); | ||||
|           setPlatformNumber(platformNumber); | ||||
|           setPlatformDescription(description); | ||||
|         } else { | ||||
|           setLineNumber(undefined); | ||||
|           setPlatformNumber(undefined); | ||||
|           setPlatformDescription(undefined); | ||||
|         } | ||||
|       }); | ||||
|   }, [currentTrainData]); | ||||
|   useEffect(() => { | ||||
| @@ -50,7 +58,8 @@ export const TrainDataView = ({ | ||||
|     const { from, to, Pos } = PosData; | ||||
|     if (isBetween === true) return `${from}~${to}`; | ||||
|     if (Pos == "") return ""; | ||||
|     return `${Pos}${platformNumber ? ` ${platformNumber}番線` : ""}`; | ||||
|     if (platformNumber) return `${Pos} ${platformNumber}番乗り場`; | ||||
|     if (lineNumber) return `${Pos} ${lineNumber}番線`; | ||||
|   }; | ||||
|   const [dialog, setDialog] = useState(false); | ||||
|   const [deleteDialog, setDeleteDialog] = useState(false); | ||||
| @@ -58,6 +67,7 @@ export const TrainDataView = ({ | ||||
|   const [descInput, setDescInput] = useState(""); | ||||
|   const [stationInput, setStationInput] = useState(""); | ||||
|   const [stationNumberInput, setStationNumberInput] = useState(""); | ||||
|   const [lineInput, setLineInput] = useState(""); | ||||
|   return ( | ||||
|     <> | ||||
|       <TrainPositionDataPush | ||||
| @@ -70,8 +80,10 @@ export const TrainDataView = ({ | ||||
|         descInput={descInput} | ||||
|         setPosInput={setPosInput} | ||||
|         setDescInput={setDescInput} | ||||
|         lineInput={lineInput} | ||||
|         setLineInput={setLineInput} | ||||
|         station={{ | ||||
|           Station_JP: trainPositionText(currentTrainData), | ||||
|           Station_JP: currentTrainData?.Pos, | ||||
|           StationNumber: currentPosition[0], | ||||
|         }} | ||||
|       /> | ||||
| @@ -100,6 +112,7 @@ export const TrainDataView = ({ | ||||
|                 getStationID(currentTrainData?.Pos, stationList) | ||||
|               ); | ||||
|               setPosInput(platformNumber?.toString() || ""); | ||||
|               setLineInput(lineNumber?.toString() || ""); | ||||
|               setDeleteDialog(true); | ||||
|             } else { | ||||
|               setStationInput(Pos.Pos); | ||||
| @@ -108,6 +121,7 @@ export const TrainDataView = ({ | ||||
|               ); | ||||
|               setDescInput(platformDescription || ""); | ||||
|               setPosInput(platformNumber?.toString() || ""); | ||||
|               setLineInput(lineNumber?.toString() || ""); | ||||
|               setDialog(true); | ||||
|             } | ||||
|           }} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user